本文整理汇总了C++中JSArray::putDirectIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ JSArray::putDirectIndex方法的具体用法?C++ JSArray::putDirectIndex怎么用?C++ JSArray::putDirectIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSArray
的用法示例。
在下文中一共展示了JSArray::putDirectIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toJS
JSValue Database::toJS(ExecState* exec) const
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* result = constructEmptyObject(exec);
JSArray* bytecodes = constructEmptyArray(exec, 0);
RETURN_IF_EXCEPTION(scope, JSValue());
for (unsigned i = 0; i < m_bytecodes.size(); ++i)
bytecodes->putDirectIndex(exec, i, m_bytecodes[i].toJS(exec));
result->putDirect(vm, exec->propertyNames().bytecodes, bytecodes);
JSArray* compilations = constructEmptyArray(exec, 0);
RETURN_IF_EXCEPTION(scope, JSValue());
for (unsigned i = 0; i < m_compilations.size(); ++i)
compilations->putDirectIndex(exec, i, m_compilations[i]->toJS(exec));
result->putDirect(vm, exec->propertyNames().compilations, compilations);
JSArray* events = constructEmptyArray(exec, 0);
RETURN_IF_EXCEPTION(scope, JSValue());
for (unsigned i = 0; i < m_events.size(); ++i)
events->putDirectIndex(exec, i, m_events[i].toJS(exec));
result->putDirect(vm, exec->propertyNames().events, events);
return result;
}
示例2: privateFuncMapIteratorNext
EncodedJSValue JSC_HOST_CALL privateFuncMapIteratorNext(ExecState* exec)
{
ASSERT(jsDynamicCast<JSMapIterator*>(exec->thisValue()));
JSMapIterator* iterator = jsCast<JSMapIterator*>(exec->thisValue());
JSValue key, value;
if (iterator->nextKeyValue(exec, key, value)) {
JSArray* resultArray = jsCast<JSArray*>(exec->uncheckedArgument(0));
resultArray->putDirectIndex(exec, 0, key);
resultArray->putDirectIndex(exec, 1, value);
return JSValue::encode(jsBoolean(false));
}
return JSValue::encode(jsBoolean(true));
}
示例3: toJS
JSValue Database::toJS(ExecState* exec) const
{
JSObject* result = constructEmptyObject(exec);
JSArray* bytecodes = constructEmptyArray(exec, 0);
for (unsigned i = 0; i < m_bytecodes.size(); ++i)
bytecodes->putDirectIndex(exec, i, m_bytecodes[i].toJS(exec));
result->putDirect(exec->vm(), exec->propertyNames().bytecodes, bytecodes);
JSArray* compilations = constructEmptyArray(exec, 0);
for (unsigned i = 0; i < m_compilations.size(); ++i)
compilations->putDirectIndex(exec, i, m_compilations[i]->toJS(exec));
result->putDirect(exec->vm(), exec->propertyNames().compilations, compilations);
return result;
}
示例4: getJSListenerFunctions
static JSArray* getJSListenerFunctions(ExecState& state, Document* document, const EventListenerInfo& listenerInfo)
{
VM& vm = state.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSArray* result = constructEmptyArray(&state, nullptr);
RETURN_IF_EXCEPTION(scope, nullptr);
size_t handlersCount = listenerInfo.eventListenerVector.size();
for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) {
const JSEventListener* jsListener = JSEventListener::cast(&listenerInfo.eventListenerVector[i]->callback());
if (!jsListener) {
ASSERT_NOT_REACHED();
continue;
}
// Hide listeners from other contexts.
if (&jsListener->isolatedWorld() != ¤tWorld(&state))
continue;
JSObject* function = jsListener->jsFunction(document);
if (!function)
continue;
JSObject* listenerEntry = constructEmptyObject(&state);
listenerEntry->putDirect(vm, Identifier::fromString(&state, "listener"), function);
listenerEntry->putDirect(vm, Identifier::fromString(&state, "useCapture"), jsBoolean(listenerInfo.eventListenerVector[i]->useCapture()));
result->putDirectIndex(&state, outputIndex++, JSValue(listenerEntry));
}
return result;
}
示例5: idbKeyToJSValue
static JSValue idbKeyToJSValue(ExecState* exec, JSDOMGlobalObject* globalObject, IDBKey* key)
{
if (!key) {
// This should be undefined, not null.
// Spec: http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBKeyRange
return jsUndefined();
}
switch (key->type()) {
case IDBKey::ArrayType:
{
const IDBKey::KeyArray& inArray = key->array();
size_t size = inArray.size();
JSArray* outArray = constructEmptyArray(exec, 0, globalObject, size);
for (size_t i = 0; i < size; ++i) {
IDBKey* arrayKey = inArray.at(i).get();
outArray->putDirectIndex(exec, i, idbKeyToJSValue(exec, globalObject, arrayKey));
}
return JSValue(outArray);
}
case IDBKey::StringType:
return jsStringWithCache(exec, key->string());
case IDBKey::DateType:
return jsDateOrNull(exec, key->date());
case IDBKey::NumberType:
return jsNumber(key->number());
case IDBKey::MinType:
case IDBKey::InvalidType:
ASSERT_NOT_REACHED();
return jsUndefined();
}
ASSERT_NOT_REACHED();
return jsUndefined();
}
示例6: weakSetEntries
JSValue JSInjectedScriptHost::weakSetEntries(ExecState* exec)
{
if (exec->argumentCount() < 1)
return jsUndefined();
JSValue value = exec->uncheckedArgument(0);
JSWeakSet* weakSet = jsDynamicCast<JSWeakSet*>(value);
if (!weakSet)
return jsUndefined();
unsigned fetched = 0;
unsigned numberToFetch = 100;
JSValue numberToFetchArg = exec->argument(1);
double fetchDouble = numberToFetchArg.toInteger(exec);
if (fetchDouble >= 0)
numberToFetch = static_cast<unsigned>(fetchDouble);
JSArray* array = constructEmptyArray(exec, nullptr);
for (auto it = weakSet->weakMapData()->begin(); it != weakSet->weakMapData()->end(); ++it) {
JSObject* entry = constructEmptyObject(exec);
entry->putDirect(exec->vm(), Identifier::fromString(exec, "value"), it->key);
array->putDirectIndex(exec, fetched++, entry);
if (numberToFetch && fetched >= numberToFetch)
break;
}
return array;
}
示例7: finishCreation
void finishCreation(VM& vm, const Vector<String>& arguments)
{
Base::finishCreation(vm);
addFunction(vm, "debug", functionDebug, 1);
addFunction(vm, "describe", functionDescribe, 1);
addFunction(vm, "print", functionPrint, 1);
addFunction(vm, "quit", functionQuit, 0);
addFunction(vm, "gc", functionGC, 0);
#ifndef NDEBUG
addFunction(vm, "dumpCallFrame", functionDumpCallFrame, 0);
addFunction(vm, "releaseExecutableMemory", functionReleaseExecutableMemory, 0);
#endif
addFunction(vm, "version", functionVersion, 1);
addFunction(vm, "run", functionRun, 1);
addFunction(vm, "load", functionLoad, 1);
addFunction(vm, "readFile", functionReadFile, 1);
addFunction(vm, "checkSyntax", functionCheckSyntax, 1);
addFunction(vm, "jscStack", functionJSCStack, 1);
addFunction(vm, "readline", functionReadline, 0);
addFunction(vm, "preciseTime", functionPreciseTime, 0);
addFunction(vm, "neverInlineFunction", functionNeverInlineFunction, 1);
addFunction(vm, "noInline", functionNeverInlineFunction, 1);
addFunction(vm, "numberOfDFGCompiles", functionNumberOfDFGCompiles, 1);
addFunction(vm, "transferArrayBuffer", functionTransferArrayBuffer, 1);
#if ENABLE(SAMPLING_FLAGS)
addFunction(vm, "setSamplingFlags", functionSetSamplingFlags, 1);
addFunction(vm, "clearSamplingFlags", functionClearSamplingFlags, 1);
#endif
JSArray* array = constructEmptyArray(globalExec(), 0);
for (size_t i = 0; i < arguments.size(); ++i)
array->putDirectIndex(globalExec(), i, jsString(globalExec(), arguments[i]));
putDirect(vm, Identifier(globalExec(), "arguments"), array);
}
示例8: functionRun
EncodedJSValue JSC_HOST_CALL functionRun(ExecState* exec)
{
String fileName = exec->argument(0).toString(exec)->value(exec);
Vector<char> script;
if (!fillBufferWithContentsOfFile(fileName, script))
return JSValue::encode(exec->vm().throwException(exec, createError(exec, "Could not open file.")));
GlobalObject* globalObject = GlobalObject::create(exec->vm(), GlobalObject::createStructure(exec->vm(), jsNull()), Vector<String>());
JSArray* array = constructEmptyArray(globalObject->globalExec(), 0);
for (unsigned i = 1; i < exec->argumentCount(); ++i)
array->putDirectIndex(globalObject->globalExec(), i - 1, exec->uncheckedArgument(i));
globalObject->putDirect(
exec->vm(), Identifier(globalObject->globalExec(), "arguments"), array);
JSValue exception;
StopWatch stopWatch;
stopWatch.start();
evaluate(globalObject->globalExec(), jscSource(script.data(), fileName), JSValue(), &exception);
stopWatch.stop();
if (!!exception) {
exec->vm().throwException(globalObject->globalExec(), exception);
return JSValue::encode(jsUndefined());
}
return JSValue::encode(jsNumber(stopWatch.getElapsedMS()));
}
示例9: addSequenceProperties
void BytecodeSequence::addSequenceProperties(ExecState* exec, JSObject* result) const
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSArray* header = constructEmptyArray(exec, 0);
RETURN_IF_EXCEPTION(scope, void());
for (unsigned i = 0; i < m_header.size(); ++i)
header->putDirectIndex(exec, i, jsString(exec, String::fromUTF8(m_header[i])));
result->putDirect(vm, exec->propertyNames().header, header);
JSArray* sequence = constructEmptyArray(exec, 0);
RETURN_IF_EXCEPTION(scope, void());
for (unsigned i = 0; i < m_sequence.size(); ++i)
sequence->putDirectIndex(exec, i, m_sequence[i].toJS(exec));
result->putDirect(vm, exec->propertyNames().bytecode, sequence);
}
示例10: getJSListenerFunctions
static JSArray* getJSListenerFunctions(ExecState* exec, Document* document, const EventListenerInfo& listenerInfo)
{
JSArray* result = constructEmptyArray(exec, nullptr);
size_t handlersCount = listenerInfo.eventListenerVector.size();
for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) {
const JSEventListener* jsListener = JSEventListener::cast(listenerInfo.eventListenerVector[i].listener.get());
if (!jsListener) {
ASSERT_NOT_REACHED();
continue;
}
// Hide listeners from other contexts.
if (&jsListener->isolatedWorld() != ¤tWorld(exec))
continue;
JSObject* function = jsListener->jsFunction(document);
if (!function)
continue;
JSObject* listenerEntry = constructEmptyObject(exec);
listenerEntry->putDirect(exec->vm(), Identifier::fromString(exec, "listener"), function);
listenerEntry->putDirect(exec->vm(), Identifier::fromString(exec, "useCapture"), jsBoolean(listenerInfo.eventListenerVector[i].useCapture));
result->putDirectIndex(exec, outputIndex++, JSValue(listenerEntry));
}
return result;
}
示例11: iteratorEntries
JSValue JSInjectedScriptHost::iteratorEntries(ExecState* exec)
{
if (exec->argumentCount() < 1)
return jsUndefined();
VM& vm = exec->vm();
JSValue iterator;
JSValue value = exec->uncheckedArgument(0);
if (JSMapIterator* mapIterator = jsDynamicCast<JSMapIterator*>(value))
iterator = mapIterator->clone(exec);
else if (JSSetIterator* setIterator = jsDynamicCast<JSSetIterator*>(value))
iterator = setIterator->clone(exec);
else if (JSStringIterator* stringIterator = jsDynamicCast<JSStringIterator*>(value))
iterator = stringIterator->clone(exec);
else if (JSPropertyNameIterator* propertyNameIterator = jsDynamicCast<JSPropertyNameIterator*>(value)) {
iterator = propertyNameIterator->clone(exec);
if (UNLIKELY(vm.exception()))
return JSValue();
} else {
if (JSObject* iteratorObject = jsDynamicCast<JSObject*>(value)) {
// Array Iterators are created in JS for performance reasons. Thus the only way to know we have one is to
// look for a property that is unique to them.
if (JSValue nextIndex = iteratorObject->getDirect(vm, vm.propertyNames->builtinNames().arrayIteratorNextIndexPrivateName()))
iterator = cloneArrayIteratorObject(exec, vm, iteratorObject, nextIndex);
}
}
if (!iterator)
return jsUndefined();
unsigned numberToFetch = 5;
JSValue numberToFetchArg = exec->argument(1);
double fetchDouble = numberToFetchArg.toInteger(exec);
if (fetchDouble >= 0)
numberToFetch = static_cast<unsigned>(fetchDouble);
JSArray* array = constructEmptyArray(exec, nullptr);
if (UNLIKELY(vm.exception()))
return jsUndefined();
for (unsigned i = 0; i < numberToFetch; ++i) {
JSValue next = iteratorStep(exec, iterator);
if (UNLIKELY(vm.exception()))
break;
if (next.isFalse())
break;
JSValue nextValue = iteratorValue(exec, next);
if (UNLIKELY(vm.exception()))
break;
JSObject* entry = constructEmptyObject(exec);
entry->putDirect(exec->vm(), Identifier::fromString(exec, "value"), nextValue);
array->putDirectIndex(exec, i, entry);
}
iteratorClose(exec, iterator);
return array;
}
示例12: addSequenceProperties
void BytecodeSequence::addSequenceProperties(ExecState* exec, JSObject* result) const
{
VM& vm = exec->vm();
JSArray* header = constructEmptyArray(exec, 0);
if (UNLIKELY(vm.exception()))
return;
for (unsigned i = 0; i < m_header.size(); ++i)
header->putDirectIndex(exec, i, jsString(exec, String::fromUTF8(m_header[i])));
result->putDirect(vm, exec->propertyNames().header, header);
JSArray* sequence = constructEmptyArray(exec, 0);
if (UNLIKELY(vm.exception()))
return;
for (unsigned i = 0; i < m_sequence.size(); ++i)
sequence->putDirectIndex(exec, i, m_sequence[i].toJS(exec));
result->putDirect(vm, exec->propertyNames().bytecode, sequence);
}
示例13: toJS
JSValue Compilation::toJS(ExecState* exec) const
{
JSObject* result = constructEmptyObject(exec);
result->putDirect(exec->vm(), exec->propertyNames().bytecodesID, jsNumber(m_bytecodes->id()));
result->putDirect(exec->vm(), exec->propertyNames().compilationKind, jsString(exec, String::fromUTF8(toCString(m_kind))));
JSArray* profiledBytecodes = constructEmptyArray(exec, 0);
for (unsigned i = 0; i < m_profiledBytecodes.size(); ++i)
profiledBytecodes->putDirectIndex(exec, i, m_profiledBytecodes[i].toJS(exec));
result->putDirect(exec->vm(), exec->propertyNames().profiledBytecodes, profiledBytecodes);
JSArray* descriptions = constructEmptyArray(exec, 0);
for (unsigned i = 0; i < m_descriptions.size(); ++i)
descriptions->putDirectIndex(exec, i, m_descriptions[i].toJS(exec));
result->putDirect(exec->vm(), exec->propertyNames().descriptions, descriptions);
JSArray* counters = constructEmptyArray(exec, 0);
for (auto it = m_counters.begin(), end = m_counters.end(); it != end; ++it) {
JSObject* counterEntry = constructEmptyObject(exec);
counterEntry->putDirect(exec->vm(), exec->propertyNames().origin, it->key.toJS(exec));
counterEntry->putDirect(exec->vm(), exec->propertyNames().executionCount, jsNumber(it->value->count()));
counters->push(exec, counterEntry);
}
result->putDirect(exec->vm(), exec->propertyNames().counters, counters);
JSArray* exitSites = constructEmptyArray(exec, 0);
for (unsigned i = 0; i < m_osrExitSites.size(); ++i)
exitSites->putDirectIndex(exec, i, m_osrExitSites[i].toJS(exec));
result->putDirect(exec->vm(), exec->propertyNames().osrExitSites, exitSites);
JSArray* exits = constructEmptyArray(exec, 0);
for (unsigned i = 0; i < m_osrExits.size(); ++i)
exits->putDirectIndex(exec, i, m_osrExits[i].toJS(exec));
result->putDirect(exec->vm(), exec->propertyNames().osrExits, exits);
result->putDirect(exec->vm(), exec->propertyNames().numInlinedGetByIds, jsNumber(m_numInlinedGetByIds));
result->putDirect(exec->vm(), exec->propertyNames().numInlinedPutByIds, jsNumber(m_numInlinedPutByIds));
result->putDirect(exec->vm(), exec->propertyNames().numInlinedCalls, jsNumber(m_numInlinedCalls));
result->putDirect(exec->vm(), exec->propertyNames().jettisonReason, jsString(exec, String::fromUTF8(toCString(m_jettisonReason))));
if (!m_additionalJettisonReason.isNull())
result->putDirect(exec->vm(), exec->propertyNames().additionalJettisonReason, jsString(exec, String::fromUTF8(m_additionalJettisonReason)));
return result;
}
示例14: toJS
JSValue OriginStack::toJS(ExecState* exec) const
{
JSArray* result = constructEmptyArray(exec, 0);
for (unsigned i = 0; i < m_stack.size(); ++i)
result->putDirectIndex(exec, i, m_stack[i].toJS(exec));
return result;
}
示例15: toJS
JSValue OSRExitSite::toJS(ExecState* exec) const
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSArray* result = constructEmptyArray(exec, 0);
RETURN_IF_EXCEPTION(scope, JSValue());
for (unsigned i = 0; i < m_codeAddresses.size(); ++i)
result->putDirectIndex(exec, i, jsString(exec, toString(RawPointer(m_codeAddresses[i]))));
return result;
}