gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. d0d861cf12c83ce384a6


From: Sandro Santilli
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. d0d861cf12c83ce384a698c0fb52329259126935
Date: Sun, 17 Oct 2010 09:02:57 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  d0d861cf12c83ce384a698c0fb52329259126935 (commit)
       via  f9419620a29fd4ec8f71be4d18329d8e0e8ac6d3 (commit)
       via  264d62b99da6803fe0b9236df60a74108f1c4897 (commit)
       via  5d70ee3a39d95586a5ea2d1c57b17486aec9f0b4 (commit)
       via  855cb491073601d34164ede075859af32ef8fea0 (commit)
      from  253bdd94086b556cdd8f2b58f13c09c11f35e3ed (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=d0d861cf12c83ce384a698c0fb52329259126935


commit d0d861cf12c83ce384a698c0fb52329259126935
Author: Sandro Santilli <address@hidden>
Date:   Sun Oct 17 10:40:42 2010 +0200

    Do not segfault when passed an object with circular refs

diff --git a/libcore/ExternalInterface.cpp b/libcore/ExternalInterface.cpp
index 9c89757..a9126a2 100644
--- a/libcore/ExternalInterface.cpp
+++ b/libcore/ExternalInterface.cpp
@@ -61,9 +61,13 @@ public:
 
 /// Convert an AS object to an XML string.
 std::string
-ExternalInterface::objectToXML(as_object *obj)
+ExternalInterface::_objectToXML(as_object *obj)
 {
     // GNASH_REPORT_FUNCTION;
+
+    if ( ! _visited.insert(obj).second ) { 
+        return "<circular/>";
+    }
     
     std::stringstream ss;
 
@@ -81,7 +85,7 @@ ExternalInterface::objectToXML(as_object *obj)
             as_value val = getMember(*obj, *i); 
             const std::string& id = i->toString(st);
             ss << "<property id=\"" << id << "\">";
-            ss << ExternalInterface::toXML(val);
+            ss << _toXML(val);
             ss << "</property>";
         }
     }
@@ -93,7 +97,7 @@ ExternalInterface::objectToXML(as_object *obj)
 
 /// Convert an AS object to an XML string.
 std::string
-ExternalInterface::arrayToXML(as_object *obj)
+ExternalInterface::_arrayToXML(as_object *obj)
 {
     // GNASH_REPORT_FUNCTION;
     std::stringstream ss;
@@ -117,7 +121,7 @@ ExternalInterface::arrayToXML(as_object *obj)
         s << i;
         as_value el = getMember(*obj, st.find(s.str()));
         ss << "<property id=\"" << i << "\">"
-           << toXML(el)
+           << _toXML(el) 
            << "</property>";
         ++i;
     }
@@ -129,7 +133,7 @@ ExternalInterface::arrayToXML(as_object *obj)
 
 /// Convert an AS object to an XML string.
 std::string
-ExternalInterface::toXML(const as_value &val)
+ExternalInterface::_toXML(const as_value &val)
 {
     // GNASH_REPORT_FUNCTION;
     
@@ -155,7 +159,7 @@ ExternalInterface::toXML(const as_value &val)
         ss << "<function>" << val.to_string() << "</function>";
     } else if (val.is_object()) {
         as_object *obj = val.get_object();
-        ss << objectToXML(obj);
+        ss << _objectToXML(obj);
     } else {
         log_error("Can't convert unknown type %d", val.to_string());
     }
@@ -477,7 +481,8 @@ ExternalInterface::makeInvoke (const std::string &method,
     ss << "<invoke name=\"" << method << "\" returntype=\"xml\">";
     ss << "<arguments>";
     for (it=args.begin(); it != args.end(); ++it) {
-        ss << ExternalInterface::toXML(*it);
+        // Should we avoid re-serializing the same object ?
+        ss << toXML(*it);
     }
     
     ss << "</arguments>";
diff --git a/libcore/ExternalInterface.h b/libcore/ExternalInterface.h
index 944c687..31d3087 100644
--- a/libcore/ExternalInterface.h
+++ b/libcore/ExternalInterface.h
@@ -24,6 +24,7 @@
 #include <string>
 #include <vector>
 #include <map>
+#include <set>
 #include <boost/shared_ptr.hpp>
 
 #include "dsodefs.h" /* For DSOEXPORT */
@@ -52,9 +53,6 @@ struct DSOEXPORT ExternalInterface
     // that while probably designed to be used internally, get used
     // by ActionScript coders.
 
-    /// Convert an AS object to an XML string.
-    DSOEXPORT static std::string toXML(const as_value &obj);
-    
     /// Convert an XML string to an AS value.
     DSOEXPORT static as_value toAS(Global_as& as, const std::string &xml);
 
@@ -63,14 +61,25 @@ struct DSOEXPORT ExternalInterface
                                                    std::string &xml);
     
     DSOEXPORT static as_value argumentsToXML(std::vector<as_value> &args);
-//    as_value argumentsToAS();
     
