OLD | NEW |
1 | 1 |
2 class {{struct.name}} { | 2 class {{struct.name}} { |
3 public: | 3 public: |
4 typedef internal::{{struct.name}}_Data Data_; | 4 typedef internal::{{struct.name}}_Data Data_; |
5 | 5 |
6 {#--- Constants #} | 6 {#--- Constants #} |
7 {%- for constant in struct.constants %} | 7 {%- for constant in struct.constants %} |
8 static const {{constant.kind|cpp_pod_type}} {{constant.name}}; | 8 static const {{constant.kind|cpp_pod_type}} {{constant.name}}; |
9 {%- endfor %} | 9 {%- endfor %} |
10 {#--- Enums #} | 10 {#--- Enums #} |
11 {%- for enum in struct.enums -%} | 11 {%- for enum in struct.enums -%} |
12 {% macro enum_def() %}{% include "enum_declaration.tmpl" %}{% endmacro %} | 12 {% macro enum_def() %}{% include "enum_declaration.tmpl" %}{% endmacro %} |
13 {{enum_def()|indent(2)}} | 13 {{enum_def()|indent(2)}} |
14 {%- endfor %} | 14 {%- endfor %} |
15 static {{struct.name}}Ptr New(); | 15 static {{struct.name}}Ptr New(); |
16 | 16 |
17 template <typename U> | 17 template <typename U> |
18 static {{struct.name}}Ptr From(const U& u) { | 18 static {{struct.name}}Ptr From(const U& u) { |
19 return mojo::TypeConverter<{{struct.name}}Ptr, U>::Convert(u); | 19 return mojo::TypeConverter<{{struct.name}}Ptr, U>::Convert(u); |
20 } | 20 } |
21 | 21 |
| 22 template <typename U> |
| 23 U To() const { |
| 24 return mojo::TypeConverter<U, {{struct.name}}>::Convert(*this); |
| 25 } |
| 26 |
22 {{struct.name}}(); | 27 {{struct.name}}(); |
23 ~{{struct.name}}(); | 28 ~{{struct.name}}(); |
24 | 29 |
25 {% if struct|is_cloneable_kind %} | 30 {% if struct|is_cloneable_kind %} |
26 {{struct.name}}Ptr Clone() const; | 31 {{struct.name}}Ptr Clone() const; |
27 {%- endif %} | 32 {%- endif %} |
28 bool Equals(const {{struct.name}}& other) const; | 33 bool Equals(const {{struct.name}}& other) const; |
29 | 34 |
30 {#--- Getters #} | 35 {#--- Getters #} |
31 {% for field in struct.fields %} | 36 {% for field in struct.fields %} |
32 {%- set type = field.kind|cpp_wrapper_type %} | 37 {%- set type = field.kind|cpp_wrapper_type %} |
33 {%- set name = field.name %} | 38 {%- set name = field.name %} |
34 {{type}} {{name}}; | 39 {{type}} {{name}}; |
35 {%- endfor %} | 40 {%- endfor %} |
36 }; | 41 }; |
OLD | NEW |