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_root.cpp

    r15990 r18461  
    2929#include <wtf/HashCountedSet.h>
    3030
    31 using namespace KJS;
    32 using namespace KJS::Bindings;
     31namespace KJS { namespace Bindings {
    3332
    3433// Java does NOT always call finalize (and thus KJS_JSObject_JSFinalize) when
     
    4645// are represented by a jlong.
    4746
    48 typedef HashMap<const Bindings::RootObject*, ReferencesSet*> ReferencesByRootMap;
     47typedef HashMap<const RootObject*, ReferencesSet*> ReferencesByRootMap;
    4948
    5049static ReferencesByRootMap* getReferencesByRootMap()
     
    5857}
    5958
    60 static ReferencesSet* getReferencesSet(const Bindings::RootObject *root)
     59static ReferencesSet* getReferencesSet(const RootObject* rootObject)
    6160{
    6261    ReferencesByRootMap* refsByRoot = getReferencesByRootMap();
    6362    ReferencesSet* referencesSet = 0;
    6463   
    65     referencesSet = refsByRoot->get(root);
     64    referencesSet = refsByRoot->get(rootObject);
    6665    if (!referencesSet) {
    6766        referencesSet  = new ReferencesSet;
    68         refsByRoot->add(root, referencesSet);
     67        refsByRoot->add(rootObject, referencesSet);
    6968    }
    7069    return referencesSet;
     
    7675// FIXME:  This is a potential performance bottleneck with many applets.  We could fix be adding a
    7776// imp to root dictionary.
    78 ReferencesSet* KJS::Bindings::findReferenceSet(JSObject *imp)
     77ReferencesSet* findReferenceSet(JSObject* imp)
    7978{
    8079    ReferencesByRootMap* refsByRoot = getReferencesByRootMap ();
     
    9493// FIXME:  This is a potential performance bottleneck with many applets.  We could fix be adding a
    9594// imp to root dictionary.
    96 const Bindings::RootObject *KJS::Bindings::rootForImp (JSObject *imp)
     95const RootObject* rootObjectForImp (JSObject* imp)
    9796{
    9897    ReferencesByRootMap* refsByRoot = getReferencesByRootMap ();
    99     const Bindings::RootObject *rootObject = 0;
     98    const RootObject* rootObject = 0;
    10099   
    101100    if (refsByRoot) {
     
    113112}
    114113
    115 const Bindings::RootObject *KJS::Bindings::rootForInterpreter (KJS::Interpreter *interpreter)
     114const RootObject* rootObjectForInterpreter(Interpreter* interpreter)
    116115{
    117116    ReferencesByRootMap* refsByRoot = getReferencesByRootMap ();
     
    120119        ReferencesByRootMap::const_iterator end = refsByRoot->end();
    121120        for (ReferencesByRootMap::const_iterator it = refsByRoot->begin(); it != end; ++it) {
    122             const Bindings::RootObject* aRootObject = it->first;
     121            const RootObject* aRootObject = it->first;
    123122           
    124123            if (aRootObject->interpreter() == interpreter)
     
    130129}
    131130
    132 void KJS::Bindings::addNativeReference (const Bindings::RootObject *root, JSObject *imp)
    133 {
    134     if (root) {
    135         ReferencesSet* referenceMap = getReferencesSet (root);
     131void addNativeReference(const RootObject* rootObject, JSObject* imp)
     132{
     133    if (rootObject) {
     134        ReferencesSet* referenceMap = getReferencesSet(rootObject);
    136135       
    137136        unsigned numReferences = referenceMap->count(imp);
     
    144143}
    145144
    146 void KJS::Bindings::removeNativeReference (JSObject *imp)
     145void removeNativeReference(JSObject* imp)
    147146{
    148147    if (!imp)
     
    280279    // thread that a JavaScript call needs to be invoked.
    281280    CFRunLoopSourceContext sourceContext = {0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, performJavaScriptAccess};
    282     Bindings::RootObject::_performJavaScriptSource = CFRunLoopSourceCreate(NULL, 0, &sourceContext);
    283     CFRunLoopAddSource(Bindings::RootObject::_runLoop, Bindings::RootObject::_performJavaScriptSource, kCFRunLoopDefaultMode);
     281    RootObject::_performJavaScriptSource = CFRunLoopSourceCreate(NULL, 0, &sourceContext);
     282    CFRunLoopAddSource(RootObject::_runLoop, RootObject::_performJavaScriptSource, kCFRunLoopDefaultMode);
    284283}
    285284#endif
     
    303302}
    304303
    305 void RootObject::setInterpreter (KJS::Interpreter *i)
    306 {
    307     _interpreter = i;
    308 }
    309 
    310 
     304void RootObject::setInterpreter (Interpreter* interpreter)
     305{
     306    _interpreter = interpreter;
     307}
     308
     309} } // namespace KJS::Bindings
Note: See TracChangeset for help on using the changeset viewer.