-    DSOEXPORT static std::string objectToXML(as_object *obj);
     DSOEXPORT static as_value objectToAS(Global_as& gl, const std::string 
&xml);
-//  std::string objectToJS(as_object &obj);
-//  as_value toJS(const std::string &xml);;
+
+    static std::string objectToXML(as_object *obj) {
+        ExternalInterface ei;
+        return ei._objectToXML(obj);
+    }
+    
+    static std::string arrayToXML(as_object *obj) {
+        ExternalInterface ei;
+        return ei._arrayToXML(obj);
+    }
+
+    /// Convert an AS object to an XML string.
+    static std::string toXML(const as_value &obj) {
+        ExternalInterface ei;
+        return ei._toXML(obj);
+    }
     
-    DSOEXPORT static std::string arrayToXML(as_object *obj);
 
 //  static std::string arrayToJS();
 //  static as_value arrayToAS();
@@ -113,6 +122,14 @@ struct DSOEXPORT ExternalInterface
 
     DSOEXPORT static size_t writeBrowser(int fd, const std::string &xml);
     DSOEXPORT static std::string readBrowser(int fd);
+
+private:
+
+    DSOEXPORT std::string _toXML(const as_value &obj);
+    DSOEXPORT std::string _objectToXML(as_object* obj);
+    DSOEXPORT std::string _arrayToXML(as_object *obj);
+
+    std::set<as_object*> _visited;
 };
 
 } // end of gnash namespace

http://git.savannah.gnu.org/cgit//commit/?id=f9419620a29fd4ec8f71be4d18329d8e0e8ac6d3


commit f9419620a29fd4ec8f71be4d18329d8e0e8ac6d3
Author: Sandro Santilli <address@hidden>
Date:   Sun Oct 17 10:08:57 2010 +0200

    Drop unused code

