blob: ac5c7062a914bc0ba6cdbdf0766001c3c4ebfb02 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/* DOMTokenList binding for browser using duktape and libdom
*
* Copyright 2015 Vincent Sanders <vince@netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* Released under the terms of the MIT License,
* http://www.opensource.org/licenses/mit-license
*/
class DOMSettableTokenList {
};
init DOMSettableTokenList(struct dom_tokenlist *tokens::tokens);
getter DOMSettableTokenList::value()
%{
dom_exception exc;
dom_string *value;
exc = dom_tokenlist_get_value(priv->parent.tokens, &value);
if (exc != DOM_NO_ERR) return 0; /* coerced to undefined */
duk_push_lstring(ctx, dom_string_data(value), dom_string_length(value));
dom_string_unref(value);
return 1;
%}
setter DOMSettableTokenList::value()
%{
dom_exception exc;
dom_string *value;
duk_size_t slen;
const char *s = duk_require_lstring(ctx, 0, &slen);
exc = dom_string_create_interned((const uint8_t *)s, slen, &value);
if (exc != DOM_NO_ERR) return 0;
exc = dom_tokenlist_set_value(priv->parent.tokens, value);
dom_string_unref(value);
return 0;
%}
|