gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r9736: Improvements in AMF0 serializ


From: Sandro Santilli
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r9736: Improvements in AMF0 serialization (skip hidden props, skip functions)
Date: Sun, 14 Sep 2008 17:43:58 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9736
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Sun 2008-09-14 17:43:58 +0200
message:
  Improvements in AMF0 serialization (skip hidden props, skip functions)
modified:
  libcore/as_value.cpp
  libcore/asobj/SharedObject.cpp
  testsuite/misc-ming.all/SharedObjectTest.as
    ------------------------------------------------------------
    revno: 9733.2.1
    committer: Sandro Santilli <address@hidden>
    branch nick: mybranch
    timestamp: Sat 2008-09-13 09:53:50 +0200
    message:
      test that function members of objects and arrays are not written in sol 
files
    modified:
      testsuite/misc-ming.all/SharedObjectTest.as
    ------------------------------------------------------------
    revno: 9733.2.2
    committer: Sandro Santilli <address@hidden>
    branch nick: mybranch
    timestamp: Sat 2008-09-13 09:55:00 +0200
    message:
      Skip AMF0 serialization of function properties
    modified:
      libcore/as_value.cpp
    ------------------------------------------------------------
    revno: 9733.2.3
    committer: Sandro Santilli <address@hidden>
    branch nick: mybranch
    timestamp: Sat 2008-09-13 09:58:39 +0200
    message:
      propagate skipping __proto__ and constructor serialization to the Element 
based serializer too
    modified:
      libcore/as_value.cpp
    ------------------------------------------------------------
    revno: 9733.2.4
    committer: Sandro Santilli <address@hidden>
    branch nick: mybranch
    timestamp: Sat 2008-09-13 10:04:00 +0200
    message:
      test functions in top-level SharedObject
    modified:
      testsuite/misc-ming.all/SharedObjectTest.as
    ------------------------------------------------------------
    revno: 9733.2.5
    committer: Sandro Santilli <address@hidden>
    branch nick: mybranch
    timestamp: Sat 2008-09-13 10:04:24 +0200
    message:
      skip serialization of functiosn in SOL file
    modified:
      libcore/asobj/SharedObject.cpp
=== modified file 'libcore/as_value.cpp'
--- a/libcore/as_value.cpp      2008-09-12 17:45:15 +0000
+++ b/libcore/as_value.cpp      2008-09-13 07:58:39 +0000
@@ -58,7 +58,7 @@
 //#define GNASH_DEBUG_SOFT_REFERENCES
 
 // Define this macto to make AMF parsing verbose
-#define GNASH_DEBUG_AMF_DESERIALIZE
+//#define GNASH_DEBUG_AMF_DESERIALIZE
 
 // Define this macto to make AMF writing verbose
 //#define GNASH_DEBUG_AMF_SERIALIZE
@@ -113,11 +113,29 @@
     
     void accept(string_table::key key, const as_value& val) 
         {
+
+            // Test conducted with AMFPHP:
+            // '__proto__' and 'constructor' members
+            // of an object don't get back from an 'echo-service'.
+            // Dunno if they are not serialized or just not sent back.
+            // A '__constructor__' member gets back, but only if 
+            // not a function. Actually no function gets back.
+            // 
+            if ( key == NSV::PROP_uuPROTOuu || 
+                 key == NSV::PROP_CONSTRUCTOR )
+            {
+#ifdef GNASH_DEBUG_AMF_SERIALIZE
+                log_debug(" skip serialization of specially-named property 
%s", _st.value(key));
+#endif
+                return;
+            }
+
             //GNASH_REPORT_FUNCTION;
             amf::AMF amf;
             amf::Element *el = 0;
            
-            const string& name = _st.string_table::value(key);
+            const string& name = _st.value(key);
+
            
 //          cerr << "FIXME: yes!!!!! " << name << ": "<< val << std::endl;
            
@@ -176,6 +194,13 @@
     {
         if ( _error ) return;
 
+        // Tested with SharedObject and AMFPHP
+        if ( val.is_function() )
+        {
+            log_debug("AMF0: skip serialization of FUNCTION property");
+            return;
+        }
+
         // Test conducted with AMFPHP:
         // '__proto__' and 'constructor' members
         // of an object don't get back from an 'echo-service'.

=== modified file 'libcore/asobj/SharedObject.cpp'
--- a/libcore/asobj/SharedObject.cpp    2008-09-13 06:33:19 +0000
+++ b/libcore/asobj/SharedObject.cpp    2008-09-13 08:04:24 +0000
@@ -153,6 +153,12 @@
     {
         if ( _error ) return;
 
+        if ( val.is_function() )
+        {
+            log_debug("SOL: skip serialization of FUNCTION property");
+            return;
+        }
+
         // Test conducted with AMFPHP:
         // '__proto__' and 'constructor' members
         // of an object don't get back from an 'echo-service'.

=== modified file 'testsuite/misc-ming.all/SharedObjectTest.as'
--- a/testsuite/misc-ming.all/SharedObjectTest.as       2008-09-13 06:33:19 
+0000
+++ b/testsuite/misc-ming.all/SharedObjectTest.as       2008-09-13 08:04:00 
+0000
@@ -16,6 +16,18 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 
+//
+//
+// NOTE: to test this with the proprietary player:
+//
+//     $ make SharedObjectTestRunner
+//     $ ./SharedObjectTestRunner flashplayer 
~/.macromedia/Flash_Player/#SharedObjects/<key>
+//     
+// take a look at the #SharedObject dir to figure out what <key> should be
+// 
+//
+//
+
 #define pass_check(x) _root.pass(x)
 #define xpass_check(x) _root.xpass(x)
 #define fail_check(x) _root.fail(x)
@@ -99,15 +111,30 @@
 
 
 so1.data.aryns = [4,5,6];
+so1.data.aryns.fun = function() {}; // functions in arrays are simply skipped
 so1.data.aryns.custom = 7;
 so1.data.aryns.length = 8; // non-strict array (ECMA_ARRAY)
 
 so1.data.obj = {a:10,b:'20',c:true};
+so1.data.obj.fun = function() {}; // functions in objects are simply skipped
+
+//AsSetPropFlags(so1.data.obj, '__proto__', 0, 1); // if we unhide __proto__ 
we'll find it in the SharedObject
+
+AsSetPropFlags(so1.data.obj, '__constructor__', 0, 1); // unhide 
__constructor__ (it's a function so will be skipped anyway)
+AsSetPropFlags(so1.data.obj, 'constructor', 0, 1); // unhide constructor (it's 
a function so will be skipped anyway)
+// so1.data.obj.constructor = 4; // if we override constructor we'll find it
+
 so1.data.obj.hidden = 7;
 AsSetPropFlags(so1.data.obj, 'hidden', 1); // hide from enumeration, should 
not end into the sol file
 
 so1.data.ref = so1.data.obj;
 
+so1.data.fun = function() {}; // functions in data 
+
+//AsSetPropFlags(so1.data, '__proto__', 0, 1); // if we unhide __proto__ we'll 
find it in the SharedObject
+AsSetPropFlags(so1.data, '__constructor__', 0, 1); // unhide __constructor__ 
(it's a function so will be skipped anyway)
+AsSetPropFlags(so1.data, 'constructor', 0, 1); // unhide constructor (it's a 
function so will be skipped anyway)
+
 so1.flush();
 
 quit = function()


reply via email to

[Prev in Thread] Current Thread [Next in Thread]