本文整理汇总了C++中JSFunction::setExtendedSlot方法的典型用法代码示例。如果您正苦于以下问题:C++ JSFunction::setExtendedSlot方法的具体用法?C++ JSFunction::setExtendedSlot怎么用?C++ JSFunction::setExtendedSlot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSFunction
的用法示例。
在下文中一共展示了JSFunction::setExtendedSlot方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: name
static JSFunction *
NewExportedFunction(JSContext *cx, const AsmJSModule::ExportedFunction &func,
HandleObject moduleObj, unsigned exportIndex)
{
RootedPropertyName name(cx, func.name());
JSFunction *fun = NewFunction(cx, NullPtr(), CallAsmJS, func.numArgs(),
JSFunction::NATIVE_FUN, cx->global(), name,
JSFunction::ExtendedFinalizeKind);
if (!fun)
return nullptr;
fun->setExtendedSlot(ASM_MODULE_SLOT, ObjectValue(*moduleObj));
fun->setExtendedSlot(ASM_EXPORT_INDEX_SLOT, Int32Value(exportIndex));
return fun;
}
示例2: shId
bool
GlobalObject::getSelfHostedFunction(JSContext *cx, HandleAtom selfHostedName, HandleAtom name,
unsigned nargs, MutableHandleValue funVal)
{
RootedId shId(cx, AtomToId(selfHostedName));
RootedObject holder(cx, cx->global()->intrinsicsHolder());
if (HasDataProperty(cx, holder, shId, funVal.address()))
return true;
if (!cx->runtime()->maybeWrappedSelfHostedFunction(cx, shId, funVal))
return false;
if (!funVal.isUndefined())
return true;
JSFunction *fun = NewFunction(cx, NullPtr(), nullptr, nargs, JSFunction::INTERPRETED_LAZY,
holder, name, JSFunction::ExtendedFinalizeKind, SingletonObject);
if (!fun)
return false;
fun->setIsSelfHostedBuiltin();
fun->setExtendedSlot(0, StringValue(selfHostedName));
funVal.setObject(*fun);
return JSObject::defineGeneric(cx, holder, shId, funVal, nullptr, nullptr, 0);
}
示例3: name
static JSFunction *
NewExportedFunction(JSContext *cx, const AsmJSModule::ExportedFunction &func,
HandleObject moduleObj, unsigned exportIndex)
{
RootedPropertyName name(cx, func.name());
unsigned numArgs = func.isChangeHeap() ? 1 : func.numArgs();
JSFunction *fun =
NewNativeConstructor(cx, CallAsmJS, numArgs, name,
JSFunction::ExtendedFinalizeKind, GenericObject,
JSFunction::ASMJS_CTOR);
if (!fun)
return nullptr;
fun->setExtendedSlot(ASM_MODULE_SLOT, ObjectValue(*moduleObj));
fun->setExtendedSlot(ASM_EXPORT_INDEX_SLOT, Int32Value(exportIndex));
return fun;
}
示例4: name
static JSFunction*
NewExportedFunction(JSContext* cx, Handle<WasmModuleObject*> moduleObj, const ExportMap& exportMap,
uint32_t exportIndex)
{
unsigned numArgs = moduleObj->module().exports()[exportIndex].sig().args().length();
const char* chars = exportMap.exportNames[exportIndex].get();
RootedAtom name(cx, AtomizeUTF8Chars(cx, chars, strlen(chars)));
if (!name)
return nullptr;
JSFunction* fun = NewNativeConstructor(cx, WasmCall, numArgs, name,
gc::AllocKind::FUNCTION_EXTENDED, GenericObject,
JSFunction::ASMJS_CTOR);
if (!fun)
return nullptr;
fun->setExtendedSlot(FunctionExtended::WASM_MODULE_SLOT, ObjectValue(*moduleObj));
fun->setExtendedSlot(FunctionExtended::WASM_EXPORT_INDEX_SLOT, Int32Value(exportIndex));
return fun;
}
示例5: name
static JSFunction*
NewExportedFunction(JSContext* cx, HandleWasmInstanceObject instanceObj, uint32_t funcExportIndex)
{
Instance& instance = instanceObj->instance();
const Metadata& metadata = instance.metadata();
const FuncExport& fe = metadata.funcExports[funcExportIndex];
unsigned numArgs = fe.sig().args().length();
RootedAtom name(cx, instance.getFuncAtom(cx, fe.funcIndex()));
if (!name)
return nullptr;
JSFunction* fun = NewNativeConstructor(cx, WasmCall, numArgs, name,
gc::AllocKind::FUNCTION_EXTENDED, GenericObject,
JSFunction::ASMJS_CTOR);
if (!fun)
return nullptr;
fun->setExtendedSlot(FunctionExtended::WASM_INSTANCE_SLOT, ObjectValue(*instanceObj));
fun->setExtendedSlot(FunctionExtended::WASM_EXPORT_INDEX_SLOT, Int32Value(funcExportIndex));
return fun;
}
示例6: addIntrinsicValue
/* static */ bool
GlobalObject::getSelfHostedFunction(JSContext* cx, Handle<GlobalObject*> global,
HandlePropertyName selfHostedName, HandleAtom name,
unsigned nargs, MutableHandleValue funVal)
{
if (GlobalObject::maybeGetIntrinsicValue(cx, global, selfHostedName, funVal))
return true;
JSFunction* fun =
NewScriptedFunction(cx, nargs, JSFunction::INTERPRETED_LAZY,
name, gc::AllocKind::FUNCTION_EXTENDED, SingletonObject);
if (!fun)
return false;
fun->setIsSelfHostedBuiltin();
fun->setExtendedSlot(0, StringValue(selfHostedName));
funVal.setObject(*fun);
return GlobalObject::addIntrinsicValue(cx, global, selfHostedName, funVal);
}
示例7: shId
bool
GlobalObject::getSelfHostedFunction(JSContext* cx, HandleAtom selfHostedName, HandleAtom name,
unsigned nargs, MutableHandleValue funVal)
{
RootedId shId(cx, AtomToId(selfHostedName));
RootedObject holder(cx, cx->global()->intrinsicsHolder());
if (cx->global()->maybeGetIntrinsicValue(shId, funVal.address()))
return true;
JSFunction* fun =
NewScriptedFunction(cx, nargs, JSFunction::INTERPRETED_LAZY,
name, JSFunction::ExtendedFinalizeKind, SingletonObject);
if (!fun)
return false;
fun->setIsSelfHostedBuiltin();
fun->setExtendedSlot(0, StringValue(selfHostedName));
funVal.setObject(*fun);
return cx->global()->addIntrinsicValue(cx, shId, funVal);
}