summaryrefslogtreecommitdiff
path: root/include/dom/core
diff options
context:
space:
mode:
Diffstat (limited to 'include/dom/core')
-rw-r--r--include/dom/core/attr.h20
-rw-r--r--include/dom/core/characterdata.h8
-rw-r--r--include/dom/core/comment.h18
-rw-r--r--include/dom/core/document.h6
-rw-r--r--include/dom/core/element.h7
-rw-r--r--include/dom/core/exceptions.h3
-rw-r--r--include/dom/core/implementation.h11
-rw-r--r--include/dom/core/namednodemap.h9
-rw-r--r--include/dom/core/node.h40
-rw-r--r--include/dom/core/string.h16
-rw-r--r--include/dom/core/typeinfo.h48
11 files changed, 138 insertions, 48 deletions
diff --git a/include/dom/core/attr.h b/include/dom/core/attr.h
index b0d98c1..7ac3956 100644
--- a/include/dom/core/attr.h
+++ b/include/dom/core/attr.h
@@ -27,12 +27,13 @@ typedef struct dom_attr_vtable {
dom_exception (*dom_attr_get_name)(struct dom_attr *attr,
struct dom_string **result);
- dom_exception (*dom_attr_get_specified)(struct dom_attr *attr, bool *result);
+ dom_exception (*dom_attr_get_specified)(struct dom_attr *attr,
+ bool *result);
dom_exception (*dom_attr_get_value)(struct dom_attr *attr,
struct dom_string **result);
dom_exception (*dom_attr_set_value)(struct dom_attr *attr,
struct dom_string *value);
- dom_exception (*dom_attr_get_owner)(struct dom_attr *attr,
+ dom_exception (*dom_attr_get_owner_element)(struct dom_attr *attr,
struct dom_element **result);
dom_exception (*dom_attr_get_schema_type_info)(struct dom_attr *attr,
struct dom_type_info **result);
@@ -48,7 +49,8 @@ static inline dom_exception dom_attr_get_name(struct dom_attr *attr,
#define dom_attr_get_name(a, r) dom_attr_get_name((struct dom_attr *) (a), \
(struct dom_string **) (r))
-static inline dom_exception dom_attr_get_specified(struct dom_attr *attr, bool *result)
+static inline dom_exception dom_attr_get_specified(struct dom_attr *attr,
+ bool *result)
{
return ((dom_attr_vtable *) ((dom_node *) attr)->vtable)->
dom_attr_get_specified(attr, result);
@@ -74,17 +76,17 @@ static inline dom_exception dom_attr_set_value(struct dom_attr *attr,
#define dom_attr_set_value(a, v) dom_attr_set_value((struct dom_attr *) (a), \
(struct dom_string *) (v))
-static inline dom_exception dom_attr_get_owner(struct dom_attr *attr,
+static inline dom_exception dom_attr_get_owner_element(struct dom_attr *attr,
struct dom_element **result)
{
return ((dom_attr_vtable *) ((dom_node *) attr)->vtable)->
- dom_attr_get_owner(attr, result);
+ dom_attr_get_owner_element(attr, result);
}
-#define dom_attr_get_owner(a, r) dom_attr_get_owner((struct dom_attr *) (a), \
- (struct dom_element **) (r))
+#define dom_attr_get_owner_element(a, r) dom_attr_get_owner_element(\
+ (struct dom_attr *) (a), (struct dom_element **) (r))
-static inline dom_exception dom_attr_get_schema_type_info(struct dom_attr *attr,
- struct dom_type_info **result)
+static inline dom_exception dom_attr_get_schema_type_info(
+ struct dom_attr *attr, struct dom_type_info **result)
{
return ((dom_attr_vtable *) ((dom_node *) attr)->vtable)->
dom_attr_get_schema_type_info(attr, result);
diff --git a/include/dom/core/characterdata.h b/include/dom/core/characterdata.h
index de65c5a..745407c 100644
--- a/include/dom/core/characterdata.h
+++ b/include/dom/core/characterdata.h
@@ -113,7 +113,7 @@ static inline dom_exception dom_characterdata_delete_data(
return ((dom_characterdata_vtable *) ((dom_node *) cdata)->vtable)->
dom_characterdata_delete_data(cdata, offset, count);
}
-#define dom_characterdata_delete_data(c, o, ct) dom_characterdata_delete_data( \
+#define dom_characterdata_delete_data(c, o, ct) dom_characterdata_delete_data(\
(struct dom_characterdata *) (c), (unsigned long) (o), \
(unsigned long) (ct))
@@ -126,8 +126,8 @@ static inline dom_exception dom_characterdata_replace_data(
data);
}
#define dom_characterdata_replace_data(c, o, ct, d) \
- dom_characterdata_replace_data((struct dom_characterdata *) (c),\
- (unsigned long) (o), (unsigned long) (ct), \
- (struct dom_string *) (d))
+ dom_characterdata_replace_data(\
+ (struct dom_characterdata *) (c), (unsigned long) (o),\
+ (unsigned long) (ct), (struct dom_string *) (d))
#endif
diff --git a/include/dom/core/comment.h b/include/dom/core/comment.h
new file mode 100644
index 0000000..43b48c2
--- /dev/null
+++ b/include/dom/core/comment.h
@@ -0,0 +1,18 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#ifndef dom_core_comment_h_
+#define dom_core_comment_h_
+
+#include <stdbool.h>
+
+#include <dom/core/exceptions.h>
+#include <dom/core/characterdata.h>
+
+typedef struct dom_comment dom_comment;
+
+#endif
diff --git a/include/dom/core/document.h b/include/dom/core/document.h
index 193c084..1fe9752 100644
--- a/include/dom/core/document.h
+++ b/include/dom/core/document.h
@@ -9,6 +9,8 @@
#define dom_core_document_h_
#include <stdbool.h>
+#include <inttypes.h>
+#include <stddef.h>
#include <stdint.h>
#include <dom/core/exceptions.h>
@@ -29,6 +31,7 @@ struct dom_nodelist;
struct dom_processing_instruction;
struct dom_string;
struct dom_text;
+struct lwc_string_s;
typedef struct dom_document dom_document;
@@ -114,9 +117,6 @@ typedef struct dom_document_vtable {
struct dom_string *qname, struct dom_node **result);
} dom_document_vtable;
-dom_exception dom_document_create_string(struct dom_document *doc,
- const uint8_t *data, size_t len, struct dom_string **result);
-
static inline dom_exception dom_document_get_doctype(struct dom_document *doc,
struct dom_document_type **result)
{
diff --git a/include/dom/core/element.h b/include/dom/core/element.h
index c56e32c..4cffa2c 100644
--- a/include/dom/core/element.h
+++ b/include/dom/core/element.h
@@ -46,8 +46,9 @@ typedef struct dom_element_vtable {
struct dom_nodelist **result);
dom_exception (*dom_element_get_attribute_ns)(
struct dom_element *element,
- struct dom_string *namespace,
- struct dom_string *localname, struct dom_string **value);
+ struct dom_string *namespace,
+ struct dom_string *localname,
+ struct dom_string **value);
dom_exception (*dom_element_set_attribute_ns)(
struct dom_element *element,
struct dom_string *namespace, struct dom_string *qname,
@@ -211,7 +212,7 @@ static inline dom_exception dom_element_remove_attribute_ns(
dom_element_remove_attribute_ns(element, namespace,
localname);
}
-#define dom_element_remove_attribute_ns(e, n, l, v) \
+#define dom_element_remove_attribute_ns(e, n, l) \
dom_element_remove_attribute_ns((dom_element *) (e), \
(struct dom_string *) (n), (struct dom_string *) (l))
diff --git a/include/dom/core/exceptions.h b/include/dom/core/exceptions.h
index 18a2b6e..fc5e247 100644
--- a/include/dom/core/exceptions.h
+++ b/include/dom/core/exceptions.h
@@ -28,7 +28,8 @@ typedef enum {
DOM_INVALID_ACCESS_ERR = 15,
DOM_VALIDATION_ERR = 16,
DOM_TYPE_MISMATCH_ERR = 17,
- DOM_NO_MEM_ERR = (1<<16) /* our own internal error */
+ DOM_NO_MEM_ERR = (1<<16)
+ /* our own internal error */
} dom_exception;
#endif
diff --git a/include/dom/core/implementation.h b/include/dom/core/implementation.h
index d8959e6..cb95f84 100644
--- a/include/dom/core/implementation.h
+++ b/include/dom/core/implementation.h
@@ -30,20 +30,19 @@ dom_exception dom_implementation_has_feature(
dom_exception dom_implementation_create_document_type(
struct dom_implementation *impl, struct dom_string *qname,
struct dom_string *public_id, struct dom_string *system_id,
- struct dom_document_type **doctype,
- dom_alloc alloc, void *pw);
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ struct dom_document_type **doctype);
dom_exception dom_implementation_create_document(
struct dom_implementation *impl,
struct dom_string *namespace, struct dom_string *qname,
struct dom_document_type *doctype,
- struct dom_document **doc,
- dom_alloc alloc, void *pw);
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ struct dom_document **doc);
dom_exception dom_implementation_get_feature(
struct dom_implementation *impl,
struct dom_string *feature, struct dom_string *version,
- void **object,
- dom_alloc alloc, void *pw);
+ void **object);
#endif
diff --git a/include/dom/core/namednodemap.h b/include/dom/core/namednodemap.h
index fd2b754..a39983e 100644
--- a/include/dom/core/namednodemap.h
+++ b/include/dom/core/namednodemap.h
@@ -43,7 +43,7 @@ dom_exception _dom_namednodemap_remove_named_item(
#define dom_namednodemap_remove_named_item(m, n, r) \
_dom_namednodemap_remove_named_item((dom_namednodemap *) (m), \
- (dom_string *) (n), (dom_node **) (n))
+ (dom_string *) (n), (dom_node **) (r))
dom_exception _dom_namednodemap_item(struct dom_namednodemap *map,
@@ -60,7 +60,7 @@ dom_exception _dom_namednodemap_get_named_item_ns(
#define dom_namednodemap_get_named_item_ns(m, n, l, r) \
_dom_namednodemap_get_named_item_ns((dom_namednodemap *) (m), \
- (dom_string *) (n), (dom_string *) (l), (dom_node **) (n))
+ (dom_string *) (n), (dom_string *) (l), (dom_node **) (r))
dom_exception _dom_namednodemap_set_named_item_ns(
@@ -77,7 +77,8 @@ dom_exception _dom_namednodemap_remove_named_item_ns(
struct dom_string *localname, struct dom_node **node);
#define dom_namednodemap_remove_named_item_ns(m, n, l, r) \
- _dom_namednodemap_remove_named_item_ns((dom_namednodemap *) (m), \
- (dom_string *) (n), (dom_string *) (l), (dom_node **) (r))
+ _dom_namednodemap_remove_named_item_ns(\
+ (dom_namednodemap *) (m), (dom_string *) (n),\
+ (dom_string *) (l), (dom_node **) (r))
#endif
diff --git a/include/dom/core/node.h b/include/dom/core/node.h
index f525d0b..5e2d89a 100644
--- a/include/dom/core/node.h
+++ b/include/dom/core/node.h
@@ -127,7 +127,7 @@ typedef struct dom_node_vtable {
dom_node_internal **result);
dom_exception (*dom_node_normalize)(dom_node_internal *node);
dom_exception (*dom_node_is_supported)(dom_node_internal *node,
- struct dom_string *feature, dom_node_internal *version,
+ struct dom_string *feature, struct dom_string *version,
bool *result);
dom_exception (*dom_node_get_namespace)(dom_node_internal *node,
struct dom_string **result);
@@ -250,10 +250,11 @@ static inline dom_exception dom_node_get_last_child(struct dom_node *node,
#define dom_node_get_last_child(n, r) dom_node_get_last_child( \
(dom_node *) (n), (dom_node **) (r))
-static inline dom_exception dom_node_get_previous_sibling(struct dom_node *node,
- dom_node **result)
+static inline dom_exception dom_node_get_previous_sibling(
+ struct dom_node *node, dom_node **result)
{
- return ((dom_node_vtable *) node->vtable)->dom_node_get_previous_sibling(
+ return ((dom_node_vtable *) node->vtable)->
+ dom_node_get_previous_sibling(
(dom_node_internal *) node,
(dom_node_internal **) result);
}
@@ -367,16 +368,16 @@ static inline dom_exception dom_node_normalize(struct dom_node *node)
#define dom_node_normalize(n) dom_node_normalize((dom_node *) (n))
static inline dom_exception dom_node_is_supported(struct dom_node *node,
- struct dom_string *feature, struct dom_node *version,
+ struct dom_string *feature, struct dom_string *version,
bool *result)
{
return ((dom_node_vtable *) node->vtable)->dom_node_is_supported(
(dom_node_internal *) node, feature,
- (dom_node_internal *) version, result);
+ version, result);
}
#define dom_node_is_supported(n, f, v, r) dom_node_is_supported( \
- (dom_node *) (n), (struct dom_string *) (f), (dom_node *) (v),\
- (bool *) (r))
+ (dom_node *) (n), (struct dom_string *) (f), \
+ (struct dom_string *) (v), (bool *) (r))
static inline dom_exception dom_node_get_namespace(struct dom_node *node,
struct dom_string **result)
@@ -385,7 +386,7 @@ static inline dom_exception dom_node_get_namespace(struct dom_node *node,
(dom_node_internal *) node, result);
}
#define dom_node_get_namespace(n, r) dom_node_get_namespace((dom_node *) (n), \
- (struct dom_string *) (r))
+ (struct dom_string **) (r))
static inline dom_exception dom_node_get_prefix(struct dom_node *node,
struct dom_string **result)
@@ -394,7 +395,7 @@ static inline dom_exception dom_node_get_prefix(struct dom_node *node,
(dom_node_internal *) node, result);
}
#define dom_node_get_prefix(n, r) dom_node_get_prefix((dom_node *) (n), \
- (struct dom_string *) (r))
+ (struct dom_string **) (r))
static inline dom_exception dom_node_set_prefix(struct dom_node *node,
struct dom_string *prefix)
@@ -412,7 +413,7 @@ static inline dom_exception dom_node_get_local_name(struct dom_node *node,
(dom_node_internal *) node, result);
}
#define dom_node_get_local_name(n, r) dom_node_get_local_name((dom_node *) (n),\
- (struct dom_string *) (r))
+ (struct dom_string **) (r))
static inline dom_exception dom_node_has_attributes(struct dom_node *node,
bool *result)
@@ -436,9 +437,10 @@ static inline dom_exception dom_node_compare_document_position(
struct dom_node *node, struct dom_node *other,
uint16_t *result)
{
- return ((dom_node_vtable *) node->vtable)->dom_node_compare_document_position(
- (dom_node_internal *) node, (dom_node_internal *) other,
- result);
+ return ((dom_node_vtable *) node->vtable)->
+ dom_node_compare_document_position(
+ (dom_node_internal *) node,
+ (dom_node_internal *) other, result);
}
#define dom_node_compare_document_position(n, o, r) \
dom_node_compare_document_position((dom_node *) (n), \
@@ -483,13 +485,15 @@ static inline dom_exception dom_node_lookup_prefix(struct dom_node *node,
(dom_node *) (n), (struct dom_string *) (ns), \
(struct dom_string **) (r))
-static inline dom_exception dom_node_is_default_namespace(struct dom_node *node,
- struct dom_string *namespace, bool *result)
+static inline dom_exception dom_node_is_default_namespace(
+ struct dom_node *node, struct dom_string *namespace,
+ bool *result)
{
- return ((dom_node_vtable *) node->vtable)->dom_node_is_default_namespace(
+ return ((dom_node_vtable *) node->vtable)->
+ dom_node_is_default_namespace(
(dom_node_internal *) node, namespace, result);
}
-#define dom_node_is_default_namesapce(n, ns, r) dom_node_is_default_namespace(\
+#define dom_node_is_default_namespace(n, ns, r) dom_node_is_default_namespace(\
(dom_node *) (n), (struct dom_string *) (ns), (bool *) (r))
static inline dom_exception dom_node_lookup_namespace(struct dom_node *node,
diff --git a/include/dom/core/string.h b/include/dom/core/string.h
index 37d78d6..2502623 100644
--- a/include/dom/core/string.h
+++ b/include/dom/core/string.h
@@ -10,10 +10,12 @@
#include <inttypes.h>
#include <stddef.h>
+#include <libwapcaplet/libwapcaplet.h>
#include <dom/functypes.h>
#include <dom/core/exceptions.h>
+
typedef struct dom_string dom_string;
/* Claim a reference on a DOM string */
@@ -25,6 +27,14 @@ void dom_string_unref(struct dom_string *str);
dom_exception dom_string_create(dom_alloc alloc, void *pw,
const uint8_t *ptr, size_t len, struct dom_string **str);
+/* Clone a dom_string */
+dom_exception dom_string_clone(dom_alloc alloc, void *pw,
+ struct dom_string *str, struct dom_string **ret);
+
+/* Get the internal lwc_string */
+dom_exception dom_string_get_intern(struct dom_string *str,
+ struct lwc_context_s **ctx, struct lwc_string_s **lwcstr);
+
/* Case sensitively compare two DOM strings */
int dom_string_cmp(struct dom_string *s1, struct dom_string *s2);
/* Case insensitively compare two DOM strings */
@@ -38,6 +48,12 @@ uint32_t dom_string_rindex(struct dom_string *str, uint32_t chr);
/* Get the length, in characters, of a dom string */
uint32_t dom_string_length(struct dom_string *str);
+/* Get the UCS-4 character at position index, the index should be in
+ * [0, length), and length can be get by calling dom_string_length
+ */
+dom_exception dom_string_at(struct dom_string *str, uint32_t index,
+ uint32_t *ch);
+
/* Concatenate two dom strings */
dom_exception dom_string_concat(struct dom_string *s1, struct dom_string *s2,
struct dom_string **result);
diff --git a/include/dom/core/typeinfo.h b/include/dom/core/typeinfo.h
new file mode 100644
index 0000000..f285799
--- /dev/null
+++ b/include/dom/core/typeinfo.h
@@ -0,0 +1,48 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#ifndef dom_core_typeinfo_h_
+#define dom_core_typeinfo_h_
+
+#include <stdbool.h>
+
+#include <dom/core/exceptions.h>
+
+struct dom_string;
+
+typedef struct dom_type_info dom_type_info;
+
+typedef enum {
+ DOM_TYPE_INFO_DERIVATION_RESTRICTION = 0x00000001,
+ DOM_TYPE_INFO_DERIVATION_EXTENSION = 0x00000002,
+ DOM_TYPE_INFO_DERIVATION_UNION = 0x00000004,
+ DOM_TYPE_INFO_DERIVATION_LIST = 0x00000008
+} dom_type_info_derivation_method;
+
+dom_exception _dom_type_info_get_type_name(dom_type_info *ti,
+ struct dom_string **ret);
+#define dom_type_info_get_type_name(t, r) _dom_type_info_get_type_name( \
+ (dom_type_info *) (t), (struct dom_string **) (r))
+
+
+dom_exception _dom_type_info_get_type_namespace(dom_type_info *ti,
+ struct dom_string **ret);
+#define dom_type_info_get_type_namespace(t, r) \
+ _dom_type_info_get_type_namespace((dom_type_info *) (t),\
+ (struct dom_string **) (r))
+
+
+dom_exception _dom_type_info_is_derived(dom_type_info *ti,
+ struct dom_string *namespace, struct dom_string *name,
+ dom_type_info_derivation_method method, bool *ret);
+#define dom_type_info_is_derived(t, s, n, m, r) _dom_type_info_is_derived(\
+ (dom_type_info *) (t), (struct dom_string *) (s), \
+ (struct dom_string *) (n), \
+ (dom_type_info_derivation_method) (m), (bool *) (r))
+
+
+#endif