Show
Ignore:
Timestamp:
04/25/06 14:34:18 (3 years ago)
Author:
brmorris
Message:

S60: populated s60/trunk with s60-051212 release.

Location:
S60/trunk/JavaScriptCore
Files:
33 added
22 removed
85 modified

Legend:

Unmodified
Added
Removed
  • S60/trunk/JavaScriptCore/bindings/NP_jsobject.cpp

    r8384 r14062  
    8686} 
    8787 
    88 static bool _isSafeScript(JavaScriptObject *obj) 
    89 { 
    90     if (obj->originExecutionContext) { 
    91         Interpreter *originInterpreter = obj->originExecutionContext->interpreter(); 
    92         if (originInterpreter) { 
    93             return originInterpreter->isSafeScript (obj->executionContext->interpreter()); 
    94         } 
    95     } 
    96     return true; 
    97 } 
    98  
    99 NPObject *_NPN_CreateScriptObject (NPP npp, KJS::ObjectImp *imp, const KJS::Bindings::RootObject *originExecutionContext, const KJS::Bindings::RootObject *executionContext) 
     88NPObject *_NPN_CreateScriptObject (NPP npp, KJS::ObjectImp *imp, KJS::Bindings::RootObject *root) 
    10089{ 
    10190    JavaScriptObject *obj = (JavaScriptObject *)_NPN_CreateObject(npp, NPScriptObjectClass); 
    10291 
    10392    obj->imp = imp; 
    104     obj->originExecutionContext = originExecutionContext;     
    105     obj->executionContext = executionContext;     
    106  
    107     addNativeReference (executionContext, imp); 
     93    obj->root = root;     
     94 
     95    addNativeReference (root, imp); 
    10896     
    10997    return (NPObject *)obj; 
     
    130118        JavaScriptObject *obj = (JavaScriptObject *)o;  
    131119         
    132         if (!_isSafeScript(obj)) 
    133             return false; 
    134              
    135120        PrivateIdentifier *i = (PrivateIdentifier *)methodName; 
    136121        if (!i->isString) 
    137122            return false; 
    138123             
    139         // Special case the "eval" method. 
    140         if (methodName == _NPN_GetStringIdentifier("eval")) { 
    141             if (argCount != 1) 
    142                 return false; 
    143             if (args[0].type != NPVariantType_String) 
    144                 return false; 
    145              
    146             return _NPN_Evaluate (npp, o, (NPString *)&args[0].value.stringValue, result); 
    147         } 
    148         else { 
    149             // Lookup the function object. 
    150             ExecState *exec = obj->executionContext->interpreter()->globalExec(); 
    151             Interpreter::lock(); 
    152             Value func = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string)); 
    153             Interpreter::unlock(); 
    154  
    155             if (func.isNull()) { 
    156                 NPN_InitializeVariantAsNull(result); 
    157                 return false; 
    158             } 
    159             else if ( func.type() == UndefinedType) { 
    160                 NPN_InitializeVariantAsUndefined(result); 
    161                 return false; 
    162             } 
    163             else { 
    164                 // Call the function object. 
    165                 ObjectImp *funcImp = static_cast<ObjectImp*>(func.imp()); 
    166                 Object thisObj = Object(const_cast<ObjectImp*>(obj->imp)); 
    167                 List argList = listFromVariantArgs(exec, args, argCount); 
    168                 Interpreter::lock(); 
    169                 Value resultV = funcImp->call (exec, thisObj, argList); 
    170                 Interpreter::unlock(); 
    171  
    172                 // Convert and return the result of the function call. 
    173                 convertValueToNPVariant(exec, resultV, result); 
    174                 return true; 
    175             } 
    176         } 
     124        // Lookup the function object. 
     125        ExecState *exec = obj->root->interpreter()->globalExec(); 
     126        Interpreter::lock(); 
     127        Value func = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string)); 
     128        Interpreter::unlock(); 
     129 
     130        if (func.isNull()) { 
     131            NPN_InitializeVariantAsNull(result); 
     132            return false; 
     133        } 
     134        else if ( func.type() == UndefinedType) { 
     135            NPN_InitializeVariantAsUndefined(result); 
     136            return false; 
     137        } 
     138        else { 
     139            // Call the function object. 
     140            ObjectImp *funcImp = static_cast<ObjectImp*>(func.imp()); 
     141            Object thisObj = Object(const_cast<ObjectImp*>(obj->imp)); 
     142            List argList = listFromVariantArgs(exec, args, argCount); 
     143            Interpreter::lock(); 
     144            Value resultV = funcImp->call (exec, thisObj, argList); 
     145            Interpreter::unlock(); 
     146 
     147            // Convert and return the result of the function call. 
     148            convertValueToNPVariant(exec, resultV, result); 
     149            return true; 
     150        } 
    177151    } 
    178152    else { 
     
    190164        JavaScriptObject *obj = (JavaScriptObject *)o;  
    191165 
    192         if (!_isSafeScript(obj)) 
    193             return false; 
    194  
    195         ExecState *exec = obj->executionContext->interpreter()->globalExec(); 
     166        ExecState *exec = obj->root->interpreter()->globalExec(); 
    196167        Object thisObj = Object(const_cast<ObjectImp*>(obj->imp)); 
    197168        Value result; 
     
    201172        unsigned int UTF16Length; 
    202173        convertNPStringToUTF16 (s, &scriptString, &UTF16Length);    // requires free() of returned memory. 
    203         Completion completion = obj->executionContext->interpreter()->evaluate(UString(), 0, UString((const UChar *)scriptString,UTF16Length)); 
     174        Completion completion = obj->root->interpreter()->evaluate(UString(), 0, UString((const UChar *)scriptString,UTF16Length)); 
    204175        ComplType type = completion.complType(); 
    205176         
     
    228199    if (o->_class == NPScriptObjectClass) { 
    229200        JavaScriptObject *obj = (JavaScriptObject *)o;  
    230  
    231         if (!_isSafeScript(obj)) 
    232             return false; 
    233  
    234         ExecState *exec = obj->executionContext->interpreter()->globalExec(); 
     201        ExecState *exec = obj->root->interpreter()->globalExec(); 
    235202 
    236203        PrivateIdentifier *i = (PrivateIdentifier *)propertyName; 
     
    288255        JavaScriptObject *obj = (JavaScriptObject *)o;  
    289256 
    290         if (!_isSafeScript(obj)) 
    291             return false; 
    292  
    293         ExecState *exec = obj->executionContext->interpreter()->globalExec(); 
     257        ExecState *exec = obj->root->interpreter()->globalExec(); 
    294258        Interpreter::lock(); 
    295259        Value result; 
     
    315279    if (o->_class == NPScriptObjectClass) { 
    316280        JavaScriptObject *obj = (JavaScriptObject *)o;  
    317  
    318         if (!_isSafeScript(obj)) 
    319             return false; 
    320  
    321         ExecState *exec = obj->executionContext->interpreter()->globalExec(); 
     281        ExecState *exec = obj->root->interpreter()->globalExec(); 
    322282 
    323283        PrivateIdentifier *i = (PrivateIdentifier *)propertyName; 
     
    351311    if (o->_class == NPScriptObjectClass) { 
    352312        JavaScriptObject *obj = (JavaScriptObject *)o;  
    353  
    354         if (!_isSafeScript(obj)) 
    355             return false; 
    356  
    357         ExecState *exec = obj->executionContext->interpreter()->globalExec(); 
     313        ExecState *exec = obj->root->interpreter()->globalExec(); 
    358314 
    359315        PrivateIdentifier *i = (PrivateIdentifier *)propertyName; 
    360316        // String identifier? 
    361317        if (i->isString) { 
    362             ExecState *exec = obj->executionContext->interpreter()->globalExec(); 
     318            ExecState *exec = obj->root->interpreter()->globalExec(); 
    363319            Interpreter::lock(); 
    364320            bool result = obj->imp->hasProperty (exec, identiferFromNPIdentifier(i->value.string)); 
     
    385341        JavaScriptObject *obj = (JavaScriptObject *)o;  
    386342         
    387         if (!_isSafeScript(obj)) 
    388             return false; 
    389  
    390343        PrivateIdentifier *i = (PrivateIdentifier *)methodName; 
    391344        if (!i->isString) 
     
    393346             
    394347        // Lookup the function object. 
    395         ExecState *exec = obj->executionContext->interpreter()->globalExec(); 
     348        ExecState *exec = obj->root->interpreter()->globalExec(); 
    396349        Interpreter::lock(); 
    397350        Value func = obj->imp->get (exec, identiferFromNPIdentifier(i->value.string)); 
     
    416369    if (o->_class == NPScriptObjectClass) { 
    417370        JavaScriptObject *obj = (JavaScriptObject *)o;  
    418         ExecState *exec = obj->executionContext->interpreter()->globalExec(); 
     371        ExecState *exec = obj->root->interpreter()->globalExec(); 
    419372        Interpreter::lock(); 
    420373        char *msg = (char *)malloc (message->UTF8Length + 1); 
  • S60/trunk/JavaScriptCore/bindings/NP_jsobject.h

    r8384 r14062  
    4242    NPObject object; 
    4343    KJS::ObjectImp *imp; 
    44     const KJS::Bindings::RootObject *originExecutionContext; 
    45     const KJS::Bindings::RootObject *executionContext; 
     44    KJS::Bindings::RootObject *root; 
    4645} JavaScriptObject; 
    4746 
    48 NPObject *_NPN_CreateScriptObject (NPP npp, KJS::ObjectImp *imp, const KJS::Bindings::RootObject *originExecutionContext, const KJS::Bindings::RootObject *executionContext); 
     47NPObject *_NPN_CreateScriptObject (NPP npp, KJS::ObjectImp *imp, KJS::Bindings::RootObject *root); 
    4948 
    5049#ifdef __cplusplus 
  • S60/trunk/JavaScriptCore/bindings/c/c_instance.cpp

    r8384 r14062  
    4747    _object = _NPN_RetainObject (o); 
    4848    _class = 0; 
    49     setExecutionContext (0); 
    5049}; 
    5150 
     
    6160    _object = _NPN_RetainObject (other._object); 
    6261    _class = 0; 
    63     setExecutionContext (other.executionContext()); 
    6462}; 
    6563 
     
    206204KJS::Value CInstance::stringValue() const 
    207205{ 
    208     char buf[1024]; 
    209     snprintf (buf, 1024, "NPObject %p, NPClass %p", _object, _object->_class); 
    210     KJS::String v(buf); 
     206    // FIXME:  Implement something sensible, like calling toString... 
     207    KJS::String v(""); 
    211208    return v; 
    212209} 
  • S60/trunk/JavaScriptCore/bindings/c/c_instance.h

    r8384 r14062  
    6464    NPObject *getObject() const { return _object; } 
    6565 
     66    void setExecutionContext (RootObject *r) { _root = r; } 
     67    const RootObject *executionContext() const { return _root; } 
     68     
    6669private: 
    6770    mutable CClass *_class; 
    6871    NPObject *_object; 
     72    RootObject *_root; 
    6973}; 
    7074 
  • S60/trunk/JavaScriptCore/bindings/c/c_utility.cpp

    r8585 r14062  
    2626#include <c_utility.h>  
    2727#include <internal.h> 
    28 #include <npruntime_impl.h> 
    2928#include <npruntime_priv.h> 
    3029#include <runtime.h> 
     
    9695    else if (type == ObjectType) { 
    9796        KJS::ObjectImp *objectImp = static_cast<KJS::ObjectImp*>(value.imp()); 
    98         if (objectImp->classInfo() == &KJS::RuntimeObjectImp::info) { 
     97        if (strcmp(objectImp->classInfo()->className, "RuntimeObject") == 0) { 
    9998            KJS::RuntimeObjectImp *imp = static_cast<KJS::RuntimeObjectImp *>(value.imp()); 
    10099            CInstance *instance = static_cast<CInstance*>(imp->getInternalInstance()); 
    101100            NPN_InitializeVariantWithObject (result, instance->getObject()); 
    102101        } 
    103         else { 
    104  
    105             KJS::Interpreter *originInterpreter = exec->interpreter(); 
    106             const Bindings::RootObject *originExecutionContext = rootForInterpreter(originInterpreter); 
    107  
    108             KJS::Interpreter *interpreter = 0; 
    109             if (originInterpreter->isGlobalObject(value)) { 
    110                 interpreter = originInterpreter->interpreterForGlobalObject (value.imp()); 
    111             } 
    112  
    113             if (!interpreter) 
    114                 interpreter = originInterpreter; 
    115                  
    116             const Bindings::RootObject *executionContext = rootForInterpreter(interpreter); 
    117             if (!executionContext) { 
    118                 Bindings::RootObject *newExecutionContext = new KJS::Bindings::RootObject(0); 
    119                 newExecutionContext->setInterpreter (interpreter); 
    120                 executionContext = newExecutionContext; 
    121             } 
    122      
    123             NPObject *obj = (NPObject *)exec->interpreter()->createLanguageInstanceForValue (exec, Instance::CLanguage, value.toObject(exec), originExecutionContext, executionContext); 
    124             NPN_InitializeVariantWithObject (result, obj); 
    125             _NPN_ReleaseObject (obj); 
    126         } 
    127102    } 
    128103    else 
  • S60/trunk/JavaScriptCore/bindings/jni/jni_instance.cpp

    r8585 r14062  
    4646    _instance = new JObjectWrapper (instance); 
    4747    _class = 0; 
    48     setExecutionContext (r); 
     48    _root = r; 
    4949}; 
    5050 
     
    6161    // Classes are kept around forever. 
    6262    _class = other._class; 
     63    _root = other._root; 
    6364}; 
    6465 
     
    247248                } 
    248249                else { 
    249                     resultValue = Instance::createRuntimeObject(Instance::JavaLanguage, result.l, executionContext()); 
     250                    resultValue = Object(new RuntimeObjectImp(new JavaInstance (result.l, executionContext()))); 
    250251                } 
    251252            } 
     
    346347}; 
    347348 
     349void JavaInstance::setExecutionContext (RootObject *r) { _root = r; } 
     350const RootObject *JavaInstance::executionContext() const { return _root; } 
     351 
    348352JObjectWrapper::JObjectWrapper(jobject instance) 
    349353{ 
  • S60/trunk/JavaScriptCore/bindings/jni/jni_instance.h

    r8384 r14062  
    9797    virtual Value invokeDefaultMethod (ExecState *exec, const List &args); 
    9898 
     99    virtual void setExecutionContext (RootObject *r); 
     100    virtual const RootObject *executionContext() const; 
     101 
    99102    jobject javaInstance() const { return _instance->_instance; } 
    100103     
     
    106109    JObjectWrapper *_instance; 
    107110    mutable JavaClass *_class; 
     111    const RootObject *_root; 
    108112}; 
    109113 
  • S60/trunk/JavaScriptCore/bindings/jni/jni_jsobject.cpp

    r8408 r14062  
    421421    jobject classOfInstance = callJNIObjectMethod(theObject, "getClass", "()Ljava/lang/Class;"); 
    422422    jstring className = (jstring)callJNIObjectMethod(classOfInstance, "getName", "()Ljava/lang/String;"); 
    423          
     423     
     424    JS_LOG ("converting instance of class %s\n", Bindings::JavaString(className).UTF8String()); 
     425     
    424426    if (strcmp(Bindings::JavaString(className).UTF8String(), "netscape.javascript.JSObject") == 0) { 
    425427        // Pull the nativeJSObject value from the Java instance.  This is a 
     
    453455    for (i = 0; i < numObjects; i++) { 
    454456        jobject anObject = env->GetObjectArrayElement ((jobjectArray)jArray, i); 
    455         if (anObject) { 
    456             aList.append (convertJObjectToValue(anObject)); 
    457             env->DeleteLocalRef (anObject); 
    458         } 
    459         else { 
    460             env->ExceptionDescribe(); 
    461             env->ExceptionClear(); 
    462         } 
     457        aList.append (convertJObjectToValue(anObject)); 
     458        env->DeleteLocalRef (anObject); 
    463459    } 
    464460    return aList; 
  • S60/trunk/JavaScriptCore/bindings/jni/jni_runtime.cpp

    r8622 r14062  
    3434#include <runtime_root.h> 
    3535