Ignore:
Timestamp:
Dec 28, 2006, 5:44:28 PM (18 years ago)
Author:
ggaren
Message:

JavaScriptCore:

Reviewed by Brady Eidson.


Some cleanup in preparation for fixing <rdar://problem/4608404>
WebScriptObject's _executionContext lack of ownership policy causes
crashes (e.g., in Dashcode)


I'm just trying to make heads or tails of this baffling code.


Renamed "root" | "execContext" | "executionContext" => "rootObject", because
that's the object's (admittedly vague) type name.


  • bindings/runtime.cpp: Removed createLanguageInstanceForValue because I'll give you a dollar if you can explain to me what it actually did.


  • bindings/runtime_root.cpp: Put everything in the KJS::Bindings namespace, removing the KJS::Bindings prefix from individual functions and datatypes. This matches the header and eliminates a lot of syntax cruft.


  • bindings/c/c_utility.cpp: (KJS::Bindings::convertValueToNPVariant): Replaced use of createLanguageInstanceForValue with call to _NPN_CreateScriptObject because that's what createLanguageInstanceForValue actually did (but don't ask me for that dollar now; that's cheating.)
  • bindings/objc/objc_utility.h:
  • bindings/objc/objc_utility.mm: (KJS::Bindings::convertValueToObjcValue): Removed. Its only purpose was to call a single function for WebKit, which WebKit can do on its own.
  • kjs/interpreter.h: Removed rtti() because it was unused, and this class is scheduled for demolition anyway.


  • kjs/interpreter.cpp: Removed createLanguageInstanceForValue because it had nothing to do with the Interpreter, and nothing makes Chuck Norris more mad than a function whose sole purpose is to call another function of the same name. (Really, I asked him.)

WebCore:

Reviewed by Brady Eidson.


Some cleanup in preparation for fixing <rdar://problem/4608404>
WebScriptObject's _executionContext lack of ownership policy causes
crashes (e.g., in Dashcode)


Layout tests pass.

Renamed "root" | "execContext" | "executionContext" => rootObject, because
that's the object's (admittedly vague) type name.


  • bindings/js/kjs_binding.cpp:
  • bindings/js/kjs_binding.h: Removed createLanguageInstanceForValue and createObjcInstanceForValue because their only purpose was to confuse you.


  • bindings/objc/DOMInternal.h: Moved declaration of createDOMWrapper here. createDOMWrapper is the new name for createObjcInstanceForValue.


  • bindings/objc/DOMInternal.mm: Renamed Interpreter::createObjcInstanceForValue to createDOMWrapper because creating DOM wrappers has nothing to do with the interpreter, and everything to do with the DOM. Renamed value to object because it is one. Removed newObj nil check that is unnecessary in ObjC.
  • bindings/objc/WebScriptObject.mm: Replaced call to createLanguageInstanceForValue with explicit code to do the same thing it would have done: (1) try to create a DOM wrapper; (2) if the object is not a wrappable DOM object, create a vanilla WebScriptObject for it instead.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bindings/runtime.cpp

    r18339 r18461  
    9393
    9494Instance::Instance()
    95 : _executionContext(0)
    96 , _refCount(0)
     95    : _rootObject(0)
     96    , _refCount(0)
    9797{
    9898}
     
    113113}
    114114
    115 Instance *Instance::createBindingForLanguageInstance(BindingLanguage language, void *nativeInstance, const RootObject *executionContext)
     115Instance* Instance::createBindingForLanguageInstance(BindingLanguage language, void* nativeInstance, const RootObject* rootObject)
    116116{
    117117    Instance *newInstance = 0;
     
    120120#if PLATFORM(MAC)
    121121        case Instance::JavaLanguage: {
    122             newInstance = new Bindings::JavaInstance((jobject)nativeInstance, executionContext);
     122            newInstance = new Bindings::JavaInstance((jobject)nativeInstance, rootObject);
    123123            break;
    124124        }
     
    143143
    144144    if (newInstance)
    145         newInstance->setExecutionContext(executionContext);
     145        newInstance->setRootObject(rootObject);
    146146       
    147147    return newInstance;
    148148}
    149149
    150 JSObject *Instance::createRuntimeObject(BindingLanguage language, void *nativeInstance, const RootObject *executionContext)
     150JSObject* Instance::createRuntimeObject(BindingLanguage language, void* nativeInstance, const RootObject* rootObject)
    151151{
    152     Instance *interfaceObject = Instance::createBindingForLanguageInstance(language, nativeInstance, executionContext);
     152    Instance* interfaceObject = Instance::createBindingForLanguageInstance(language, nativeInstance, rootObject);
    153153   
    154154    JSLock lock;
     
    156156}
    157157
    158 void *Instance::createLanguageInstanceForValue(ExecState*, BindingLanguage language, JSObject* value, const RootObject* origin, const RootObject* current)
    159 {
    160     void *result = 0;
    161    
    162     if (!value->isObject())
    163         return 0;
    164 
    165     JSObject *imp = static_cast<JSObject*>(value);
    166    
    167     switch (language) {
    168 #if PLATFORM(MAC)
    169         case Instance::ObjectiveCLanguage: {
    170             result = createObjcInstanceForValue(value, origin, current);
    171             break;
    172         }
    173         case Instance::JavaLanguage: {
    174             // FIXME:  factor creation of jni_jsobjects, also remove unnecessary thread
    175             // invocation code.
    176             break;
    177         }
    178 #endif
    179         case Instance::CLanguage: {
    180             result = _NPN_CreateScriptObject(0, imp, origin, current);
    181             break;
    182         }
    183         default:
    184             break;
    185     }
    186    
    187     return result;
    188 }
    189 
    190158} } // namespace KJS::Bindings
Note: See TracChangeset for help on using the changeset viewer.