gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash/server xml.h xml.cpp


From: Rob Savoye
Subject: [Gnash-commit] gnash/server xml.h xml.cpp
Date: Mon, 06 Feb 2006 21:42:00 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Branch:         
Changes by:     Rob Savoye <address@hidden>     06/02/06 21:42:00

Modified files:
        server         : xml.h xml.cpp 

Log message:
        * server/xml.{h,cpp}: Fix capitalization errors in
        names. Implement getBytesTotal(), getBytesLoaded(),
        and hasChildNodes().

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/xml.h.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/xml.cpp.diff?tr1=1.6&tr2=1.7&r1=text&r2=text

Patches:
Index: gnash/server/xml.cpp
diff -u gnash/server/xml.cpp:1.6 gnash/server/xml.cpp:1.7
--- gnash/server/xml.cpp:1.6    Mon Feb  6 04:11:04 2006
+++ gnash/server/xml.cpp        Mon Feb  6 21:42:00 2006
@@ -37,6 +37,7 @@
 #include "xml.h"
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
+#include <libxml/tree.h>
 #include <libxml/xmlreader.h>
 
 namespace gnash {
@@ -678,39 +679,89 @@
 }
 
 
-
+/// \brief add or change the HTTP Request header
+///
+/// Method; adds or changes HTTP request headers (such as Content-Type
+/// or SOAPAction) sent with POST actions. In the first usage, you pass
+/// two strings to the method: headerName and headerValue. In the
+/// second usage, you pass an array of strings, alternating header
+/// names and header values.
+///
+/// If multiple calls are made to set the same header name, each
+/// successive value replaces the value set in the previous call.
 void
-XML::addRequestHeader()
+XML::addRequestHeader(const char *name, const char *value)
 {
     log_msg("%s:unimplemented \n", __FUNCTION__);
 }
 
+/// \brief append a node the the XML object
+///
+/// Method; appends the specified node to the XML object\ufffds child
+/// list. This method operates directly on the node referenced by the
+/// childNode parameter; it does not append a copy of the node. If the
+/// node to be appended already exists in another tree structure,
+/// appending the node to the new location will remove it from its
+/// current location. If the childNode parameter refers to a node that
+/// already exists in another XML tree structure, the appended child
+/// node is placed in the new tree structure after it is removed from
+/// its existing parent node. 
 void
-XML::appendChild()
+XML::appendChild(XMLNode *node)
 {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+    _nodes->_children.push_back(node);
 }
 
-void
-XML::cloneNode()
+/// \brief copy a node
+///
+/// Method; constructs and returns a new XML node of the same type,
+/// name, value, and attributes as the specified XML object. If deep
+/// is set to true, all child nodes are recursively cloned, resulting
+/// in an exact copy of the original object\ufffds document tree. 
+XMLNode *
+XML::cloneNode(bool deep)
 {
     log_msg("%s:unimplemented \n", __FUNCTION__);
 }
 
-void
-XML::createElement()
+/// \brief create a new XML element
+///
+/// Method; creates a new XML element with the name specified in the
+/// parameter. The new element initially has no parent, no children,
+/// and no siblings. The method returns a reference to the newly
+/// created XML object that represents the element. This method and
+/// the XML.createTextNode() method are the constructor methods for
+/// creating nodes for an XML object. 
+XMLNode *
+XML::createElement(const char *name)
 {
     log_msg("%s:unimplemented \n", __FUNCTION__);
 }
 
-void
-XML::createTextNode()
+/// \brief Create a new XML node
+/// 
+/// Method; creates a new XML text node with the specified text. The
+/// new node initially has no parent, and text nodes cannot have
+/// children or siblings. This method returns a reference to the XML
+/// object that represents the new text node. This method and the
+/// XML.createElement() method are the constructor methods for
+/// creating nodes for an XML object.
+XMLNode *
+XML::createTextNode(const char *name)
 {
     log_msg("%s:unimplemented \n", __FUNCTION__);
 }
 
+/// \brief insert a node before a node
+///
+/// Method; inserts a new child node into the XML object\ufffds child
+/// list, before the beforeNode node. If the beforeNode parameter is
+/// undefined or null, the node is added using the appendChild()
+/// method. If beforeNode is not a child of my_xml, the insertion
+/// fails.
+
 void
