[Top][All Lists]
[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: |
Thu, 18 Jan 2007 15:31:13 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/01/18 15:30:53
Modified files:
. : ChangeLog
server/asobj : xml.cpp xmlnode.cpp xmlnode.h
testsuite/actionscript.all: XMLNode.as
Log message:
* server/asobj/: xml.cpp, xmlnode.{cpp,h}: drop
xmlnode_as_object,
making XMLNode a direct subclass of as_object; Implement or
stub
many properties as actual *properties* (new layout).
* testsuite/actionscript.all/XMLNode.as: other unexpected
successes.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2132&r2=1.2133
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.cpp?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlnode.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlnode.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/XMLNode.as?cvsroot=gnash&r1=1.7&r2=1.8
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2132
retrieving revision 1.2133
diff -u -b -r1.2132 -r1.2133
--- ChangeLog 18 Jan 2007 14:23:17 -0000 1.2132
+++ ChangeLog 18 Jan 2007 15:30:53 -0000 1.2133
@@ -1,5 +1,12 @@
2007-01-18 Sandro Santilli <address@hidden>
+ * server/asobj/: xml.cpp, xmlnode.{cpp,h}: drop xmlnode_as_object,
+ making XMLNode a direct subclass of as_object; Implement or stub
+ many properties as actual *properties* (new layout).
+ * testsuite/actionscript.all/XMLNode.as: other unexpected successes.
+
+2007-01-18 Sandro Santilli <address@hidden>
+
* server/asobj/xmlnode.{cpp,h}: (nodeValueSet): always replace
previous value. (xmlnode_nodevalue, xmlnode_nodename): act
both as a setter and a getter.
Index: server/asobj/xml.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xml.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- server/asobj/xml.cpp 18 Jan 2007 13:43:06 -0000 1.6
+++ server/asobj/xml.cpp 18 Jan 2007 15:30:53 -0000 1.7
@@ -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.6 2007/01/18 13:43:06 strk Exp $ */
+/* $Id: xml.cpp,v 1.7 2007/01/18 15:30:53 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -594,7 +594,7 @@
int length;
as_value inum;
XMLNode *childnode;
- xmlnode_as_object *xmlchildnode_obj;
+ 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);
@@ -652,7 +652,7 @@
inum = 0;
for (child=0; child<length; child++) {
// Create a new AS object for this node's children
- xmlchildnode_obj = new xmlnode_as_object;
+ 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) {
@@ -1134,22 +1134,22 @@
// log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
assert(ptr);
- xmlnode_as_object *xml_obj =
(xmlnode_as_object*)fn.env->top(0).to_object();
+ XMLNode *xml_obj = (XMLNode*)fn.env->top(0).to_object();
- ptr->obj.appendChild(&(xml_obj->obj));
+ ptr->obj.appendChild(xml_obj);
}
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;
- xmlnode_as_object *xml_obj;
+ XMLNode *xml_obj;
assert(ptr);
if (fn.nargs > 0) {
bool deep = fn.arg(0).to_bool();
- xml_obj = new xmlnode_as_object;
- ptr->obj.cloneNode(xml_obj->obj, deep);
+ xml_obj = new XMLNode;
+ ptr->obj.cloneNode(*xml_obj, deep);
fn.result->set_as_object(xml_obj);
} else {
log_msg("ERROR: no Depth paramater!\n");
@@ -1161,14 +1161,14 @@
// log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
assert(ptr);
- xmlnode_as_object *xml_obj;
+ XMLNode *xml_obj;
const char *text;
if (fn.nargs > 0) {
text = fn.arg(0).to_string();
- xml_obj = new xmlnode_as_object;
- xml_obj->obj.nodeNameSet((char *)text);
- xml_obj->obj._type = XML_ELEMENT_NODE;
+ xml_obj = new XMLNode;
+ xml_obj->nodeNameSet(text);
+ xml_obj->nodeTypeSet(XML_ELEMENT_NODE);
fn.result->set_as_object(xml_obj);
} else {
log_msg("ERROR: no text for element creation!\n");
@@ -1180,18 +1180,18 @@
{
log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
- assert(dynamic_cast<xml_as_object*>(fn.this_ptr));
- xml_as_object *ptr = static_cast<xml_as_object*>(fn.this_ptr);
+ //assert(dynamic_cast<xml_as_object*>(fn.this_ptr));
+ //xml_as_object *ptr = static_cast<xml_as_object*>(fn.this_ptr);
- xmlnode_as_object *xml_obj;
+ XMLNode *xml_obj;
const char *text;
if (fn.nargs > 0)
{
text = fn.arg(0).to_string();
- xml_obj = new xmlnode_as_object;
- xml_obj->obj.nodeValueSet(text);
- xml_obj->obj._type = XML_TEXT_NODE;
+ xml_obj = new XMLNode;
+ xml_obj->nodeValueSet(text);
+ xml_obj->nodeTypeSet(XML_TEXT_NODE);
fn.result->set_as_object(xml_obj);
// log_msg("%s: xml obj is %p\n", __PRETTY_FUNCTION__, xml_obj);
} else {
Index: server/asobj/xmlnode.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlnode.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/xmlnode.cpp 18 Jan 2007 14:23:17 -0000 1.4
+++ server/asobj/xmlnode.cpp 18 Jan 2007 15:30:53 -0000 1.5
@@ -18,7 +18,7 @@
//
//
-/* $Id: xmlnode.cpp,v 1.4 2007/01/18 14:23:17 strk Exp $ */
+/* $Id: xmlnode.cpp,v 1.5 2007/01/18 15:30:53 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -60,12 +60,22 @@
static void xmlnode_insertbefore(const fn_call& fn);
static void xmlnode_removenode(const fn_call& fn);
static void xmlnode_tostring(const fn_call& fn);
-static void xmlnode_nodevalue(const fn_call& fn);
static void xmlnode_nodename(const fn_call& fn);
+static void xmlnode_firstchild(const fn_call& fn);
+static void xmlnode_lastchild(const fn_call& fn);
+static void xmlnode_nextsibling(const fn_call& fn);
+static void xmlnode_previoussibling(const fn_call& fn);
+static as_object* getXMLNodeInterface();
+
//std::vector<as_object *> _xmlobjs; // FIXME: hack alert
-XMLNode::XMLNode() :_name(0), _value(0), _type(XML_ELEMENT_NODE)
+XMLNode::XMLNode()
+ :
+ as_object(getXMLNodeInterface()),
+ _name(0),
+ _value(0),
+ _type(XML_ELEMENT_NODE)
{
//log_msg("%s: %p \n", __PRETTY_FUNCTION__, this);
#ifdef DEBUG_MEMORY_ALLOCATION
@@ -191,20 +201,24 @@
/// already exists in another XMLNode tree structure, the appended child
/// node is placed in the new tree structure after it is removed from
/// its existing parent node.
+///
+/// @param as
+/// The XMLNode ?
+///
+/// @param node
+/// same as XMLNode::obj ?
+///
void
-XMLNode::appendChild(as_object *as, XMLNode *node)
+XMLNode::appendChild(XMLNode *node)
{
// log_msg("%s: %p, as is %d, node is %d\n",
-// __PRETTY_FUNCTION__, this, _objects.size(), _children.size());
+// __PRETTY_FUNCTION__, this, _children.size(), _children.size());
+//
if (node) {
_children.push_back(node);
}
- if (as) {
- _objects.push_back(as);
- }
-
// log_msg("%s: partially unimplemented\n", __PRETTY_FUNCTION__);
}
@@ -271,24 +285,24 @@
return "Hello World!";
}
-as_object *
+XMLNode *
XMLNode::previousSibling(int x)
{
log_msg("%s: partially implemented. " SIZET_FMT " objects\n",
- __PRETTY_FUNCTION__, _objects.size());
- if (_objects.size() > 0) {
- return _objects[x-1];
+ __PRETTY_FUNCTION__, _children.size());
+ if (_children.size() > 0) {
+ return _children[x-1];
}
return NULL;
}
-as_object *
+XMLNode *
XMLNode::nextSibling(int x)
{
log_msg("%s: unimplemented \n", __PRETTY_FUNCTION__);
- if (x < (int) _objects.size()) {
- return _objects[x];
+ if (x < (int) _children.size()) {
+ return _children[x];
}
return NULL;
}
@@ -305,18 +319,16 @@
// Properties - FIXME: use addProperty !
- boost::intrusive_ptr<builtin_function> getter;
- boost::intrusive_ptr<builtin_function> setter;
+ boost::intrusive_ptr<builtin_function> gettersetter;
- getter = new builtin_function(&xmlnode_nodevalue, NULL);
- setter = new builtin_function(&xmlnode_nodevalue, NULL);
- o.add_property("nodeValue", *getter, *setter);
-
- getter = new builtin_function(&xmlnode_nodename, NULL);
- setter = new builtin_function(&xmlnode_nodename, NULL);
- o.add_property("nodeName", *getter, *setter);
+ gettersetter = new builtin_function(&xmlnode_nodevalue, NULL);
+ o.add_property("nodeValue", *gettersetter, *gettersetter);
- o.set_member("nodeType", as_value(""));
+ gettersetter = new builtin_function(&xmlnode_nodename, NULL);
+ o.add_property("nodeName", *gettersetter, *gettersetter);
+
+ gettersetter = new builtin_function(&xmlnode_nodetype, NULL);
+ o.add_property("nodeType", *gettersetter, *gettersetter);
// These two return an array of objects
o.set_member("attributes", as_value(""));
@@ -332,7 +344,8 @@
/// node. This is a read-only property and cannot be used to
/// manipulate child nodes; use the appendChild(), insertBefore(),
/// and removeNode() methods to manipulate child nodes.
- o.set_member("firstChild", as_value(""));
+ gettersetter = new builtin_function(&xmlnode_firstchild, NULL);
+ o.add_property("firstChild", *gettersetter, *gettersetter);
/// \fn MLNode::lastChild
/// \brief XMLNode::lastChild property
@@ -343,13 +356,17 @@
/// be used to manipulate child nodes; use the appendChild(),
/// insertBefore(), and removeNode() methods to manipulate child
/// nodes.
- o.set_member("lastChild", as_value(""));
+ gettersetter = new builtin_function(&xmlnode_lastchild, NULL);
+ o.add_property("lastChild", *gettersetter, *gettersetter);
+
+ gettersetter = new builtin_function(&xmlnode_nextsibling, NULL);
+ o.add_property("nextSibling", *gettersetter, *gettersetter);
- o.set_member("nextSibling", as_value(""));
+ gettersetter = new builtin_function(&xmlnode_previoussibling, NULL);
+ o.add_property("previousSibling", *gettersetter, *gettersetter);
- o.set_member("parentNode", as_value(""));
+ o.set_member("parentNode", as_value().set_null());
- o.set_member("previousSibling", as_value(""));
}
static as_object*
@@ -364,28 +381,22 @@
return o.get();
}
-xmlnode_as_object::xmlnode_as_object()
- :
- as_object(getXMLNodeInterface())
-{
-}
-
static void
xmlnode_new(const fn_call& fn)
{
- xmlnode_as_object *xml_obj;
+ XMLNode *xml_obj;
//const char *data;
// log_msg("%s\n", __PRETTY_FUNCTION__);
- xml_obj = new xmlnode_as_object;
+ xml_obj = new XMLNode;
if ( fn.nargs > 0 )
{
-
xml_obj->obj.nodeTypeSet(static_cast<xmlElementType>(fn.arg(0).to_number()));
+
xml_obj->nodeTypeSet(static_cast<xmlElementType>(fn.arg(0).to_number()));
if ( fn.nargs > 1 )
{
- xml_obj->obj.nodeValueSet(fn.arg(1).to_string());
+ xml_obj->nodeValueSet(fn.arg(1).to_string());
}
}
@@ -395,29 +406,25 @@
static void
xmlnode_appendchild(const fn_call& fn)
{
- xmlnode_as_object *ptr = (xmlnode_as_object*)fn.this_ptr;
+ XMLNode *ptr = (XMLNode*)fn.this_ptr;
assert(ptr);
// log_msg("%s: %p, %d args\n", __PRETTY_FUNCTION__, ptr, fn.nargs);
- xmlnode_as_object *xml_obj =
(xmlnode_as_object*)fn.env->bottom(fn.first_arg_bottom_index).to_object();
+ XMLNode *node = dynamic_cast<XMLNode*>(fn.arg(0).to_object());
// log_msg("%s: %p \n", __PRETTY_FUNCTION__, xml_obj);
- XMLNode *node = &(xml_obj->obj);
- if (ptr->obj.hasChildNodes() == false) {
- ptr->set_member("firstChild", xml_obj);
- }
- int length = ptr->obj.length();
+ int length = ptr->length();
if (length > 0) {
- as_object *ass = xml_obj->obj.previousSibling(length);
+ XMLNode *ass = node->previousSibling(length); // or is it 'ptr' ??
// FIXME: This shouldn't always be NULL
// log_msg("%s: ASS is %p, length is %d\n", __PRETTY_FUNCTION__,
// ass, length);
- ptr->set_member("previousSibling", ass);
+ ptr->set_member("previousSibling", ass); // FIXME: don't do this, rely
on getter/setter
// ptr->set_member("nextSibling",
xml_obj->obj.nextSibling(ptr->obj.length()));
}
- ptr->obj.appendChild((as_object *)xml_obj, node);
+ ptr->appendChild(node);
// The last child in the list is always the one we just appended
- ptr->set_member("lastChild", xml_obj);
+ ptr->set_member("lastChild", node); // FIXME: don't do this, rely on
getter/setter
// ptr->obj.appendChild(&(xml_obj->obj));
// ptr->obj.nodeValueSet((char *)xmlnode_obj->obj.nodeValue());
@@ -427,14 +434,14 @@
xmlnode_clonenode(const fn_call& fn)
{
log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
- xmlnode_as_object *ptr = (xmlnode_as_object*)fn.this_ptr;
- xmlnode_as_object *xmlnode_obj;
+ XMLNode *ptr = (XMLNode*)fn.this_ptr;
+ XMLNode *xmlnode_obj;
assert(ptr);
if (fn.nargs > 0) {
- bool deep = fn.env->bottom(fn.first_arg_bottom_index).to_bool();
- xmlnode_obj = new xmlnode_as_object;
- ptr->obj.cloneNode(xmlnode_obj->obj, deep);
+ bool deep = fn.arg(0).to_bool();
+ xmlnode_obj = new XMLNode;
+ ptr->cloneNode(*xmlnode_obj, deep);
fn.result->set_as_object(xmlnode_obj);
} else {
log_msg("ERROR: no Depth paramater!\n");
@@ -445,7 +452,7 @@
static void
xmlnode_insertbefore(const fn_call& fn)
{
- xmlnode_as_object *ptr = (xmlnode_as_object*)fn.this_ptr;
+ XMLNode *ptr = (XMLNode*)fn.this_ptr;
assert(ptr);
// fn.result->set_int(ptr->obj.getAllocated());
@@ -455,27 +462,29 @@
static void
xmlnode_removenode(const fn_call& fn)
{
- xmlnode_as_object *ptr = (xmlnode_as_object*)fn.this_ptr;
+ XMLNode *ptr = (XMLNode*)fn.this_ptr;
assert(ptr);
// fn.result->set_int(ptr->obj.getAllocated());
- ptr->obj.removeNode();
+ ptr->removeNode();
}
+
+// TODO: shouldn't overriding get_text_value() be fine ?
static void
xmlnode_tostring(const fn_call& fn)
{
- xmlnode_as_object *ptr = (xmlnode_as_object*)fn.this_ptr;
+ XMLNode *ptr = (XMLNode*)fn.this_ptr;
assert(ptr);
- fn.result->set_string(ptr->obj.toString());
+ fn.result->set_string(ptr->toString());
}
static void
xmlnode_haschildnodes(const fn_call& fn)
{
- xmlnode_as_object *ptr = (xmlnode_as_object*)fn.this_ptr;
+ XMLNode *ptr = (XMLNode*)fn.this_ptr;
assert(ptr);
- fn.result->set_bool(ptr->obj.hasChildNodes());
+ fn.result->set_bool(ptr->hasChildNodes());
}
// Both a getter and a setter for nodeValue
@@ -484,13 +493,13 @@
{
//GNASH_REPORT_FUNCTION;
- assert(dynamic_cast<xmlnode_as_object*>(fn.this_ptr));
- xmlnode_as_object *ptr = static_cast<xmlnode_as_object*>(fn.this_ptr);
+ assert(dynamic_cast<XMLNode*>(fn.this_ptr));
+ XMLNode *ptr = static_cast<XMLNode*>(fn.this_ptr);
//log_msg("xmlnode_nodevalue called with %d args against 'this' = %p",
fn.nargs, ptr);
if ( fn.nargs == 0 ) {
- //log_msg(" nodeValue() returns '%s'", ptr->obj.nodeValue());
- const char* val = ptr->obj.nodeValue();
+ //log_msg(" nodeValue() returns '%s'", ptr->nodeValue());
+ const char* val = ptr->nodeValue();
if ( val ) {
fn.result->set_string(val);
} else {
@@ -498,7 +507,7 @@
}
} else {
//log_msg(" arg(0) == '%s'", fn.arg(0).to_string());
- ptr->obj.nodeValueSet(fn.arg(0).to_string());
+ ptr->nodeValueSet(fn.arg(0).to_string());
}
}
@@ -506,18 +515,117 @@
static void
xmlnode_nodename(const fn_call& fn)
{
- assert(dynamic_cast<xmlnode_as_object*>(fn.this_ptr));
- xmlnode_as_object *ptr = static_cast<xmlnode_as_object*>(fn.this_ptr);
+ assert(dynamic_cast<XMLNode*>(fn.this_ptr));
+ XMLNode *ptr = static_cast<XMLNode*>(fn.this_ptr);
if ( fn.nargs == 0 ) {
- const char* val = ptr->obj.nodeName();
+ const char* val = ptr->nodeName();
if ( val ) {
fn.result->set_string(val);
} else {
fn.result->set_null();
}
} else {
- ptr->obj.nodeNameSet(fn.arg(0).to_string());
+ ptr->nodeNameSet(fn.arg(0).to_string());
+ }
+}
+
+// Both a getter and a (do-nothing) setter for nodeType
+static void
+xmlnode_nodetype(const fn_call& fn)
+{
+ assert(dynamic_cast<XMLNode*>(fn.this_ptr));
+ XMLNode *ptr = static_cast<XMLNode*>(fn.this_ptr);
+
+ if ( fn.nargs == 0 )
+ {
+ fn.result->set_double(ptr->nodeType());
+ }
+ else
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("Tried to set read-only property
XMLNode.nodeType");
+ );
+ }
+}
+
+// Both a getter and a (do-nothing) setter for firstChild
+static void
+xmlnode_firstchild(const fn_call& fn)
+{
+ assert(dynamic_cast<XMLNode*>(fn.this_ptr));
+ XMLNode *ptr = static_cast<XMLNode*>(fn.this_ptr);
+
+ if ( fn.nargs == 0 )
+ {
+ fn.result->set_as_object(ptr->firstChild());
+ }
+ else
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("Tried to set read-only property
XMLNode.firstChild");
+ );
+ }
+}
+
+// Both a getter and a (do-nothing) setter for lastChild
+static void
+xmlnode_lastchild(const fn_call& fn)
+{
+ assert(dynamic_cast<XMLNode*>(fn.this_ptr));
+ XMLNode *ptr = static_cast<XMLNode*>(fn.this_ptr);
+
+ if ( fn.nargs == 0 )
+ {
+ fn.result->set_as_object(ptr->lastChild());
+ }
+ else
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("Tried to set read-only property
XMLNode.lastChild");
+ );
+ }
+}
+
+// Both a getter and a (do-nothing) setter for nextSibling
+static void
+xmlnode_nextsibling(const fn_call& fn)
+{
+ assert(dynamic_cast<XMLNode*>(fn.this_ptr));
+ XMLNode *ptr = static_cast<XMLNode*>(fn.this_ptr);
+
+ if ( fn.nargs == 0 )
+ {
+ log_error("FIXME: XMLNode.nextSibling unimplemented");
+ //fn.result->set_as_object(ptr->nextSibling());
+ fn.result->set_null();
+ }
+ else
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("Tried to set read-only property
XMLNode.nextSibling");
+ );
+ }
+}
+
+// Both a getter and a (do-nothing) setter for previousSibling
+static void
+xmlnode_previoussibling(const fn_call& fn)
+{
+ assert(dynamic_cast<XMLNode*>(fn.this_ptr));
+ XMLNode *ptr = static_cast<XMLNode*>(fn.this_ptr);
+
+ if ( fn.nargs == 0 )
+ {
+ log_error("FIXME: XMLNode.previousSibling unimplemented");
+ //fn.result->set_as_object(ptr->previousSibling());
+ fn.result->set_null();
+ }
+ else
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("Tried to set read-only property
XMLNode.previousSibling");
+ );
}
}
Index: server/asobj/xmlnode.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlnode.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/xmlnode.h 18 Jan 2007 14:23:17 -0000 1.4
+++ server/asobj/xmlnode.h 18 Jan 2007 15:30:53 -0000 1.5
@@ -45,7 +45,7 @@
namespace gnash {
/// XML Node
-class DSOLOCAL XMLNode
+class DSOLOCAL XMLNode : public gnash::as_object
{
public:
XMLNode();
@@ -71,16 +71,24 @@
void nodeValueSet(const char *value);
// nodeType XML.nodeType
- bool hasChildNodes() {
- if (_children.size()) {
- return true;
+ bool hasChildNodes()
+ {
+ return ! _children.empty();
}
- return false;
+
+ XMLNode *firstChild()
+ {
+ return _children.empty() ? NULL : _children.front();
}
- XMLNode *firstChild() { return _children[0]; }
+ XMLNode *lastChild()
+ {
+ return _children.empty() ? NULL : _children.back();
+ }
- std::vector<XMLNode *>childNodes() { return _children; }
+ std::vector<XMLNode *>& childNodes() {
+ return _children;
+ }
XMLNode *operator [] (int x) {
gnash::log_msg("%s: get element %d\n", __PRETTY_FUNCTION__, x);
@@ -106,10 +114,11 @@
return this;
}
- as_object *previousSibling(int x);
- as_object *nextSibling(int x);
+ XMLNode* previousSibling(int x);
+ XMLNode* nextSibling(int x);
XMLNode &cloneNode(XMLNode &newnode, bool deep);
- void appendChild(as_object *as,XMLNode *node);
+ void appendChild(XMLNode *node);
+
void insertBefore(XMLNode *newnode, XMLNode *node);
void removeNode();
const char *toString();
@@ -123,30 +132,9 @@
char *_value;
xmlElementType _type;
- std::vector<as_object *> _objects;
std::vector<XMLNode *> _children;
std::vector<XMLAttr *> _attributes;
-};
-
-/// XML Node ActionScript object
-class DSOLOCAL xmlnode_as_object : public gnash::as_object
-{
-public:
- XMLNode obj;
-
- xmlnode_as_object();
-
-// int _padding;
-#ifdef DEBUG_MEMORY_ALLOCATION
- xmlnode_as_object() {
- // obj = new XMLNode;
- log_msg("\tCreating xmlnode_as_object at %p \n", this);
- };
- ~xmlnode_as_object() {
- log_msg("\tDeleting xmlnode_as_object at %p \n", this);
- };
-#endif
};
// Initialize the global XMLNode class
Index: testsuite/actionscript.all/XMLNode.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/XMLNode.as,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- testsuite/actionscript.all/XMLNode.as 18 Jan 2007 14:23:17 -0000
1.7
+++ testsuite/actionscript.all/XMLNode.as 18 Jan 2007 15:30:53 -0000
1.8
@@ -22,7 +22,7 @@
// compile this test case with Ming makeswf, and then
// execute it like this gnash -1 -r 0 -v out.swf
-rcsid="$Id: XMLNode.as,v 1.7 2007/01/18 14:23:17 strk Exp $";
+rcsid="$Id: XMLNode.as,v 1.8 2007/01/18 15:30:53 strk Exp $";
#include "dejagnu.as"
@@ -55,33 +55,33 @@
// The read only properties. These should all return NULL, because
// there are no children.
check_equals(textnode.hasChildNodes(), false);
-xcheck_equals(textnode.firstChild, undefined);
-xcheck_equals(textnode.lastChild, undefined);
-xcheck_equals(textnode.parentNode, undefined);
-xcheck_equals(textnode.nextSibling, undefined);
-xcheck_equals(textnode.previousSibling, undefined);
+check_equals(typeof(textnode.firstChild), 'null');
+check_equals(typeof(textnode.lastChild), 'null');
+check_equals(typeof(textnode.parentNode), 'null');
+check_equals(typeof(textnode.nextSibling), 'null');
+check_equals(typeof(textnode.previousSibling), 'null');
//note("Now test the functionality of the methods");
var childnode1 = new XMLNode(3, "first child");
-xcheck_equals(childnode1.nodeType, 3);
+check_equals(childnode1.nodeType, 3);
textnode.appendChild(childnode1);
check_equals(textnode.hasChildNodes(), true);
check_equals(textnode.firstChild, childnode1);
check_equals(textnode.lastChild, childnode1);
-xcheck_equals(childnode1.nextSibling, undefined);
-xcheck_equals(childnode1.previousSibling, undefined);
+check_equals(childnode1.nextSibling, undefined);
+check_equals(childnode1.previousSibling, undefined);
var nextnode = new XMLNode(3, "second child");
-xcheck_equals(nextnode.nodeType, 3);
+check_equals(nextnode.nodeType, 3);
textnode.appendChild(nextnode);
check_equals(textnode.hasChildNodes(), true);
check_equals(textnode.firstChild, childnode1);
check_equals(textnode.lastChild, nextnode);
xcheck_equals(childnode1.nextSibling, nextnode);
-xcheck_equals(childnode1.previousSibling, undefined);
+check_equals(childnode1.previousSibling, undefined);
xcheck_equals(nextnode.previousSibling, childnode1);
//var out = textnode.toString();
- [Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso...,
Sandro Santilli <=