summaryrefslogtreecommitdiff
path: root/javascript/jsapi/nodelist.bnd
blob: 4aa8c47f50667e3c15c5ecad4c65e22673d041be (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* Binding to generate NodeList interface
 *
 * Copyright 2012 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
 */

/* The hdrcomment are added into the geenrated output comment header */
hdrcomment "Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>";
hdrcomment "This file is part of NetSurf, http://www.netsurf-browser.org/";
hdrcomment "Released under the terms of the MIT License,";
hdrcomment "        http://www.opensource.org/licenses/mit-license";

preamble %{

#include <dom/dom.h>
        
#include "utils/config.h"
#include "utils/log.h"
#include "javascript/jsapi.h"
#include "render/html_internal.h"

#include "nodelist.h"
#include "htmlelement.h"

%}

webidlfile "dom.idl";

binding nodelist {
	type js_libdom; /* the binding type */

	interface NodeList; /* The WebIDL interface to generate a binding for */

	private "dom_nodelist *" nodelist;
	private "struct html_content *" htmlc;
}

getter length %{
        dom_exception err;

        err = dom_nodelist_get_length(private->nodelist, &jsret);
        if (err != DOM_NO_ERR) {
                return JS_FALSE;
        }
%}
  
operation item %{
        dom_exception err;
        dom_node *domnode;

        err = dom_nodelist_item(private->nodelist, index, &domnode);
        if (err != DOM_NO_ERR)  {
                return JS_FALSE;
        }

        if (domnode != NULL) {
                jsret = jsapi_new_HTMLElement(cx, NULL, NULL, (dom_element *)domnode, private->htmlc);
        }
%}

api finalise %{
        if (private != NULL) {
                dom_nodelist_unref(private->nodelist);
        }
%}