r3474 jshaw - in /trunk/dom: include/dom/core/node.h src/core/node.c
by netsurf@semichrome.net
Author: jshaw
Date: Sat Aug 4 00:11:31 2007
New Revision: 3474
URL: http://source.netsurf-browser.org?rev=3474&view=rev
Log:
Fix structure name dom_nodelist
Modified:
trunk/dom/include/dom/core/node.h
trunk/dom/src/core/node.c
Modified: trunk/dom/include/dom/core/node.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/core/node.h?rev=3...
==============================================================================
--- trunk/dom/include/dom/core/node.h (original)
+++ trunk/dom/include/dom/core/node.h Sat Aug 4 00:11:31 2007
@@ -15,7 +15,7 @@
struct dom_document;
struct dom_node;
-struct dom_node_list;
+struct dom_nodelist;
struct dom_named_node_map;
struct dom_string;
@@ -85,7 +85,7 @@
dom_exception dom_node_get_parent_node(struct dom_node *node,
struct dom_node **result);
dom_exception dom_node_get_child_nodes(struct dom_node *node,
- struct dom_node_list **result);
+ struct dom_nodelist **result);
dom_exception dom_node_get_first_child(struct dom_node *node,
struct dom_node **result);
dom_exception dom_node_get_last_child(struct dom_node *node,
Modified: trunk/dom/src/core/node.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/node.c?rev=3474&r1=3...
==============================================================================
--- trunk/dom/src/core/node.c (original)
+++ trunk/dom/src/core/node.c Sat Aug 4 00:11:31 2007
@@ -348,10 +348,10 @@
* \param result Pointer to location to receive child list
* \return DOM_NO_ERR.
*
- * \todo Work out reference counting semantics of dom_node_list
+ * \todo Work out reference counting semantics of dom_nodelist
*/
dom_exception dom_node_get_child_nodes(struct dom_node *node,
- struct dom_node_list **result)
+ struct dom_nodelist **result)
{
UNUSED(node);
UNUSED(result);
15 years, 6 months
r3473 jshaw - /trunk/dom/test/xml/tests/documentcreateattribute.xml
by netsurf@semichrome.net
Author: jshaw
Date: Fri Aug 3 22:42:38 2007
New Revision: 3473
URL: http://source.netsurf-browser.org?rev=3473&view=rev
Log:
Import test from W3C test suite
Added:
trunk/dom/test/xml/tests/documentcreateattribute.xml
Added: trunk/dom/test/xml/tests/documentcreateattribute.xml
URL: http://source.netsurf-browser.org/trunk/dom/test/xml/tests/documentcreate...
==============================================================================
--- trunk/dom/test/xml/tests/documentcreateattribute.xml (added)
+++ trunk/dom/test/xml/tests/documentcreateattribute.xml Fri Aug 3 22:42:38 2007
@@ -1,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2001 World Wide Web Consortium,
+(Massachusetts Institute of Technology, Institut National de
+Recherche en Informatique et en Automatique, Keio University). All
+Rights Reserved. This program is distributed under the W3C's Software
+Intellectual Property License. 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 W3C License http://www.w3.org/Consortium/Legal/ for more details.
+--><!DOCTYPE test SYSTEM "dom1.dtd">
+
+<test xmlns="http://www.w3.org/2001/DOM-Test-Suite/Level-1" name="documentcreateattribute">
+<metadata>
+<title>documentCreateAttribute</title>
+<creator>NIST</creator>
+<description>
+ The "createAttribute(name)" method creates an Attribute
+ node of the given name.
+
+ Retrieve the entire DOM document and invoke its
+ "createAttribute(name)" method. It should create a
+ new Attribute node with the given name. The name, value
+ and type of the newly created object are retrieved and
+ output.
+</description>
+<contributor>Mary Brady</contributor>
+<date qualifier="created">2001-08-17</date>
+<subject resource="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084..."/>
+</metadata>
+<var name="doc" type="Document"/>
+<var name="newAttrNode" type="Attr"/>
+<var name="attrValue" type="DOMString"/>
+<var name="attrName" type="DOMString"/>
+<var name="attrType" type="int"/>
+<load var="doc" href="staff" willBeModified="true"/>
+<createAttribute obj="doc" var="newAttrNode" name=""district""/>
+<nodeValue obj="newAttrNode" var="attrValue"/>
+<assertEquals actual="attrValue" expected="""" ignoreCase="false" id="value"/>
+<nodeName obj="newAttrNode" var="attrName"/>
+<assertEquals actual="attrName" expected=""district"" ignoreCase="false" id="name"/>
+<nodeType obj="newAttrNode" var="attrType"/>
+<assertEquals actual="attrType" expected="2" ignoreCase="false" id="type"/>
+</test>
15 years, 6 months
r3472 jshaw - /trunk/dom/test/transform/test-to-c.xsl
by netsurf@semichrome.net
Author: jshaw
Date: Fri Aug 3 22:42:14 2007
New Revision: 3472
URL: http://source.netsurf-browser.org?rev=3472&view=rev
Log:
Reinstate assertEquals template
Modified:
trunk/dom/test/transform/test-to-c.xsl
Modified: trunk/dom/test/transform/test-to-c.xsl
URL: http://source.netsurf-browser.org/trunk/dom/test/transform/test-to-c.xsl?...
==============================================================================
--- trunk/dom/test/transform/test-to-c.xsl (original)
+++ trunk/dom/test/transform/test-to-c.xsl Fri Aug 3 22:42:14 2007
@@ -343,7 +343,7 @@
</xsl:choose>
</xsl:variable>
- <xsl:variable name="current-position" select="position()"/>
+ <xsl:variable name="current-position"><xsl:number level="any" count="*"/></xsl:variable>
<!--
setup variables to hold parameter literals (for DOMStrings)
@@ -537,7 +537,56 @@
</xsl:template>
<xsl:template match="*[local-name() = 'assertEquals']" mode="body">
- <!-- TODO: implement -->
+ <xsl:variable name="vardefs" select="//*[local-name() = 'var']"/>
+
+ <xsl:variable name="actual" select="@actual"/>
+
+ <xsl:variable name="var-type" select="$vardefs[@name = $actual]/@type"/>
+
+ <xsl:choose>
+ <xsl:when test="$var-type = 'DOMString'">
+ <!-- a globally unique identifier for the temporary string -->
+ <xsl:variable name="dom-string-id"><xsl:number level="any" count="*"/></xsl:variable>
+
+ <xsl:call-template name="produce-dom-string">
+ <xsl:with-param name="vardefs" select="$vardefs"/>
+ <xsl:with-param name="var-name">matchString_<xsl:value-of select="$dom-string-id"/></xsl:with-param>
+ <xsl:with-param name="string" select="@expected"/>
+ </xsl:call-template>
+ <xsl:text> assert(</xsl:text>
+ <xsl:choose>
+ <xsl:when test="@ignoreCase = 'true'">
+ <xsl:text>dom_string_icmp</xsl:text>
+ </xsl:when>
+ <xsl:when test="@ignoreCase = 'auto'">
+ <!--
+ TODO: implement auto case comparison (see java's DOMTestCase.assertEqualsAutoCase()
+ -->
+ <xsl:message><assertEquals ignoreCase='auto'> not supported</xsl:message>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>dom_string_cmp</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>(</xsl:text>
+ <xsl:value-of select="@actual"/>
+ <xsl:text>, matchString_</xsl:text>
+ <xsl:value-of select="$dom-string-id"/>
+ <xsl:text>) == 0);
+</xsl:text>
+ </xsl:when>
+ <xsl:when test="$var-type = 'int'">
+ <xsl:text> assert(</xsl:text>
+ <xsl:value-of select="@actual"/>
+ <xsl:text> == </xsl:text>
+ <xsl:value-of select="@expected"/>
+ <xsl:text>);
+</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message>assertEquals on unknown type <xsl:value-of select="$var-type"/></xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<!--
15 years, 6 months
r3471 jshaw - /trunk/dom/test/transform/test-to-c.xsl
by netsurf@semichrome.net
Author: jshaw
Date: Wed Aug 1 23:51:38 2007
New Revision: 3471
URL: http://source.netsurf-browser.org?rev=3471&view=rev
Log:
Implemented variable-or-literal type guessing. Implemented creation of temporary DOMStrings with autogenned, globally unique identifiers.
Modified:
trunk/dom/test/transform/test-to-c.xsl
Modified: trunk/dom/test/transform/test-to-c.xsl
URL: http://source.netsurf-browser.org/trunk/dom/test/transform/test-to-c.xsl?...
==============================================================================
--- trunk/dom/test/transform/test-to-c.xsl (original)
+++ trunk/dom/test/transform/test-to-c.xsl Wed Aug 1 23:51:38 2007
@@ -341,20 +341,23 @@
<xsl:value-of select="$method/@name"/>
</xsl:otherwise>
</xsl:choose>
- </xsl:variable>
-
- <!-- setup variables to hold parameter literals (for DOMStrings) -->
+ </xsl:variable>
+
+ <xsl:variable name="current-position" select="position()"/>
+
+ <!--
+ setup variables to hold parameter literals (for DOMStrings)
+ TODO: needs testing with method that takes more than one parameter
+ TODO: needs testing with more than one method call per test
+ -->
<xsl:for-each select="$method/parameters/param">
<xsl:variable name="paramDef" select="."/>
<xsl:variable name="value" select="$current-node/@*[name() = $paramDef/@name]"/>
<xsl:if test="starts-with($value, '"')">
-
<xsl:call-template name="produce-dom-string">
<xsl:with-param name="vardefs" select="$vardefs"/>
-
- <!-- FIXME: xsl:number isn't sufficient to guarantee global uniqueness -->
- <xsl:with-param name="var-name"><xsl:text>domString</xsl:text><xsl:number/></xsl:with-param>
+ <xsl:with-param name="var-name"><xsl:text>domString</xsl:text><xsl:value-of select="$current-position"/>_<xsl:number/></xsl:with-param>
<xsl:with-param name="string" select="$value"/>
</xsl:call-template>
</xsl:if>
@@ -380,12 +383,12 @@
<xsl:variable name="value" select="$current-node/@*[name() = $paramDef/@name]"/>
<xsl:text>, </xsl:text>
- <!-- TODO: cast, also, need to handle stuff like string constants (need turning into DOMStrings) -->
<xsl:call-template name="produce-param">
<xsl:with-param name="vardefs" select="$vardefs"/>
<xsl:with-param name="var-or-literal" select="$value"/>
<xsl:with-param name="interface-type" select="./@type"/>
+ <xsl:with-param name="current-position" select="$current-position"/>
</xsl:call-template>
</xsl:for-each>
@@ -410,6 +413,13 @@
</xsl:text>
</xsl:template>
+<!--
+This template expects to be called with
+a current context of a $domspec//method/parameters/param.
+
+TODO: If this template needs to be more flexible, will need to pass $current-position
+through as a parameter
+-->
<xsl:template name="produce-param">
<xsl:param name="vardefs"/>
@@ -428,12 +438,16 @@
</xsl:call-template>
</xsl:variable>
+ <!-- used for referencing DOMStrings -->
+ <xsl:param name="current-position"/>
+
<xsl:choose>
<xsl:when test="$var-type = 'DOMString'">
<!--
- TODO use the dom_string that was generated for this param
- before the method call. somehow need to link the unique
- identifier used there so that we can reference it here. -->
+ TODO: put this string creation in its own template so it can be reused.
+ Be careful with the behaviour of xsl:number, though.
+ -->
+ <xsl:text>domString</xsl:text><xsl:value-of select="$current-position"/>_<xsl:number/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="cast">
@@ -456,7 +470,20 @@
<!-- the expected type of $var-or-literal -->
<xsl:param name="interface-type"/>
- <!-- FIXME implement me -->
+ <xsl:choose>
+ <!-- string literal -->
+ <xsl:when test="starts-with($var-or-literal, '"')">
+ <xsl:text>DOMString</xsl:text>
+ </xsl:when>
+ <!-- variable -->
+ <xsl:when test="$vardefs[@name = $var-or-literal]">
+ <xsl:value-of select="$vardefs[@name = $var-or-literal]/@type"/>
+ </xsl:when>
+ <!-- unknown; return the interface type -->
+ <xsl:otherwise>
+ <xsl:value-of select="$interface-type"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<xsl:template name="cast">
15 years, 6 months