OLD | NEW |
1 {#--- Begin #} | 1 {#--- Begin #} |
2 {%- import "encoding_macros.tmpl" as encoding_macros %} | 2 {%- import "encoding_macros.tmpl" as encoding_macros %} |
3 {%- macro struct_def(struct) %} | 3 {%- import "mojom_type_macros.tmpl" as mojom_type_macros %} |
| 4 {%- macro struct_def(struct, typepkg, package) %} |
4 {#--- Enums #} | 5 {#--- Enums #} |
5 {%- from "enum_definition.tmpl" import enum_def %} | 6 {%- from "enum_definition.tmpl" import enum_def %} |
6 {%- for enum in struct.enums %} | 7 {%- for enum in struct.enums %} |
7 {{enum_def(enum)}} | 8 {{enum_def(enum, typepkg, package)}} |
8 {%- endfor %} | 9 {%- endfor %} |
9 | 10 |
10 class {{struct|name}} extends bindings.Struct { | 11 class {{struct|name}} extends bindings.Struct { |
11 static const List<bindings.StructDataHeader> kVersions = const [ | 12 static const List<bindings.StructDataHeader> kVersions = const [ |
12 {%- for version in struct.versions %} | 13 {%- for version in struct.versions %} |
13 const bindings.StructDataHeader({{version.num_bytes}}, {{version.version}}){
% if not loop.last %},{% endif %} | 14 const bindings.StructDataHeader({{version.num_bytes}}, {{version.version}}){
% if not loop.last %},{% endif %} |
14 {%- endfor %} | 15 {%- endfor %} |
15 ]; | 16 ]; |
16 | 17 |
17 {#--- Constants #} | 18 {#--- Constants #} |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 {%- for packed_field in struct.packed.packed_fields %} | 97 {%- for packed_field in struct.packed.packed_fields %} |
97 map["{{packed_field.field|name}}"] = {{packed_field.field|name}}; | 98 map["{{packed_field.field|name}}"] = {{packed_field.field|name}}; |
98 {%- endfor %} | 99 {%- endfor %} |
99 return map; | 100 return map; |
100 {%- else %} | 101 {%- else %} |
101 throw new bindings.MojoCodecError( | 102 throw new bindings.MojoCodecError( |
102 'Object containing handles cannot be encoded to JSON.'); | 103 'Object containing handles cannot be encoded to JSON.'); |
103 {%- endif %} | 104 {%- endif %} |
104 } | 105 } |
105 } | 106 } |
| 107 |
| 108 {% if should_gen_mojom_types -%} |
| 109 {{ mojom_type_macros.writeMojomTypeDef(struct, typepkg, package) }} |
| 110 {%- endif -%} |
106 {%- endmacro %} | 111 {%- endmacro %} |
OLD | NEW |