gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso...
Date: Wed, 04 Apr 2007 07:53:28 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/04/04 07:53:28

Modified files:
        .              : ChangeLog 
        server/asobj   : xml.cpp xml.h xmlsocket.cpp 
        testsuite/actionscript.all: XMLSocket.as 

Log message:
                * server/asobj/xml.{cpp,h}: tu_string => std::string
                * server/asobj/xmlsocket.cpp: provide a builtin onData
                  event handler to XMLSocket instances.
                * testsuite/actionscript.all/XMLSocket.as: more successes.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2772&r2=1.2773
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.cpp?cvsroot=gnash&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.h?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlsocket.cpp?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/XMLSocket.as?cvsroot=gnash&r1=1.3&r2=1.4

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2772
retrieving revision 1.2773
diff -u -b -r1.2772 -r1.2773
--- ChangeLog   4 Apr 2007 07:10:19 -0000       1.2772
+++ ChangeLog   4 Apr 2007 07:53:28 -0000       1.2773
@@ -1,5 +1,9 @@
 2007-04-04 Sandro Santilli <address@hidden>
 
+       * server/asobj/xml.{cpp,h}: tu_string => std::string
+       * server/asobj/xmlsocket.cpp: provide a builtin onData
+         event handler to XMLSocket instances.
+       * testsuite/actionscript.all/XMLSocket.as: more successes.
        * server/URLAccessManager.{cpp,h}: add allowHost interface.
        * server/asobj/xmlsocket.cpp (connect): check host security.
 

