[Fwd: Re: [RFC] Single threaded JSRuntime in Firefox 10]

Thomas Meyer thomas at m3y3r.de
Sat Feb 4 07:27:10 PST 2012


-------- Weitergeleitete Nachricht --------
> Von: Thomas Meyer <thomas at m3y3r.de>
> An: IcedTea <distro-pkg-dev at openjdk.java.net>
> Betreff: Re: [RFC] Single threaded JSRuntime in Firefox 10
> Datum: Sat, 04 Feb 2012 13:32:46 +0100
> 
> Am Samstag, den 04.02.2012, 02:11 +0100 schrieb Thomas Meyer:
> > Hello,
> > 
> > please have a look at this first patch that fixes the sendMember() and
> > eval() methods for firefox 10:
> > 
> 
> this is a second patch on top of the first one to fix these methods for
> the single thread JSRuntime:
> - eval()
> - sendMember() (aka. _getMember())
> - call()
> - setMember()
> 
> Methods still to fix are:
> - sendWindow()
> - finalize()

# HG changeset patch
# User thomas
# Date 1328356961 -3600
# Node ID 80168a317e301fa04d6b34d92674162f7a87ce08
# Parent  6962b636cfdaeef1efa884bcd2207a1360baa978
Fix single threaded JSRuntime: call, setMember and sendMember

diff -r 6962b636cfda -r 80168a317e30 plugin/icedteanp/IcedTeaPluginRequestProcessor.cc
--- a/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc	Sat Feb 04 02:05:26 2012 +0100
+++ b/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc	Sat Feb 04 13:02:41 2012 +0100
@@ -326,19 +326,9 @@
 
     IcedTeaPluginUtilities::callAndWaitForResult(instance, &_call, &thread_data);
 
-    result_variant = (NPVariant*) IcedTeaPluginUtilities::stringToJSID(thread_data.result);
-
-    if (result_variant)
-    {
-        createJavaObjectFromVariant(instance, *result_variant, &result_variant_jniid);
-    } else
-    {
-        result_variant_jniid = "0";
-    }
-
     IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &response);
     response += " JavaScriptCall ";
-    response += result_variant_jniid;
+    response += thread_data.result;
 
     plugin_to_java_bus->post(response.c_str());
 
@@ -405,7 +395,8 @@
 
     NPP instance;
     NPVariant* member;
-    NPIdentifier property_identifier;
+    std::string property_id = std::string();
+    bool int_identifier;
 
     JavaRequestProcessor java_request = JavaRequestProcessor();
     JavaResultData* java_result;
@@ -435,7 +426,8 @@
 
     if (*(message_parts->at(4)) == "SetSlot")
     {
-        property_identifier = browser_functions.getintidentifier(atoi(message_parts->at(6)->c_str()));
+    	property_id.append(*(message_parts->at(6)));
+    	int_identifier = true;
     } else
     {
         java_result = java_request.getString(propertyNameID);
@@ -447,7 +439,8 @@
             //goto cleanup;
         }
 
-        property_identifier = browser_functions.getstringidentifier(java_result->return_string->c_str());
+        property_id.append(*(java_result->return_string));
+    	int_identifier = false;
     }
 
     AsyncCallThreadData thread_data = AsyncCallThreadData();
@@ -457,8 +450,9 @@
 
     thread_data.parameters.push_back(instance);
     thread_data.parameters.push_back(NPVARIANT_TO_OBJECT(*member));
-    thread_data.parameters.push_back(&property_identifier);
+    thread_data.parameters.push_back(&property_id);
     thread_data.parameters.push_back(&value);
+    thread_data.parameters.push_back(&int_identifier);
 
     IcedTeaPluginUtilities::callAndWaitForResult(instance, &_setMember, &thread_data);
 
@@ -498,6 +492,7 @@
     int method_id;
     int instance_id;
     int reference;
+    bool int_identifier;
 
     // debug printout of parent thread data
     IcedTeaPluginUtilities::printStringPtrVector("PluginRequestProcessor::getMember:", message_parts);
