Ignore:
Timestamp:
Nov 18, 2007, 1:09:27 AM (18 years ago)
Author:
[email protected]
Message:

Fix: <rdar://problem/5607032> (REGRESSION: testapi exits with assertion failure in debug build) and <rdar://problem/5440659> (JSGlobalContextCreate throws away globalObjectClass's prototype)

Split Interpreter's initialization into two distinct steps: the creation of the global prototypes
and constructors, and storing them on the global object. This allows JSClassRef's passed to
JSGlobalContextCreate to be instantiated with the correct prototype.

Reviewed by Darin Adler.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r27022 r27885  
    4242JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, JSClassRef jsClass, JSValue* prototype, void* data)
    4343    : Base(prototype)
    44     , m_class(0)
    45     , m_isInitialized(false)
    46 {
    47     init(exec, jsClass, data);
    48 }
    49 
    50 template <class Base>
    51 void JSCallbackObject<Base>::init(ExecState* exec, JSClassRef jsClass, void* data)
    52 {
    53     m_privateData = data;
    54     JSClassRef oldClass = m_class;
    55     m_class = JSClassRetain(jsClass);
    56     if (oldClass)
    57         JSClassRelease(oldClass);
    58    
    59     if (!exec)
    60         return;
     44    , m_privateData(data)
     45    , m_class(JSClassRetain(jsClass))
     46{
     47    init(exec);
     48}
     49
     50template <class Base>
     51JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass, JSValue* prototype, void* data)
     52    : Base(prototype)
     53    , m_privateData(data)
     54    , m_class(JSClassRetain(jsClass))
     55{
     56}
     57
     58template <class Base>
     59void JSCallbackObject<Base>::init(ExecState* exec)
     60{
     61    ASSERT(exec);
    6162   
    6263    Vector<JSObjectInitializeCallback, 16> initRoutines;
     64    JSClassRef jsClass = m_class;
    6365    do {
    6466        if (JSObjectInitializeCallback initialize = jsClass->initialize)
     
    7274        initialize(toRef(exec), toRef(this));
    7375    }
    74     m_isInitialized = true;
    7576}
    7677
     
    8687           
    8788    JSClassRelease(m_class);
    88 }
    89 
    90 template <class Base>
    91 void JSCallbackObject<Base>::initializeIfNeeded(ExecState* exec)
    92 {
    93     if (m_isInitialized)
    94         return;
    95     init(exec, m_class, m_privateData);
    9689}
    9790
Note: See TracChangeset for help on using the changeset viewer.