gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10299: Implement more XMLNode metho


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10299: Implement more XMLNode methods.
Date: Wed, 19 Nov 2008 10:02:21 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10299
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2008-11-19 10:02:21 +0100
message:
  Implement more XMLNode methods.
modified:
  libcore/asobj/ClassHierarchy.cpp
  libcore/asobj/XMLNode_as.cpp
  libcore/asobj/XMLNode_as.h
  libcore/asobj/XML_as.cpp
  libcore/asobj/XML_as.h
  testsuite/actionscript.all/XMLNode.as
    ------------------------------------------------------------
    revno: 10295.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Wed 2008-11-19 08:56:04 +0100
    message:
      Test getNamespaceForPrefix, getPrefixForNamespace, namespaceURI methods
      of XMLNode. Implement namespaceURI.
    modified:
      libcore/asobj/XMLNode_as.cpp
      libcore/asobj/XMLNode_as.h
      libcore/asobj/XML_as.cpp
      testsuite/actionscript.all/XMLNode.as
    ------------------------------------------------------------
    revno: 10295.1.2
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Wed 2008-11-19 09:14:34 +0100
    message:
      Test and implement XMLNode.prefix and XMLNode.localName.
    modified:
      libcore/asobj/XMLNode_as.cpp
      testsuite/actionscript.all/XMLNode.as
    ------------------------------------------------------------
    revno: 10295.1.3
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Wed 2008-11-19 09:41:47 +0100
    message:
      Comments, test totals, rename XMLNode class to XMLNode_as.
    modified:
      libcore/asobj/ClassHierarchy.cpp
      libcore/asobj/XMLNode_as.cpp
      libcore/asobj/XMLNode_as.h
      libcore/asobj/XML_as.cpp
      libcore/asobj/XML_as.h
      testsuite/actionscript.all/XMLNode.as
=== modified file 'libcore/asobj/ClassHierarchy.cpp'
--- a/libcore/asobj/ClassHierarchy.cpp  2008-11-06 23:06:02 +0000
+++ b/libcore/asobj/ClassHierarchy.cpp  2008-11-19 08:41:47 +0000
@@ -274,7 +274,7 @@
        { xmlsocket_class_init, NSV::CLASS_X_M_L_SOCKET, NSV::CLASS_OBJECT, 
NSV::NS_FLASH_NET, 5 },
        { date_class_init, NSV::CLASS_DATE, NSV::CLASS_OBJECT, NS_GLOBAL, 5 },
        { xml_class_init, NSV::CLASS_X_M_L, NSV::CLASS_OBJECT, NS_GLOBAL, 5 },
-       { XMLNode_class_init, NSV::CLASS_X_M_L_NODE, NSV::CLASS_OBJECT, 
NSV::NS_FLASH_XML, 5 },
+       { xmlnode_class_init, NSV::CLASS_X_M_L_NODE, NSV::CLASS_OBJECT, 
NSV::NS_FLASH_XML, 5 },
        { mouse_class_init, NSV::CLASS_MOUSE, NSV::CLASS_OBJECT, 
NSV::NS_FLASH_UI, 5 },
        { number_class_init, NSV::CLASS_NUMBER, NSV::CLASS_OBJECT, NS_GLOBAL, 5 
},
        { textformat_class_init, NSV::CLASS_TEXT_FORMAT, NSV::CLASS_OBJECT, 
NS_GLOBAL, 5 },

=== modified file 'libcore/asobj/XMLNode_as.cpp'
--- a/libcore/asobj/XMLNode_as.cpp      2008-11-18 09:29:12 +0000
+++ b/libcore/asobj/XMLNode_as.cpp      2008-11-19 08:41:47 +0000
@@ -1,4 +1,4 @@
-// XMLNode_as.cpp:  ActionScript "XMLNode" class, for Gnash.
+// XMLNode_as.cpp:  ActionScript "XMLNode_as" class, for Gnash.
 // 
 //   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 // 
@@ -37,33 +37,33 @@
 
 namespace gnash {
 
-static as_value XMLNode_new(const fn_call& fn);
-static as_value XMLNode_nodename(const fn_call& fn);
-static as_value XMLNode_node_value(const fn_call& fn);
-static as_value XMLNode_nodetype(const fn_call& fn);
-static as_value XMLNode_attributes(const fn_call& fn);
-static as_value XMLNode_appendchild(const fn_call& fn);
-static as_value XMLNode_clonenode(const fn_call& fn);
-static as_value XMLNode_haschildnodes(const fn_call& fn);
-static as_value XMLNode_insertbefore(const fn_call& fn);
-static as_value XMLNode_removenode(const fn_call& fn);
-static as_value XMLNode_tostring(const fn_call& fn);
-static as_value XMLNode_firstchild(const fn_call& fn);
-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);
-static as_value XMLNode_parentNode(const fn_call& fn);
-static as_value XMLNode_getPrefixForNamespace(const fn_call& fn);
-static as_value XMLNode_getNamespaceForPrefix(const fn_call& fn);
-static as_value XMLNode_namespaceURI(const fn_call& fn);
-static as_value XMLNode_localName(const fn_call& fn);
-static as_value XMLNode_prefix(const fn_call& fn);
+static as_value xmlnode_new(const fn_call& fn);
+static as_value xmlnode_nodename(const fn_call& fn);
+static as_value xmlnode_node_value(const fn_call& fn);
+static as_value xmlnode_nodetype(const fn_call& fn);
+static as_value xmlnode_attributes(const fn_call& fn);
+static as_value xmlnode_appendchild(const fn_call& fn);
+static as_value xmlnode_clonenode(const fn_call& fn);
+static as_value xmlnode_haschildnodes(const fn_call& fn);
+static as_value xmlnode_insertbefore(const fn_call& fn);
+static as_value xmlnode_removenode(const fn_call& fn);
+static as_value xmlnode_tostring(const fn_call& fn);
+static as_value xmlnode_firstchild(const fn_call& fn);
+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);
+static as_value xmlnode_parentNode(const fn_call& fn);
+static as_value xmlnode_getPrefixForNamespace(const fn_call& fn);
+static as_value xmlnode_getNamespaceForPrefix(const fn_call& fn);
+static as_value xmlnode_namespaceURI(const fn_call& fn);
+static as_value xmlnode_localName(const fn_call& fn);
+static as_value xmlnode_prefix(const fn_call& fn);
 
 as_object* getXMLNodeInterface();
 
 
-XMLNode::XMLNode()
+XMLNode_as::XMLNode_as()
     :
     as_object(getXMLNodeInterface()),
     _parent(0),
@@ -75,7 +75,7 @@
 #endif
 }
 
-XMLNode::XMLNode(const XMLNode& tpl, bool deep)
+XMLNode_as::XMLNode_as(const XMLNode_as& tpl, bool deep)
     :
     as_object(getXMLNodeInterface()),
     _parent(0), // _parent is never implicitly copied
