gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/array.cpp server/array.h...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/array.cpp server/array.h...
Date: Wed, 04 Apr 2007 10:32:43 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/04/04 10:32:42

Modified files:
        .              : ChangeLog 
        server         : array.cpp array.h 
        server/asobj   : xmlnode.cpp xml.cpp 

Log message:
                * server/array.{cpp,h}: const-corrected push and unshift
                  methods.
                * server/asobj/xmlnode.cpp: implement childNodes getter/setter.
                * server/asobj/xml.cpp: cleanups.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2778&r2=1.2779
http://cvs.savannah.gnu.org/viewcvs/gnash/server/array.cpp?cvsroot=gnash&r1=1.56&r2=1.57
http://cvs.savannah.gnu.org/viewcvs/gnash/server/array.h?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlnode.cpp?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.cpp?cvsroot=gnash&r1=1.31&r2=1.32

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2778
retrieving revision 1.2779
diff -u -b -r1.2778 -r1.2779
--- ChangeLog   4 Apr 2007 10:02:02 -0000       1.2778
+++ ChangeLog   4 Apr 2007 10:32:42 -0000       1.2779
@@ -1,5 +1,12 @@
 2007-04-04 Sandro Santilli <address@hidden>
 
+       * server/array.{cpp,h}: const-corrected push and unshift
+         methods.
+       * server/asobj/xmlnode.cpp: implement childNodes getter/setter.
+       * server/asobj/xml.cpp: cleanups.
+
+2007-04-04 Sandro Santilli <address@hidden>
+
        * testsuite/misc-ming.all/Makefile.am: enable
          reverse_execute_PlaceObject2_test1runner in 'check' rule.
        * server/array.cpp: use a getter/setter for the 'length' property.

Index: server/array.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/array.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- server/array.cpp    4 Apr 2007 09:49:43 -0000       1.56
+++ server/array.cpp    4 Apr 2007 10:32:42 -0000       1.57
@@ -176,13 +176,13 @@
 }
 
 void
-as_array_object::push(as_value& val)
+as_array_object::push(const as_value& val)
 {
        elements.push_back(val);
 }
 
 void
-as_array_object::unshift(as_value& val)
+as_array_object::unshift(const as_value& val)
 {
        elements.push_front(val);
 }

Index: server/array.h
===================================================================
RCS file: /sources/gnash/gnash/server/array.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- server/array.h      28 Mar 2007 14:58:30 -0000      1.23
+++ server/array.h      4 Apr 2007 10:32:42 -0000       1.24
@@ -68,9 +68,9 @@
 
        as_array_object(const as_array_object& other);
 
-       void push(as_value& val);
+       void push(const as_value& val);
 
-       void unshift(as_value& val);
+       void unshift(const as_value& val);
 
        as_value shift();
 

