More (untested) Node stuff
This commit is contained in:
parent
dc7f0dce9f
commit
e46a705b0f
|
@ -44,9 +44,28 @@ getter Node::nodeName()
|
|||
return 1;
|
||||
%}
|
||||
|
||||
/*** @todo baseURI */
|
||||
getter Node::baseURI()
|
||||
%{
|
||||
dom_exception exc;
|
||||
dom_string *base;
|
||||
exc = dom_node_get_base(priv->node, &base);
|
||||
if (exc != DOM_NO_ERR) return 0;
|
||||
duk_push_lstring(ctx, dom_string_data(base), dom_string_length(base));
|
||||
dom_string_unref(base);
|
||||
return 1;
|
||||
%}
|
||||
|
||||
/*** @todo ownerDocument */
|
||||
getter Node::ownerDocument()
|
||||
%{
|
||||
dom_exception exc;
|
||||
dom_node *doc;
|
||||
exc = dom_node_get_owner_document(priv->node, &doc);
|
||||
if (exc != DOM_NO_ERR) return 0;
|
||||
if (doc == NULL) return 0;
|
||||
dukky_push_node(ctx, doc);
|
||||
dom_node_unref(doc);
|
||||
return 1;
|
||||
%}
|
||||
|
||||
getter Node::parentNode()
|
||||
%{
|
||||
|
@ -182,7 +201,18 @@ getter Node::nodeValue()
|
|||
return 0;
|
||||
%}
|
||||
|
||||
/*** @todo setter nodeValue */
|
||||
setter Node::nodeValue()
|
||||
%{
|
||||
dom_exception exc;
|
||||
dom_string *content;
|
||||
duk_size_t slen;
|
||||
const char *s = duk_safe_to_lstring(ctx, 0, &slen);
|
||||
exc = dom_string_create((const uint8_t *)s, slen, &content);
|
||||
if (exc != DOM_NO_ERR) return 0;
|
||||
exc = dom_node_set_node_value(priv->node, content);
|
||||
dom_string_unref(content);
|
||||
return 0;
|
||||
%}
|
||||
|
||||
getter Node::textContent()
|
||||
%{
|
||||
|
@ -202,13 +232,58 @@ getter Node::textContent()
|
|||
return 0;
|
||||
%}
|
||||
|
||||
/*** @todo setter textContent */
|
||||
setter Node::textContent()
|
||||
%{
|
||||
dom_exception exc;
|
||||
dom_string *content;
|
||||
duk_size_t slen;
|
||||
const char *s = duk_safe_to_lstring(ctx, 0, &slen);
|
||||
exc = dom_string_create((const uint8_t *)s, slen, &content);
|
||||
if (exc != DOM_NO_ERR) return 0;
|
||||
exc = dom_node_set_text_content(priv->node, content);
|
||||
dom_string_unref(content);
|
||||
return 0;
|
||||
%}
|
||||
|
||||
/*** @todo method normalize */
|
||||
method Node::normalize()
|
||||
%{
|
||||
dom_exception exc;
|
||||
exc = dom_node_normalize(priv->node);
|
||||
return 0;
|
||||
%}
|
||||
|
||||
/*** @todo method cloneNode */
|
||||
method Node::cloneNode()
|
||||
%{
|
||||
dom_exception exc;
|
||||
bool deep;
|
||||
dom_node *clone;
|
||||
|
||||
/*** @todo method isEqualNode */
|
||||
deep = duk_to_boolean(ctx, 0);
|
||||
|
||||
exc = dom_node_clone_node(priv->node, deep, &clone);
|
||||
if (exc != DOM_NO_ERR) return 0;
|
||||
duk_set_top(ctx, 0);
|
||||
dukky_push_node(ctx, clone);
|
||||
dom_node_unref(clone);
|
||||
return 1;
|
||||
%}
|
||||
|
||||
method Node::isEqualNode()
|
||||
%{
|
||||
dom_exception exc;
|
||||
bool result;
|
||||
|
||||
if (!dukky_instanceof_at(ctx, 0, PROTO_NAME(NODE))) return 0;
|
||||
|
||||
duk_get_prop_string(ctx, 0, PRIVATE_MAGIC);
|
||||
node_private_t *other = duk_get_pointer(ctx, -1);
|
||||
duk_pop(ctx);
|
||||
|
||||
exc = dom_node_is_equal(priv->node, other->node, &result);
|
||||
if (exc != DOM_NO_ERR) return 0;
|
||||
duk_push_boolean(ctx, result);
|
||||
return 1;
|
||||
%}
|
||||
|
||||
/*** @todo method compareDocumentPosition */
|
||||
|
||||
|
|
Loading…
Reference in New Issue