@@ -86,16 +86,16 @@
     // only clone children if in deep mode
     if ( deep ) 
     {
-        const ChildList& from=tpl._children;
-        for (ChildList::const_iterator it=from.begin(), itEnd=from.end();
+        const Children& from=tpl._children;
+        for (Children::const_iterator it=from.begin(), itEnd=from.end();
                         it != itEnd; ++it)
         {
-                _children.push_back(new XMLNode(*(*it), deep));
+                _children.push_back(new XMLNode_as(*(*it), deep));
         }
     }
 }
 
-XMLNode::~XMLNode()
+XMLNode_as::~XMLNode_as()
 {
     //log_debug("%s: %p", __PRETTY_FUNCTION__, this);
 #ifdef DEBUG_MEMORY_ALLOCATION
@@ -104,7 +104,7 @@
 }
 
 bool
-XMLNode::hasChildNodes()
+XMLNode_as::hasChildNodes()
 {
     //GNASH_REPORT_FUNCTION;
     if (_children.size()) {
@@ -113,21 +113,21 @@
     return false;
 }
 
-boost::intrusive_ptr<XMLNode>
-XMLNode::firstChild()
+boost::intrusive_ptr<XMLNode_as>
+XMLNode_as::firstChild()
 {
     //GNASH_REPORT_FUNCTION;
     if ( _children.empty() ) return NULL;
     return _children.front();
 }
 
-boost::intrusive_ptr<XMLNode>
-XMLNode::lastChild()
+boost::intrusive_ptr<XMLNode_as>
+XMLNode_as::lastChild()
 {
        //GNASH_REPORT_FUNCTION;
        if ( _children.empty() )
        {
-                       log_debug(_("XMLNode %p has no children"), (void*)this);
+                       log_debug(_("XMLNode_as %p has no children"), 
(void*)this);
                        return NULL;
        }
        return _children.back();
@@ -135,11 +135,11 @@
 
 
 void
-XMLNode::appendChild(boost::intrusive_ptr<XMLNode> node)
+XMLNode_as::appendChild(boost::intrusive_ptr<XMLNode_as> node)
 {
     assert (node);
 
-    boost::intrusive_ptr<XMLNode> oldparent = node->getParent();
+    boost::intrusive_ptr<XMLNode_as> oldparent = node->getParent();
     node->setParent(this);
     _children.push_back(node);
     if ( oldparent ) {
@@ -149,22 +149,23 @@
 //  log_unimpl("%s: partially unimplemented", __PRETTY_FUNCTION__);
 }
 
-boost::intrusive_ptr<XMLNode> 
-XMLNode::cloneNode(bool deep)
+boost::intrusive_ptr<XMLNode_as> 
+XMLNode_as::cloneNode(bool deep)
 {
     //GNASH_REPORT_FUNCTION;
     //log_debug(_("%s: deep is %d"), __PRETTY_FUNCTION__, deep);
 
-    boost::intrusive_ptr<XMLNode> newnode = new XMLNode(*this, deep);
+    boost::intrusive_ptr<XMLNode_as> newnode = new XMLNode_as(*this, deep);
 
     return newnode;
 }
 
 void
-XMLNode::insertBefore(boost::intrusive_ptr<XMLNode> newnode, 
boost::intrusive_ptr<XMLNode> pos)
+XMLNode_as::insertBefore(boost::intrusive_ptr<XMLNode_as> newnode,
+        boost::intrusive_ptr<XMLNode_as> pos)
 {
     // find iterator for positional parameter
-    ChildList::iterator it = std::find(_children.begin(), _children.end(), 
pos);
+    Children::iterator it = std::find(_children.begin(), _children.end(), pos);
     if ( it == _children.end() )
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -174,7 +175,7 @@
     }
 
     _children.insert(it, newnode);
-    boost::intrusive_ptr<XMLNode> oldparent = newnode->getParent();
+    boost::intrusive_ptr<XMLNode_as> oldparent = newnode->getParent();
     newnode->setParent(this);
     if ( oldparent )
     {
@@ -185,12 +186,12 @@
 /// \brief removes the specified XML object from its parent. Also
 /// deletes all descendants of the node.
 void
-XMLNode::removeNode()
+XMLNode_as::removeNode()
 {
 #ifndef GNASH_USE_GC
     assert(get_ref_count() > 1);
 #endif
-    boost::intrusive_ptr<XMLNode> oldparent = getParent();
+    boost::intrusive_ptr<XMLNode_as> oldparent = getParent();
     if ( oldparent )
     {
         oldparent->_children.remove(this);
@@ -201,21 +202,21 @@
 #endif
 }
 
-XMLNode *
-XMLNode::previousSibling()
+XMLNode_as *
+XMLNode_as::previousSibling()
 {
     //GNASH_REPORT_FUNCTION;
 
     if ( ! _parent) return NULL;
        if (_parent->_children.size() <= 1) return NULL;
 
-    XMLNode *previous_node = NULL;
-    ChildList::iterator itx;
+    XMLNode_as *previous_node = NULL;
+    Children::iterator itx;
     for (itx = _parent->_children.begin(); itx != _parent->_children.end(); 
itx++)
     {
         if (itx->get() == this)
         {
-            // log_debug("Found the previous XMLNode child !!!! %s <%p>", 
(*itx)->nodeName(), (void*)*itx);
+            // log_debug("Found the previous XMLNode_as child !!!! %s <%p>", 
(*itx)->nodeName(), (void*)*itx);
                    return previous_node;
                }
                previous_node = itx->get();
@@ -224,8 +225,8 @@
     return NULL;
 }
 
-XMLNode *
-XMLNode::nextSibling()
+XMLNode_as *
+XMLNode_as::nextSibling()
 {
     //GNASH_REPORT_FUNCTION;
 
@@ -240,8 +241,8 @@
             return NULL;
     }
 
-    XMLNode *previous_node = NULL;
-    ChildList::reverse_iterator itx;
+    XMLNode_as *previous_node = NULL;
+    Children::reverse_iterator itx;
     for (itx = _parent->_children.rbegin(); itx != _parent->_children.rend(); 
itx++)
     {
         if (itx->get() == this)
@@ -255,14 +256,14 @@
 }
 
 void
-XMLNode::toString(std::ostream& xmlout, bool encode) const
+XMLNode_as::toString(std::ostream& xmlout, bool encode) const
 {
     stringify(*this, xmlout, encode);
 }
 
 /* static private */
 void
-XMLNode::stringify(const XMLNode& xml, std::ostream& xmlout, bool encode) 
+XMLNode_as::stringify(const XMLNode_as& xml, std::ostream& xmlout, bool 
encode) 
 {
 
     const std::string& node_value = xml.nodeValue();
@@ -282,7 +283,7 @@
         xmlout << "<" << nodename;
     
         // Process the attributes, if any
-        AttribList::const_iterator ita;
+        Attributes::const_iterator ita;
         for (ita = xml._attributes.begin(); ita != xml._attributes.end(); 
ita++)
         {
             const XMLAttr& xa = *ita;
@@ -315,13 +316,13 @@
     }
 
     // Childs, after node as_value.
-    ChildList::const_iterator itx;
+    Children::const_iterator itx;
     for (itx = xml._children.begin(); itx != xml._children.end(); itx++)
     {
         (*itx)->toString(xmlout, encode);
     }
 
-    if ( nodename.size() )
+    if (!nodename.empty())
     {
            xmlout << "</" << nodename << ">";
     }
@@ -336,44 +337,44 @@
     
     // No prop flags:
     o.init_member("appendChild", new builtin_function(
-                XMLNode_appendchild), noFlags);
+                xmlnode_appendchild), noFlags);
     o.init_member("cloneNode", new builtin_function(
-                XMLNode_clonenode), noFlags);
+                xmlnode_clonenode), noFlags);
     o.init_member("hasChildNodes", new builtin_function(
-                XMLNode_haschildnodes), noFlags);
+                xmlnode_haschildnodes), noFlags);
     o.init_member("insertBefore", new builtin_function(
-                XMLNode_insertbefore), noFlags);
+                xmlnode_insertbefore), noFlags);
     o.init_member("removeNode", new builtin_function(
-                XMLNode_removenode), noFlags);
-    o.init_member("toString", new builtin_function(XMLNode_tostring), noFlags);
+                xmlnode_removenode), noFlags);
+    o.init_member("toString", new builtin_function(xmlnode_tostring), noFlags);
     o.init_member("getPrefixForNamespace", new builtin_function(
-                XMLNode_getPrefixForNamespace), noFlags);
+                xmlnode_getPrefixForNamespace), noFlags);
     o.init_member("getNamespaceForPrefix", new builtin_function(
-                XMLNode_getNamespaceForPrefix), noFlags);
+                xmlnode_getNamespaceForPrefix), noFlags);
 
 
     const int protectedFlags = as_prop_flags::isProtected;
 
     // Just the protected flag:
