Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
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));
}