Ignore:
Timestamp:
Feb 11, 2005, 4:58:13 PM (20 years ago)
Author:
rjw
Message:

WebCore:

Fixed <rdar://problem/3985118> DOM objects not being marshaled on JS->native calls

Re-factored how 'native' wrappers for JS objects are created. The interpreter now
creates these wrappers. The WebCore subclass of the interpreter now overrides
createLanguageInstanceForValue() and creates a DOM ObjC wrapper for DOM objects.

  • WebCore.pbproj/project.pbxproj:
  • khtml/ecma/kjs_binding.cpp: (ScriptInterpreter::createLanguageInstanceForValue):
  • khtml/ecma/kjs_binding.h:
  • kwq/DOMUtility.mm: Added. (KJS::ScriptInterpreter::createObjcInstanceForValue):
  • kwq/KWQKHTMLPart.mm: (KWQKHTMLPart::getAppletInstanceForView): (getInstanceForView): (KWQKHTMLPart::getEmbedInstanceForView): (KWQKHTMLPart::getObjectInstanceForView):

JavaScriptCore:

Fixed <rdar://problem/3985118> DOM objects not being marshaled on JS->native calls

Re-factored how 'native' wrappers for JS objects are created. The interpreter now
creates these wrappers. The WebCore subclass of the interpreter now overrides
createLanguageInstanceForValue() and creates a DOM ObjC wrapper for DOM objects.

Reviewed by Ken.

  • bindings/c/c_utility.cpp: (convertValueToNPVariant):
  • bindings/jni/jni_instance.cpp: (JavaInstance::invokeMethod):
  • bindings/jni/jni_runtime.cpp: (JavaField::valueFromInstance): (JavaArray::valueAt):
  • bindings/objc/WebScriptObject.mm: (-[WebScriptObject _setExecutionContext:KJS::Bindings::]): (+[WebScriptObject _convertValueToObjcValue:KJS::originExecutionContext:Bindings::executionContext:Bindings::]):
  • bindings/objc/WebScriptObjectPrivate.h:
  • bindings/objc/objc_utility.h:
  • bindings/objc/objc_utility.mm: (KJS::Bindings::convertObjcValueToValue): (KJS::Bindings::createObjcInstanceForValue):
  • bindings/runtime.cpp: (Instance::createBindingForLanguageInstance): (Instance::createRuntimeObject): (Instance::createLanguageInstanceForValue):
  • bindings/runtime.h:
  • kjs/interpreter.cpp: (Interpreter::createLanguageInstanceForValue):
  • kjs/interpreter.h:
File:
1 edited

Legend:

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

    r8384 r8585  
    3030#include <objc_instance.h>
    3131#include <c_instance.h>
     32#include <NP_jsobject.h>
     33#include <jni_jsobject.h>
    3234
    3335using namespace KJS;
     
    98100}
    99101
    100 Instance *Instance::createBindingForLanguageInstance (BindingLanguage language, void *instance)
     102Instance *Instance::createBindingForLanguageInstance (BindingLanguage language, void *nativeInstance, const RootObject *executionContext)
    101103{
    102     if (language == Instance::JavaLanguage)
    103         return new Bindings::JavaInstance ((jobject)instance, 0);
    104     else if (language == Instance::ObjectiveCLanguage)
    105         return new Bindings::ObjcInstance ((struct objc_object *)instance);
     104    Instance *newInstance = 0;
     105   
     106    switch (language) {
     107        case Instance::JavaLanguage: {
     108            newInstance = new Bindings::JavaInstance ((jobject)nativeInstance, executionContext);
     109            break;
     110        }
     111        case Instance::ObjectiveCLanguage: {
     112            newInstance = new Bindings::ObjcInstance ((struct objc_object *)nativeInstance);
     113            break;
     114        }
     115        case Instance::CLanguage: {
     116            newInstance = new Bindings::CInstance ((NPObject *)nativeInstance);
     117            break;
     118        }
     119        default:
     120            break;
     121    }
    106122
    107     else if (language == Instance::CLanguage)
    108         return new Bindings::CInstance ((NPObject *)instance);
    109 
    110     return 0;
     123    if (newInstance)
     124        newInstance->setExecutionContext (executionContext);
     125       
     126    return newInstance;
    111127}
    112128
    113 Object Instance::createRuntimeObject (BindingLanguage language, void *myInterface)
     129Object Instance::createRuntimeObject (BindingLanguage language, void *nativeInstance, const RootObject *executionContext)
    114130{
    115     Instance *interfaceObject = Instance::createBindingForLanguageInstance (language, (void *)myInterface);
     131    Instance *interfaceObject = Instance::createBindingForLanguageInstance (language, (void *)nativeInstance, executionContext);
    116132   
    117133    Interpreter::lock();
     
    120136   
    121137    return theObject;
     138}
     139
     140void *Instance::createLanguageInstanceForValue (ExecState *exec, BindingLanguage language, const Object &value, const RootObject *origin, const RootObject *current)
     141{
     142    void *result = 0;
     143   
     144    if (value.type() != ObjectType)
     145        return 0;
     146
     147    ObjectImp *imp = static_cast<ObjectImp*>(value.imp());
     148   
     149    switch (language) {
     150        case Instance::ObjectiveCLanguage: {
     151            result = createObjcInstanceForValue (value, origin, current);
     152            break;
     153        }
     154        case Instance::CLanguage: {
     155            result = _NPN_CreateScriptObject (0, imp, origin, current);
     156            break;
     157        }
     158        case Instance::JavaLanguage: {
     159            // FIXME:  factor creation of jni_jsobjects, also remove unnecessary thread
     160            // invocation code.
     161            break;
     162        }
     163        default:
     164            break;
     165    }
     166   
     167    return result;
    122168}
    123169
Note: See TracChangeset for help on using the changeset viewer.