本文整理汇总了C++中CallArgs::callee方法的典型用法代码示例。如果您正苦于以下问题:C++ CallArgs::callee方法的具体用法?C++ CallArgs::callee怎么用?C++ CallArgs::callee使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CallArgs
的用法示例。
在下文中一共展示了CallArgs::callee方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: callee
static bool
GCZeal(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() > 2) {
RootedObject callee(cx, &args.callee());
ReportUsageError(cx, callee, "Too many arguments");
return false;
}
uint32_t zeal;
if (!ToUint32(cx, args.get(0), &zeal))
return false;
uint32_t frequency = JS_DEFAULT_ZEAL_FREQ;
if (args.length() >= 2) {
if (!ToUint32(cx, args.get(1), &frequency))
return false;
}
JS_SetGCZeal(cx, (uint8_t)zeal, frequency);
args.rval().setUndefined();
return true;
}
示例2: wrapped
// Async Iteration proposal 8.3.10 Runtime Semantics: EvaluateBody.
static bool
WrappedAsyncGenerator(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedFunction wrapped(cx, &args.callee().as<JSFunction>());
RootedValue unwrappedVal(cx, wrapped->getExtendedSlot(WRAPPED_ASYNC_UNWRAPPED_SLOT));
RootedFunction unwrapped(cx, &unwrappedVal.toObject().as<JSFunction>());
RootedValue thisValue(cx, args.thisv());
// Step 1.
RootedValue generatorVal(cx);
InvokeArgs args2(cx);
if (!args2.init(cx, argc))
return false;
for (size_t i = 0, len = argc; i < len; i++)
args2[i].set(args[i]);
if (!Call(cx, unwrappedVal, thisValue, args2, &generatorVal))
return false;
// Step 2.
Rooted<AsyncGeneratorObject*> asyncGenObj(
cx, AsyncGeneratorObject::create(cx, wrapped, generatorVal));
if (!asyncGenObj)
return false;
// Step 3 (skipped).
// Done in AsyncGeneratorObject::create and generator.
// Step 4.
args.rval().setObject(*asyncGenObj);
return true;
}
示例3: CallArgsFromSp
void
stubs::UncachedCallHelper(VMFrame &f, uint32 argc, UncachedCallResult *ucr)
{
ucr->init();
JSContext *cx = f.cx;
CallArgs args = CallArgsFromSp(argc, f.regs.sp);
if (IsFunctionObject(args.calleev(), &ucr->callee)) {
ucr->callee = &args.callee();
ucr->fun = GET_FUNCTION_PRIVATE(cx, ucr->callee);
if (ucr->fun->isInterpreted()) {
if (!UncachedInlineCall(f, NO_CONSTRUCT, &ucr->codeAddr, &ucr->unjittable, argc))
THROW();
return;
}
if (ucr->fun->isNative()) {
if (!CallJSNative(cx, ucr->fun->u.n.native, args))
THROW();
return;
}
}
if (!Invoke(f.cx, args))
THROW();
return;
}
示例4: message
static bool
Error(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
/* Compute the error message, if any. */
RootedString message(cx, nullptr);
if (args.hasDefined(0)) {
message = ToString<CanGC>(cx, args[0]);
if (!message)
return false;
}
/* Find the scripted caller. */
NonBuiltinScriptFrameIter iter(cx);
/* Set the 'fileName' property. */
RootedScript script(cx, iter.done() ? nullptr : iter.script());
RootedString fileName(cx);
if (args.length() > 1) {
fileName = ToString<CanGC>(cx, args[1]);
} else {
fileName = cx->runtime()->emptyString;
if (!iter.done()) {
if (const char *cfilename = script->filename())
fileName = JS_NewStringCopyZ(cx, cfilename);
}
}
if (!fileName)
return false;
/* Set the 'lineNumber' property. */
uint32_t lineNumber, columnNumber = 0;
if (args.length() > 2) {
if (!ToUint32(cx, args[2], &lineNumber))
return false;
} else {
lineNumber = iter.done() ? 0 : PCToLineNumber(script, iter.pc(), &columnNumber);
}
Rooted<JSString*> stack(cx, ComputeStackString(cx));
if (!stack)
return false;
/*
* ECMA ed. 3, 15.11.1 requires Error, etc., to construct even when
* called as functions, without operator new. But as we do not give
* each constructor a distinct JSClass, we must get the exception type
* ourselves.
*/
JSExnType exnType = JSExnType(args.callee().as<JSFunction>().getExtendedSlot(0).toInt32());
RootedObject obj(cx, ErrorObject::create(cx, exnType, stack, fileName,
lineNumber, columnNumber, nullptr, message));
if (!obj)
return false;
args.rval().setObject(*obj);
return true;
}
示例5: callee
static bool
WasmEval(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject callee(cx, &args.callee());
if (args.length() < 1 || args.length() > 2) {
ReportUsageError(cx, callee, "Wrong number of arguments");
return false;
}
if (!args[0].isObject() || !args[0].toObject().is<ArrayBufferObject>()) {
ReportUsageError(cx, callee, "First argument must be an ArrayBuffer");
return false;
}
RootedObject importObj(cx);
if (!args.get(1).isUndefined()) {
if (!args.get(1).isObject()) {
ReportUsageError(cx, callee, "Second argument, if present, must be an Object");
return false;
}
importObj = &args[1].toObject();
}
Rooted<ArrayBufferObject*> code(cx, &args[0].toObject().as<ArrayBufferObject>());
RootedObject exportObj(cx);
if (!Eval(cx, code, importObj, &exportObj))
return false;
args.rval().setObject(*exportObj);
return true;
}
示例6: callee
JSBool
MJitChunkLimit(JSContext *cx, unsigned argc, jsval *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (argc != 1) {
RootedObject callee(cx, &args.callee());
ReportUsageError(cx, callee, "Wrong number of arguments");
return JS_FALSE;
}
if (cx->runtime->alwaysPreserveCode) {
JS_ReportError(cx, "Can't change chunk limit after gcPreserveCode()");
return JS_FALSE;
}
double t;
if (!JS_ValueToNumber(cx, args[0], &t))
return JS_FALSE;
#ifdef JS_METHODJIT
mjit::SetChunkLimit((uint32_t) t);
#endif
// Clear out analysis information which might refer to code compiled with
// the previous chunk limit.
JS_GC(cx->runtime);
vp->setUndefined();
return true;
}
示例7: EvalKernel
bool
js::IndirectEval(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
Rooted<GlobalObject*> global(cx, &args.callee().global());
return EvalKernel(cx, args, INDIRECT_EVAL, NullFramePtr(), global, nullptr);
}
示例8: optionsObj
/*
* Forwards the call to the exported function. Clones all the non reflectors, ignores
* the |this| argument.
*/
static bool
CloningFunctionForwarder(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
// Grab the options from the reserved slot.
RootedObject optionsObj(cx, &js::GetFunctionNativeReserved(&args.callee(), 1).toObject());
FunctionForwarderOptions options(cx, optionsObj);
if (!options.Parse())
return false;
// Grab and unwrap the underlying callable.
RootedObject forwarderObj(cx, &js::GetFunctionNativeReserved(&args.callee(), 0).toObject());
RootedObject origFunObj(cx, UncheckedUnwrap(forwarderObj));
{
JSAutoCompartment ac(cx, origFunObj);
// Note: only the arguments are cloned not the |this| or the |callee|.
// Function forwarder does not use those.
StackScopedCloneOptions cloneOptions;
cloneOptions.wrapReflectors = true;
for (unsigned i = 0; i < args.length(); i++) {
RootedObject argObj(cx, args[i].isObject() ? &args[i].toObject() : nullptr);
if (options.allowCallbacks && argObj && JS_ObjectIsCallable(cx, argObj)) {
FunctionForwarderOptions innerOptions(cx);
if (!JS_WrapObject(cx, &argObj))
return false;
if (!xpc::NewFunctionForwarder(cx, JSID_VOIDHANDLE, argObj, innerOptions, args[i]))
return false;
} else if (!StackScopedClone(cx, cloneOptions, args[i])) {
return false;
}
}
// JS API does not support any JSObject to JSFunction conversion,
// so let's use JS_CallFunctionValue instead.
RootedValue functionVal(cx, ObjectValue(*origFunObj));
if (!JS_CallFunctionValue(cx, JS::NullPtr(), functionVal, args, args.rval()))
return false;
}
// Return value must be wrapped.
return JS_WrapValue(cx, args.rval());
}
示例9: EvalKernel
JSBool
js::IndirectEval(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (!WarnOnTooManyArgs(cx, args))
return false;
Rooted<GlobalObject*> global(cx, &args.callee().global());
return EvalKernel(cx, args, INDIRECT_EVAL, NullFramePtr(), global);
}
示例10:
bool
ContextStack::pushInvokeFrame(JSContext *cx, const CallArgs &args,
InitialFrameFlags initial, InvokeFrameGuard *ifg)
{
JSObject &callee = args.callee();
JSFunction *fun = callee.toFunction();
if (!pushInvokeFrame(cx, REPORT_ERROR, args, fun, initial, ifg))
return false;
return true;
}
示例11: callee
static bool
WasmCall(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedFunction callee(cx, &args.callee().as<JSFunction>());
Module& module = ExportedFunctionToModuleObject(callee)->module();
uint32_t exportIndex = ExportedFunctionToIndex(callee);
return module.callExport(cx, exportIndex, args);
}
示例12: fun
JSBool
js::LinkAsmJS(JSContext *cx, unsigned argc, JS::Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedFunction fun(cx, &args.callee().as<JSFunction>());
RootedObject moduleObj(cx, &AsmJSModuleObject(fun));
AsmJSModule &module = AsmJSModuleObjectToModule(moduleObj);
// If linking fails, recompile the function (including emitting bytecode)
// as if it's normal JS code.
if (!DynamicallyLinkModule(cx, args, module)) {
RootedPropertyName name(cx, fun->name());
return HandleDynamicLinkFailure(cx, args, module, name);
}
#if defined(MOZ_VTUNE)
if (!SendFunctionsToVTune(cx, module))
return false;
#endif
if (module.numExportedFunctions() == 1) {
const AsmJSModule::ExportedFunction &func = module.exportedFunction(0);
if (!func.maybeFieldName()) {
RootedFunction fun(cx, NewExportedFunction(cx, func, moduleObj, 0));
if (!fun)
return false;
args.rval().set(ObjectValue(*fun));
return true;
}
}
gc::AllocKind allocKind = gc::GetGCObjectKind(module.numExportedFunctions());
RootedObject obj(cx, NewBuiltinClassInstance(cx, &ObjectClass, allocKind));
if (!obj)
return false;
for (unsigned i = 0; i < module.numExportedFunctions(); i++) {
const AsmJSModule::ExportedFunction &func = module.exportedFunction(i);
RootedFunction fun(cx, NewExportedFunction(cx, func, moduleObj, i));
if (!fun)
return false;
JS_ASSERT(func.maybeFieldName() != NULL);
RootedId id(cx, NameToId(func.maybeFieldName()));
RootedValue val(cx, ObjectValue(*fun));
if (!DefineNativeProperty(cx, obj, id, val, NULL, NULL, JSPROP_ENUMERATE, 0, 0))
return false;
}
args.rval().set(ObjectValue(*obj));
return true;
}
示例13: callee
static bool
WasmCall(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedFunction callee(cx, &args.callee().as<JSFunction>());
Instance& instance = ExportedFunctionToInstance(callee);
uint32_t funcExportIndex = ExportedFunctionToExportIndex(callee);
return instance.callExport(cx, funcExportIndex, args);
}
示例14: typeObj
bool
X4Type::call(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
const uint32_t LANES = 4;
if (args.length() < LANES) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED,
args.callee().getClass()->name, "3", "s");
return false;
}
double values[LANES];
for (uint32_t i = 0; i < LANES; i++) {
if (!ToNumber(cx, args[i], &values[i]))
return false;
}
RootedObject typeObj(cx, &args.callee());
Rooted<TypedObject*> result(cx, TypedObject::createZeroed(cx, typeObj, 0));
if (!result)
return false;
X4TypeRepresentation *typeRepr = typeRepresentation(*typeObj)->asX4();
switch (typeRepr->type()) {
#define STORE_LANES(_constant, _type, _name) \
case _constant: \
{ \
_type *mem = reinterpret_cast<_type*>(result->typedMem()); \
for (uint32_t i = 0; i < LANES; i++) { \
mem[i] = ConvertScalar<_type>(values[i]); \
} \
break; \
}
JS_FOR_EACH_X4_TYPE_REPR(STORE_LANES)
#undef STORE_LANES
}
args.rval().setObject(*result);
return true;
}
示例15: CallArgsFromVp
bool
X4TypeDescr::call(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
const unsigned LANES = 4;
if (args.length() < LANES) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED,
args.callee().getClass()->name, "3", "s");
return false;
}
double values[LANES];
for (unsigned i = 0; i < LANES; i++) {
if (!ToNumber(cx, args[i], &values[i]))
return false;
}
Rooted<X4TypeDescr*> descr(cx, &args.callee().as<X4TypeDescr>());
Rooted<TypedObject*> result(cx, TypedObject::createZeroed(cx, descr, 0));
if (!result)
return false;
MOZ_ASSERT(!result->owner().isNeutered());
switch (descr->type()) {
#define STORE_LANES(_constant, _type, _name) \
case _constant: \
{ \
_type *mem = reinterpret_cast<_type*>(result->typedMem()); \
for (unsigned i = 0; i < LANES; i++) \
mem[i] = ConvertScalar<_type>(values[i]); \
break; \
}
JS_FOR_EACH_X4_TYPE_REPR(STORE_LANES)
#undef STORE_LANES
}
args.rval().setObject(*result);
return true;
}