-XML::insertBefore()
+XML::insertBefore(XMLNode *newnode, XMLNode *node)
 {
     log_msg("%s:unimplemented \n", __FUNCTION__);
 }
@@ -727,6 +778,8 @@
     log_msg("%s:unimplemented \n", __FUNCTION__);
 }
 
+/// \brief removes the specified XML object from its parent. Also
+/// deletes all descendants of the node.
 void
 XML::removeNode()
 {
@@ -1043,95 +1096,144 @@
 }
 
 
-void xml_addrequestheader(const fn_call& fn) {
+void xml_addrequestheader(const fn_call& fn)
+{
+    log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
     xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
     assert(ptr);
     
 //    fn.result->set_int(ptr->obj.getAllocated());
-    ptr->obj.addRequestHeader();
+//    ptr->obj.addRequestHeader();
+    log_msg("%s:unimplemented \n", __FUNCTION__);
 }
-void xml_appendchild(const fn_call& fn) {
+void xml_appendchild(const fn_call& fn)
+{
+    log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
     xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
     assert(ptr);
-    
+    xml_as_object *xml_obj = (xml_as_object*)fn.env->top(0).to_object();
+
 //    fn.result->set_int(ptr->obj.getAllocated());
-    ptr->obj.appendChild();
+//    ptr->obj.appendChild(xml_obj->obj);
+    log_msg("%s:unimplemented \n", __FUNCTION__);
 }
-void xml_clonenode(const fn_call& fn) {
+
+void xml_clonenode(const fn_call& fn)
+{
+    log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
     xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
     assert(ptr);
     
+    bool deep = fn.env->bottom(fn.first_arg_bottom_index).to_bool();
+
 //    fn.result->set_int(ptr->obj.getAllocated());
-    ptr->obj.cloneNode();
+    ptr->obj.cloneNode(deep);
 }
-void xml_createelement(const fn_call& fn) {
-    xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
+void xml_createelement(const fn_call& fn)
+{
+    log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
+    xmlnode_as_object *xmlnode_obj;
+    const char *text;
+    xmlnode_as_object *ptr = (xmlnode_as_object*)fn.this_ptr;
     assert(ptr);
+
+    if (fn.nargs > 0) {
+        text = fn.env->bottom(fn.first_arg_bottom_index).to_string();
+         xmlnode_obj = new xmlnode_as_object;
+    } else {
+        log_msg("ERROR: no text for element creation!\n");
+    }
     
-//    fn.result->set_int(ptr->obj.getAllocated());
-    ptr->obj.createElement();
+//    xmlNewNode(text);
+    
+    xmlnode_obj->obj.nodeNameSet((char *)text);
+    fn.result->set_as_object_interface(xmlnode_obj);
 }
-void xml_createtextnode(const fn_call& fn) {
+
+void xml_createtextnode(const fn_call& fn)
+{
+    xmlnode_as_object *xmlnode_obj;
+    char *text;
     xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
     assert(ptr);
     
-//    fn.result->set_int(ptr->obj.getAllocated());
-    ptr->obj.createTextNode();
+    
+    if (fn.nargs > 0) {
+        text = (char *)fn.env->bottom(fn.first_arg_bottom_index).to_string();
+        xmlnode_obj = new xmlnode_as_object;
+    } else {
+        log_msg("ERROR: no text for element creation!\n");
+    }
+
+//    xmlNewText(text)
+
+    xmlnode_obj->obj.valueSet(text);
+    fn.result->set_as_object_interface(xmlnode_obj);
 }
 
-void xml_getbytesloaded(const fn_call& fn) {
+void xml_getbytesloaded(const fn_call& fn)
+{
     xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
     assert(ptr);
     fn.result->set_int(ptr->obj.getBytesLoaded());
 }
 
-void xml_getbytestotal(const fn_call& fn) {
+void xml_getbytestotal(const fn_call& fn)
+{
     xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
     assert(ptr);
     fn.result->set_int(ptr->obj.getBytesTotal());
 }
 
-void xml_haschildnodes(const fn_call& fn) {
+void xml_haschildnodes(const fn_call& fn)
+{
     xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
     assert(ptr);    
     fn.result->set_bool(ptr->obj.hasChildNodes());
 }
-void xml_insertbefore(const fn_call& fn) {
+void xml_insertbefore(const fn_call& fn)
+{
     xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
     assert(ptr);
     
 //    fn.result->set_int(ptr->obj.getAllocated());
-    ptr->obj.insertBefore();
+//    ptr->obj.insertBefore();
+    log_msg("%s:unimplemented \n", __FUNCTION__);
 }
-void xml_parsexml(const fn_call& fn) {
+void xml_parsexml(const fn_call& fn)
+{
     xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
     assert(ptr);
     
 //    fn.result->set_int(ptr->obj.getAllocated());
     ptr->obj.parseXML();
 }
-void xml_removenode(const fn_call& fn) {
+void xml_removenode(const fn_call& fn)
+{
     xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
     assert(ptr);
     
 //    fn.result->set_int(ptr->obj.getAllocated());
     ptr->obj.removeNode();
 }
-void xml_send(const fn_call& fn) {
+void xml_send(const fn_call& fn)
+{
     xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
     assert(ptr);
     
 //    fn.result->set_int(ptr->obj.getAllocated());
     ptr->obj.send();
 }
-void xml_sendandload(const fn_call& fn) {
+void xml_sendandload(const fn_call& fn)
+{
     xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
     assert(ptr);
     
 //    fn.result->set_int(ptr->obj.getAllocated());
     ptr->obj.sendAndLoad();
 }
-void xml_tostring(const fn_call& fn) {
+void xml_tostring(const fn_call& fn)
+{
     xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
     assert(ptr);
     
Index: gnash/server/xml.h
diff -u gnash/server/xml.h:1.8 gnash/server/xml.h:1.9
--- gnash/server/xml.h:1.8      Sun Feb  5 22:17:49 2006
+++ gnash/server/xml.h  Mon Feb  6 21:42:00 2006
@@ -86,10 +86,14 @@
     XMLNode();
     ~XMLNode();
 
-    int length()         { return _children.size(); }
-    tu_string nodeName() { return _name; }
+    int length()                 { return _children.size(); }
+    const char *nodeName()       { return _name; }
+    
+    void nodeNameSet(char *name) { _name = name; }
+    char *valueGet()             { return _value; }
+    void valueSet(char *value)   { _value = value; }
 
-    char *nodeValue()    { return _value; }
+    const char *nodeValue()    { return _value; }
   
     //  nodeType       XML.nodeType
 
@@ -146,7 +150,7 @@
 /// XML Node ActionScript object
 struct xmlnode_as_object : public gnash::as_object
 {
-    //XMLNode obj;
+    XMLNode obj;
     int                _padding;
 
 #ifdef DEBUG_MEMORY_ALLOCATION
@@ -205,9 +209,7 @@
     // XML.sendAndLoad().
 
     // Appends a node to the end of the specified object's child list.
-    void appendChild(XMLNode *node) {
-        _nodes->_children.push_back(node);
-    }
+    void appendChild(XMLNode *node);
     
     virtual bool on_event(gnash::event_id id);
     virtual void       on_event_load();
@@ -241,16 +243,17 @@
     as_object *setupFrame(gnash::as_object *xml, XMLNode *data, bool src);
   
     const char *nodeNameGet()    { return _nodename; }
+    void nodeNameSet(const char *name)    { _nodename = name; }
   
     int length()                 { return _nodes->length(); }
   
-    void addRequestHeader();
-    void appendChild();
-    void cloneNode();
-    void createElement();
-    void createTextNode();
-    
-    void insertBefore();
+    // These 6 have to 
+    void addRequestHeader(const char *name, const char *value);
+    XMLNode *cloneNode(bool deep);
+    XMLNode *createElement(const char *name);
+    XMLNode *createTextNode(const char *name);
+    void insertBefore(XMLNode *newnode, XMLNode *node);
+
     void load();
     void parseXML();
     void removeNode();




reply via email to

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