本文整理汇总了C++中JSClassRef类的典型用法代码示例。如果您正苦于以下问题:C++ JSClassRef类的具体用法?C++ JSClassRef怎么用?C++ JSClassRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JSClassRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toJS
JSValueRef JSCallbackFunction::toStringCallback(JSContextRef ctx, JSObjectRef, JSObjectRef thisObject, size_t, const JSValueRef[], JSValueRef* exception)
{
JSObject* object = toJS(thisObject);
if (object->inherits(&JSCallbackObject<JSNonFinalObject>::s_info)) {
for (JSClassRef jsClass = jsCast<JSCallbackObject<JSNonFinalObject>*>(object)->classRef(); jsClass; jsClass = jsClass->parentClass)
if (jsClass->convertToType)
return jsClass->convertToType(ctx, thisObject, kJSTypeString, exception);
} else if (object->inherits(&JSCallbackObject<JSGlobalObject>::s_info)) {
for (JSClassRef jsClass = jsCast<JSCallbackObject<JSGlobalObject>*>(object)->classRef(); jsClass; jsClass = jsClass->parentClass)
if (jsClass->convertToType)
return jsClass->convertToType(ctx, thisObject, kJSTypeString, exception);
}
return 0;
}
示例2: JSGlobalContextCreateInGroup
JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass)
{
initializeThreading();
RefPtr<VM> vm = group ? PassRefPtr<VM>(toJS(group)) : VM::createContextGroup();
JSLockHolder locker(vm.get());
if (!globalObjectClass) {
JSGlobalObject* globalObject = JSGlobalObject::create(*vm, JSGlobalObject::createStructure(*vm, jsNull()));
#if ENABLE(REMOTE_INSPECTOR)
if (JSRemoteInspectorGetInspectionEnabledByDefault())
globalObject->setRemoteDebuggingEnabled(true);
#endif
return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec()));
}
JSGlobalObject* globalObject = JSCallbackObject<JSGlobalObject>::create(*vm, globalObjectClass, JSCallbackObject<JSGlobalObject>::createStructure(*vm, 0, jsNull()));
ExecState* exec = globalObject->globalExec();
JSValue prototype = globalObjectClass->prototype(exec);
if (!prototype)
prototype = jsNull();
globalObject->resetPrototype(*vm, prototype);
#if ENABLE(REMOTE_INSPECTOR)
if (JSRemoteInspectorGetInspectionEnabledByDefault())
globalObject->setRemoteDebuggingEnabled(true);
#endif
return JSGlobalContextRetain(toGlobalRef(exec));
}
示例3: JSObjectMakeConstructor
JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSValue jsPrototype = jsClass ? jsClass->prototype(exec) : 0;
if (!jsPrototype)
jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
JSCallbackConstructor* constructor = JSCallbackConstructor::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
constructor->putDirect(exec->globalData(), exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
return toRef(constructor);
}
示例4: JSObjectMakeConstructor
JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor)
{
JSLock lock;
ExecState* exec = toJS(ctx);
JSValue* jsPrototype = jsClass
? jsClass->prototype(ctx)
: exec->dynamicGlobalObject()->objectPrototype();
JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec, jsClass, callAsConstructor);
constructor->putDirect(exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
return toRef(constructor);
}
示例5: JSObjectMake
JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
if (!jsClass)
return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure())); // slightly more efficient
JSCallbackObject<JSObject>* object = new (exec) JSCallbackObject<JSObject>(exec, exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
if (JSObject* prototype = jsClass->prototype(exec))
object->setPrototype(prototype);
return toRef(object);
}
示例6: JSObjectMakeConstructor
JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap.registerThread();
JSLock lock(exec);
JSValuePtr jsPrototype = jsClass
? jsClass->prototype(exec)
: exec->lexicalGlobalObject()->objectPrototype();
JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
constructor->putDirect(exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
return toRef(constructor);
}
示例7: JSObjectMake
JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data)
{
JSLock lock;
ExecState* exec = toJS(ctx);
if (!jsClass)
return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype())); // slightly more efficient
JSValue* jsPrototype = jsClass->prototype(ctx);
if (!jsPrototype)
jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
return toRef(new (exec) JSCallbackObject<JSObject>(exec, jsClass, jsPrototype, data));
}
示例8: JSObjectMake
JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
if (!jsClass)
return toRef(constructEmptyObject(exec));
JSCallbackObject<JSNonFinalObject>* object = JSCallbackObject<JSNonFinalObject>::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
if (JSObject* prototype = jsClass->prototype(exec))
object->setPrototype(exec->globalData(), prototype);
return toRef(object);
}
示例9: JSObjectMake
JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap->registerThread();
JSLock lock(exec);
if (!jsClass)
return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype())); // slightly more efficient
JSObject* jsPrototype = jsClass->prototype(exec);
if (!jsPrototype)
jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
return toRef(new (exec) JSCallbackObject<JSObject>(exec, jsClass, jsPrototype, data));
}
示例10: JSObjectMakeConstructor
JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
JSValue jsPrototype = jsClass ? jsClass->prototype(exec) : 0;
if (!jsPrototype)
jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
JSCallbackConstructor* constructor = JSCallbackConstructor::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
constructor->putDirect(exec->vm(), exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
return toRef(constructor);
}
示例11: JSGlobalContextCreate
JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass)
{
initializeThreading();
#if OS(DARWIN)
// When running on Tiger or Leopard, or if the application was linked before JSGlobalContextCreate was changed
// to use a unique JSGlobalData, we use a shared one for compatibility.
#ifndef BUILDING_ON_LEOPARD
if (NSVersionOfLinkTimeLibrary("JavaScriptCore") <= webkitFirstVersionWithConcurrentGlobalContexts) {
#else
{
#endif
JSLock lock(LockForReal);
return JSGlobalContextCreateInGroup(toRef(&JSGlobalData::sharedInstance()), globalObjectClass);
}
#endif // OS(DARWIN)
return JSGlobalContextCreateInGroup(0, globalObjectClass);
}
JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass)
{
initializeThreading();
JSLock lock(LockForReal);
RefPtr<JSGlobalData> globalData = group ? PassRefPtr<JSGlobalData>(toJS(group)) : JSGlobalData::createContextGroup(ThreadStackTypeSmall);
APIEntryShim entryShim(globalData.get(), false);
#if ENABLE(JSC_MULTIPLE_THREADS)
globalData->makeUsableFromMultipleThreads();
#endif
if (!globalObjectClass) {
JSGlobalObject* globalObject = JSGlobalObject::create(*globalData, JSGlobalObject::createStructure(*globalData, jsNull()));
return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec()));
}
JSGlobalObject* globalObject = JSCallbackObject<JSGlobalObject>::create(*globalData, globalObjectClass, JSCallbackObject<JSGlobalObject>::createStructure(*globalData, 0, jsNull()));
ExecState* exec = globalObject->globalExec();
JSValue prototype = globalObjectClass->prototype(exec);
if (!prototype)
prototype = jsNull();
globalObject->resetPrototype(*globalData, prototype);
return JSGlobalContextRetain(toGlobalRef(exec));
}
示例12: JSObjectMake
JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
if (!jsClass)
return toRef(constructEmptyObject(exec));
JSCallbackObject<JSDestructibleObject>* object = JSCallbackObject<JSDestructibleObject>::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
if (JSObject* prototype = jsClass->prototype(exec))
object->setPrototype(exec->vm(), prototype);
return toRef(object);
}
示例13: JSGlobalContextCreate
JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass)
{
initializeThreading();
JSLock lock;
if (!globalObjectClass) {
JSGlobalObject* globalObject = new (JSGlobalObject::Shared) JSGlobalObject;
return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec()));
}
JSGlobalObject* globalObject = new (JSGlobalObject::Shared) JSCallbackObject<JSGlobalObject>(globalObjectClass);
JSGlobalContextRef ctx = toGlobalRef(globalObject->globalExec());
JSValue* prototype = globalObjectClass->prototype(ctx);
if (!prototype)
prototype = jsNull();
globalObject->reset(prototype);
return JSGlobalContextRetain(ctx);
}
示例14: JSGlobalContextCreate
JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass)
{
initializeThreading();
JSLock lock(true);
JSGlobalData* sharedGlobalData = &JSGlobalData::sharedInstance();
if (!globalObjectClass) {
JSGlobalObject* globalObject = new (sharedGlobalData) JSGlobalObject;
return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec()));
}
JSGlobalObject* globalObject = new (sharedGlobalData) JSCallbackObject<JSGlobalObject>(globalObjectClass);
ExecState* exec = globalObject->globalExec();
JSValue* prototype = globalObjectClass->prototype(exec);
if (!prototype)
prototype = jsNull();
globalObject->reset(prototype);
return JSGlobalContextRetain(toGlobalRef(exec));
}
示例15: JSGlobalContextCreateInGroup
JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass)
{
initializeThreading();
JSLock lock(true);
RefPtr<JSGlobalData> globalData = group ? PassRefPtr<JSGlobalData>(toJS(group)) : JSGlobalData::create();
if (!globalObjectClass) {
JSGlobalObject* globalObject = new (globalData.get()) JSGlobalObject(globalData.get());
return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec()));
}
JSGlobalObject* globalObject = new (globalData.get()) JSCallbackObject<JSGlobalObject>(globalData.get(), globalObjectClass);
ExecState* exec = globalObject->globalExec();
JSValue* prototype = globalObjectClass->prototype(exec);
if (!prototype)
prototype = jsNull();
globalObject->resetPrototype(prototype);
return JSGlobalContextRetain(toGlobalRef(exec));
}