@@ -512,7 +507,7 @@
     /** Request data from Java if necessary **/
     if (*(message_parts->at(4)) == "GetSlot")
     {
-    	//member_id = ;
+    	int_identifier=true;
     } else
     {
         // make a new request for getString, to get the name of the identifier
@@ -525,7 +520,8 @@
             //goto cleanup;
         }
 
-        member_id = *java_result->return_string;
+        member_id.assign(*(java_result->return_string));
+    	int_identifier=false;
     }
 
     AsyncCallThreadData thread_data = AsyncCallThreadData();
@@ -542,6 +538,7 @@
     thread_data.parameters.push_back(instance);
     thread_data.parameters.push_back(NPVARIANT_TO_OBJECT(*parent_ptr));
     thread_data.parameters.push_back(&member_id);
+    thread_data.parameters.push_back(&int_identifier);
 
     IcedTeaPluginUtilities::callAndWaitForResult(instance, &_getMember, &thread_data);
 
@@ -752,19 +749,26 @@
     NPP instance;
     NPVariant value_variant = NPVariant();
     NPObject* member;
-    NPIdentifier* property;
+    NPIdentifier property_identifier;
+
 
     std::vector<void*> parameters = ((AsyncCallThreadData*) data)->parameters;
     instance = (NPP) parameters.at(0);
     member = (NPObject*) parameters.at(1);
-    property = (NPIdentifier*) parameters.at(2);
+    std::string*  property_id = (std::string*) parameters.at(2);
     value = (std::string*) parameters.at(3);
+    bool* int_identifier = (bool*) parameters.at(4);
 
-    PLUGIN_DEBUG("Setting %s on instance %p, object %p to value %s\n", browser_functions.utf8fromidentifier(*property), instance, member, value->c_str());
+    if(*int_identifier==true)
+    	property_identifier = browser_functions.getintidentifier(atoi(property_id->c_str()));
+    else
+    	property_identifier = browser_functions.getstringidentifier(property_id->c_str());
+
+    PLUGIN_DEBUG("Setting %s on instance %p, object %p to value %s\n", browser_functions.utf8fromidentifier(property_identifier), instance, member, value->c_str());
 
     IcedTeaPluginUtilities::javaResultToNPVariant(instance, value, &value_variant);
 
-    ((AsyncCallThreadData*) data)->call_successful = browser_functions.setproperty(instance, member, *property, &value_variant);
+    ((AsyncCallThreadData*) data)->call_successful = browser_functions.setproperty(instance, member, property_identifier, &value_variant);
 
     ((AsyncCallThreadData*) data)->result_ready = true;
 }
@@ -784,7 +788,12 @@
     std::string*  member_id = (std::string*) parameters.at(2);
     NPIdentifier member_identifier;
 
-    member_identifier = browser_functions.getintidentifier(atoi(member_id->c_str()));
+    bool* int_identifier = (bool*) parameters.at(3);
+
+    if(*int_identifier==true)
+    	member_identifier = browser_functions.getintidentifier(atoi(member_id->c_str()));
+    else
+    	member_identifier = browser_functions.getstringidentifier(member_id->c_str());
 
     // Get the NPVariant corresponding to this member
     PLUGIN_DEBUG("Looking for %p %p %p (%s)\n", instance, parent_ptr, member_identifier, browser_functions.utf8fromidentifier(member_identifier));
@@ -898,7 +907,15 @@
 
     if (((AsyncCallThreadData*) data)->call_successful)
     {
-        IcedTeaPluginUtilities::JSIDToString(call_result, &call_result_ptr_str);
+
+        if (call_result)
+        {
+            createJavaObjectFromVariant(instance, *call_result, &call_result_ptr_str);
+        } else
+        {
+        	call_result_ptr_str = "0";
+        }
+
         ((AsyncCallThreadData*) data)->result.append(call_result_ptr_str);
     }
 





More information about the distro-pkg-dev mailing list