Index: server/asobj/xml.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xml.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- server/asobj/xml.cpp        3 Apr 2007 13:22:23 -0000       1.28
+++ server/asobj/xml.cpp        4 Apr 2007 07:53:28 -0000       1.29
@@ -14,7 +14,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: xml.cpp,v 1.28 2007/04/03 13:22:23 strk Exp $ */
+/* $Id: xml.cpp,v 1.29 2007/04/04 07:53:28 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -98,7 +98,7 @@
 
 
 // Parse the ASCII XML string into memory
-XML::XML(tu_string xml_in)
+XML::XML(const std::string& xml_in)
     :
     XMLNode(getXMLInterface()),
     _loaded(false), 
@@ -299,14 +299,14 @@
 // This reads in an XML file from disk and parses into into a memory resident
 // tree which can be walked through later.
 bool
-XML::parseXML(tu_string xml_in)
+XML::parseXML(const std::string& xml_in)
 {
     GNASH_REPORT_FUNCTION;
 
-    log_msg("Parse XML from memory: %s\n", xml_in.c_str());
+    log_msg("Parse XML from memory: %s", xml_in.c_str());
 
-    if (xml_in.size() == 0) {
-        log_error("XML data is empty!\n");
+    if (xml_in.empty()) {
+        log_error("XML data is empty!");
         return false;
     }
 

Index: server/asobj/xml.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xml.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/asobj/xml.h  3 Apr 2007 12:34:43 -0000       1.11
+++ server/asobj/xml.h  4 Apr 2007 07:53:28 -0000       1.12
@@ -55,7 +55,7 @@
 public:
 
     XML();
-    XML(tu_string xml_in);
+    XML(const std::string& xml_in);
     XML(struct node * childNode);
     virtual ~XML();
   
@@ -64,7 +64,7 @@
     bool parseDoc(xmlDocPtr document, bool mem);
 
     // Parses an XML document into the specified XML object tree.
-    bool parseXML(tu_string xml_in);
+    bool parseXML(const std::string& xml_in);
 
     // Loads a document (specified by
     // the XML object) from a URL.

Index: server/asobj/xmlsocket.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlsocket.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- server/asobj/xmlsocket.cpp  4 Apr 2007 07:10:19 -0000       1.18
+++ server/asobj/xmlsocket.cpp  4 Apr 2007 07:53:28 -0000       1.19
@@ -71,10 +71,13 @@
 static as_value xmlsocket_close(const fn_call& fn);
 
 // These are the event handlers called for this object
-static as_value xmlsocket_event_ondata(const fn_call& fn);
+static as_value xmlsocket_inputChecker(const fn_call& fn);
+
+static as_value xmlsocket_onData(const fn_call& fn);
 
 static as_object* getXMLSocketInterface();
 static void attachXMLSocketInterface(as_object& o);
+static void attachXMLSocketProperties(as_object& o);
 
 const int SOCKET_DATA = 1;
   
@@ -88,7 +91,9 @@
         xmlsocket_as_object()
                 :
                 as_object(getXMLSocketInterface())
-        {}
+        {
+            attachXMLSocketProperties(*this);
+        }
 
                /// This function should be called everytime we're willing
                /// to check if any data is available on the socket.
@@ -457,7 +462,7 @@
         log_warning("Setting up timer for calling XMLSocket.onData()");
 
         Timer timer;
-        boost::intrusive_ptr<builtin_function> ondata_handler = new 
builtin_function(&xmlsocket_event_ondata, NULL);
+        boost::intrusive_ptr<builtin_function> ondata_handler = new 
builtin_function(&xmlsocket_inputChecker, NULL);
         unsigned interval = 50; // just make sure it's expired at every frame 
iteration (20 FPS used here)
         timer.setInterval(*ondata_handler, interval, 
boost::dynamic_pointer_cast<as_object>(ptr), &fn.env());
         VM::get().getRoot().add_interval_timer(timer);
@@ -513,20 +518,17 @@
 
 
 as_value
-xmlsocket_event_ondata(const fn_call& fn)
+xmlsocket_inputChecker(const fn_call& fn)
 {
     GNASH_REPORT_FUNCTION;
 
-    //log_msg("doing nothing as this function is completely broken");
-    //return as_value();
-    
     as_value   method;
     as_value   val;
     
     boost::intrusive_ptr<xmlsocket_as_object> ptr = 
ensureType<xmlsocket_as_object>(fn.this_ptr);
     if ( ! ptr->obj.connected() )
     {
-           log_warning("XMLSocket not connected at xmlsocket_event_ondata 
call");
+        log_warning("XMLSocket not connected at xmlsocket_inputChecker call");
            return as_value();
     }
 
@@ -535,6 +537,53 @@
     return as_value();
 }
 
+as_value
+xmlsocket_onData(const fn_call& fn)
+{
+    GNASH_REPORT_FUNCTION;
+
+    as_value   method;
+    as_value   val;
+    
+    boost::intrusive_ptr<xmlsocket_as_object> ptr = 
ensureType<xmlsocket_as_object>(fn.this_ptr);
+
+    boost::intrusive_ptr<as_function> onXMLEvent = 
ptr->getEventHandler("onXML");
+    if ( ! onXMLEvent )
+    {
+            log_msg("Builtin XMLSocket.onData doing nothing as no "
+                            "onXML event is defined on XMLSocket %p",
+                            (void*)ptr.get());
+            return as_value();
+    }
+
+    if ( fn.nargs < 1 )
+    {
+        IF_VERBOSE_ASCODING_ERRORS(
+        log_aserror("Builtin XMLSocket.onData() needs an argument");
+        );
+        return as_value();
+    }
+
+    as_environment& env = fn.env();
+    std::string xmlin = fn.arg(0).to_std_string(&env);
+
+    if ( xmlin.empty() )
+    {
+            log_error("Builtin XMLSocket.onData() called with an argument "
+                            "that resolves to the empty string: %s",
+                            fn.arg(0).to_debug_string().c_str());
+            return as_value();
+    }
+
+    boost::intrusive_ptr<as_object> xml = new XML(xmlin);
+
+    env.push(xml);
+    call_method(as_value(onXMLEvent.get()), &env, ptr.get(), 1, 
env.stack_size()-1);
+    return as_value();
+
+
+}
+
 static as_object*
 getXMLSocketInterface()
 {
@@ -555,6 +604,12 @@
     o.init_member("close", new builtin_function(xmlsocket_close));
 }
 
+static void
+attachXMLSocketProperties(as_object& o)
+{
+    o.init_member("onData", new builtin_function(xmlsocket_onData));
+}
+
 // extern (used by Global.cpp)
 void xmlsocket_class_init(as_object& global)
 {

Index: testsuite/actionscript.all/XMLSocket.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/XMLSocket.as,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- testsuite/actionscript.all/XMLSocket.as     3 Apr 2007 17:39:42 -0000       
1.3
+++ testsuite/actionscript.all/XMLSocket.as     4 Apr 2007 07:53:28 -0000       
1.4
@@ -20,7 +20,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: XMLSocket.as,v 1.3 2007/04/03 17:39:42 strk Exp $";
+rcsid="$Id: XMLSocket.as,v 1.4 2007/04/04 07:53:28 strk Exp $";
 
 #include "check.as"
 
@@ -45,9 +45,9 @@
 socketObj = new XMLSocket;
 
 // The default onData handler calls onXML after parsing the code
-xcheck_equals(typeof(socketObj.onData), 'function');
+check_equals(typeof(socketObj.onData), 'function');
 #if OUTPUT_VERSION >= 6
-xcheck(socketObj.hasOwnProperty('onData'));
+check(socketObj.hasOwnProperty('onData'));
 #endif
 
 check_equals(typeof(socketObj), 'object');
@@ -70,11 +70,12 @@
        }
 };
 
-#if 1 // the default onData calls onXML
+#if 0 // the default onData calls onXML
 socketObj.onData = function(src) {
        check_equals(this.secret, 4);
        check_equals(typeof(src), 'string');
        note("XMLSocket.onData("+src+") called with "+arguments.length+" args");
+    this.onXML(new XML(src));
 };
 #endif
 
@@ -83,6 +84,7 @@
        check_equals(arguments.length, 1);
        check(x instanceof XML);
        note("XMLSocket.onXML() called with a "+typeof(arguments[0])+" as arg");
+    note("Parsed XML: "+x.toString());
 };
 
 socketObj.onClose = function() {




reply via email to

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