-    o.init_property("nodeValue", &XMLNode_node_value, 
-            &XMLNode_node_value, protectedFlags);
-    o.init_property("nodeName", &XMLNode_nodename, 
-            &XMLNode_nodename, protectedFlags);
+    o.init_property("nodeValue", &xmlnode_node_value, 
+            &xmlnode_node_value, protectedFlags);
+    o.init_property("nodeName", &xmlnode_nodename, 
+            &xmlnode_nodename, protectedFlags);
 
-    o.init_readonly_property("firstChild", &XMLNode_firstchild, 
protectedFlags);
-    o.init_readonly_property("lastChild", &XMLNode_lastchild, protectedFlags);
-    o.init_readonly_property("localName", &XMLNode_localName, protectedFlags);
+    o.init_readonly_property("firstChild", &xmlnode_firstchild, 
protectedFlags);
+    o.init_readonly_property("lastChild", &xmlnode_lastchild, protectedFlags);
+    o.init_readonly_property("localName", &xmlnode_localName, protectedFlags);
     o.init_readonly_property("namespaceURI", 
-            &XMLNode_namespaceURI, protectedFlags);
+            &xmlnode_namespaceURI, protectedFlags);
     o.init_readonly_property("nextSibling", 
-            &XMLNode_nextsibling, protectedFlags);
-    o.init_readonly_property("prefix", &XMLNode_prefix, protectedFlags);
+            &xmlnode_nextsibling, protectedFlags);
+    o.init_readonly_property("prefix", &xmlnode_prefix, protectedFlags);
     o.init_readonly_property("previousSibling", 
-            &XMLNode_previoussibling, protectedFlags);
-    o.init_readonly_property("nodeType", &XMLNode_nodetype, protectedFlags);
-    o.init_readonly_property("attributes", &XMLNode_attributes, 
protectedFlags);
-    o.init_readonly_property("childNodes", &XMLNode_childNodes, 
protectedFlags);
-    o.init_readonly_property("parentNode", &XMLNode_parentNode, 
protectedFlags);
+            &xmlnode_previoussibling, protectedFlags);
+    o.init_readonly_property("nodeType", &xmlnode_nodetype, protectedFlags);
+    o.init_readonly_property("attributes", &xmlnode_attributes, 
protectedFlags);
+    o.init_readonly_property("childNodes", &xmlnode_childNodes, 
protectedFlags);
+    o.init_readonly_property("parentNode", &xmlnode_parentNode, 
protectedFlags);
 
 }
 
@@ -390,14 +391,13 @@
 }
 
 static as_value
