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; }
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)); }
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); }
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); }
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); }
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); }
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)); }
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); }
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)); }
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); }
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)); }
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); }
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); }
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)); }
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)); }
JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass) { initializeThreading(); RefPtr<VM> vm = group ? PassRefPtr<VM>(toJS(group)) : VM::createContextGroup(); APIEntryShim entryShim(vm.get(), false); vm->makeUsableFromMultipleThreads(); if (!globalObjectClass) { JSGlobalObject* globalObject = JSGlobalObject::create(*vm, JSGlobalObject::createStructure(*vm, jsNull())); 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); return JSGlobalContextRetain(toGlobalRef(exec)); }
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. #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) if (NSVersionOfLinkTimeLibrary("JavaScriptCore") <= webkitFirstVersionWithConcurrentGlobalContexts) { #else { #endif return JSGlobalContextCreateInGroup(toRef(&JSGlobalData::sharedInstance()), globalObjectClass); } #endif // OS(DARWIN) return JSGlobalContextCreateInGroup(0, globalObjectClass); } JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass) { initializeThreading(); RefPtr<JSGlobalData> globalData = group ? PassRefPtr<JSGlobalData>(toJS(group)) : JSGlobalData::createNonDefault(); APIEntryShim entryShim(globalData.get()); if (!globalObjectClass) { JSGlobalObject* globalObject = new (globalData.get()) JSGlobalObject; return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec())); } JSGlobalObject* globalObject = new (globalData.get()) JSCallbackObject<JSGlobalObject>(globalObjectClass); ExecState* exec = globalObject->globalExec(); JSValue prototype = globalObjectClass->prototype(exec); if (!prototype) prototype = jsNull(); globalObject->resetPrototype(prototype); return JSGlobalContextRetain(toGlobalRef(exec)); }
void JSClassRelease(JSClassRef jsClass) { JSLock lock; jsClass->deref(); }
void JSClassRelease(JSClassRef jsClass) { jsClass->deref(); }
JSClassRef JSClassRetain(JSClassRef jsClass) { jsClass->ref(); return jsClass; }
JSClassRef JSClassRetain(JSClassRef jsClass) { JSLock lock; jsClass->ref(); return jsClass; }