[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash server/xml.cpp testsuite/actionscript.all...
From: |
Rob Savoye |
Subject: |
[Gnash-commit] gnash server/xml.cpp testsuite/actionscript.all... |
Date: |
Tue, 17 Oct 2006 00:09:53 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Rob Savoye <rsavoye> 06/10/17 00:09:53
Modified files:
server : xml.cpp
testsuite/actionscript.all: XML.as
. : ChangeLog
Added files:
testsuite/actionscript.all: with.as
Log message:
* server/xml.cpp: Fix parseXML so it takes a string, and
properly
sets up the stack with the values parsed from the XML.
* testsuite/actionscript.all/XML.as: Tests pass now, no expected
failures anymore.
* testsuite/actionscript.all/with.as: New test case for making
sure the 'with' Flash keyword works, which currently it doesn't.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/server/xml.cpp?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/XML.as?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/with.as?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1254&r2=1.1255
Patches:
Index: server/xml.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/xml.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- server/xml.cpp 3 Oct 2006 10:44:41 -0000 1.29
+++ server/xml.cpp 17 Oct 2006 00:09:53 -0000 1.30
@@ -36,7 +36,7 @@
//
//
-/* $Id: xml.cpp,v 1.29 2006/10/03 10:44:41 nihilus Exp $ */
+/* $Id: xml.cpp,v 1.30 2006/10/17 00:09:53 rsavoye Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -171,6 +171,8 @@
bool
XML::on_event(event_id /* id */)
{
+ GNASH_REPORT_FUNCTION;
+
// Keep m_as_environment alive during any method calls!
// smart_ptr<as_object_interface> this_ptr(this);
@@ -293,7 +295,8 @@
bool
XML::parseDoc(xmlDocPtr document, bool mem)
{
- log_msg("%s:\n", __PRETTY_FUNCTION__);
+ GNASH_REPORT_FUNCTION;
+
XMLNode *top;
xmlNodePtr cur;
@@ -334,6 +337,8 @@
//dump_memory_stats(__FUNCTION__, __LINE__, "before xmlParseMemory");
#endif
+ _bytes_total = _bytes_loaded = xml_in.size();
+
#ifdef USE_XMLREADER
XMLNode *node = 0;
xmlTextReaderPtr reader;
@@ -518,6 +523,7 @@
bool
XML::load(const char *filespec)
{
+ GNASH_REPORT_FUNCTION;
struct stat stats;
log_msg("Load disk XML file: %s\n", filespec);
@@ -606,6 +612,8 @@
as_object *
XML::setupFrame(as_object *obj, XMLNode *xml, bool mem)
{
+// GNASH_REPORT_FUNCTION;
+
int child;
unsigned int i;
const char *nodename;
@@ -633,7 +641,7 @@
obj->set_member("length", length);
if (xml->_value != 0) {
obj->set_member("nodeValue", xml->_value);
- //log_msg("\tnodevalue for %s is: %s\n", nodename, xml->_value);
+ log_msg("\tnodevalue for %s is: %s\n", nodename, xml->_value);
} else {
obj->set_member("nodeValue", as_value::UNDEFINED);
}
@@ -656,9 +664,9 @@
attr_obj = new xmlattr_as_object;
for (i=0; i<xml->_attributes.size(); i++) {
attr_obj->set_member(xml->_attributes[i]->_name,
xml->_attributes[i]->_value);
-// log_msg("\t\tAdding attribute as member %s, value is %s to node %s
(%p)\n",
-// xml->_attributes[i]->_name,
-// xml->_attributes[i]->_value, nodename, obj);
+ log_msg("\t\tAdding attribute as member %s, value is %s to node %s
(%p)\n",
+ xml->_attributes[i]->_name,
+ xml->_attributes[i]->_value, nodename, obj);
}
obj->set_member("attributes", attr_obj);
}
@@ -807,7 +815,7 @@
void
XML::parseXML()
{
- log_msg("%s:unimplemented \n", __FUNCTION__);
+ log_msg("%s: unimplemented \n", __FUNCTION__);
}
/// \brief removes the specified XML object from its parent. Also
@@ -901,8 +909,7 @@
bool ret;
struct stat stats;
-
- //log_msg("%s:\n", __FUNCTION__);
+ //GNASH_REPORT_FUNCTION;
xml_as_object *xml_obj = (xml_as_object*)fn.this_ptr;
@@ -940,14 +947,11 @@
fn.env->set_variable("success", true);
fn.env->bottom(fn.first_arg_bottom_index) = true;
as_c_function_ptr func = method.to_c_function();
- if (func)
- {
+ if (func) {
// It's a C function. Call it.
log_msg("Calling C function for onLoad\n");
(*func)(fn_call(&val, xml_obj, fn.env, fn.nargs,
fn.first_arg_bottom_index)); // was this_ptr instead of node
- }
- else if (as_function* as_func = method.to_as_function())
- {
+ } else if (as_function* as_func = method.to_as_function()) {
// It's an ActionScript function. Call it.
log_msg("Calling ActionScript function for onLoad\n");
(*as_func)(fn_call(&val, xml_obj, fn.env, fn.nargs,
fn.first_arg_bottom_index)); // was this_ptr instead of node
@@ -1257,12 +1261,45 @@
}
void xml_parsexml(const fn_call& fn)
{
+ const char *text;
+ as_value method;
+ as_value val;
xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
assert(ptr);
+ if (fn.nargs > 0) {
+ text = fn.env->bottom(fn.first_arg_bottom_index).to_string();
+ ptr->obj.parseXML(text);
+ ptr->obj.setupFrame(ptr, ptr->obj.firstChild(), false);
+ }
+
+#if 1
+ if (fn.this_ptr->get_member("onLoad", &method)) {
+ // log_msg("FIXME: Found onLoad!\n");
+ fn.env->set_variable("success", true);
+ fn.env->bottom(fn.first_arg_bottom_index) = true;
+ as_c_function_ptr func = method.to_c_function();
+ if (func) {
+ // It's a C function. Call it.
+ log_msg("Calling C function for onLoad\n");
+ (*func)(fn_call(&val, ptr, fn.env, fn.nargs,
fn.first_arg_bottom_index)); // was this_ptr instead of node
+ } else if (as_function* as_func = method.to_as_function()) {
+ // It's an ActionScript function. Call it.
+ log_msg("Calling ActionScript function for onLoad\n");
+ (*as_func)(fn_call(&val, ptr, fn.env, fn.nargs,
fn.first_arg_bottom_index)); // was this_ptr instead of node
+ } else {
+ log_error("error in call_method(): method is not a function\n");
+ }
+ } else {
+ log_msg("Couldn't find onLoad event handler, setting up callback\n");
+ // ptr->set_event_handler(event_id::XML_LOAD,
(as_c_function_ptr)&xml_onload);
+ }
+#else
+
+#endif
// fn.result->set_int(ptr->obj.getAllocated());
- ptr->obj.parseXML();
}
+
void xml_removenode(const fn_call& fn)
{
xml_as_object *ptr = (xml_as_object*)fn.this_ptr;
Index: testsuite/actionscript.all/XML.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/XML.as,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- testsuite/actionscript.all/XML.as 15 Oct 2006 02:30:55 -0000 1.7
+++ testsuite/actionscript.all/XML.as 17 Oct 2006 00:09:53 -0000 1.8
@@ -41,13 +41,11 @@
// execute it like this gnash -1 -r 0 -v out.swf
var existtests = true;
-var tmp = new XML;
+var tmp = new XML();
#include "dejagnu.as"
#include "utils.as"
-var xml = "<TOPNODE><SUBNODE1><SUBSUBNODE1>sub sub1 node data
1</SUBSUBNODE1><SUBSUBNODE2>sub sub1 node data
2</SUBSUBNODE2></SUBNODE1><SUBNODE2><SUBSUBNODE1>sub sub2 node data
1</SUBSUBNODE1><SUBSUBNODE2>sub sub2 node data
2</SUBSUBNODE2></SUBNODE2></TOPNODE>";
-
// test the XML constuctor
if (tmp) {
pass("XML::XML() constructor");
@@ -58,103 +56,103 @@
if (existtests) {
// test the XML::addrequestheader method
-if (tmp.addRequestHeader) {
+ if (tmp.addRequestHeader) {
pass("XML::addRequestHeader() exists");
-} else {
+ } else {
fail("XML::addRequestHeader() doesn't exist");
-}
+ }
// test the XML::appendchild method
-if (tmp.appendChild) {
+ if (tmp.appendChild) {
pass("XML::appendChild() exists");
-} else {
+ } else {
fail("XML::appendChild() doesn't exist");
-}
+ }
// test the XML::clonenode method
-if (tmp.cloneNode) {
+ if (tmp.cloneNode) {
pass("XML::cloneNode() exists");
-} else {
+ } else {
fail("XML::cloneNode() doesn't exist");
-}
+ }
// test the XML::createelement method
-if (tmp.createElement) {
+ if (tmp.createElement) {
pass("XML::createElement() exists");
-} else {
+ } else {
fail("XML::createElement() doesn't exist");
-}
+ }
// test the XML::createtextnode method
-if (tmp.createTextNode) {
+ if (tmp.createTextNode) {
pass("XML::createTextNode() exists");
-} else {
+ } else {
fail("XML::createTextNode() doesn't exist");
-}
+ }
// test the XML::getbytesloaded method
-if (tmp.getBytesLoaded) {
+ if (tmp.getBytesLoaded) {
pass("XML::getBytesLoaded() exists");
-} else {
+ } else {
fail("XML::getBytesLoaded() doesn't exist");
-}
+ }
// test the XML::getbytestotal method
-if (tmp.getBytesTotal) {
+ if (tmp.getBytesTotal) {
pass("XML::getBytesTotal() exists");
-} else {
+ } else {
fail("XML::getBytesTotal() doesn't exist");
-}
+ }
// test the XML::haschildnodes method
-if (tmp.hasChildNodes) {
+ if (tmp.hasChildNodes) {
pass("XML::hasChildNodes() exists");
-} else {
+ } else {
fail("XML::hasChildNodes() doesn't exist");
-}
+ }
// test the XML::insertbefore method
-if (tmp.insertBefore) {
+ if (tmp.insertBefore) {
pass("XML::insertBefore() exists");
-} else {
+ } else {
fail("XML::insertBefore() doesn't exist");
-}
+ }
// test the XML::load method
-if (tmp.load) {
+ if (tmp.load) {
pass("XML::load() exists");
-} else {
+ } else {
fail("XML::load() doesn't exist");
-}
+ }
// This doesn't seem to exist in the real player
// test the XML::loaded method
-if (tmp.loaded) {
+ if (tmp.loaded) {
unresolved("XML::loaded() exists, it shouldn't!");
-} else {
+ } else {
unresolved("XML::loaded() doesn't exist yet");
-}
+ }
//test the XML::parse method
-if (tmp.parseXML) {
+ if (tmp.parseXML) {
pass("XML::parseXML() exists");
-} else {
+ } else {
fail("XML::parseXML() doesn't exist");
-}
+ }
// test the XML::removenode method
-if (tmp.removeNode) {
+ if (tmp.removeNode) {
pass("XML::removeNode() exists");
-} else {
+ } else {
fail("XML::removeNode() doesn't exist");
-}
+ }
// test the XML::send method
-if (tmp.send) {
+ if (tmp.send) {
pass("XML::send() exists");
-} else {
+ } else {
fail("XML::send() doesn't exist");
-}
+ }
// test the XML::sendandload method
-if (tmp.sendAndLoad) {
+ if (tmp.sendAndLoad) {
pass("XML::sendAndLoad() exists");
-} else {
+ } else {
fail("XML::sendAndLoad() doesn't exist");
-}
+ }
// test the XML::tostring method
-if (tmp.toString) {
+ if (tmp.toString) {
pass("XML::toString() exists");
-} else {
+ } else {
fail("XML::toString() doesn't exist");
-}
+ }
} // end of existtests
/////////////////////////////////////////////////////
@@ -165,37 +163,40 @@
// } else {
// fail("XML::load() doesn't work");
// }
-if (tmp.parseXML($xml)) {
- xpass("XML::parseXML() works");
+var xml = "<TOPNODE><SUBNODE1><SUBSUBNODE1>sub sub1 node data
1</SUBSUBNODE1><SUBSUBNODE2>sub sub1 node data
2</SUBSUBNODE2></SUBNODE1><SUBNODE2><SUBSUBNODE1>sub sub2 node data
1</SUBSUBNODE1><SUBSUBNODE2>sub sub2 node data
2</SUBSUBNODE2></SUBNODE2></TOPNODE>";
+
+// parseXML doesn't return anything
+tmp.parseXML(xml);
+
+if (tmp.firstChild.nodeName == "TOPNODE") {
+ pass("XML::parseXML() works");
} else {
- xfail("XML::parseXML() doesn't work");
+ fail("XML::parseXML() doesn't work");
}
-//
if (tmp.hasChildNodes() == true) {
- xpass("XML::hasChildNodes() works");
+ pass("XML::hasChildNodes() works");
} else {
- xfail("XML::hasChildNodes() doesn't work");
+ fail("XML::hasChildNodes() doesn't work");
}
-note(tmp.getBytesLoaded());
-note(tmp.getBytesTotal());
+// note(tmp.getBytesLoaded());
+// note(tmp.getBytesTotal());
if (tmp.getBytesLoaded() > 0) {
- xpass("XML::getBytesLoaded() works");
+ pass("XML::getBytesLoaded() works");
} else {
- xfail("XML::getBytesLoaded() doesn't work");
+ fail("XML::getBytesLoaded() doesn't work");
}
if (tmp.getBytesTotal() > 0) {
- unresolved("XML::getBytesTotal() works");
+ pass("XML::getBytesTotal() works");
} else {
- unresolved("XML::getBytesTotal() doesn't work");
+ fail("XML::getBytesTotal() doesn't work");
}
-// FIXME: So this will fail as well
if (tmp.getBytesLoaded() == tmp.getBytesTotal()) {
- unresolved("bytes count are the same");
+ pass("bytes count are the same");
} else {
- unresolved("bytes counts are not the same");
+ fail("bytes counts are not the same");
}
myXML = new XML();
@@ -224,9 +225,9 @@
nodevalue = getElement.nodeValue;
trace(nodevalue);
if ((nodename == "module") && (nodevalue == "")) {
- unresolved("Appending Text Node to Element Node works");
+ pass("Appending Text Node to Element Node works");
} else {
- unresolved("Appending Text Node to Element Node doesn't work");
+ fail("Appending Text Node to Element Node doesn't work");
}
nodename = getElement.nodeName;
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1254
retrieving revision 1.1255
diff -u -b -r1.1254 -r1.1255
--- ChangeLog 16 Oct 2006 22:17:14 -0000 1.1254
+++ ChangeLog 17 Oct 2006 00:09:53 -0000 1.1255
@@ -1,3 +1,12 @@
+2006-10-16 Rob Savoye <address@hidden>
+
+ * server/xml.cpp: Fix parseXML so it takes a string, and properly
+ sets up the stack with the values parsed from the XML.
+ * testsuite/actionscript.all/XML.as: Tests pass now, no expected
+ failures anymore.
+ * testsuite/actionscript.all/with.as: New test case for making
+ sure the 'with' Flash keyword works, which currently it doesn't.
+
2006-10-16 Tomas Groth Christensen <address@hidden>
* backend/sound_handler_gst.cpp, backend/sound_handler_sdl.cpp,
Index: testsuite/actionscript.all/with.as
===================================================================
RCS file: testsuite/actionscript.all/with.as
diff -N testsuite/actionscript.all/with.as
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/actionscript.all/with.as 17 Oct 2006 00:09:53 -0000 1.1
@@ -0,0 +1,121 @@
+//
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+// Linking Gnash statically or dynamically with other modules is making a
+// combined work based on Gnash. Thus, the terms and conditions of the GNU
+// General Public License cover the whole combination.
+//
+// As a special exception, the copyright holders of Gnash give you
+// permission to combine Gnash with free software programs or libraries
+// that are released under the GNU LGPL and with code included in any
+// release of Talkback distributed by the Mozilla Foundation. You may
+// copy and distribute such a system following the terms of the GNU GPL
+// for all but the LGPL-covered parts and Talkback, and following the
+// LGPL for the LGPL-covered parts.
+//
+// Note that people who make modified versions of Gnash are not obligated
+// to grant this special exception for their modified versions; it is their
+// choice whether to do so. The GNU General Public License gives permission
+// to release a modified version without this exception; this exception
+// also makes it possible to release a modified version which carries
+// forward this exception.
+//
+
+// Test case for XML ActionScript class
+// compile this test case with Ming makeswf, and then
+// execute it like this gnash -1 -r 0 -v out.swf
+
+var XMLObj = new XML;
+
+#include "dejagnu.as"
+#include "utils.as"
+
+var xml = "<TOPNODE><SUBNODE1><SUBSUBNODE1>sub sub1 node data
1</SUBSUBNODE1><SUBSUBNODE2>sub sub1 node data
2</SUBSUBNODE2></SUBNODE1><SUBNODE2><SUBSUBNODE1>sub sub2 node data
1</SUBSUBNODE1><SUBSUBNODE2>sub sub2 node data
2</SUBSUBNODE2></SUBNODE2></TOPNODE>";
+
+XMLObj.onLoad = function (success) {
+ with (XMLObj.firstChild) {
+ if (nodeName == 'TOPNODE') {
+ childa = 0;
+ while (childa < childNodes.length) {
+ with (childNodes[childa]) {
+ if (nodeName == 'SUBNODE1') {
+ childb = 0;
+ while (childb < childNodes.length) {
+ with (childNodes[childb]) {
+ if (nodeName == 'SUBSUBNODE1') {
+ _global.child1 = firstChild.nodeValue;
+ } else {
+ if (nodeName == 'SUBNODE2') {
+ _global.child2 = firstChild.nodeValue;
+ } else {
+ if (nodeName == 'SUBSUBNODE1') {
+ _global.child3 =
firstChild.nodeValue;
+ }
+ }
+ }
+ }
+ ++childb;
+ }
+ }
+ }
+ ++childa;
+ }
+ }
+ }
+ Root_Path.mv_Everything.mv_System_Info.txt_Sysinfo_XMLPort.text = XML_port;
+ if (Connected == 0) {
+ Root_Path.mv_Everything.mv_Loading_Splash.txt_Debug.text = 'Connecting
to\'' + IP_add + '\' on port ' + XML_port;
+ ARQSocket_Connect();
+ }
+};
+
+// Load
+// if (XMLObj.load("testin.xml")) {
+// pass("XML::load() works");
+// } else {
+// fail("XML::load() doesn't work");
+// }
+
+XMLObj.parseXML(xml);
+if (XMLObj.firstChild.nodeName == "TOPNODE") {
+ pass("XML::parseXML() works");
+} else {
+ fail("XML::parseXML() doesn't work");
+}
+
+// These tests only work if 'with' processed the XML file correctly
+if (_global.child1 == "sub sub1 node data 1") {
+ xpass("with level 1 works");
+} else {
+ xfail("with level 1 doesn't work");
+}
+
+if (_global.child2 == "") {
+ xpass("with level 2 works");
+} else {
+ xfail("with level 2 doesn't work");
+}
+
+if (_global.child3 == "sub sub2 node data 1") {
+ xpass("with level 3 works");
+} else {
+ xfail("with level 3 doesn't work");
+}
+
+// We're done
+totals();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash server/xml.cpp testsuite/actionscript.all...,
Rob Savoye <=