[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: |
Mon, 14 May 2007 14:37:38 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/05/14 14:37:38
Modified files:
. : ChangeLog
server/asobj : xml.cpp xml.h
testsuite/actionscript.all: XML.as
Log message:
* server/asobj/xml.{cpp,h}: parseDoc made private; add clear()
method for dropping childs and attibutes; clear() on
parseXML() or
load() calls.
* testsuite/actionscript.all/XML.as: add a cleaner test for
parseXML
not appending new definitions. Misses the same for load()
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3198&r2=1.3199
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.cpp?cvsroot=gnash&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.h?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/XML.as?cvsroot=gnash&r1=1.29&r2=1.30
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3198
retrieving revision 1.3199
diff -u -b -r1.3198 -r1.3199
--- ChangeLog 14 May 2007 14:18:27 -0000 1.3198
+++ ChangeLog 14 May 2007 14:37:37 -0000 1.3199
@@ -1,5 +1,13 @@
2007-05-14 Sandro Santilli <address@hidden>
+ * server/asobj/xml.{cpp,h}: parseDoc made private; add clear()
+ method for dropping childs and attibutes; clear() on parseXML() or
+ load() calls.
+ * testsuite/actionscript.all/XML.as: add a cleaner test for parseXML
+ not appending new definitions. Misses the same for load()
+
+2007-05-14 Sandro Santilli <address@hidden>
+
* utilities/Makefile.am: put GNASH_LIBS in LDADD and external
libs in LDFLAGS. Drop '-dlopen self'. Please review.
Index: server/asobj/xml.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xml.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- server/asobj/xml.cpp 18 Apr 2007 14:07:32 -0000 1.40
+++ server/asobj/xml.cpp 14 May 2007 14:37:37 -0000 1.41
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: xml.cpp,v 1.40 2007/04/18 14:07:32 jgilmore Exp $ */
+/* $Id: xml.cpp,v 1.41 2007/05/14 14:37:37 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -299,7 +299,7 @@
}
}
-// Read in an XML document from the specified source
+/*private*/
bool
XML::parseDoc(xmlDocPtr document, bool mem)
{
@@ -345,7 +345,8 @@
//_bytes_total = _bytes_loaded = xml_in.size();
- bool ret=true;
+ // Clear current data
+ clear();
xmlInitParser();
_doc = xmlParseMemory(xml_in.c_str(), xml_in.size());
@@ -353,7 +354,8 @@
log_error(_("Can't parse XML data"));
return false;
}
- ret = parseDoc(_doc, true);
+
+ bool ret = parseDoc(_doc, true);
xmlCleanupParser();
xmlFreeDoc(_doc);
xmlMemoryDump();
@@ -371,10 +373,13 @@
bool
XML::load(const URL& url)
{
-// GNASH_REPORT_FUNCTION;
+ GNASH_REPORT_FUNCTION;
//log_msg(_("%s: mem is %d"), __FUNCTION__, mem);
+ // Clear current data
+ clear();
+
std::auto_ptr<tu_file> str (
StreamProvider::getDefaultInstance().getStream(url) );
if ( ! str.get() )
{
@@ -695,16 +700,21 @@
as_value xml_parsexml(const fn_call& fn)
{
-// GNASH_REPORT_FUNCTION;
+ //GNASH_REPORT_FUNCTION;
as_value method;
as_value val;
boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
- if (fn.nargs > 0)
+ if (fn.nargs < 1)
{
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("XML.parseXML() needs one argument");
+ );
+ return as_value();
+ }
+
const std::string& text = fn.arg(0).to_string(&(fn.env()));
ptr->parseXML(text);
- }
return as_value();
}
@@ -807,6 +817,14 @@
}
}
+void
+XML::clear()
+{
+ // TODO: should set childs's parent to NULL ?
+ _children.clear();
+
+ _attributes.clear();
+}
} // end of gnash namespace
Index: server/asobj/xml.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xml.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/asobj/xml.h 4 Apr 2007 14:22:11 -0000 1.13
+++ server/asobj/xml.h 14 May 2007 14:37:38 -0000 1.14
@@ -107,10 +107,14 @@
void set_member(const std::string& name, const as_value& val );
// Methods
- // This is the base method used by both parseXML() and load().
- bool parseDoc(xmlDocPtr document, bool mem);
- // Parses an XML document into the specified XML object tree.
+ /// Parses an XML document into the specified XML object tree.
+ //
+ /// This reads in an XML file from disk and parses into into a memory
resident
+ /// tree which can be walked through later.
+ ///
+ /// Calls to this function clear any precedently parsed data.
+ ///
bool parseXML(const std::string& xml_in);
// Loads a document (specified by
@@ -127,8 +131,6 @@
bool loaded() { return _loaded; }
- void clear() {}
-
XMLNode *processNode(xmlTextReaderPtr reader, XMLNode *node);
void change_stack_frame(int frame, gnash::as_object *xml,
gnash::as_environment *env);
@@ -155,6 +157,17 @@
int getBytesTotal() { return _bytes_total; };
private:
+
+ /// Remove all childs
+ void clear();
+
+
+ /// Read in an XML document from the specified source
+ //
+ /// This is the base method used by both parseXML() and load().
+ ///
+ bool parseDoc(xmlDocPtr document, bool mem);
+
xmlDocPtr _doc;
xmlNodePtr _firstChild;
Index: testsuite/actionscript.all/XML.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/XML.as,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- testsuite/actionscript.all/XML.as 13 May 2007 17:13:09 -0000 1.29
+++ testsuite/actionscript.all/XML.as 14 May 2007 14:37:38 -0000 1.30
@@ -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.29 2007/05/13 17:13:09 strk Exp $";
+rcsid="$Id: XML.as,v 1.30 2007/05/14 14:37:38 strk Exp $";
#include "dejagnu.as"
#include "utils.as"
@@ -644,6 +644,17 @@
topnode = myxml.firstChild;
check_equals(topnode.nodeName, 'XML');
check_equals(topnode.attributes.attr1, 'attr1 value');
+
+ // XML, comment, NULL
+ if ( typeof(myxml.lastChildNodesCount) == 'undefined' )
+ {
+ myxml.lastChildNodesCount = myxml.childNodes.length;
+ }
+ else
+ {
+ check_equals(myxml.childNodes.length,
myxml.lastChildNodesCount);
+ }
+ xcheck_equals(myxml.childNodes.length, 3); // gnash fails discarding
the comment and the ending blanks
};
check_equals(typeof(myxml.status), 'number');
#if OUTPUT_VERSION < 7
@@ -671,6 +682,9 @@
note("myxml.loaded = "+myxml.loaded);
note("myxml.load() returned "+ret);
+// Load again, to verify new parsing doesn't get appended to the old
+ret = myxml.load( MEDIA(gnash.xml) );
+
//------------------------------------------------
// Test XML.ignoreWhite
//------------------------------------------------
@@ -684,8 +698,10 @@
myxml2.ignoreWhite = false; // doesn't work w/out load ?
myxml2.parseXML(xmlin);
+check_equals(myxml2.childNodes.length, 1);
xcheck_equals(myxml2.toString(), xmlin); // gnash fails discarding newlines
and tabs I think..
myxml2.parseXML(xmlin2); // parsing twice doesn't append !
+check_equals(myxml2.childNodes.length, 1);
xcheck_equals(myxml2.toString(), xmlin2_out);
myxml2.ignoreWhite = true; // doesn't work w/out load ?
- [Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso...,
Sandro Santilli <=