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/NP_jsobject.cpp

    r15972 r18461  
    6262static bool _isSafeScript(JavaScriptObject* obj)
    6363{
    64     if (obj->originExecutionContext) {
    65         Interpreter* originInterpreter = obj->originExecutionContext->interpreter();
     64    if (obj->originRootObject) {
     65        Interpreter* originInterpreter = obj->originRootObject->interpreter();
    6666        if (originInterpreter)
    67             return originInterpreter->isSafeScript(obj->executionContext->interpreter());
     67            return originInterpreter->isSafeScript(obj->rootObject->interpreter());
    6868    }
    6969    return true;
    7070}
    7171
    72 NPObject *_NPN_CreateScriptObject (NPP npp, JSObject *imp, const RootObject *originExecutionContext, const RootObject *executionContext)
     72NPObject* _NPN_CreateScriptObject (NPP npp, JSObject* imp, const RootObject* originRootObject, const RootObject* rootObject)
    7373{
    7474    JavaScriptObject* obj = (JavaScriptObject*)_NPN_CreateObject(npp, NPScriptObjectClass);
    7575
    7676    obj->imp = imp;
    77     obj->originExecutionContext = originExecutionContext;   
    78     obj->executionContext = executionContext;   
    79 
    80     addNativeReference(executionContext, imp);
     77    obj->originRootObject = originRootObject;   
     78    obj->rootObject = rootObject;   
     79
     80    addNativeReference(rootObject, imp);
    8181
    8282    return (NPObject *)obj;
     
    120120
    121121        // Lookup the function object.
    122         ExecState* exec = obj->executionContext->interpreter()->globalExec();
     122        ExecState* exec = obj->rootObject->interpreter()->globalExec();
    123123        JSLock lock;
    124124        JSValue* func = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string));
     
    157157            return false;
    158158
    159         ExecState* exec = obj->executionContext->interpreter()->globalExec();
     159        ExecState* exec = obj->rootObject->interpreter()->globalExec();
    160160       
    161161        JSLock lock;
     
    163163        unsigned int UTF16Length;
    164164        convertNPStringToUTF16(s, &scriptString, &UTF16Length); // requires free() of returned memory
    165         Completion completion = obj->executionContext->interpreter()->evaluate(UString(), 0, UString((const UChar*)scriptString,UTF16Length));
     165        Completion completion = obj->rootObject->interpreter()->evaluate(UString(), 0, UString((const UChar*)scriptString,UTF16Length));
    166166        ComplType type = completion.complType();
    167167       
     
    192192            return false;
    193193
    194         ExecState* exec = obj->executionContext->interpreter()->globalExec();
     194        ExecState* exec = obj->rootObject->interpreter()->globalExec();
    195195        PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
    196196       
     
    231231            return false;
    232232
    233         ExecState* exec = obj->executionContext->interpreter()->globalExec();
     233        ExecState* exec = obj->rootObject->interpreter()->globalExec();
    234234        JSLock lock;
    235235        PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
     
    254254            return false;
    255255
    256         ExecState* exec = obj->executionContext->interpreter()->globalExec();
     256        ExecState* exec = obj->rootObject->interpreter()->globalExec();
    257257        PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
    258258        if (i->isString) {
     
    282282            return false;
    283283
    284         ExecState* exec = obj->executionContext->interpreter()->globalExec();
     284        ExecState* exec = obj->rootObject->interpreter()->globalExec();
    285285        PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
    286286        JSLock lock;
     
    307307            return false;
    308308
    309         ExecState* exec = obj->executionContext->interpreter()->globalExec();
     309        ExecState* exec = obj->rootObject->interpreter()->globalExec();
    310310        JSLock lock;
    311311        JSValue* func = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string));
     
    323323    if (o->_class == NPScriptObjectClass) {
    324324        JavaScriptObject* obj = (JavaScriptObject*)o;
    325         ExecState* exec = obj->executionContext->interpreter()->globalExec();
     325        ExecState* exec = obj->rootObject->interpreter()->globalExec();
    326326        JSLock lock;
    327327        throwError(exec, GeneralError, message);
Note: See TracChangeset for help on using the changeset viewer.