OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 {%- set header_guard = "%s_H_"| | 5 {%- set header_guard = "%s_H_"| |
6 format(module.path|upper|replace("/","_")|replace(".","_")) %} | 6 format(module.path|upper|replace("/","_")|replace(".","_")) %} |
7 | 7 |
8 #ifndef {{header_guard}} | 8 #ifndef {{header_guard}} |
9 #define {{header_guard}} | 9 #define {{header_guard}} |
10 | 10 |
11 #include "mojo/public/cpp/bindings/array.h" | 11 #include "mojo/public/cpp/bindings/array.h" |
12 #include "mojo/public/cpp/bindings/callback.h" | 12 #include "mojo/public/cpp/bindings/callback.h" |
13 #include "mojo/public/cpp/bindings/interface_impl.h" | 13 #include "mojo/public/cpp/bindings/interface_impl.h" |
14 #include "mojo/public/cpp/bindings/interface_ptr.h" | 14 #include "mojo/public/cpp/bindings/interface_ptr.h" |
15 #include "mojo/public/cpp/bindings/message_filter.h" | 15 #include "mojo/public/cpp/bindings/message_filter.h" |
16 #include "mojo/public/cpp/bindings/no_interface.h" | 16 #include "mojo/public/cpp/bindings/no_interface.h" |
| 17 #include "mojo/public/cpp/bindings/string.h" |
| 18 #include "mojo/public/cpp/bindings/struct_ptr.h" |
17 #include "{{module.path}}-internal.h" | 19 #include "{{module.path}}-internal.h" |
18 {%- for import in imports %} | 20 {%- for import in imports %} |
19 #include "{{import.module.path}}.h" | 21 #include "{{import.module.path}}.h" |
20 {%- endfor %} | 22 {%- endfor %} |
21 | 23 |
22 {%- for namespace in namespaces_as_array %} | 24 {%- for namespace in namespaces_as_array %} |
23 namespace {{namespace}} { | 25 namespace {{namespace}} { |
24 {%- endfor %} | 26 {%- endfor %} |
25 | 27 |
26 {#--- Constants #} | 28 {#--- Constants #} |
27 {% for constant in module.constants %} | 29 {% for constant in module.constants %} |
28 extern const {{constant.kind|cpp_pod_type}} {{constant.name}}; | 30 extern const {{constant.kind|cpp_pod_type}} {{constant.name}}; |
29 {%- endfor %} | 31 {%- endfor %} |
30 | 32 |
31 {#--- Enums #} | 33 {#--- Enums #} |
32 {% for enum in enums %} | 34 {% for enum in enums %} |
33 {% include "enum_declaration.tmpl" %} | 35 {% include "enum_declaration.tmpl" %} |
34 {%- endfor %} | 36 {%- endfor %} |
35 | 37 |
36 {#--- Interface Forward Declarations -#} | 38 {#--- Interface Forward Declarations -#} |
37 {% for interface in interfaces %} | 39 {% for interface in interfaces %} |
38 class {{interface.name}}; | 40 class {{interface.name}}; |
39 typedef mojo::InterfacePtr<{{interface.name}}> {{interface.name}}Ptr; | 41 typedef mojo::InterfacePtr<{{interface.name}}> {{interface.name}}Ptr; |
40 {% endfor %} | 42 {% endfor %} |
41 | 43 |
42 {#--- Structs #} | 44 {#--- Struct Forward Declarations -#} |
43 {% for struct in structs %} | 45 {% for struct in structs %} |
44 {% include "wrapper_class_declaration.tmpl" %} | 46 class {{struct.name}}; |
| 47 {% if struct|should_inline %} |
| 48 typedef mojo::InlinedStructPtr<{{struct.name}}> {{struct.name}}Ptr; |
| 49 {% else %} |
| 50 typedef mojo::StructPtr<{{struct.name}}> {{struct.name}}Ptr; |
| 51 {% endif %} |
| 52 {% endfor %} |
| 53 |
| 54 {#--- NOTE: Non-inlined structs may have pointers to inlined structs, so we #} |
| 55 {#--- need to fully define inlined structs ahead of the others. #} |
| 56 |
| 57 {#--- Inlined structs #} |
| 58 {% for struct in structs %} |
| 59 {% if struct|should_inline %} |
| 60 {% include "wrapper_class_declaration.tmpl" %} |
| 61 {% endif %} |
| 62 {%- endfor %} |
| 63 |
| 64 {#--- Non-inlined structs #} |
| 65 {% for struct in structs %} |
| 66 {% if not struct|should_inline %} |
| 67 {% include "wrapper_class_declaration.tmpl" %} |
| 68 {% endif %} |
45 {%- endfor %} | 69 {%- endfor %} |
46 | 70 |
47 {#--- Interfaces -#} | 71 {#--- Interfaces -#} |
48 {% for interface in interfaces %} | 72 {% for interface in interfaces %} |
49 {% include "interface_declaration.tmpl" %} | 73 {% include "interface_declaration.tmpl" %} |
50 {%- endfor %} | 74 {%- endfor %} |
51 | 75 |
52 {#--- Interface Proxies -#} | 76 {#--- Interface Proxies -#} |
53 {% for interface in interfaces %} | 77 {% for interface in interfaces %} |
54 {% include "interface_proxy_declaration.tmpl" %} | 78 {% include "interface_proxy_declaration.tmpl" %} |
55 {%- endfor %} | 79 {%- endfor %} |
56 | 80 |
57 {#--- Interface Stubs -#} | 81 {#--- Interface Stubs -#} |
58 {% for interface in interfaces %} | 82 {% for interface in interfaces %} |
59 {% include "interface_stub_declaration.tmpl" %} | 83 {% include "interface_stub_declaration.tmpl" %} |
60 {%- endfor %} | 84 {%- endfor %} |
61 | 85 |
62 {#--- Interface Request Validators -#} | 86 {#--- Interface Request Validators -#} |
63 {% for interface in interfaces %} | 87 {% for interface in interfaces %} |
64 {% include "interface_request_validator_declaration.tmpl" %} | 88 {% include "interface_request_validator_declaration.tmpl" %} |
65 {%- endfor %} | 89 {%- endfor %} |
66 | 90 |
67 {#--- Interface Response Validators -#} | 91 {#--- Interface Response Validators -#} |
68 {% for interface in interfaces if interface|has_callbacks %} | 92 {% for interface in interfaces if interface|has_callbacks %} |
69 {% include "interface_response_validator_declaration.tmpl" %} | 93 {% include "interface_response_validator_declaration.tmpl" %} |
70 {%- endfor %} | 94 {%- endfor %} |
71 | 95 |
| 96 {#--- Struct Serialization Helpers -#} |
| 97 {% if structs %} |
| 98 {% for struct in structs %} |
| 99 {% include "struct_serialization_declaration.tmpl" %} |
| 100 {%- endfor %} |
| 101 {%- endif %} |
| 102 |
72 {%- for namespace in namespaces_as_array|reverse %} | 103 {%- for namespace in namespaces_as_array|reverse %} |
73 } // namespace {{namespace}} | 104 } // namespace {{namespace}} |
74 {%- endfor %} | 105 {%- endfor %} |
75 | 106 |
76 {#--- Enum TypeTraits Specializations #} | |
77 {% if enums %} | |
78 namespace mojo { | |
79 namespace internal { | |
80 {% for enum in enums %} | |
81 {% include "enum_traits.tmpl" %} | |
82 {%- endfor %} | |
83 } // namespace internal | |
84 } // namespace mojo | |
85 {%- endif %} | |
86 | |
87 #endif // {{header_guard}} | 107 #endif // {{header_guard}} |
OLD | NEW |