-XMLNode_new(const fn_call& fn)
+xmlnode_new(const fn_call& fn)
 {
-//    GNASH_REPORT_FUNCTION;
     
-    XMLNode *xml_obj = new XMLNode;
+    XMLNode_as *xml_obj = new XMLNode_as;
     if ( fn.nargs > 0 )
     {
-        xml_obj->nodeTypeSet(XMLNode::NodeType(fn.arg(0).to_int()));
+        xml_obj->nodeTypeSet(XMLNode_as::NodeType(fn.arg(0).to_int()));
         if (fn.nargs > 1)
         {
             xml_obj->nodeValueSet(fn.arg(1).to_string());
@@ -408,11 +408,11 @@
 }
 
 static as_value
-XMLNode_appendchild(const fn_call& fn)
+xmlnode_appendchild(const fn_call& fn)
 {
 //    GNASH_REPORT_FUNCTION;
 
-       boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+       boost::intrusive_ptr<XMLNode_as> ptr = 
ensureType<XMLNode_as>(fn.this_ptr);
 
        if ( ! fn.nargs )
        {
@@ -422,11 +422,13 @@
                return as_value();
        }
 
-       boost::intrusive_ptr<XMLNode> xml_obj = 
boost::dynamic_pointer_cast<XMLNode>(fn.arg(0).to_object());    
+       boost::intrusive_ptr<XMLNode_as> xml_obj = 
+        boost::dynamic_pointer_cast<XMLNode_as>(fn.arg(0).to_object());        
        if ( ! xml_obj )
        {
                IF_VERBOSE_ASCODING_ERRORS(
-               log_aserror(_("First argument to XMLNode::appendChild() is not 
an XMLNode"));
+               log_aserror(_("First argument to XMLNode::appendChild() is not "
+                "an XMLNode"));
                );
                return as_value();
        }
@@ -437,52 +439,52 @@
 }
 
 static as_value
-XMLNode_clonenode(const fn_call& fn)
+xmlnode_clonenode(const fn_call& fn)
 {
-    //GNASH_REPORT_FUNCTION;
-//    log_debug("%s: %d args", __PRETTY_FUNCTION__, fn.nargs);
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
 
     bool deep = false;
     if (fn.nargs > 0) deep = fn.arg(0).to_bool();
 
-    boost::intrusive_ptr<XMLNode> newnode = ptr->cloneNode(deep);
+    boost::intrusive_ptr<XMLNode_as> newnode = ptr->cloneNode(deep);
     return as_value(newnode.get());
 }
 
 static as_value
-XMLNode_insertbefore(const fn_call& fn)
+xmlnode_insertbefore(const fn_call& fn)
 {
-       //GNASH_REPORT_FUNCTION;
-       boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+       boost::intrusive_ptr<XMLNode_as> ptr = 
ensureType<XMLNode_as>(fn.this_ptr);
 
        if ( fn.nargs < 2 )
        {
                IF_VERBOSE_ASCODING_ERRORS(
                std::stringstream ss; fn.dump_args(ss);
-               log_aserror(_("XMLNode.insertBefore(%s) needs at least two 
argument"), ss.str().c_str());
+               log_aserror(_("XMLNode.insertBefore(%s) needs at least two "
+                "arguments"), ss.str());
                );
                return as_value();
        }
 
-       boost::intrusive_ptr<XMLNode> newnode = 
boost::dynamic_pointer_cast<XMLNode>(fn.arg(0).to_object());
+       boost::intrusive_ptr<XMLNode_as> newnode = 
+        boost::dynamic_pointer_cast<XMLNode_as>(fn.arg(0).to_object());
        if ( ! newnode )
        {
                IF_VERBOSE_ASCODING_ERRORS(
                std::stringstream ss; fn.dump_args(ss);
-               log_aserror(_("First argument to XMLNode.insertBefore(%s) is 
not an XMLNode"),
-                ss.str().c_str());
+               log_aserror(_("First argument to XMLNode.insertBefore(%s) is 
not "
+                "an XMLNode"), ss.str());
                );
                return as_value();
        }
 
-       boost::intrusive_ptr<XMLNode> pos = 
boost::dynamic_pointer_cast<XMLNode>(fn.arg(1).to_object());
+       boost::intrusive_ptr<XMLNode_as> pos = 
+        boost::dynamic_pointer_cast<XMLNode_as>(fn.arg(1).to_object());
        if ( ! pos )
        {
                IF_VERBOSE_ASCODING_ERRORS(
         std::stringstream ss; fn.dump_args(ss);
-               log_aserror(_("Second argument to XMLNode.insertBefore(%s) is 
not an XMLNode"),
-                ss.str().c_str());
+               log_aserror(_("Second argument to XMLNode.insertBefore(%s) is 
not "
+                "an XMLNode"), ss.str());
                );
                return as_value();
        }
@@ -490,98 +492,102 @@
     ptr->insertBefore(newnode, pos);
     return as_value();
     
-//    return as_value(ptr->obj.getAllocated());
-//    ptr->obj.insertBefore();
-    log_unimpl (__PRETTY_FUNCTION__);
-    return as_value();
 }
 
 
 as_value
-XMLNode_getNamespaceForPrefix(const fn_call& fn)
+xmlnode_getNamespaceForPrefix(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     log_unimpl("XMLNode.getNamespaceForPrefix");
     return as_value();
 }
 
 
 as_value
-XMLNode_getPrefixForNamespace(const fn_call& fn)
+xmlnode_getPrefixForNamespace(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     log_unimpl("XMLNode.getPrefixForNamespace");
     return as_value();
 }
 
 
-as_value
-XMLNode_namespaceURI(const fn_call& fn)
-{
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
-
-    if (fn.nargs > 0)
-    {
-        // no setter
-        IF_VERBOSE_ASCODING_ERRORS(
-            log_aserror("XMLNode.namespaceURI is readonly!");
-        );
-        
-        return as_value();
-    }
-    
-    // TODO: implement getter
-    log_unimpl("XMLNode.namespaceURI");
-    return as_value();
-}
-
-
-as_value
-XMLNode_prefix(const fn_call& fn)
-{
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
-
-    if (fn.nargs > 0)
-    {
-        // no setter
-        IF_VERBOSE_ASCODING_ERRORS(
-            log_aserror("XMLNode.prefix is readonly!");
-        );
-        
-        return as_value();
-    }
-    
-    // TODO: implement getter
-    log_unimpl("XMLNode.prefix");
-    return as_value();
-}
-
-
-as_value
-XMLNode_localName(const fn_call& fn)
-{
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
-
-    if (fn.nargs > 0)
-    {
-        // no setter
-        IF_VERBOSE_ASCODING_ERRORS(
-            log_aserror("XMLNode.localName is readonly!");
-        );
-        
-        return as_value();
-    }
-    
-    // TODO: implement getter
-    log_unimpl("XMLNode.localName");
-    return as_value();
-}
-
-
-as_value
-XMLNode_removenode(const fn_call& fn)
-{
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+/// Returns a namespaceURI set with the xmlns attribute, searching upwards
+/// through parent nodes if necessary.
+//
+/// This property can only be set during XML parsing and cannot be changed
+/// or set using attributes.
+//
+/// Conversely, the similar getNamespaceForPrefix("") can be set and changed
+/// through attributes.
+as_value
+xmlnode_namespaceURI(const fn_call& fn)
+{
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+
+    // Read-only property
+    
+    // Search recursively for a namespace. Return an empty string
+    // if none found.
+    XMLNode_as* node = ptr.get();
+    while (node && node->getNamespaceURI().empty()) {
+        node = node->getParent();
+    }
+    if (!node) return as_value("");
+
+    return as_value(ptr->getNamespaceURI());
+}
+
+
+// Return the prefix part of the node name. If there is no colon, or one
+// colon at the end of the string, this is empty. Otherwise it is the part
+// up to the first colon.
+as_value
+xmlnode_prefix(const fn_call& fn)
+{
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+
+    // Read-only property
+    
+    const std::string& nodeName = ptr->nodeName();
+    if (nodeName.empty()) return as_value("");
+
+    std::string::size_type pos = nodeName.find(':');
+    if (pos == std::string::npos || pos == nodeName.size() - 1) {
+        return as_value("");
+    }
+
+    return as_value(nodeName.substr(0, pos));
+}
+
+
+// The local part of a node name. If there is no colon or a single colon
+// at the end of the string, this is the whole string. Otherwise all of the
+// string after the first colon.
+as_value
+xmlnode_localName(const fn_call& fn)
+{
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+
+    // Read-only property
+    
+    const std::string& nodeName = ptr->nodeName();
+    if (nodeName.empty()) return as_value("");
+
+    std::string::size_type pos = nodeName.find(':');
+    if (pos == std::string::npos || pos == nodeName.size() - 1) {
+        return as_value(nodeName);
+    }
+
+    return as_value(nodeName.substr(pos + 1));
+}
+
+
+as_value
+xmlnode_removenode(const fn_call& fn)
+{
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     
     ptr->removeNode();
     return as_value();
@@ -590,11 +596,11 @@
 
 // TODO: shouldn't overriding get_text_value() be fine ?
 as_value
-XMLNode_tostring(const fn_call& fn)
+xmlnode_tostring(const fn_call& fn)
 {
     //GNASH_REPORT_FUNCTION;
     
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     
     std::stringstream ss;
     ptr->toString(ss);
@@ -603,20 +609,20 @@
 }
 
 as_value
-XMLNode_haschildnodes(const fn_call& fn)
+xmlnode_haschildnodes(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     return as_value(ptr->hasChildNodes());
 }
 
 as_value
-XMLNode_node_value(const fn_call& fn)
+xmlnode_node_value(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     as_value rv;
     rv.set_null();
     
-    //log_debug("XMLNode_node_value called with %d args against 'this' = %p", 
fn.nargs, ptr);
+    //log_debug("xmlnode_node_value called with %d args against 'this' = %p", 
fn.nargs, ptr);
     if ( fn.nargs == 0 )
     {
            //log_debug("  nodeValue() returns '%s'", ptr->nodeValue().c_str());
@@ -631,9 +637,9 @@
 }
 
 as_value
-XMLNode_nodename(const fn_call& fn)
+xmlnode_nodename(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     as_value rv;
     rv.set_null();
 
@@ -649,34 +655,34 @@
 }
 
 as_value
-XMLNode_nodetype(const fn_call& fn)
+xmlnode_nodetype(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     return as_value(ptr->nodeType());
 }
 
 
 as_value
-XMLNode_attributes(const fn_call& fn)
+xmlnode_attributes(const fn_call& fn)
 {
     
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
 
     VM& vm = ptr->getVM();
     string_table& st = vm.getStringTable();
 
-    XMLNode::AttribList& attrs = ptr->attributes();
-    //log_debug("Node %p has %d attributes", (void*)ptr.get(), attrs.size());
-
-    boost::intrusive_ptr<as_object> ret = new as_object(); // attributes are 
not Object types (getObjectInterface());
-    for (XMLNode::AttribList::const_iterator it=attrs.begin(),
+    XMLNode_as::Attributes& attrs = ptr->attributes();
+
+    // Attributes are simple objects.
+    boost::intrusive_ptr<as_object> ret = new as_object(); 
+
+    for (XMLNode_as::Attributes::const_iterator it=attrs.begin(),
         itEnd=attrs.end(); it != itEnd; ++it)
     {
 
         const XMLAttr& at = *it;
         const std::string& name = at.name();
         const std::string& val = at.value();
-        //log_debug("%s: %s", name.c_str(), val.c_str());
         // These must be enumerable !
         ret->set_member(st.find(name), val);
     }
@@ -693,13 +699,13 @@
 /// and removeNode() methods to manipulate child nodes. 
 ///
 as_value
-XMLNode_firstchild(const fn_call& fn)
+xmlnode_firstchild(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     as_value rv;
     rv.set_null();
 
-    boost::intrusive_ptr<XMLNode> node = ptr->firstChild();
+    boost::intrusive_ptr<XMLNode_as> node = ptr->firstChild();
     if (node) {
        rv = node.get();
     }
@@ -714,13 +720,13 @@
 /// insertBefore(), and removeNode() methods to manipulate child
 /// nodes.
 as_value
-XMLNode_lastchild(const fn_call& fn)
+xmlnode_lastchild(const fn_call& fn)
 {
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     as_value rv;
     rv.set_null();
 
-    boost::intrusive_ptr<XMLNode> node = ptr->lastChild();
+    boost::intrusive_ptr<XMLNode_as> node = ptr->lastChild();
     if (node) rv = node.get();
 
     return rv;
@@ -728,75 +734,75 @@
 
 
 as_value
-XMLNode_nextsibling(const fn_call& fn)
-{
-    as_value rv;
-    rv.set_null();
-
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
-    XMLNode *node = ptr->nextSibling();
-    if (node) {
-       rv = node;
-    }
-    return rv;
-}
-
-as_value
-XMLNode_previoussibling(const fn_call& fn)
-{
-    as_value rv;
-    rv.set_null();
-
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
-    XMLNode *node = ptr->previousSibling();
-    if (node) {
-       rv = node;
-    }
-    return rv;
-}
-
-as_value
-XMLNode_parentNode(const fn_call& fn)
-{
-    as_value rv;
-    rv.set_null();
-
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
-    XMLNode *node = ptr->getParent();
-    if (node) {
-       rv = node;
-    }
-    return rv;
-}
-
-
-as_value
-XMLNode_childNodes(const fn_call& fn)
-{
-    boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
+xmlnode_nextsibling(const fn_call& fn)
+{
+    as_value rv;
+    rv.set_null();
+
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    XMLNode_as *node = ptr->nextSibling();
+    if (node) {
+       rv = node;
+    }
+    return rv;
+}
+
+as_value
+xmlnode_previoussibling(const fn_call& fn)
+{
+    as_value rv;
+    rv.set_null();
+
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    XMLNode_as *node = ptr->previousSibling();
+    if (node) {
+       rv = node;
+    }
+    return rv;
+}
+
+as_value
+xmlnode_parentNode(const fn_call& fn)
+{
+    as_value rv;
+    rv.set_null();
+
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
+    XMLNode_as *node = ptr->getParent();
+    if (node) {
+       rv = node;
+    }
+    return rv;
+}
+
+
+as_value
+xmlnode_childNodes(const fn_call& fn)
+{
+    boost::intrusive_ptr<XMLNode_as> ptr = ensureType<XMLNode_as>(fn.this_ptr);
     boost::intrusive_ptr<Array_as> ary = new Array_as();
 
-    typedef XMLNode::ChildList ChildList;
+    typedef XMLNode_as::Children Children;
 
-    ChildList& child = ptr->childNodes();
-    for ( ChildList::const_iterator it=child.begin(), itEnd=child.end();
+    Children& child = ptr->childNodes();
+    for ( Children::const_iterator it=child.begin(), itEnd=child.end();
                     it != itEnd; ++it )
     {
-            boost::intrusive_ptr<XMLNode> node = *it;
+            boost::intrusive_ptr<XMLNode_as> node = *it;
             ary->push(as_value(node.get()));
     }
 
     return as_value(ary.get());
 }
 
-void XMLNode_class_init(as_object& global)
+void xmlnode_class_init(as_object& global)
 {
-    // This is the global XMLNode "class"
+    // This is the global XMLNode_as "class"
     static boost::intrusive_ptr<builtin_function> cl;
 
     if ( cl == NULL )
     {
-        cl=new builtin_function(&XMLNode_new, getXMLNodeInterface());
+        cl=new builtin_function(&xmlnode_new, getXMLNodeInterface());
     }
 
     global.init_member("XMLNode", cl.get());
@@ -805,10 +811,11 @@
 
 #ifdef GNASH_USE_GC
 void
-XMLNode::markReachableResources() const
+XMLNode_as::markReachableResources() const
 {
        // Mark childs
-       for (ChildList::const_iterator i=_children.begin(), e=_children.end(); 
i!=e; ++i)
+       for (Children::const_iterator i=_children.begin(),
+            e=_children.end(); i!=e; ++i)
        {
                (*i)->setReachable();
        }

=== modified file 'libcore/asobj/XMLNode_as.h'
--- a/libcore/asobj/XMLNode_as.h        2008-11-18 13:36:25 +0000
+++ b/libcore/asobj/XMLNode_as.h        2008-11-19 08:41:47 +0000
@@ -38,7 +38,7 @@
 /// This is also the base class for the XML actionscript class (see
 /// XML_as.cpp, XML_as.h). Because XML_as also inherits from LoadableObject,
 /// this is a virtual base class.
-class XMLNode : public virtual as_object
+class XMLNode_as : public virtual as_object
 {
 public:
 
@@ -82,10 +82,10 @@
 
     };
 
-    XMLNode();
+    XMLNode_as();
 
-    XMLNode(const XMLNode &node, bool deep);
-    virtual ~XMLNode();
+    XMLNode_as(const XMLNode_as &node, bool deep);
+    virtual ~XMLNode_as();
 
     size_t length() const { return _children.size(); }
 
@@ -110,25 +110,32 @@
 
     /// Set value of this node, overriding any previous value
     void nodeValueSet(const std::string& value) { _value = value; }
-    //  nodeType       XML.nodeType
+
+    void setNamespaceURI(const std::string value) {
+        _namespaceURI = value;
+    }
+
+    const std::string& getNamespaceURI() const {
+        return _namespaceURI;
+    }
 
     ///  Returns true if the specified node has child nodes; otherwise,
     ///  returns false.
     bool hasChildNodes();
 
-    boost::intrusive_ptr<XMLNode> firstChild();
-    boost::intrusive_ptr<XMLNode> lastChild();
+    boost::intrusive_ptr<XMLNode_as> firstChild();
+    boost::intrusive_ptr<XMLNode_as> lastChild();
     
     // Use a list for quick erasing
-    typedef std::list< boost::intrusive_ptr<XMLNode> > ChildList;
-
-    typedef std::vector< XMLAttr > AttribList;
-
-    ChildList& childNodes() { return _children; }
-
-    AttribList& attributes() { return _attributes; }
+    typedef std::list< boost::intrusive_ptr<XMLNode_as> > Children;
+
+    typedef std::vector< XMLAttr > Attributes;
+
+    Children& childNodes() { return _children; }
+
+    Attributes& attributes() { return _attributes; }
     
-    XMLNode& operator = (XMLNode &node) {
+    XMLNode_as& operator = (XMLNode_as &node) {
         log_debug("%s: \n", __PRETTY_FUNCTION__);
         if (this == &node) return *this;
         _name = node._name;
@@ -138,14 +145,14 @@
         return *this;
     }
     
-    XMLNode& operator = (XMLNode *node)
+    XMLNode_as& operator = (XMLNode_as *node)
     {
            assert(node);
            return (*this = *node);
     }
 
-    XMLNode* previousSibling();
-    XMLNode* nextSibling();
+    XMLNode_as* previousSibling();
+    XMLNode_as* nextSibling();
 
     /// Copy a node
     //
@@ -154,7 +161,7 @@
     /// is set to true, all child nodes are recursively cloned, resulting
     /// in an exact copy of the original object's document tree. 
     ///
-    boost::intrusive_ptr<XMLNode> cloneNode(bool deep);
+    boost::intrusive_ptr<XMLNode_as> cloneNode(bool deep);
 
     /// Append a child node the the XML object
     //
@@ -169,15 +176,15 @@
     /// its existing parent node. 
     ///
     /// @param as
-    ///           The XMLNode ?
+    ///           The XMLNode_as ?
     ///
     /// @param node
-    ///           same as XMLNode::obj ?
+    ///           same as XMLNode_as::obj ?
     ///
-    void appendChild(boost::intrusive_ptr<XMLNode> childNode);
+    void appendChild(boost::intrusive_ptr<XMLNode_as> childNode);
 
-    void setParent(XMLNode *node) { _parent = node; };
-    XMLNode *getParent() { return _parent.get(); };
+    void setParent(XMLNode_as *node) { _parent = node; };
+    XMLNode_as *getParent() { return _parent.get(); };
 
     /// Insert a node before a node
     //
@@ -194,7 +201,8 @@
     ///     The node before which to insert the new one.
     ///     Must be a child of this XMLNode or the operation will fail.
     ///
-    void insertBefore(boost::intrusive_ptr<XMLNode> newnode, 
boost::intrusive_ptr<XMLNode> pos);
+    void insertBefore(boost::intrusive_ptr<XMLNode_as> newnode, 
+            boost::intrusive_ptr<XMLNode_as> pos);
 
     /// Removes the specified XML object from its parent.
     //
@@ -217,10 +225,10 @@
     // as we'll make sure in the XMLNode destructor and
     // any child cleaning interface to set child parent
     // to NULL
-    boost::intrusive_ptr<XMLNode> _parent;
+    boost::intrusive_ptr<XMLNode_as> _parent;
 
-    ChildList       _children;
-    AttribList      _attributes;
+    Children _children;
+    Attributes _attributes;
 
 protected:
 
@@ -245,20 +253,23 @@
 
     NodeType     _type;
 
-    static void stringify(const XMLNode& xml, std::ostream& xmlout, bool 
encode);
+    std::string _namespaceURI;
+
+    static void stringify(const XMLNode_as& xml, std::ostream& xmlout,
+            bool encode);
 
 };
 
 // Initialize the global XMLNode class
-void XMLNode_class_init(as_object& global);
+void xmlnode_class_init(as_object& global);
 
-// External, used by getXMLInterface() !
+// Used by XML_as
 as_object* getXMLNodeInterface();
 
-} // end of gnash namespace
-
-
-#endif // __XMLNODE_NODE_H__
+} // gnash namespace
+
+
+#endif 
 
 
 // Local Variables:

=== modified file 'libcore/asobj/XML_as.cpp'
--- a/libcore/asobj/XML_as.cpp  2008-11-18 14:39:48 +0000
+++ b/libcore/asobj/XML_as.cpp  2008-11-19 08:41:47 +0000
@@ -154,7 +154,7 @@
     if (!_xmlDecl.empty()) o << _xmlDecl;
     if (!_docTypeDecl.empty()) o << _docTypeDecl;
 
-    XMLNode::toString(o, encode);
+    XMLNode_as::toString(o, encode);
 }
 
 bool
@@ -208,7 +208,7 @@
 }
 
 void
-XML_as::parseAttribute(XMLNode* node, const std::string& xml,
+XML_as::parseAttribute(XMLNode_as* node, const std::string& xml,
         std::string::const_iterator& it)
 {
 
@@ -272,9 +272,18 @@
     // Replace entities in the value.
     escape(value);
 
+    // Handle namespace. This is set once only for each node, and is also
+    // pushed to the attributes list once.
+    StringNoCaseEqual noCaseCompare;
+    if (noCaseCompare(name, "xmlns")) {
+        if (!node->getNamespaceURI().empty()) return;
+        node->setNamespaceURI(value);
+    }
+
     XMLAttr attr(name, value);
     node->_attributes.push_back(attr);
 
+
 }
 
 /// Parse and set the docTypeDecl. This is stored without any validation and
@@ -315,7 +324,7 @@
 
 // The iterator should be pointing to the first char after the '<'
 void
-XML_as::parseTag(XMLNode*& node, const std::string& xml,
+XML_as::parseTag(XMLNode_as*& node, const std::string& xml,
     std::string::const_iterator& it)
 {
     //log_debug("Processing node: %s", node->nodeName());
@@ -346,7 +355,7 @@
 
     if (!closing) {
 
-        XMLNode* childNode = new XMLNode;
+        XMLNode_as* childNode = new XMLNode_as;
         childNode->nodeNameSet(tagName);
         childNode->nodeTypeSet(Element);
 
@@ -402,7 +411,7 @@
     }
     else {
         // Malformed. Search for the parent node.
-        XMLNode* s = node;
+        XMLNode_as* s = node;
         while (s && !noCaseCompare(s->nodeName(), tagName)) {
             //log_debug("parent: %s, this: %s", s->nodeName(), tagName);
             s = s->getParent();
@@ -420,7 +429,7 @@
 }
 
 void
-XML_as::parseText(XMLNode* node, const std::string& xml, 
+XML_as::parseText(XMLNode_as* node, const std::string& xml, 
         std::string::const_iterator& it)
 {
     std::string::const_iterator end = std::find(it, xml.end(), '<');
@@ -431,9 +440,9 @@
     if (ignoreWhite() && 
         content.find_first_not_of("\t\r\n ") == std::string::npos) return;
 
-    XMLNode* childNode = new XMLNode;
+    XMLNode_as* childNode = new XMLNode_as;
 
-    childNode->nodeTypeSet(XMLNode::Text);
+    childNode->nodeTypeSet(XMLNode_as::Text);
 
     // Replace any entitites.
     unescape(content);
@@ -447,7 +456,7 @@
 
 
 void
-XML_as::parseComment(XMLNode* /*node*/, const std::string& xml, 
+XML_as::parseComment(XMLNode_as* /*node*/, const std::string& xml, 
         std::string::const_iterator& it)
 {
     log_debug("discarding comment node");
@@ -463,7 +472,7 @@
 }
 
 void
-XML_as::parseCData(XMLNode* node, const std::string& xml, 
+XML_as::parseCData(XMLNode_as* node, const std::string& xml, 
         std::string::const_iterator& it)
 {
     std::string content;
@@ -473,7 +482,7 @@
         return;
     }
 
-    XMLNode* childNode = new XMLNode;
+    XMLNode_as* childNode = new XMLNode_as;
     childNode->nodeValueSet(content);
     childNode->nodeTypeSet(Text);
     node->appendChild(childNode);
@@ -498,7 +507,7 @@
     
 
     std::string::const_iterator it = xml.begin();
-    XMLNode* node = this;
+    XMLNode_as* node = this;
 
     while (it != xml.end() && _status == XML_OK)
     {
@@ -691,9 +700,9 @@
     if (fn.nargs > 0)
     {
         const std::string& text = fn.arg(0).to_string();
-        XMLNode *xml_obj = new XMLNode;
+        XMLNode_as *xml_obj = new XMLNode_as;
         xml_obj->nodeNameSet(text);
-        xml_obj->nodeTypeSet(XMLNode::Text);
+        xml_obj->nodeTypeSet(XMLNode_as::Text);
 
         return as_value(xml_obj);
         
@@ -719,9 +728,9 @@
 
     if (fn.nargs > 0) {
         const std::string& text = fn.arg(0).to_string();
-        XMLNode* xml_obj = new XMLNode;
+        XMLNode_as* xml_obj = new XMLNode_as;
         xml_obj->nodeValueSet(text);
-        xml_obj->nodeTypeSet(XMLNode::Text);
+        xml_obj->nodeTypeSet(XMLNode_as::Text);
         return as_value(xml_obj);
     }
     else {

=== modified file 'libcore/asobj/XML_as.h'
--- a/libcore/asobj/XML_as.h    2008-11-18 14:30:05 +0000
+++ b/libcore/asobj/XML_as.h    2008-11-19 08:41:47 +0000
@@ -36,7 +36,7 @@
 class LoaderThread;
 
 /// XML class and ActionScript object
-class XML_as : public XMLNode, public LoadableObject
+class XML_as : public XMLNode_as, public LoadableObject
 {
 public:
 
@@ -109,25 +109,25 @@
     ///
     void parseXML(const std::string& xml);
 
-    void parseTag(XMLNode*& node, const std::string& xml, 
+    void parseTag(XMLNode_as*& node, const std::string& xml, 
             std::string::const_iterator& it);
 
-    void parseAttribute(XMLNode* node, const std::string& xml, 
+    void parseAttribute(XMLNode_as* node, const std::string& xml, 
             std::string::const_iterator& it);
 
     void parseDocTypeDecl(const std::string& xml, 
             std::string::const_iterator& it);
 
-    void parseText(XMLNode* node, const std::string& xml, 
+    void parseText(XMLNode_as* node, const std::string& xml, 
             std::string::const_iterator& it);
 
     void parseXMLDecl(const std::string& xml, 
             std::string::const_iterator& it);
 
-    void parseComment(XMLNode* node, const std::string& xml, 
+    void parseComment(XMLNode_as* node, const std::string& xml, 
             std::string::const_iterator& it);
 
-    void parseCData(XMLNode* node, const std::string& xml, 
+    void parseCData(XMLNode_as* node, const std::string& xml, 
             std::string::const_iterator& it);
  
     // An event handler that returns a what?
@@ -143,9 +143,9 @@
     /// Note this is not the same as a URL unescape.
     static void unescape(std::string& text);
 
-    XMLNode* createElement(const std::string& name);
+    XMLNode_as* createElement(const std::string& name);
 
-    XMLNode* createTextNode(const std::string& name);
+    XMLNode_as* createTextNode(const std::string& name);
 
 private:
 

=== modified file 'testsuite/actionscript.all/XMLNode.as'
--- a/testsuite/actionscript.all/XMLNode.as     2008-08-25 10:16:16 +0000
+++ b/testsuite/actionscript.all/XMLNode.as     2008-11-19 08:41:47 +0000
@@ -193,5 +193,131 @@
 //     trace(aNode);
 // }
 
-
-check_totals(78);
+// Standard namespace
+x = new XML('<tag xmlns="standard" att="u"></tag>');
+ns = x.firstChild;
+check_equals(ns.nodeName, "tag");
+check_equals(ns.attributes["att"], "u");
+check_equals(ns.attributes["xmlns"], "standard");
+check_equals(ns.namespaceURI, "standard");
+check_equals(ns.getNamespaceForPrefix(), undefined);
+xcheck_equals(ns.getNamespaceForPrefix(""), "standard");
+xcheck_equals(ns.getPrefixForNamespace("standard"), "");
+
+ns.attributes["xmlns"] = "standard2";
+check_equals(ns.namespaceURI, "standard");
+xcheck_equals(ns.getNamespaceForPrefix(""), "standard2");
+
+x = new XML('<tag xmlns:t="standard"></tag>');
+ns = x.firstChild;
+check_equals(ns.namespaceURI, "");
+check_equals(ns.getNamespaceForPrefix(), undefined);
+xcheck_equals(ns.getNamespaceForPrefix("t"), "standard");
+xcheck_equals(ns.getPrefixForNamespace("standard"), "t");
+
+x = new XML('<tag xmlns:t="nst"><tag2 xmlns="nss"><tag3 
xmlns:r="nsr"></tag3></tag2></tag>');
+
+n = x.firstChild;
+check_equals(n.nodeName, "tag");
+check_equals(n.namespaceURI, "");
+check_equals(n.getNamespaceForPrefix("r"), undefined);
+check_equals(n.getPrefixForNamespace("nsr"), undefined);
+check_equals(n.getNamespaceForPrefix(), undefined);
+xcheck_equals(n.getNamespaceForPrefix("t"), "nst");
+xcheck_equals(n.getPrefixForNamespace("nst"), "t");
+
+n = n.firstChild;
+check_equals(n.nodeName, "tag2");
+check_equals(n.namespaceURI, "nss");
+check_equals(n.getNamespaceForPrefix(), undefined);
+check_equals(n.getNamespaceForPrefix("r"), undefined);
+check_equals(n.getPrefixForNamespace("nsr"), undefined);
+xcheck_equals(n.getNamespaceForPrefix("t"), "nst");
+xcheck_equals(n.getPrefixForNamespace("nst"), "t");
+
+n = n.firstChild;
+check_equals(n.nodeName, "tag3");
+xcheck_equals(n.namespaceURI, "nss");
+check_equals(n.getNamespaceForPrefix(), undefined);
+xcheck_equals(n.getNamespaceForPrefix("r"), "nsr");
+xcheck_equals(n.getPrefixForNamespace("nsr"), "r");
+xcheck_equals(n.getNamespaceForPrefix("t"), "nst");
+xcheck_equals(n.getPrefixForNamespace("nst"), "t");
+
+// Multiple definition of standard namespace (first one counts, second never
+// defined).
+x = new XML('<tag xmlns="standard" xmlns="standard2"></tag>');
+ns = x.firstChild;
+check_equals(ns.nodeName, "tag");
+check_equals(ns.attributes["xmlns"], "standard");
+check_equals(ns.namespaceURI, "standard");
+xcheck_equals(ns.getNamespaceForPrefix(""), "standard");
+xcheck_equals(ns.getPrefixForNamespace("standard"), "");
+check_equals(ns.getPrefixForNamespace("standard2"), undefined);
+
+// Multiple definition of prefix during parsing (first one counts,
+// second never defined). Can be changed later using attributes.
+x = new XML('<tag xmlns:n1="ns1" xmlns:n1="ns2"></tag>');
+ns = x.firstChild;
+check_equals(ns.nodeName, "tag");
+check_equals(ns.attributes["xmlns"], undefined);
+xcheck_equals(ns.attributes["xmlns:n1"], "ns1");
+check_equals(ns.namespaceURI, "");
+xcheck_equals(ns.getNamespaceForPrefix("n1"), "ns1");
+xcheck_equals(ns.getPrefixForNamespace("ns1"), "n1");
+check_equals(ns.getPrefixForNamespace("ns2"), undefined);
+
+ns.attributes["xmlns:n1"] = "ns2";
+check_equals(ns.attributes["xmlns:n1"], "ns2");
+xcheck_equals(ns.getNamespaceForPrefix("n1"), "ns2");
+check_equals(ns.getPrefixForNamespace("ns1"), undefined);
+xcheck_equals(ns.getPrefixForNamespace("ns2"), "n1");
+
+// Setting via attributes
+x = new XML('<tag></tag>');
+ns = x.firstChild;
+check_equals(ns.nodeName, "tag");
+check_equals(ns.attributes["xmlns"], undefined);
+check_equals(ns.namespaceURI, "");
+ns.attributes["xmlns"] = "nss";
+xcheck_equals(ns.attributes["xmlns"], "nss");
+check_equals(ns.namespaceURI, "");
+
+/// Prefix, localName
+x = new XML('<fr:tag/>');
+ns = x.firstChild;
+check_equals(ns.nodeName, "fr:tag");
+check_equals(ns.localName, "tag");
+check_equals(ns.prefix, "fr");
+
+x = new XML('<fr:pr:tag/>');
+ns = x.firstChild;
+check_equals(ns.nodeName, "fr:pr:tag");
+check_equals(ns.localName, "pr:tag");
+check_equals(ns.prefix, "fr");
+
+x = new XML('<:fr:tag/>');
+ns = x.firstChild;
+check_equals(ns.nodeName, ":fr:tag");
+check_equals(ns.localName, "fr:tag");
+check_equals(ns.prefix, "");
+
+x = new XML('<:tag/>');
+ns = x.firstChild;
+check_equals(ns.nodeName, ":tag");
+check_equals(ns.localName, "tag");
+check_equals(ns.prefix, "");
+
+x = new XML('<tag:/>');
+ns = x.firstChild;
+check_equals(ns.nodeName, "tag:");
+check_equals(ns.localName, "tag:");
+check_equals(ns.prefix, "");
+
+x = new XML('<tag/>');
+ns = x.firstChild;
+check_equals(ns.nodeName, "tag");
+check_equals(ns.localName, "tag");
+check_equals(ns.prefix, "");
+
+check_totals(152);


reply via email to

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