summaryrefslogtreecommitdiff
path: root/mojo/public/tools/bindings/generators/js_templates/module_definition.tmpl
blob: a119ee9480f0725a4afac7ba0b26567e48e5611c (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
{#--- Constants #}
{%- for constant in module.constants %}
  var {{constant.name}} = {{constant.value|expression_to_text}};
{%- endfor %}

{#--- Enums #}
{%- from "enum_definition.tmpl" import enum_def %}
{%- for enum in enums %}
  var {{ enum_def(enum.name, enum) }}
{%-  endfor %}

{#--- Struct definitions #}
{%  for struct in structs %}
{%-   include "struct_definition.tmpl" %}
{%- endfor -%}

{#--- Union definitions #}
{%- from "union_definition.tmpl" import union_def %}
{%- for union in unions %}
{{union_def(union)|indent(2)}}
{%- endfor %}

{#--- Interface definitions #}
{%- for interface in interfaces -%}
{%-   include "interface_definition.tmpl" %}
{%- endfor %}

{%- if use_new_js_bindings %}
  var exports = mojo.internal.exposeNamespace("{{module.namespace}}");
{%- else %}
  var exports = {};
{%- endif %}

{%- for constant in module.constants %}
  exports.{{constant.name}} = {{constant.name}};
{%- endfor %}
{%- for enum in enums %}
  exports.{{enum.name}} = {{enum.name}};
{%- endfor %}
{%- for struct in structs if struct.exported %}
  exports.{{struct.name}} = {{struct.name}};
{%- endfor %}
{%- for union in unions %}
  exports.{{union.name}} = {{union.name}};
{%- endfor %}
{%- for interface in interfaces %}
  exports.{{interface.name}} = {{interface.name}};
  exports.{{interface.name}}Ptr = {{interface.name}}Ptr;
{%- endfor %}