Index: server/asobj/xmlnode.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlnode.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- server/asobj/xmlnode.cpp    4 Apr 2007 09:02:10 -0000       1.23
+++ server/asobj/xmlnode.cpp    4 Apr 2007 10:32:42 -0000       1.24
@@ -14,38 +14,37 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: xmlnode.cpp,v 1.23 2007/04/04 09:02:10 strk Exp $ */
+/* $Id: xmlnode.cpp,v 1.24 2007/04/04 10:32:42 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <vector>
 #include "log.h"
 #include "tu_config.h"
 #include "fn_call.h"
 #include "builtin_function.h"
-
-//#define DEBUG_MEMORY_ALLOCATION 1
-
+#include "array.h" // for childNodes
 #include "xmlnode.h"
-
-#ifdef DEBUG_MEMORY_ALLOCATION
 #include "log.h"
-#endif
 
-#include <unistd.h>
 #include <string>
 #include <sstream>
+#include <vector>
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 #include <libxml/xmlreader.h>
 
+
 using namespace std;
 
+//#define DEBUG_MEMORY_ALLOCATION 1
+
 namespace gnash {
 
 static as_value xmlnode_new(const fn_call& fn);
@@ -63,6 +62,7 @@
 static as_value xmlnode_lastchild(const fn_call& fn);
 static as_value xmlnode_nextsibling(const fn_call& fn);
 static as_value xmlnode_previoussibling(const fn_call& fn);
+static as_value xmlnode_childNodes(const fn_call& fn);
 as_object* getXMLNodeInterface();
 
 static LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
@@ -414,7 +414,8 @@
     o.init_property("attributes", *gettersetter, *gettersetter);
 
     // These two return an array of objects
-    o.init_member("childNodes", as_value(""));
+    gettersetter = new builtin_function(xmlnode_childNodes, NULL);
+    o.init_property("childNodes", *gettersetter, *gettersetter);
 
     /// \fn MLNode::firstChild
     /// \brief XMLNode::firstChild property
@@ -786,6 +787,35 @@
     return rv;
 }
 
+// Both a getter and a (do-nothing) setter for childNodes
+static as_value
+xmlnode_childNodes(const fn_call& fn)
+{
+//    GNASH_REPORT_FUNCTION;
+    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+    boost::intrusive_ptr<as_array_object> ary = new as_array_object();
+
+    if ( fn.nargs )  // setter
+    {
+        IF_VERBOSE_ASCODING_ERRORS(
+           log_aserror("Tried to set read-only property XMLNode.childNodes");
+           );
+        return as_value();
+    }
+
+    typedef XMLNode::ChildList ChildList;
+
+    ChildList& child = ptr->childNodes();
+    for ( ChildList::const_iterator it=child.begin(), itEnd=child.end();
+                    it != itEnd; ++it )
+    {
+            boost::intrusive_ptr<XMLNode> node = *it;
+            ary->push(as_value(node.get()));
+    }
+
+    return as_value(ary.get());
+}
+
 // extern (used by Global.cpp)
 void xmlnode_class_init(as_object& global)
 {

Index: server/asobj/xml.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xml.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- server/asobj/xml.cpp        4 Apr 2007 09:02:10 -0000       1.31
+++ server/asobj/xml.cpp        4 Apr 2007 10:32:42 -0000       1.32
@@ -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.31 2007/04/04 09:02:10 strk Exp $ */
+/* $Id: xml.cpp,v 1.32 2007/04/04 10:32:42 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -395,83 +395,6 @@
     GNASH_REPORT_FUNCTION;
 }
 
-#if 0
-void
-XML::setupFrame(as_object *obj, XMLNode *xml, bool mem)
-{
-//    GNASH_REPORT_FUNCTION;
-    
-    int                 child;
-    unsigned int i;
-    const char    *nodename;
-    //const char    *nodevalue;
-    //AS_value      nodevalue;
-    int           length;
-    XMLNode       *childnode;
-    XMLNode *xmlchildnode_obj;
-    xmlattr_as_object* attr_obj;
-
-    //log_msg("\t%s: processing node %s for object %p, mem is %d\n", 
__FUNCTION__, xml->_name, obj, mem);
-  
-    // Get the data for this node
-    nodename   = xml->_name;
-    length     = xml->length();
-
-    // Set these members in the top level object passed in. This are used
-    // primarily by the disk based XML parser, where at least in all my current
-    // test cases this is referenced with firstChild first, then nodeName and
-    // childNodes.
-    //obj->set_member("nodeName", nodename); // use the getter/setter !
-    obj->set_member("length", length); // FIXME: use a getter/setter !
-
-    // Process the attributes, if any
-    if (xml->_attributes.size() == 0)
-    {
-        //log_msg("\t\tNo attributes for node %s, created empty object at 
%p\n", nodename, attr_obj);
-    }
-    else
-    {
-        attr_obj = new xmlattr_as_object;
-        for (i=0; i<xml->_attributes.size(); i++) {
-            attr_obj->set_member(xml->_attributes[i]->_name, 
xml->_attributes[i]->_value);
-        }
-        obj->set_member("attributes", attr_obj);
-    }
-
-    //xml->_attributes.resize(0);
-    //obj->set_member("attributes", attr_obj);
-
-    // Process the children, if there are any
-    if (length)
-    {
-        //log_msg("\tProcessing %d children nodes for %s\n", length, nodename);
-        int inum;
-        inum = 0;
-        for (child=0; child<length; child++) {
-            // Create a new AS object for this node's children
-            xmlchildnode_obj = new XMLNode;
-            // When parsing XML from memory, the test movies I have expect the 
firstChild
-            // to be the first element of the array instead.
-            if (mem) {
-                childnode = xml;
-            } else {
-                childnode = xml->_children[child];
-            }
-            setupFrame(xmlchildnode_obj, childnode, false); // setup child node
-
-            obj->set_member(boost::lexical_cast<std::string>(inum), 
xmlchildnode_obj);
-            ++inum;
-        }
-    }
-    else
-    {
-        //log_msg("\tNode %s has no children\n", nodename);
-    }  
-
-}
-#endif
-
-
 /// \brief add or change the HTTP Request header
 ///
 /// Method; adds or changes HTTP request headers (such as Content-Type
@@ -742,18 +665,14 @@
 as_value xml_parsexml(const fn_call& fn)
 {
 //    GNASH_REPORT_FUNCTION;
-    const char *text;
     as_value   method;
     as_value   val;    
     boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
 
     if (fn.nargs > 0)
     {
-        text = fn.arg(0).to_string(); 
-           if (ptr->parseXML(text))
-        {
-               //ptr->setupFrame(ptr.get(), ptr->firstChild().get(), false);
-           }
+        std::string text = fn.arg(0).to_std_string(&(fn.env()));
+        ptr->parseXML(text);
     }
     
     return as_value();




reply via email to

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