本文整理汇总了C++中JSFunction::isFunctionPrototype方法的典型用法代码示例。如果您正苦于以下问题:C++ JSFunction::isFunctionPrototype方法的具体用法?C++ JSFunction::isFunctionPrototype怎么用?C++ JSFunction::isFunctionPrototype使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSFunction
的用法示例。
在下文中一共展示了JSFunction::isFunctionPrototype方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: proto
static JSObject *
ResolveInterpretedFunctionPrototype(JSContext *cx, HandleObject obj)
{
#ifdef DEBUG
JSFunction *fun = obj->toFunction();
JS_ASSERT(fun->isInterpreted());
JS_ASSERT(!fun->isFunctionPrototype());
#endif
/*
* Assert that fun is not a compiler-created function object, which
* must never leak to script or embedding code and then be mutated.
* Also assert that obj is not bound, per the ES5 15.3.4.5 ref above.
*/
JS_ASSERT(!IsInternalFunctionObject(obj));
JS_ASSERT(!obj->isBoundFunction());
/*
* Make the prototype object an instance of Object with the same parent
* as the function object itself.
*/
JSObject *objProto = obj->global().getOrCreateObjectPrototype(cx);
if (!objProto)
return NULL;
RootedObject proto(cx, NewObjectWithGivenProto(cx, &ObjectClass, objProto, NULL));
if (!proto || !proto->setSingletonType(cx))
return NULL;
/*
* Per ES5 15.3.5.2 a user-defined function's .prototype property is
* initially non-configurable, non-enumerable, and writable. Per ES5 13.2
* the prototype's .constructor property is configurable, non-enumerable,
* and writable.
*/
RootedValue protoVal(cx, ObjectValue(*proto));
RootedValue objVal(cx, ObjectValue(*obj));
if (!obj->defineProperty(cx, cx->runtime->atomState.classPrototypeAtom,
protoVal, JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_PERMANENT) ||
!proto->defineProperty(cx, cx->runtime->atomState.constructorAtom,
objVal, JS_PropertyStub, JS_StrictPropertyStub, 0))
{
return NULL;
}
return proto;
}