本文整理汇总了C++中GlobalObject::createBlankPrototype方法的典型用法代码示例。如果您正苦于以下问题:C++ GlobalObject::createBlankPrototype方法的具体用法?C++ GlobalObject::createBlankPrototype怎么用?C++ GlobalObject::createBlankPrototype使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlobalObject
的用法示例。
在下文中一共展示了GlobalObject::createBlankPrototype方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
JSObject *
js_InitBooleanClass(JSContext *cx, JSObject *obj)
{
JS_ASSERT(obj->isNative());
GlobalObject *global = obj->asGlobal();
JSObject *booleanProto = global->createBlankPrototype(cx, &BooleanClass);
if (!booleanProto)
return NULL;
booleanProto->setPrimitiveThis(BooleanValue(false));
JSFunction *ctor = global->createConstructor(cx, Boolean, &BooleanClass,
CLASS_ATOM(cx, Boolean), 1);
if (!ctor)
return NULL;
if (!LinkConstructorAndPrototype(cx, ctor, booleanProto))
return NULL;
if (!DefinePropertiesAndBrand(cx, booleanProto, NULL, boolean_methods))
return NULL;
if (!DefineConstructorAndPrototype(cx, global, JSProto_Boolean, ctor, booleanProto))
return NULL;
return booleanProto;
}
示例2:
JSObject *
js_InitWeakMapClass(JSContext *cx, JSObject *obj)
{
JS_ASSERT(obj->isNative());
GlobalObject *global = obj->asGlobal();
JSObject *weakMapProto = global->createBlankPrototype(cx, &WeakMapClass);
if (!weakMapProto)
return NULL;
weakMapProto->setPrivate(NULL);
JSFunction *ctor = global->createConstructor(cx, WeakMap_construct, &WeakMapClass,
CLASS_ATOM(cx, WeakMap), 0);
if (!ctor)
return NULL;
if (!LinkConstructorAndPrototype(cx, ctor, weakMapProto))
return NULL;
if (!DefinePropertiesAndBrand(cx, weakMapProto, NULL, weak_map_methods))
return NULL;
if (!DefineConstructorAndPrototype(cx, global, JSProto_WeakMap, ctor, weakMapProto))
return NULL;
return weakMapProto;
}