| OLD | NEW |
| 1 {#--- Constants #} | 1 {#--- Constants #} |
| 2 {%- for constant in module.constants %} | 2 {%- for constant in module.constants %} |
| 3 var {{constant.name}} = {{constant.value|expression_to_text}}; | 3 var {{constant.name}} = {{constant.value|expression_to_text}}; |
| 4 {%- endfor %} | 4 {%- endfor %} |
| 5 | 5 |
| 6 {#--- Enums #} | 6 {#--- Enums #} |
| 7 {%- from "enum_definition.tmpl" import enum_def %} | 7 {%- from "enum_definition.tmpl" import enum_def %} |
| 8 {%- for enum in enums %} | 8 {%- for enum in enums %} |
| 9 var {{ enum_def(enum.name, enum) }} | 9 var {{ enum_def(enum.name, enum) }} |
| 10 {%- endfor %} | 10 {%- endfor %} |
| 11 | 11 |
| 12 {#--- Struct definitions #} | 12 {#--- Struct definitions #} |
| 13 {% for struct in structs %} | 13 {% for struct in structs %} |
| 14 {%- include "struct_definition.tmpl" %} | 14 {%- include "struct_definition.tmpl" %} |
| 15 {%- endfor -%} | 15 {%- endfor -%} |
| 16 | 16 |
| 17 {#--- Union definitions #} | 17 {#--- Union definitions #} |
| 18 {%- from "union_definition.tmpl" import union_def %} | 18 {%- from "union_definition.tmpl" import union_def %} |
| 19 {%- for union in unions %} | 19 {%- for union in unions %} |
| 20 {{union_def(union)|indent(2)}} | 20 {{union_def(union)|indent(2)}} |
| 21 {%- endfor %} | 21 {%- endfor %} |
| 22 | 22 |
| 23 {#--- Interface definitions #} | 23 {#--- Interface definitions #} |
| 24 {%- for interface in interfaces -%} | 24 {%- for interface in interfaces -%} |
| 25 {%- include "interface_definition.tmpl" %} | 25 {%- include "interface_definition.tmpl" %} |
| 26 {%- endfor %} | 26 {%- endfor %} |
| 27 | 27 |
| 28 {%- if use_new_js_bindings %} | |
| 29 var exports = mojoBindings.internal.exposeNamespace("{{module.namespace}}"); | |
| 30 {%- else %} | |
| 31 var exports = {}; | 28 var exports = {}; |
| 32 {%- endif %} | 29 {%- for constant in module.constants %} |
| 33 | |
| 34 {%- for constant in module.constants %} | |
| 35 exports.{{constant.name}} = {{constant.name}}; | 30 exports.{{constant.name}} = {{constant.name}}; |
| 36 {%- endfor %} | 31 {%- endfor %} |
| 37 {%- for enum in enums %} | 32 {%- for enum in enums %} |
| 38 exports.{{enum.name}} = {{enum.name}}; | 33 exports.{{enum.name}} = {{enum.name}}; |
| 39 {%- endfor %} | 34 {%- endfor %} |
| 40 {%- for struct in structs if struct.exported %} | 35 {%- for struct in structs if struct.exported %} |
| 41 exports.{{struct.name}} = {{struct.name}}; | 36 exports.{{struct.name}} = {{struct.name}}; |
| 42 {%- endfor %} | 37 {%- endfor %} |
| 43 {%- for union in unions %} | 38 {%- for union in unions %} |
| 44 exports.{{union.name}} = {{union.name}}; | 39 exports.{{union.name}} = {{union.name}}; |
| 45 {%- endfor %} | 40 {%- endfor %} |
| 46 {%- for interface in interfaces %} | 41 {%- for interface in interfaces %} |
| 47 exports.{{interface.name}} = {{interface.name}}; | 42 exports.{{interface.name}} = {{interface.name}}; |
| 48 exports.{{interface.name}}Ptr = {{interface.name}}Ptr; | 43 exports.{{interface.name}}Ptr = {{interface.name}}Ptr; |
| 44 {#--- Interface Client #} |
| 45 {%- if interface.client in interfaces|map(attribute='name') %} |
| 46 exports.{{interface.name}}.client = {{interface.client}}; |
| 47 {%- elif interface.client in imported_interfaces %} |
| 48 exports.{{interface.name}}.client = {{imported_interfaces[interface.client]}}; |
| 49 {%- endif %} |
| 49 {%- endfor %} | 50 {%- endfor %} |
| OLD | NEW |