[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: |
Tue, 03 Apr 2007 13:22:24 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/04/03 13:22:24
Modified files:
. : ChangeLog
server/asobj : xml.cpp xmlattrs.cpp xmlattrs.h xmlnode.cpp
xmlnode.h
testsuite/actionscript.all: XML.as
testsuite/media: gnash.xml
Log message:
* server/asobj/xmlattrs.{cpp,h}: use std::string
for name and value, access trough members, initialize
trought contructor.
* server/asobj/xmlnode.{cpp,h}: keep XMLAttr by value,
not by pointer; implement the 'attributes' getter.
* server/asobj/xml.cpp: update XMLAttr uses.
* testsuite/actionscript.all/XML.as: more tests, less failures.
* testsuite/media/gnash.xml: add a tag attribute.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2760&r2=1.2761
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.cpp?cvsroot=gnash&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlattrs.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlattrs.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlnode.cpp?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlnode.h?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/XML.as?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/media/gnash.xml?cvsroot=gnash&r1=1.1&r2=1.2
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2760
retrieving revision 1.2761
diff -u -b -r1.2760 -r1.2761
--- ChangeLog 3 Apr 2007 12:34:43 -0000 1.2760
+++ ChangeLog 3 Apr 2007 13:22:23 -0000 1.2761
@@ -1,5 +1,16 @@
2007-04-03 Sandro Santilli <address@hidden>
+ * server/asobj/xmlattrs.{cpp,h}: use std::string
+ for name and value, access trough members, initialize
+ trought contructor.
+ * server/asobj/xmlnode.{cpp,h}: keep XMLAttr by value,
+ not by pointer; implement the 'attributes' getter.
+ * server/asobj/xml.cpp: update XMLAttr uses.
+ * testsuite/actionscript.all/XML.as: more tests, less failures.
+ * testsuite/media/gnash.xml: add a tag attribute.
+
+2007-04-03 Sandro Santilli <address@hidden>
+
* server/asobj/xml.{cpp,h}: have XML be a subclass
of XMLNode. Many cleanups.
* server/asobj/xmlnode.{cpp,h}: many cleanups.
Index: server/asobj/xml.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xml.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- server/asobj/xml.cpp 3 Apr 2007 12:34:43 -0000 1.27
+++ server/asobj/xml.cpp 3 Apr 2007 13:22:23 -0000 1.28
@@ -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.27 2007/04/03 12:34:43 strk Exp $ */
+/* $Id: xml.cpp,v 1.28 2007/04/03 13:22:23 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -209,15 +209,21 @@
{
//log_msg("extractNode %s has property %s, value is %s\n",
// node->name, attr->name, attr->children->content);
- XMLAttr *attrib = new XMLAttr;
+ XMLAttr attrib(reinterpret_cast<const char*>(attr->name),
+ reinterpret_cast<const char*>(attr->children->content));
+
+#if 0
len = memadjust(strlen(reinterpret_cast<const char *>(attr->name))+1);
attrib->_name = (char *)new char[len];
memset(attrib->_name, 0, len);
strcpy(attrib->_name, reinterpret_cast<const char *>(attr->name));
+
len = memadjust(strlen(reinterpret_cast<const char
*>(attr->children->content))+1);
attrib->_value = (char *)new char[len];
memset(attrib->_value, 0, len);
strcpy(attrib->_value, reinterpret_cast<const char
*>(attr->children->content));
+#endif
+
//log_msg("\tPushing attribute %s for element %s has value %s\n",
// attr->name, node->name, attr->children->content);
element._attributes.push_back(attrib);
Index: server/asobj/xmlattrs.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlattrs.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/asobj/xmlattrs.cpp 9 Jan 2007 15:14:20 -0000 1.2
+++ server/asobj/xmlattrs.cpp 3 Apr 2007 13:22:23 -0000 1.3
@@ -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: xmlattrs.cpp,v 1.2 2007/01/09 15:14:20 rsavoye Exp $ */
+/* $Id: xmlattrs.cpp,v 1.3 2007/04/03 13:22:23 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -49,28 +49,6 @@
//std::vector<as_object *> _xmlobjs; // FIXME: hack alert
-XMLAttr::XMLAttr()
-{
-#ifdef DEBUG_MEMORY_ALLOCATION
- log_msg("\t\tCreating XMLAttr data at %p \n", this);
-#endif
- _name = 0;
- _value = 0;
-}
-
-XMLAttr::~XMLAttr()
-{
-#ifdef DEBUG_MEMORY_ALLOCATION
- log_msg("\t\tDeleting XMLAttr data %s at %p \n", this->_name, this);
-#endif
- //log_msg("%s: %p \n", __FUNCTION__, this);
- if (_name) {
- delete _name;
- }
- if (_value) {
- delete _value;
- }
-}
} // end of gnash namespace
Index: server/asobj/xmlattrs.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlattrs.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/asobj/xmlattrs.h 9 Jan 2007 15:14:20 -0000 1.2
+++ server/asobj/xmlattrs.h 3 Apr 2007 13:22:24 -0000 1.3
@@ -47,28 +47,39 @@
/// XML Attribute class
class DSOLOCAL XMLAttr {
public:
- XMLAttr();
- ~XMLAttr();
- // why don't we use std::strings here ?
- // code would be much simpler and safer!
- char *_name;
- char *_value;
- xmlAttributeType _type;
-
- XMLAttr *operator = (XMLAttr node) {
- log_msg("\t\tCopying XMLAttr object at %p\n", (void*)this);
+ XMLAttr()
+ {}
- _name = new char[strlen(node._name)+2];
- memset(_name, 0, strlen(node._name)+2);
- strcpy(_name, node._name);
-
- _value = new char[strlen(node._value)+2];
- memset(_value, 0, strlen(node._value)+2);
- strcpy(_value, node._value);
+ XMLAttr(const std::string& name, const std::string& value)
+ :
+ _name(name),
+ _value(value)
+ {}
+
+ ~XMLAttr()
+ {}
+
+#if 0
+ XMLAttr& operator = (const XMLAttr& node)
+ {
+ _name = node._name;
+ _value = node._value;
- return this;
+ return *this;
}
+#endif
+
+ const std::string& name() const { return _name; }
+
+ const std::string& value() const { return _value; }
+
+private:
+
+ std::string _name;
+ std::string _value;
+ xmlAttributeType _type;
+
};
/// XML Attribute ActionScript Object
Index: server/asobj/xmlnode.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlnode.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/asobj/xmlnode.cpp 3 Apr 2007 12:34:43 -0000 1.20
+++ server/asobj/xmlnode.cpp 3 Apr 2007 13:22:24 -0000 1.21
@@ -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: xmlnode.cpp,v 1.20 2007/04/03 12:34:43 strk Exp $ */
+/* $Id: xmlnode.cpp,v 1.21 2007/04/03 13:22:24 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -138,13 +138,10 @@
}
}
- for (i=0; i<_attributes.size(); i++) {
- if (_attributes[i]->_name) {
- delete [] _attributes[i]->_name;
- }
- if (_attributes[i]->_value) {
- delete [] _attributes[i]->_value;
- }
+ for (i=0; i<_attributes.size(); i++)
+ {
+ // shouldn't we delete attributes here ??
+ // TODO: plug this leak somehow !!
}
_children.clear();
@@ -348,13 +345,12 @@
xmlout << "<" << nodename;
// Process the attributes, if any
- vector<XMLAttr *>::const_iterator ita;
+ AttribList::const_iterator ita;
for (ita = xml._attributes.begin(); ita != xml._attributes.end(); ita++)
{
- const XMLAttr *xa = *ita;
-// log_msg("\t\tAdding attribute as member %s, value is %s to node %s",
-// nodename, xa->_name, xa->_value);
- xmlout << " " << xa->_name << "=\"" << xa->_value << "\"";
+ const XMLAttr& xa = *ita;
+ // TODO: replace with XMLAttr::operator<<
+ xmlout << " " << xa.name() << "=\"" << xa.value() << "\"";
}
xmlout << ">"; // closing symbol for this tag
@@ -661,8 +657,19 @@
if ( fn.nargs == 0 )
{
- log_error("FIXME: XMLNode.attributes not implemented yet");
- return as_value();
+ XMLNode::AttribList& attrs = ptr->attributes();
+ boost::intrusive_ptr<as_object> ret = new as_object();
+ for (XMLNode::AttribList::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();
+ ret->init_member(name, val);
+ }
+ //log_error("FIXME: XMLNode.attributes not implemented yet");
+ return as_value(ret);
}
else
{
Index: server/asobj/xmlnode.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlnode.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- server/asobj/xmlnode.h 3 Apr 2007 12:34:43 -0000 1.8
+++ server/asobj/xmlnode.h 3 Apr 2007 13:22:24 -0000 1.9
@@ -90,8 +90,7 @@
typedef std::vector< boost::intrusive_ptr<XMLNode> > ChildList;
- // Change this !! We want a managed thing, maybe also shared ?
- typedef std::vector< XMLAttr* > AttribList;
+ typedef std::vector< XMLAttr > AttribList;
ChildList& childNodes() { return _children; }
Index: testsuite/actionscript.all/XML.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/XML.as,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- testsuite/actionscript.all/XML.as 3 Apr 2007 12:34:43 -0000 1.19
+++ testsuite/actionscript.all/XML.as 3 Apr 2007 13:22:24 -0000 1.20
@@ -20,7 +20,7 @@
// compile this test case with Ming makeswf, and then
// execute it like this gnash -1 -r 0 -v out.swf
-rcsid="$Id: XML.as,v 1.19 2007/04/03 12:34:43 strk Exp $";
+rcsid="$Id: XML.as,v 1.20 2007/04/03 13:22:24 strk Exp $";
#include "dejagnu.as"
#include "utils.as"
@@ -373,9 +373,16 @@
note("gnash.xml successfully loaded");
note("myxml status is "+myxml.status);
note("myxml.toString(): "+myxml.toString());
- xcheck_equals(typeof(myxml.attributes), 'object');
+ check_equals(typeof(myxml.attributes), 'object');
+ xcheck(! myxml.attributes instanceof Object);
+ xcheck_equals(typeof(myxml.attributes.__proto__), 'undefined');
+
check(myxml.hasChildNodes());
check_equals(myxml.nodeName, null);
+
+ topnode = myxml.firstChild;
+ check_equals(topnode.nodeName, 'XML');
+ check_equals(topnode.attributes.attr1, 'attr1 value');
};
myxml.load( MEDIA(gnash.xml) );
Index: testsuite/media/gnash.xml
===================================================================
RCS file: /sources/gnash/gnash/testsuite/media/gnash.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- testsuite/media/gnash.xml 3 Apr 2007 08:05:28 -0000 1.1
+++ testsuite/media/gnash.xml 3 Apr 2007 13:22:24 -0000 1.2
@@ -1,4 +1,4 @@
-<XML>
+<XML attr1="attr1 value">
<elem1>
<elem1_1>
Elem 1.1 content
- [Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso..., Sandro Santilli, 2007/04/03
- [Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso..., Sandro Santilli, 2007/04/03
- [Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso...,
Sandro Santilli <=
- [Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso..., Sandro Santilli, 2007/04/04
- [Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso..., Sandro Santilli, 2007/04/04
- [Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso..., Sandro Santilli, 2007/04/04
- [Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso..., Sandro Santilli, 2007/04/04
- [Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso..., Sandro Santilli, 2007/04/04
- [Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso..., Sandro Santilli, 2007/04/07