Ignore:
Timestamp:
Jan 13, 2008, 3:08:39 AM (17 years ago)
Author:
[email protected]
Message:

2008-01-13 Michael Goddard <[email protected]>

Reviewed by Anders Carlsson.

Add binding language type to Instance.
Allows runtime determination of the type of an
Instance, to allow safe casting. Doesn't actually
add any safe casting yet, though.

Add a helper function to get an Instance from a JSObject*.
Given an object and the expected binding language, see if
the JSObject actually wraps an Instance of the given type
and return it. Otherwise return 0.

Move RuntimeObjectImp creations into Instance.
Make the ctor protected, and Instance a friend class, so
that all creation of RuntimeObjectImps goes through
one place.

Remove copy ctor/assignment operator for QtInstance.
Instance itself is Noncopyable, so QtInstance doesn't
need to have these.

Add caching for QtInstance and associated RuntimeObjectImps.
Push any dealings with QtLanguage bindings into QtInstance,
and cache them there, rather than in the Instance layer. Add
a QtRuntimeObjectImp to help with caching.

  • JavaScriptCore.exp:
  • bindings/c/c_instance.h:
  • bindings/jni/jni_instance.h:
  • bindings/objc/objc_instance.h:
  • bindings/qt/qt_instance.cpp: (KJS::Bindings::QtRuntimeObjectImp::QtRuntimeObjectImp): (KJS::Bindings::QtRuntimeObjectImp::~QtRuntimeObjectImp): (KJS::Bindings::QtRuntimeObjectImp::invalidate): (KJS::Bindings::QtRuntimeObjectImp::removeFromCache): (KJS::Bindings::QtInstance::QtInstance): (KJS::Bindings::QtInstance::~QtInstance): (KJS::Bindings::QtInstance::getQtInstance): (KJS::Bindings::QtInstance::getRuntimeObject):
  • bindings/qt/qt_instance.h: (KJS::Bindings::QtInstance::getBindingLanguage):
  • bindings/runtime.cpp: (KJS::Bindings::Instance::createBindingForLanguageInstance): (KJS::Bindings::Instance::createRuntimeObject): (KJS::Bindings::Instance::getInstance):
  • bindings/runtime.h:
  • bindings/runtime_object.h: (KJS::RuntimeObjectImp::getInternalInstance):

2008-01-13 Michael Goddard <[email protected]>

Reviewed by Anders Carlsson.

Move RuntimeObjectImp creations into Instance.
Make the ctor protected, and Instance a friend class, so
that all creation of RuntimeObjectImps goes through
one place.

  • bindings/js/kjs_dom.cpp: (WebCore::getRuntimeObject):
File:
1 edited

Legend:

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

    r25000 r29447  
    106106#if PLATFORM(QT)
    107107        case Instance::QtLanguage: {
    108             newInstance = new Bindings::QtInstance((QObject *)nativeInstance, rootObject);
     108            newInstance = Bindings::QtInstance::getQtInstance((QObject *)nativeInstance, rootObject);
    109109            break;
    110110        }
     
    120120{
    121121    Instance* instance = Instance::createBindingForLanguageInstance(language, nativeInstance, rootObject);
    122    
     122
     123    return createRuntimeObject(instance);
     124}
     125
     126JSObject* Instance::createRuntimeObject(Instance* instance)
     127{
     128#if PLATFORM(QT)
     129    if (instance->getBindingLanguage() == QtLanguage)
     130        return QtInstance::getRuntimeObject(static_cast<QtInstance*>(instance));
     131#endif
    123132    JSLock lock;
    124133    return new RuntimeObjectImp(instance);
    125134}
    126135
    127 RootObject* Instance::rootObject() const
    128 {
     136Instance* Instance::getInstance(JSObject* object, BindingLanguage language)
     137{
     138    if (!object)
     139        return 0;
     140    if (!object->inherits(&RuntimeObjectImp::info))
     141        return 0;
     142    Instance* instance = (static_cast<RuntimeObjectImp*>(object))->getInternalInstance();
     143    if (!instance)
     144        return 0;
     145    if (instance->getBindingLanguage() != language)
     146        return 0;
     147    return instance;
     148}
     149
     150RootObject* Instance::rootObject() const
     151{
    129152    return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0;
    130153}
Note: See TracChangeset for help on using the changeset viewer.