[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/asobj/Global.cpp server/...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/asobj/Global.cpp server/... |
Date: |
Thu, 18 Jan 2007 13:43:06 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/01/18 13:43:06
Modified files:
. : ChangeLog
server/asobj : Global.cpp xml.cpp xmlnode.cpp xmlnode.h
testsuite/actionscript.all: XML.as
Log message:
* server/asobj/: Global.cpp, xml.cpp, xmlnode.{cpp,h}:
Port XMLNode class to current correct architecture.
* testsuite/actionscript.all/XML.as: unexpected pass ;)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2130&r2=1.2131
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?cvsroot=gnash&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.cpp?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlnode.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlnode.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/XML.as?cvsroot=gnash&r1=1.13&r2=1.14
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2130
retrieving revision 1.2131
diff -u -b -r1.2130 -r1.2131
--- ChangeLog 18 Jan 2007 11:53:36 -0000 1.2130
+++ ChangeLog 18 Jan 2007 13:43:06 -0000 1.2131
@@ -1,3 +1,9 @@
+2007-01-18 Sandro Santilli <address@hidden>
+
+ * server/asobj/: Global.cpp, xml.cpp, xmlnode.{cpp,h}:
+ Port XMLNode class to current correct architecture.
+ * testsuite/actionscript.all/XML.as: unexpected pass ;)
+
2007-01-18 Tomas Groth Christensen <address@hidden>
* backend/sound_handler_sdl.cpp: Fixed a bug for 8=>16 bit conversion.
Index: server/asobj/Global.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Global.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- server/asobj/Global.cpp 11 Jan 2007 13:29:32 -0000 1.30
+++ server/asobj/Global.cpp 18 Jan 2007 13:43:06 -0000 1.31
@@ -18,7 +18,7 @@
// Implementation of the Global ActionScript Object
-/* $Id: Global.cpp,v 1.30 2007/01/11 13:29:32 strk Exp $ */
+/* $Id: Global.cpp,v 1.31 2007/01/18 13:43:06 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -457,7 +457,7 @@
selection_class_init(*this); // Selection
set_member("Sound", as_value(sound_new));
set_member("XML", as_value(xml_new));
- set_member("XMLNode", as_value(xmlnode_new));
+ xmlnode_class_init(*this);
set_member("XMLSocket", as_value(xmlsocket_new));
set_member("Date", as_value(date_new));
mouse_class_init(*this);
Index: server/asobj/xml.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xml.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- server/asobj/xml.cpp 17 Jan 2007 23:06:24 -0000 1.5
+++ server/asobj/xml.cpp 18 Jan 2007 13:43:06 -0000 1.6
@@ -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.5 2007/01/17 23:06:24 strk Exp $ */
+/* $Id: xml.cpp,v 1.6 2007/01/18 13:43:06 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1149,9 +1149,6 @@
if (fn.nargs > 0) {
bool deep = fn.arg(0).to_bool();
xml_obj = new xmlnode_as_object;
- xml_obj->set_member("nodeName", as_value().set_null());
- xml_obj->set_member("nodeValue", as_value());
- xml_obj->set_member("appendChild", &xmlnode_appendchild);
ptr->obj.cloneNode(xml_obj->obj, deep);
fn.result->set_as_object(xml_obj);
} else {
@@ -1170,10 +1167,7 @@
if (fn.nargs > 0) {
text = fn.arg(0).to_string();
xml_obj = new xmlnode_as_object;
- xml_obj->set_member("nodeName", as_value(text));
- xml_obj->set_member("nodeValue", as_value());
- xml_obj->set_member("appendChild", &xmlnode_appendchild);
-// xml_obj->obj.nodeNameSet((char *)text);
+ xml_obj->obj.nodeNameSet((char *)text);
xml_obj->obj._type = XML_ELEMENT_NODE;
fn.result->set_as_object(xml_obj);
} else {
@@ -1184,19 +1178,19 @@
void xml_createtextnode(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);
+ 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);
+
xmlnode_as_object *xml_obj;
const char *text;
- if (fn.nargs > 0) {
+ if (fn.nargs > 0)
+ {
text = fn.arg(0).to_string();
xml_obj = new xmlnode_as_object;
- xml_obj->set_member("nodeName", as_value().set_null());
- xml_obj->set_member("nodeValue", as_value(text));
- xml_obj->set_member("appendChild", &xmlnode_appendchild);
-// xml_obj->obj.nodeValueSet((char *)text);
+ xml_obj->obj.nodeValueSet(text);
xml_obj->obj._type = XML_TEXT_NODE;
fn.result->set_as_object(xml_obj);
// log_msg("%s: xml obj is %p\n", __PRETTY_FUNCTION__, xml_obj);
Index: server/asobj/xmlnode.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlnode.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/asobj/xmlnode.cpp 9 Jan 2007 15:14:20 -0000 1.2
+++ server/asobj/xmlnode.cpp 18 Jan 2007 13:43:06 -0000 1.3
@@ -18,7 +18,7 @@
//
//
-/* $Id: xmlnode.cpp,v 1.2 2007/01/09 15:14:20 rsavoye Exp $ */
+/* $Id: xmlnode.cpp,v 1.3 2007/01/18 13:43:06 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -29,6 +29,7 @@
#include <vector>
#include "tu_config.h"
#include "fn_call.h"
+#include "builtin_function.h"
//#define DEBUG_MEMORY_ALLOCATION 1
@@ -48,6 +49,21 @@
namespace gnash {
+static void xmlnode_new(const fn_call& fn);
+static void xmlnode_haschildren(const fn_call& fn);
+static void xmlnode_nodename(const fn_call& fn);
+static void xmlnode_nodevalue(const fn_call& fn);
+static void xmlnode_nodetype(const fn_call& fn);
+static void xmlnode_appendchild(const fn_call& fn);
+static void xmlnode_clonenode(const fn_call& fn);
+static void xmlnode_haschildnodes(const fn_call& fn);
+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 do_nothing(const fn_call& fn);
+static void xmlnode_nodevalue(const fn_call& fn);
+static void xmlnode_nodename(const fn_call& fn);
+
//std::vector<as_object *> _xmlobjs; // FIXME: hack alert
XMLNode::XMLNode() :_name(0), _value(0), _type(XML_ELEMENT_NODE)
@@ -99,26 +115,27 @@
}
void
-XMLNode::nodeNameSet(char *name)
+XMLNode::nodeNameSet(const char *name)
{
int len = strlen(name) + 1;
if (!_name) {
_name = (char *)new char[len];
memset(_name, 0, len);
- strcpy(_name, reinterpret_cast<const char *>(name));
+ strcpy(_name, name);
}
}
void
-XMLNode::nodeValueSet(char *value)
+XMLNode::nodeValueSet(const char *value)
{
int len = strlen(value) + 1;
if (!_value) {
- _value = (char *)new char[len];
+ //_value = (char *)new char[len];
+ _value = new char[len];
memset(_value, 0, len);
- strcpy(_value, reinterpret_cast<const char *>(value));
+ strcpy(_value, value);
}
}
@@ -153,7 +170,7 @@
if (_name) {
return _name;
}
- return "unknown";
+ return NULL;
}
const char *
@@ -162,7 +179,7 @@
if (_value) {
return _value;
}
- return "unknown";
+ return NULL;
}
/// \brief append a node the the XMLNode object
@@ -279,33 +296,33 @@
}
void
-xmlnode_new(const fn_call& fn)
+attachXMLNodeInterface(as_object& o)
{
- xmlnode_as_object *xml_obj;
- //const char *data;
+ o.set_member("appendChild", &xmlnode_appendchild);
+ o.set_member("cloneNode", &xmlnode_clonenode);
+ o.set_member("hasChildNodes", &xmlnode_haschildnodes);
+ o.set_member("insertBefore", &xmlnode_insertbefore);
+ o.set_member("removeNode", &xmlnode_removenode);
+ o.set_member("toString", &xmlnode_tostring);
-// log_msg("%s\n", __PRETTY_FUNCTION__);
+ // Properties - FIXME: use addProperty !
- xml_obj = new xmlnode_as_object;
- // Methods
- xml_obj->set_member("appendChild", &xmlnode_appendchild);
- xml_obj->set_member("cloneNode", &xmlnode_clonenode);
- xml_obj->set_member("hasChildNodes", &xmlnode_haschildnodes);
- xml_obj->set_member("insertBefore", &xmlnode_insertbefore);
- xml_obj->set_member("removeNode", &xmlnode_removenode);
- xml_obj->set_member("toString", &xmlnode_tostring);
-
- // Properties
- xml_obj->set_member("nodeName", as_value(""));
- xml_obj->set_member("nodeValue", as_value(""));
- xml_obj->set_member("nodeType", as_value(""));
+ boost::intrusive_ptr<builtin_function> getter;
+ boost::intrusive_ptr<builtin_function> setter;
- // FIXME: these need real values
- // These two return an array of objects
- xml_obj->set_member("attributes", as_value(""));
- xml_obj->set_member("childNodes", as_value(""));
+ 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);
- //These return a reference to an object
+ o.set_member("nodeType", as_value(""));
+
+ // These two return an array of objects
+ o.set_member("attributes", as_value(""));
+ o.set_member("childNodes", as_value(""));
/// \fn MLNode::firstChild
/// \brief XMLNode::firstChild property
@@ -317,8 +334,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(""));
- xml_obj->set_member("firstChild", as_value(""));
/// \fn MLNode::lastChild
/// \brief XMLNode::lastChild property
///
@@ -328,15 +345,48 @@
/// be used to manipulate child nodes; use the appendChild(),
/// insertBefore(), and removeNode() methods to manipulate child
/// nodes.
- xml_obj->set_member("lastChild", as_value(""));
- xml_obj->set_member("nextSibling", as_value(""));
- xml_obj->set_member("parentNode", as_value(""));
- xml_obj->set_member("previousSibling", as_value(""));
+ o.set_member("lastChild", as_value(""));
+
+ o.set_member("nextSibling", as_value(""));
+
+ o.set_member("parentNode", as_value(""));
+
+ o.set_member("previousSibling", as_value(""));
+}
+
+static as_object*
+getXMLNodeInterface()
+{
+ static boost::intrusive_ptr<as_object> o;
+ if ( o == NULL )
+ {
+ o = new as_object();
+ attachXMLNodeInterface(*o);
+ }
+ 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;
+ //const char *data;
+
+// log_msg("%s\n", __PRETTY_FUNCTION__);
+
+ xml_obj = new xmlnode_as_object;
fn.result->set_as_object(xml_obj);
}
-void xmlnode_appendchild(const fn_call& fn)
+static void
+xmlnode_appendchild(const fn_call& fn)
{
xmlnode_as_object *ptr = (xmlnode_as_object*)fn.this_ptr;
assert(ptr);
@@ -366,7 +416,8 @@
// ptr->obj.nodeValueSet((char *)xmlnode_obj->obj.nodeValue());
}
-void xmlnode_clonenode(const fn_call& fn)
+static void
+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;
@@ -384,7 +435,8 @@
}
-void xmlnode_insertbefore(const fn_call& fn)
+static void
+xmlnode_insertbefore(const fn_call& fn)
{
xmlnode_as_object *ptr = (xmlnode_as_object*)fn.this_ptr;
assert(ptr);
@@ -393,7 +445,8 @@
// ptr->obj.insertBefore();
log_msg("%s:unimplemented \n", __PRETTY_FUNCTION__);
}
-void xmlnode_removenode(const fn_call& fn)
+static void
+xmlnode_removenode(const fn_call& fn)
{
xmlnode_as_object *ptr = (xmlnode_as_object*)fn.this_ptr;
assert(ptr);
@@ -401,7 +454,8 @@
// fn.result->set_int(ptr->obj.getAllocated());
ptr->obj.removeNode();
}
-void xmlnode_tostring(const fn_call& fn)
+static void
+xmlnode_tostring(const fn_call& fn)
{
xmlnode_as_object *ptr = (xmlnode_as_object*)fn.this_ptr;
assert(ptr);
@@ -409,31 +463,79 @@
fn.result->set_string(ptr->obj.toString());
}
-void xmlnode_haschildnodes(const fn_call& fn)
+static void
+xmlnode_haschildnodes(const fn_call& fn)
{
xmlnode_as_object *ptr = (xmlnode_as_object*)fn.this_ptr;
assert(ptr);
fn.result->set_bool(ptr->obj.hasChildNodes());
}
-#ifdef ENABLE_TESTING
-void xmlnode_nodevalue(const fn_call& fn)
+static void
+do_nothing(const fn_call& fn)
{
- log_msg("%s: \n", __PRETTY_FUNCTION__);
- xmlnode_as_object *ptr = (xmlnode_as_object*)fn.this_ptr;
- assert(ptr);
+ log_msg("Doing nothing");
+}
+
+// Both a getter and a setter for nodeValue
+static void
+xmlnode_nodevalue(const fn_call& fn)
+{
+ GNASH_REPORT_FUNCTION;
- fn.result->set_string(ptr->obj.nodeValue());
+ assert(dynamic_cast<xmlnode_as_object*>(fn.this_ptr));
+ xmlnode_as_object *ptr = static_cast<xmlnode_as_object*>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) {
+ const char* val = ptr->obj.nodeValue();
+ if ( val ) {
+ fn.result->set_string(val);
+ } else {
+ fn.result->set_null();
+ }
+ } else {
+ ptr->obj.nodeValueSet(fn.arg(0).to_string());
+ }
}
-void xmlnode_nodename(const fn_call& fn)
+
+// Both a getter and a setter for nodeName
+static void
+xmlnode_nodename(const fn_call& fn)
{
- log_msg("%s: \n", __PRETTY_FUNCTION__);
- xmlnode_as_object *ptr = (xmlnode_as_object*)fn.this_ptr;
- assert(ptr);
+ assert(dynamic_cast<xmlnode_as_object*>(fn.this_ptr));
+ xmlnode_as_object *ptr = static_cast<xmlnode_as_object*>(fn.this_ptr);
+
+ if ( fn.nargs == 0 ) {
+ const char* val = ptr->obj.nodeName();
+ if ( val ) {
+ fn.result->set_string(val);
+ } else {
+ fn.result->set_null();
+ }
+ } else {
+ ptr->obj.nodeNameSet(fn.arg(0).to_string());
+ }
+}
+
+// extern (used by Global.cpp)
+void xmlnode_class_init(as_object& global)
+{
+ // This is going to be the global XMLNode "class"/"function"
+ static boost::intrusive_ptr<builtin_function> cl;
+
+ if ( cl == NULL )
+ {
+ cl=new builtin_function(&xmlnode_new, getXMLNodeInterface());
+ // replicate all interface to class, to be able to access
+ // all methods as static functions
+ attachXMLNodeInterface(*cl);
+
+ }
+
+ // Register _global.String
+ global.set_member("XMLNode", cl.get());
- fn.result->set_string(ptr->obj.nodeName());
}
-#endif
} // end of gnash namespace
Index: server/asobj/xmlnode.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlnode.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/asobj/xmlnode.h 9 Jan 2007 15:14:20 -0000 1.2
+++ server/asobj/xmlnode.h 18 Jan 2007 13:43:06 -0000 1.3
@@ -58,8 +58,8 @@
// char *valueGet();
- void nodeNameSet(char *name);
- void nodeValueSet(char *value);
+ void nodeNameSet(const char *name);
+ void nodeValueSet(const char *value);
// nodeType XML.nodeType
bool hasChildNodes() {
@@ -124,6 +124,9 @@
{
public:
XMLNode obj;
+
+ xmlnode_as_object();
+
// int _padding;
#ifdef DEBUG_MEMORY_ALLOCATION
@@ -137,19 +140,8 @@
#endif
};
-DSOEXPORT void xmlnode_new(const fn_call& fn);
-
-DSOEXPORT void xmlnode_haschildren(const fn_call& fn);
-DSOEXPORT void xmlnode_nodename(const fn_call& fn);
-DSOEXPORT void xmlnode_nodevalue(const fn_call& fn);
-DSOEXPORT void xmlnode_nodetype(const fn_call& fn);
-
-DSOEXPORT void xmlnode_appendchild(const fn_call& fn);
-DSOEXPORT void xmlnode_clonenode(const fn_call& fn);
-DSOEXPORT void xmlnode_haschildnodes(const fn_call& fn);
-DSOEXPORT void xmlnode_insertbefore(const fn_call& fn);
-DSOEXPORT void xmlnode_removenode(const fn_call& fn);
-DSOEXPORT void xmlnode_tostring(const fn_call& fn);
+// Initialize the global XMLNode class
+void xmlnode_class_init(as_object& global);
} // end of gnash namespace
Index: testsuite/actionscript.all/XML.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/XML.as,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- testsuite/actionscript.all/XML.as 21 Dec 2006 14:12:00 -0000 1.13
+++ testsuite/actionscript.all/XML.as 18 Jan 2007 13:43:06 -0000 1.14
@@ -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: XML.as,v 1.13 2006/12/21 14:12:00 strk Exp $";
+rcsid="$Id: XML.as,v 1.14 2007/01/18 13:43:06 strk Exp $";
#include "dejagnu.as"
#include "utils.as"
@@ -277,7 +277,7 @@
check(getElement.appendChild);
check(textElement);
-xcheck_equals(getElement.hasChildNodes(), false);
+check_equals(getElement.hasChildNodes(), false);
getElement.appendChild(textElement);
if ( getElement.hasChildNodes() ) {