本文整理汇总了C++中HandleObject::isFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ HandleObject::isFunction方法的具体用法?C++ HandleObject::isFunction怎么用?C++ HandleObject::isFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HandleObject
的用法示例。
在下文中一共展示了HandleObject::isFunction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: id
static JSBool
fun_enumerate(JSContext *cx, HandleObject obj)
{
JS_ASSERT(obj->isFunction());
RootedId id(cx);
bool found;
if (!obj->isBoundFunction()) {
id = NameToId(cx->runtime->atomState.classPrototypeAtom);
if (!obj->hasProperty(cx, id, &found, JSRESOLVE_QUALIFIED))
return false;
}
id = NameToId(cx->runtime->atomState.lengthAtom);
if (!obj->hasProperty(cx, id, &found, JSRESOLVE_QUALIFIED))
return false;
id = NameToId(cx->runtime->atomState.nameAtom);
if (!obj->hasProperty(cx, id, &found, JSRESOLVE_QUALIFIED))
return false;
for (unsigned i = 0; i < ArrayLength(poisonPillProps); i++) {
const uint16_t offset = poisonPillProps[i];
id = NameToId(OFFSET_TO_NAME(cx->runtime, offset));
if (!obj->hasProperty(cx, id, &found, JSRESOLVE_QUALIFIED))
return false;
}
return true;
}
示例2:
bool
CreateThis(JSContext *cx, HandleObject callee, MutableHandleValue rval)
{
rval.set(MagicValue(JS_IS_CONSTRUCTING));
if (callee->isFunction()) {
JSFunction *fun = callee->toFunction();
if (fun->isInterpreted())
rval.set(ObjectValue(*js_CreateThisForFunction(cx, callee, false)));
}
return true;
}
示例3:
bool
CreateThis(JSContext *cx, HandleObject callee, MutableHandleValue rval)
{
rval.set(MagicValue(JS_IS_CONSTRUCTING));
if (callee->isFunction()) {
JSFunction *fun = callee->toFunction();
if (fun->isInterpreted()) {
JSScript *script = fun->getOrCreateScript(cx);
if (!script || !script->ensureHasTypes(cx))
return false;
rval.set(ObjectValue(*CreateThisForFunction(cx, callee, false)));
}
}
return true;
}
示例4: clone
static RawObject
CloneObject(JSContext *cx, HandleObject srcObj, CloneMemory &clonedObjects)
{
CloneMemory::AddPtr p = clonedObjects.lookupForAdd(srcObj.get());
if (p)
return p->value;
RootedObject clone(cx);
if (srcObj->isFunction()) {
RootedFunction fun(cx, srcObj->toFunction());
clone = CloneFunctionObject(cx, fun, cx->global(), fun->getAllocKind());
} else if (srcObj->isRegExp()) {
RegExpObject &reobj = srcObj->asRegExp();
RootedAtom source(cx, reobj.getSource());
clone = RegExpObject::createNoStatics(cx, source, reobj.getFlags(), NULL);
} else if (srcObj->isDate()) {
clone = JS_NewDateObjectMsec(cx, srcObj->getDateUTCTime().toNumber());
} else if (srcObj->isBoolean()) {
clone = BooleanObject::create(cx, srcObj->asBoolean().unbox());
} else if (srcObj->isNumber()) {
clone = NumberObject::create(cx, srcObj->asNumber().unbox());
} else if (srcObj->isString()) {
Rooted<JSStableString*> str(cx, srcObj->asString().unbox()->ensureStable(cx));
if (!str)
return NULL;
str = js_NewStringCopyN(cx, str->chars().get(), str->length())->ensureStable(cx);
if (!str)
return NULL;
clone = StringObject::create(cx, str);
} else if (srcObj->isDenseArray()) {
return CloneDenseArray(cx, srcObj, clonedObjects);
} else {
if (srcObj->isArray()) {
clone = NewDenseEmptyArray(cx);
} else {
JS_ASSERT(srcObj->isNative());
clone = NewObjectWithClassProto(cx, srcObj->getClass(), NULL, cx->global(),
srcObj->getAllocKind());
}
}
if (!clone || !clonedObjects.relookupOrAdd(p, srcObj.get(), clone.get()) ||
!CloneProperties(cx, srcObj, clone, clonedObjects))
{
return NULL;
}
return clone;
}