diff --git a/libcore/ExternalInterface.cpp b/libcore/ExternalInterface.cpp
index a53f664..9c89757 100644
--- a/libcore/ExternalInterface.cpp
+++ b/libcore/ExternalInterface.cpp
@@ -49,74 +49,6 @@
 
 namespace gnash {
 
-namespace {
-
-/// Class used to serialize properties of an object to a buffer
-class PropsSerializer : public AbstractPropertyVisitor
-{
-
-public:
-    
-    PropsSerializer(VM& vm)
-        : _st(vm.getStringTable())
-        { /* do nothing */}
-    
-    bool accept(const ObjectURI& uri, const as_value& val) {
-
-        const string_table::key key = getName(uri);
-
-        if (key == NSV::PROP_uuPROTOuu || key == NSV::PROP_CONSTRUCTOR) {
-            log_debug(" skip serialization of specially-named property %s",
-                      _st.value(key));
-            return true;
-        }
-
-        // write property name
-        const std::string& id = _st.value(key);
-
-//        log_debug(" serializing property %s", id);
-        
-        std::stringstream xml;
-        xml << "<property id=\"" << id << "\">";
-        xml << ExternalInterface::toXML(val);
-        xml << "</property>";
-
-        _propsxml.push_back(xml.str());
-            
-        return true;
-    }
-
-    std::string getReverseXML() {
-        typedef std::vector<std::string> Strings;
-        std::stringstream xml;
-        for (Strings::const_reverse_iterator
-            i=_propsxml.rbegin(), e=_propsxml.rend();
-            i != e; ++i)
-        {
-            xml << *i;
-        }
-        return xml.str();
-    };
-
-    std::string getXML() {
-        typedef std::vector<std::string> Strings;
-        std::stringstream xml;
-        for (Strings::const_iterator
-            i=_propsxml.begin(), e=_propsxml.end();
-            i != e; ++i)
-        {
-            xml << *i;
-        }
-        return xml.str();
-    };
-    
-private:
-    string_table&       _st;
-    std::vector<std::string> _propsxml;
-};
-
-}
-
 #if 0
 class ExternalExecutor: public movie_root::AbstractExternalCallback {
 public:

http://git.savannah.gnu.org/cgit//commit/?id=264d62b99da6803fe0b9236df60a74108f1c4897


commit 264d62b99da6803fe0b9236df60a74108f1c4897
Author: Sandro Santilli <address@hidden>
Date:   Sun Oct 17 10:05:40 2010 +0200

    PP tested to hang when trying to XML-serialize an object with circular refs 
(gnash segfaults smashing the stack right now)

diff --git a/testsuite/actionscript.all/ExternalInterface.as 
b/testsuite/actionscript.all/ExternalInterface.as
index b217bed..3b9c9c8 100644
--- a/testsuite/actionscript.all/ExternalInterface.as
+++ b/testsuite/actionscript.all/ExternalInterface.as
@@ -142,12 +142,6 @@ if ( EI.available ) {
     check_equals(typeof(ret), 'null');
 }
 
-// An object with circular references
-oc = {};
-oc.a = {};
-oc.a.a = oc.b;
-oc.b = oc.a;
-
 // A native class
 nc = Mouse;
 
@@ -194,10 +188,18 @@ xml = EI._objectToXML(o, 1, 2, 3);
 check_equals (xml, '<object><property 
id="a"><number>1</number></property><property 
id="b"><string>string</string></property></object>');
 
 // An object with an object reference
+
 o = { o: o };
 xml = EI._objectToXML(o);
 check_equals (xml, '<object><property id="o"><object><property 
id="a"><number>1</number></property><property 
id="b"><string>string</string></property></object></property></object>');
 
+// An object with circular references
+// (the proprietary player hangs here, we jus don't want to segfault)
+// oc = {};
+// oc.cr = oc;
+// xml = EI._objectToXML(oc);
+// check_equals (xml, '');
+
 // An undefined
 
 xml = EI._objectToXML(undefined);

http://git.savannah.gnu.org/cgit//commit/?id=5d70ee3a39d95586a5ea2d1c57b17486aec9f0b4


commit 5d70ee3a39d95586a5ea2d1c57b17486aec9f0b4
Author: Sandro Santilli <address@hidden>
Date:   Sun Oct 17 10:00:44 2010 +0200

    Add test for object reference as object property (ExternalInterface)

diff --git a/testsuite/actionscript.all/ExternalInterface.as 
b/testsuite/actionscript.all/ExternalInterface.as
index cf1d301..b217bed 100644
--- a/testsuite/actionscript.all/ExternalInterface.as
+++ b/testsuite/actionscript.all/ExternalInterface.as
@@ -142,9 +142,6 @@ if ( EI.available ) {
     check_equals(typeof(ret), 'null');
 }
 
-// An object
-o = { a: 1, b: "string" };
-
 // An object with circular references
 oc = {};
 oc.a = {};
@@ -187,12 +184,22 @@ check_equals(typeof(r._unescapeXML), 'undefined');
 xml = EI._objectToXML(nc);
 check_equals (xml, '<object></object>');
 
+// An object
+o = { a: 1, b: "string" };
+
 xml = EI._objectToXML(o);
 check_equals (xml, '<object><property 
id="a"><number>1</number></property><property 
id="b"><string>string</string></property></object>');
 
 xml = EI._objectToXML(o, 1, 2, 3);
 check_equals (xml, '<object><property 
id="a"><number>1</number></property><property 
id="b"><string>string</string></property></object>');
 
+// An object with an object reference
+o = { o: o };
+xml = EI._objectToXML(o);
+check_equals (xml, '<object><property id="o"><object><property 
id="a"><number>1</number></property><property 
id="b"><string>string</string></property></object></property></object>');
+
+// An undefined
+
 xml = EI._objectToXML(undefined);
 check_equals (xml, '<object></object>');
 
@@ -299,6 +306,6 @@ xcheck_equals (typeOf(val), 'object');
 #elif OUTPUT_VERSION < 8 // }{
        check_totals(49);
 #else // SWF8+ }{
-       check_totals(99);
+       check_totals(100);
 # endif // }
 

http://git.savannah.gnu.org/cgit//commit/?id=855cb491073601d34164ede075859af32ef8fea0


commit 855cb491073601d34164ede075859af32ef8fea0
Author: Sandro Santilli <address@hidden>
Date:   Sun Oct 17 09:57:41 2010 +0200

    Support object properties in ExternalInterface. The testcase still fails 
due to some weird values for XML object properties (nulls rather than 
functions), we'll want to add a focused test for objects in objects not 
involving too much of native objects composition. Also, this opens up for 
crashes in circular chanis

diff --git a/libcore/ExternalInterface.cpp b/libcore/ExternalInterface.cpp
index cbdcfe8..a53f664 100644
--- a/libcore/ExternalInterface.cpp
+++ b/libcore/ExternalInterface.cpp
@@ -138,11 +138,20 @@ ExternalInterface::objectToXML(as_object *obj)
     ss << "<object>";
 
     if (obj) {
-        VM& vm = getVM(*obj);
         // Get all the properties
-        PropsSerializer props(vm);
-        obj->visitProperties<IsEnumerable>(props);
-        ss << props.getReverseXML();
+        VM& vm = getVM(*obj);
+        string_table& st = vm.getStringTable();
+        typedef std::vector<ObjectURI> URIs;
+        URIs uris;
+        obj->enumeratePropertyKeys(uris);
+        for (URIs::const_reverse_iterator i=uris.rbegin(), e=uris.rend();
+                i!=e; ++i) {
+            as_value val = getMember(*obj, *i); 
+            const std::string& id = i->toString(st);
+            ss << "<property id=\"" << id << "\">";
+            ss << ExternalInterface::toXML(val);
+            ss << "</property>";
+        }
     }
 
     ss << "</object>";

-----------------------------------------------------------------------

Summary of changes:
 libcore/ExternalInterface.cpp                   |  102 ++++++-----------------
 libcore/ExternalInterface.h                     |   33 ++++++--
 testsuite/actionscript.all/ExternalInterface.as |   29 ++++--
 3 files changed, 68 insertions(+), 96 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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