r3430 jmb - /trunk/netsurf/Docs/01-content
by netsurf@semichrome.net
Author: jmb
Date: Wed Jul 18 01:17:50 2007
New Revision: 3430
URL: http://source.netsurf-browser.org?rev=3430&view=rev
Log:
Improve documentation of content type handler addition
Modified:
trunk/netsurf/Docs/01-content
Modified: trunk/netsurf/Docs/01-content
URL: http://source.netsurf-browser.org/trunk/netsurf/Docs/01-content?rev=3430&...
==============================================================================
--- trunk/netsurf/Docs/01-content (original)
+++ trunk/netsurf/Docs/01-content Wed Jul 18 01:17:50 2007
@@ -58,6 +58,7 @@
Type functions
--------------
+[[typefunc]]
The type-specific functions for a content are as follows (where 'type' is
replaced by something):
@@ -104,3 +105,23 @@
and fetch, convert, and cache it if not present.
The fetch module provides a low-level URL fetching interface.
+
+Adding support for a new content type
+-------------------------------------
+Addition of support for new content types is fairly simple and the process is
+as follows:
+
+- Implement, or at least stub out, the new content type handler. See the
+ <<typefunc,Type Functions>> section above for details of the type handler API.
+- Add a type value to the 'content_type' enumeration (content_type.h)
+- Add an entry for the new type's private data in the 'data' union within
+ 'struct content' (content.h)
+- Add appropriate mappings in the 'mime_map' table from MIME type strings to
+ the 'content_type' value created. (content.c)
+- Add a textual name for the new content type to 'content_type_name'. This
+ array is indexed by 'content_type'. (content.c)
+- Add an entry for the new content type's handler in the 'handler_map' array.
+ This array is indexed by 'content_type'. (content.c)
+
+For examples of content type handlers, consult the image/ directory. The JPEG
+handler is fairly self-explanatory.
15 years, 10 months
r3428 jshaw - /trunk/dom/test/test-to-c.xsl
by netsurf@semichrome.net
Author: jshaw
Date: Tue Jul 17 22:40:18 2007
New Revision: 3428
URL: http://source.netsurf-browser.org?rev=3428&view=rev
Log:
Take out lots of <assertEquals> code because it's broken, and needs
rethinking. Partially fix
attribute generation to call method on the right interface.
Modified:
trunk/dom/test/test-to-c.xsl
Modified: trunk/dom/test/test-to-c.xsl
URL: http://source.netsurf-browser.org/trunk/dom/test/test-to-c.xsl?rev=3428&r...
==============================================================================
--- trunk/dom/test/test-to-c.xsl (original)
+++ trunk/dom/test/test-to-c.xsl Tue Jul 17 22:40:18 2007
@@ -69,7 +69,10 @@
</xsl:template>
<xsl:template match="*[local-name() = 'test']">
-<xsl:text>#include <dom/dom.h>
+<xsl:text>#include <string.h>
+
+#include <dom/dom.h>
+#include <utils.h>
#include "testutils.h"
</xsl:text>
@@ -115,7 +118,7 @@
append a counter to the variable name?
-->
<xsl:text>
- TestObject testObject = test_object_create(argc, argv, "</xsl:text><xsl:value-of select="@href"/><xsl:text>.xml", false);
+ TestObject *testObject = test_object_create(argc, argv, "</xsl:text><xsl:value-of select="@href"/><xsl:text>.xml", false);
assert(testObject != NULL);
</xsl:text><xsl:value-of select="@var"/><xsl:text> = test_object_get_doc(testObject);
@@ -245,13 +248,13 @@
<xsl:text>
err = </xsl:text>
<xsl:call-template name="convert_var_type">
- <xsl:with-param name="var_type"><xsl:value-of select="//*[local-name() = 'var' and @name = $obj]/@type"/></xsl:with-param>
+ <xsl:with-param name="var_type"><xsl:value-of select="$domspec/library/interface[attribute = $attribute]/@name"/></xsl:with-param>
</xsl:call-template>
<xsl:text>_get_</xsl:text>
<xsl:call-template name="convert_attribute_name">
<xsl:with-param name="attribute_name"><xsl:value-of select="$attribute/@name"/></xsl:with-param>
</xsl:call-template>
- <xsl:text>(</xsl:text><xsl:value-of select="@obj"/><xsl:text>, &</xsl:text><xsl:value-of select="@var"/><xsl:text>);
+ <xsl:text>(</xsl:text><!-- TODO: cast to the type expected by the interface if necessary --><xsl:value-of select="@obj"/><xsl:text>, &</xsl:text><xsl:value-of select="@var"/><xsl:text>);
assert(err == DOM_NO_ERR);
</xsl:text>
@@ -286,13 +289,13 @@
<!-- implement equality test depending upon $var_type -->
<xsl:choose>
<xsl:when test="$var_type = 'DOMString'">
+ <!--
+ FIXME: this is currently broken, because doc is hardwired
+ -->
<xsl:text>
struct dom_string *match;
- struct dom_document *actualDoc;
- err = dom_node_get_owner_document(</xsl:text><xsl:value-of select="@actual"/><xsl:text>, &actualDoc);
- assert(err == DOM_NO_ERR);
-
- err = dom_string_create_from_const_ptr(actualDoc, </xsl:text><xsl:value-of select="@expected"/><xsl:text>,
+
+ err = dom_string_create_from_const_ptr(doc, </xsl:text><xsl:value-of select="@expected"/><xsl:text>,
SLEN(</xsl:text><xsl:value-of select="@expected"/><xsl:text>), &match);
assert(err == DOM_NO_ERR); <!-- TODO: pull this line out, since it's reused everywhere -->
@@ -342,6 +345,9 @@
<xsl:when test="$var_type = 'Element'">
<xsl:text>dom_element</xsl:text>
</xsl:when>
+ <xsl:when test="$var_type = 'Node'">
+ <xsl:text>dom_node</xsl:text>
+ </xsl:when>
<xsl:otherwise>
<xsl:value-of select="$var_type"/>
</xsl:otherwise>
15 years, 10 months
r3427 bursa - /trunk/netsurf/image/svg.c
by netsurf@semichrome.net
Author: bursa
Date: Tue Jul 17 03:45:33 2007
New Revision: 3427
URL: http://source.netsurf-browser.org?rev=3427&view=rev
Log:
Start on implementing SVG <path>.
Modified:
trunk/netsurf/image/svg.c
Modified: trunk/netsurf/image/svg.c
URL: http://source.netsurf-browser.org/trunk/netsurf/image/svg.c?rev=3427&r1=3...
==============================================================================
--- trunk/netsurf/image/svg.c (original)
+++ trunk/netsurf/image/svg.c Tue Jul 17 03:45:33 2007
@@ -50,6 +50,7 @@
static bool svg_redraw_svg(xmlNode *svg, struct svg_redraw_state state);
+static bool svg_redraw_path(xmlNode *path, struct svg_redraw_state state);
static bool svg_redraw_rect(xmlNode *rect, struct svg_redraw_state state);
static bool svg_redraw_circle(xmlNode *circle, struct svg_redraw_state state);
static bool svg_redraw_line(xmlNode *line, struct svg_redraw_state state);
@@ -100,7 +101,7 @@
}
c->data.svg.doc = document;
- xmlDebugDumpDocument(stderr, document);
+ /* xmlDebugDumpDocument(stderr, document); */
/* find root <svg> element */
for (svg = document->children;
@@ -169,6 +170,8 @@
state.stroke = TRANSPARENT;
state.stroke_width = 1;
+ plot.clg(0xffffff);
+
return svg_redraw_svg(c->data.svg.svg, state);
}
@@ -211,6 +214,8 @@
ok = svg_redraw_svg(child, state);
else if (strcmp(child->name, "g") == 0)
ok = svg_redraw_svg(child, state);
+ else if (strcmp(child->name, "path") == 0)
+ ok = svg_redraw_path(child, state);
else if (strcmp(child->name, "rect") == 0)
ok = svg_redraw_rect(child, state);
else if (strcmp(child->name, "circle") == 0)
@@ -224,6 +229,135 @@
if (!ok)
return false;
}
+
+ return true;
+}
+
+
+/**
+ * Redraw a <path> element node.
+ */
+
+bool svg_redraw_path(xmlNode *path, struct svg_redraw_state state)
+{
+ svg_parse_paint_attributes(path, &state);
+
+ /* read d attribute */
+ char *s = (char *) xmlGetProp(path, (const xmlChar *) "d");
+ if (!s) {
+ LOG(("path missing d attribute"));
+ return false;
+ }
+
+ /* allocate space for path: it will never have more elements than d */
+ float *p = malloc(sizeof p[0] * strlen(s));
+ if (!p) {
+ LOG(("out of memory"));
+ return false;
+ }
+
+ /* parse d and build path */
+ for (unsigned int i = 0; s[i]; i++)
+ if (s[i] == ',')
+ s[i] = ' ';
+ unsigned int i = 0;
+ float last_x = 0, last_y = 0;
+ while (*s) {
+ char command[2];
+ int plot_command;
+ float x, y, x1, y1, x2, y2;
+ int n;
+
+ LOG(("s \"%s\"", s));
+
+ /* M, m, L, l (2 arguments) */
+ if (sscanf(s, " %1[MmLl] %f %f %n", command, &x, &y, &n) == 3) {
+ LOG(("moveto or lineto"));
+ if (*command == 'M' || *command == 'm')
+ plot_command = PLOTTER_PATH_MOVE;
+ else
+ plot_command = PLOTTER_PATH_LINE;
+ do {
+ p[i++] = plot_command;
+ if ('a' <= *command) {
+ x += last_x;
+ y += last_y;
+ }
+ p[i++] = last_x = x;
+ p[i++] = last_y = y;
+ s += n;
+ plot_command = PLOTTER_PATH_LINE;
+ } while (sscanf(s, "%f %f %n", &x, &y, &n) == 2);
+
+ /* Z, z (no arguments) */
+ } else if (sscanf(s, " %1[Zz] %n", command, &n) == 1) {
+ LOG(("closepath"));
+ p[i++] = PLOTTER_PATH_CLOSE;
+ s += n;
+
+ /* H, h (1 argument) */
+ } else if (sscanf(s, " %1[Hh] %f %n", command, &x, &n) == 2) {
+ LOG(("horizontal lineto"));
+ do {
+ p[i++] = PLOTTER_PATH_LINE;
+ if (*command == 'h')
+ x += last_x;
+ p[i++] = last_x = x;
+ p[i++] = last_y;
+ s += n;
+ } while (sscanf(s, "%f %n", &x, &n) == 1);
+
+ /* V, v (1 argument) */
+ } else if (sscanf(s, " %1[Vv] %f %n", command, &y, &n) == 2) {
+ LOG(("vertical lineto"));
+ do {
+ p[i++] = PLOTTER_PATH_LINE;
+ if (*command == 'v')
+ y += last_y;
+ p[i++] = last_x;
+ p[i++] = last_y = y;
+ s += n;
+ } while (sscanf(s, "%f %n", &x, &n) == 1);
+
+ /* C, c (6 arguments) */
+ } else if (sscanf(s, " %1[Cc] %f %f %f %f %f %f %n", command,
+ &x1, &y1, &x2, &y2, &x, &y, &n) == 7) {
+ LOG(("curveto"));
+ do {
+ p[i++] = PLOTTER_PATH_BEZIER;
+ if (*command == 'c') {
+ x1 += last_x;
+ y1 += last_y;
+ x2 += last_x;
+ y2 += last_y;
+ x += last_x;
+ y += last_y;
+ }
+ p[i++] = x1;
+ p[i++] = y1;
+ p[i++] = x2;
+ p[i++] = y2;
+ p[i++] = last_x = x;
+ p[i++] = last_y = y;
+ s += n;
+ } while (sscanf(s, "%f %f %f %f %f %f %n",
+ &x1, &y1, &x2, &y2, &x, &y, &n) == 7);
+
+ } else {
+ LOG(("parse failed"));
+ break;
+ }
+ }
+
+ LOG(("path:"));
+ for (unsigned int j = 0; j != i; j++) {
+ LOG((" %f", p[j]));
+ }
+
+ bool ok = plot.path(p, i, state.fill, state.stroke_width, state.stroke,
+ &state.ctm.a);
+
+ free(p);
return true;
}
15 years, 10 months
r3426 jmb - /trunk/dom/bindings/xml/xmlparser.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Jul 16 23:05:49 2007
New Revision: 3426
URL: http://source.netsurf-browser.org?rev=3426&view=rev
Log:
Add xml_parser_add_element_node; builds DOM Elements from XML_ELEMENT_NODEs.
Modified:
trunk/dom/bindings/xml/xmlparser.c
Modified: trunk/dom/bindings/xml/xmlparser.c
URL: http://source.netsurf-browser.org/trunk/dom/bindings/xml/xmlparser.c?rev=...
==============================================================================
--- trunk/dom/bindings/xml/xmlparser.c (original)
+++ trunk/dom/bindings/xml/xmlparser.c Mon Jul 16 23:05:49 2007
@@ -7,6 +7,7 @@
#include <stdbool.h>
#include <stdio.h>
+#include <string.h>
#include <libxml/parser.h>
#include <libxml/SAX2.h>
@@ -30,6 +31,8 @@
static void xml_parser_add_node(xml_parser *parser, struct dom_node *parent,
xmlNodePtr child);
+static void xml_parser_add_element_node(xml_parser *parser,
+ struct dom_node *parent, xmlNodePtr child);
static void xml_parser_internal_subset(void *ctx, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *SystemID);
@@ -493,22 +496,134 @@
void xml_parser_add_node(xml_parser *parser, struct dom_node *parent,
xmlNodePtr child)
{
- UNUSED(parser);
- UNUSED(parent);
-
switch (child->type) {
case XML_ELEMENT_NODE:
+ xml_parser_add_element_node(parser, parent, child);
+ break;
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
- case XML_PI_NODE:
+ case XML_ENTITY_REF_NODE:
case XML_COMMENT_NODE:
- case XML_DOCUMENT_NODE:
- case XML_DOCUMENT_TYPE_NODE:
- case XML_NOTATION_NODE:
case XML_DTD_NODE:
default:
fprintf(stderr, "Unsupported node type: %d\n", child->type);
}
+}
+
+/**
+ * Add an element node to the DOM
+ *
+ * \param parser The parser context
+ * \param parent The parent DOM node
+ * \param child The xmlNode to mirror in the DOM as a child of parent
+ */
+void xml_parser_add_element_node(xml_parser *parser, struct dom_node *parent,
+ xmlNodePtr child)
+{
+ struct dom_element *el;
+ xmlAttrPtr a;
+ dom_exception err;
+
+ /* Create the element node */
+ if (child->ns == NULL) {
+ /* No namespace */
+ struct dom_string *tag_name;
+
+ /* Create tag name DOM string */
+ err = dom_string_create_from_const_ptr(parser->doc,
+ child->name,
+ strlen((const char *) child->name),
+ &tag_name);
+ if (err != DOM_NO_ERR)
+ return;
+
+ /* Create element node */
+ err = dom_document_create_element(parser->doc,
+ tag_name, &el);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(tag_name);
+ return;
+ }
+
+ /* No longer need tag name */
+ dom_string_unref(tag_name);
+ } else {
+ /* Namespace */
+
+ /** \todo implement this */
+ }
+
+ /* Add attributes to created element */
+ for (a = child->properties; a != NULL; a = a->next) {
+ struct dom_attr *attr;
+ xmlNodePtr c;
+
+ /* Create attribute node */
+ if (a->ns == NULL) {
+ /* Attribute has no namespace */
+ struct dom_string *name;
+
+ /* Create attribute name DOM string */
+ err = dom_string_create_from_const_ptr(parser->doc,
+ a->name,
+ strlen((const char *) a->name),
+ &name);
+ if (err != DOM_NO_ERR)
+ goto cleanup;
+
+ /* Create attribute */
+ err = dom_document_create_attribute(parser->doc,
+ name, &attr);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(name);
+ goto cleanup;
+ }
+
+ /* No longer need attribute name */
+ dom_string_unref(name);
+ } else {
+ /* Attribute has namespace */
+
+ /** \todo implement this */
+ }
+
+ /* Clone subtree (attribute value) */
+ for (c = a->children; c != NULL; c = c->next) {
+ xml_parser_add_node(parser,
+ (struct dom_node *) attr, c);
+ }
+
+ /* And add attribute to the element */
+ err = dom_element_set_attribute_node(el, attr, &attr);
+ if (err != DOM_NO_ERR) {
+ dom_node_unref((struct dom_node *) attr);
+ goto cleanup;
+ }
+
+ /* We're no longer interested in the attribute node */
+ dom_node_unref((struct dom_node *) attr);
+ }
+
+ /* Finally, append element to parent */
+ err = dom_node_append_child(parent, (struct dom_node *) el,
+ (struct dom_node **) &el);
+ if (err != DOM_NO_ERR) {
+ goto cleanup;
+ }
+
+ /* No longer interested in element node */
+ dom_node_unref((struct dom_node *) el);
+
+ return;
+
+cleanup:
+
+ /** \todo clean up attributes */
+
+ /* No longer want node */
+ dom_node_unref((struct dom_node *) el);
+
+ return;
}
/* */
15 years, 10 months
r3425 jmb - /trunk/dom/src/core/element.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Jul 16 23:04:19 2007
New Revision: 3425
URL: http://source.netsurf-browser.org?rev=3425&view=rev
Log:
Fix typo
Modified:
trunk/dom/src/core/element.c
Modified: trunk/dom/src/core/element.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/element.c?rev=3425&r...
==============================================================================
--- trunk/dom/src/core/element.c (original)
+++ trunk/dom/src/core/element.c Mon Jul 16 23:04:19 2007
@@ -125,7 +125,7 @@
*
* \param element The element to add a node to
* \param attr The attribute node to add
- * \param result Pointer to location to recieve previous node
+ * \param result Pointer to location to receive previous node
* \return DOM_NO_ERR on success,
* DOM_WRONG_DOCUMENT_ERR if ::attr does not belong to the
* same document as ::element,
15 years, 10 months
r3424 jmb - in /trunk/dom: include/dom/core/document_type.h src/core/document_type.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Jul 16 23:03:54 2007
New Revision: 3424
URL: http://source.netsurf-browser.org?rev=3424&view=rev
Log:
Stub out remainder of DocumentType API.
Minor other changes.
Modified:
trunk/dom/include/dom/core/document_type.h
trunk/dom/src/core/document_type.c
Modified: trunk/dom/include/dom/core/document_type.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/core/document_typ...
==============================================================================
--- trunk/dom/include/dom/core/document_type.h (original)
+++ trunk/dom/include/dom/core/document_type.h Mon Jul 16 23:03:54 2007
@@ -3,19 +3,34 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ * Copyright 2007 James Shaw <EMAIL_ADDRESS>
*/
#ifndef dom_core_document_type_h_
#define dom_core_document_type_h_
-#include <stdbool.h>
-
#include <dom/core/exceptions.h>
+struct dom_document_type;
+struct dom_namednodemap;
struct dom_string;
-struct dom_document_type;
-dom_exception dom_document_type_get_name(struct dom_document_type *docType,
+dom_exception dom_document_type_get_name(struct dom_document_type *doc_type,
+ struct dom_string **result);
+dom_exception dom_document_type_get_entities(
+ struct dom_document_type *doc_type,
+ struct dom_namednodemap **result);
+dom_exception dom_document_type_get_notations(
+ struct dom_document_type *doc_type,
+ struct dom_namednodemap **result);
+dom_exception dom_document_type_get_public_id(
+ struct dom_document_type *doc_type,
+ struct dom_string **result);
+dom_exception dom_document_type_get_system_id(
+ struct dom_document_type *doc_type,
+ struct dom_string **result);
+dom_exception dom_document_type_get_internal_subset(
+ struct dom_document_type *doc_type,
struct dom_string **result);
#endif
Modified: trunk/dom/src/core/document_type.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/document_type.c?rev=...
==============================================================================
--- trunk/dom/src/core/document_type.c (original)
+++ trunk/dom/src/core/document_type.c Mon Jul 16 23:03:54 2007
@@ -3,17 +3,145 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ * Copyright 2007 James Shaw <EMAIL_ADDRESS>
*/
-#include <dom/functypes.h>
#include <dom/core/document_type.h>
+
+#include "core/node.h"
#include "utils/utils.h"
-dom_exception dom_document_type_get_name(struct dom_document_type *docType,
+/**
+ * DOM DocumentType node
+ */
+struct dom_document_type {
+ struct dom_node base; /**< Base node */
+
+ /** \todo other members */
+};
+
+/**
+ * Retrieve a document type's name
+ *
+ * \param doc_type Document type to retrieve name from
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_document_type_get_name(struct dom_document_type *doc_type,
struct dom_string **result)
{
- UNUSED(docType);
+ UNUSED(doc_type);
UNUSED(result);
return DOM_NOT_SUPPORTED_ERR;
}
+
+/**
+ * Retrieve a document type's entities
+ *
+ * \param doc_type Document type to retrieve entities from
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned map will have its reference count increased. It is
+ * the responsibility of the caller to unref the map once it has
+ * finished with it.
+ */
+dom_exception dom_document_type_get_entities(
+ struct dom_document_type *doc_type,
+ struct dom_namednodemap **result)
+{
+ UNUSED(doc_type);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve a document type's notations
+ *
+ * \param doc_type Document type to retrieve notations from
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned map will have its reference count increased. It is
+ * the responsibility of the caller to unref the map once it has
+ * finished with it.
+ */
+dom_exception dom_document_type_get_notations(
+ struct dom_document_type *doc_type,
+ struct dom_namednodemap **result)
+{
+ UNUSED(doc_type);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve a document type's public id
+ *
+ * \param doc_type Document type to retrieve public id from
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_document_type_get_public_id(
+ struct dom_document_type *doc_type,
+ struct dom_string **result)
+{
+ UNUSED(doc_type);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve a document type's system id
+ *
+ * \param doc_type Document type to retrieve system id from
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_document_type_get_system_id(
+ struct dom_document_type *doc_type,
+ struct dom_string **result)
+{
+ UNUSED(doc_type);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve a document type's internal subset
+ *
+ * \param doc_type Document type to retrieve internal subset from
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_document_type_get_internal_subset(
+ struct dom_document_type *doc_type,
+ struct dom_string **result)
+{
+ UNUSED(doc_type);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
15 years, 10 months
r3422 jshaw - in /trunk/dom: include/dom/core/document_type.h include/dom/dom.h src/core/Makefile src/core/document_type.c
by netsurf@semichrome.net
Author: jshaw
Date: Mon Jul 16 22:12:55 2007
New Revision: 3422
URL: http://source.netsurf-browser.org?rev=3422&view=rev
Log:
Stub implementation of of dom_document_type methods
Added:
trunk/dom/include/dom/core/document_type.h
trunk/dom/src/core/document_type.c
Modified:
trunk/dom/include/dom/dom.h
trunk/dom/src/core/Makefile
Added: trunk/dom/include/dom/core/document_type.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/core/document_typ...
==============================================================================
--- trunk/dom/include/dom/core/document_type.h (added)
+++ trunk/dom/include/dom/core/document_type.h Mon Jul 16 22:12:55 2007
@@ -1,0 +1,21 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef dom_core_document_type_h_
+#define dom_core_document_type_h_
+
+#include <stdbool.h>
+
+#include <dom/core/exceptions.h>
+
+struct dom_string;
+struct dom_document_type;
+
+dom_exception dom_document_type_get_name(struct dom_document_type *docType,
+ struct dom_string **result);
+
+#endif
Modified: trunk/dom/include/dom/dom.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/dom.h?rev=3422&r1...
==============================================================================
--- trunk/dom/include/dom/dom.h (original)
+++ trunk/dom/include/dom/dom.h Mon Jul 16 22:12:55 2007
@@ -24,6 +24,7 @@
#include <dom/core/attr.h>
#include <dom/core/characterdata.h>
#include <dom/core/document.h>
+#include <dom/core/document_type.h>
#include <dom/core/element.h>
#include <dom/core/exceptions.h>
#include <dom/core/implementation.h>
Modified: trunk/dom/src/core/Makefile
URL: http://source.netsurf-browser.org/trunk/dom/src/core/Makefile?rev=3422&r1...
==============================================================================
--- trunk/dom/src/core/Makefile (original)
+++ trunk/dom/src/core/Makefile Mon Jul 16 22:12:55 2007
@@ -22,7 +22,7 @@
CFLAGS += -I$(CURDIR)
# Objects
-OBJS = attr characterdata document element implementation impllist \
+OBJS = attr characterdata document document_type element implementation impllist \
namednodemap node nodelist string text
.PHONY: clean debug distclean export release setup test
Added: trunk/dom/src/core/document_type.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/document_type.c?rev=...
==============================================================================
--- trunk/dom/src/core/document_type.c (added)
+++ trunk/dom/src/core/document_type.c Mon Jul 16 22:12:55 2007
@@ -1,0 +1,19 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#include <dom/functypes.h>
+#include <dom/core/document_type.h>
+#include "utils/utils.h"
+
+dom_exception dom_document_type_get_name(struct dom_document_type *docType,
+ struct dom_string **result)
+{
+ UNUSED(docType);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
15 years, 10 months
r3421 jshaw - /trunk/dom/test/test-to-c.xsl
by netsurf@semichrome.net
Author: jshaw
Date: Mon Jul 16 21:03:04 2007
New Revision: 3421
URL: http://source.netsurf-browser.org?rev=3421&view=rev
Log:
Partially implement method invocation. Should be sufficient to generate
documentcreateelement.c
Modified:
trunk/dom/test/test-to-c.xsl
Modified: trunk/dom/test/test-to-c.xsl
URL: http://source.netsurf-browser.org/trunk/dom/test/test-to-c.xsl?rev=3421&r...
==============================================================================
--- trunk/dom/test/test-to-c.xsl (original)
+++ trunk/dom/test/test-to-c.xsl Mon Jul 16 21:03:04 2007
@@ -165,7 +165,46 @@
-->
<xsl:template name="produce-method">
-<!-- TODO: implement me -->
+ <xsl:variable name="methodName" select="local-name(.)"/>
+ <!-- if interface is specified -->
+ <xsl:choose>
+ <xsl:when test="@interface">
+ <xsl:variable name="interface" select="@interface"/>
+ <xsl:call-template name="produce-specific-method">
+ <xsl:with-param name="method" select="$domspec/library/interface[@name = $interface]/method[@name = $methodName]"/>
+ <!--<xsl:with-param name="vardefs" select="$vardefs"/>-->
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="methods" select="$domspec/library/interface/method[@name = $methodName]"/>
+ <xsl:call-template name="produce-specific-method">
+ <xsl:with-param name="method" select="$methods[1]"/>
+ <!--<xsl:with-param name="vardefs" select="$vardefs"/>-->
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="produce-specific-method">
+ <xsl:param name="method"/>
+ <xsl:variable name="current" select="."/>
+ <xsl:variable name="obj" select="@obj"/>
+ <!--<xsl:variable name="var" select="@var"/>-->
+
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="convert_method_name">
+ <xsl:with-param name="method_target"><xsl:value-of select="//*[local-name() = 'var' and @name = $obj]/@type"/></xsl:with-param>
+ <xsl:with-param name="method_name"><xsl:value-of select="$method/@name"/></xsl:with-param>
+ </xsl:call-template>
+ <xsl:text>(</xsl:text><xsl:value-of select="@obj"/>
+ <xsl:for-each select="$method/parameters/param">
+ <xsl:variable name="paramDef" select="."/>
+ <xsl:text>, </xsl:text><xsl:value-of select="$current/@*[name() = $paramDef/@name]"/>
+ </xsl:for-each>
+ <xsl:if test="@var">
+ <xsl:text>, &</xsl:text><xsl:value-of select="@var"/>
+ </xsl:if>
+ <xsl:text>);</xsl:text>
</xsl:template>
<xsl:template name="produce-attribute">
@@ -219,6 +258,7 @@
</xsl:if>
</xsl:template>
+
<!--
================================
Assert templates
@@ -329,6 +369,29 @@
</xsl:template>
<!--
+Method name is in the form dom_<type>_<methodName>
+For example, dom_document_create_element
+-->
+<xsl:template name="convert_method_name">
+ <xsl:param name="method_target"/>
+ <xsl:param name="method_name"/>
+ <xsl:message><xsl:value-of select="$method_name"/></xsl:message>
+ <xsl:call-template name="convert_var_type">
+ <xsl:with-param name="var_type"><xsl:value-of select="$method_target"/></xsl:with-param>
+ </xsl:call-template>
+ <xsl:text>_</xsl:text>
+ <xsl:choose>
+ <xsl:when test="$method_name = 'createElement'">
+ <xsl:text>create_element</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- assume no conversion is needed -->
+ <xsl:text><xsl:value-of select="$method_name"/></xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!--
stolen from test-to-java.xsl
Prepends every line with asterisks, suitable for use in a block comment
-->
15 years, 10 months