| 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 {%- if variant -%} | 5 {%- if variant -%} |
| 6 {%- set variant_path = "%s-%s"|format(module.path, variant) -%} | 6 {%- set variant_path = "%s-%s"|format(module.path, variant) -%} |
| 7 {%- else -%} | 7 {%- else -%} |
| 8 {%- set variant_path = module.path -%} | 8 {%- set variant_path = module.path -%} |
| 9 {%- endif -%} | 9 {%- endif -%} |
| 10 | 10 |
| 11 {%- set header_guard = "%s_H_"|format( | 11 {%- set header_guard = "%s_H_"|format( |
| 12 variant_path|upper|replace("/","_")|replace(".","_")| | 12 variant_path|upper|replace("/","_")|replace(".","_")| |
| 13 replace("-", "_")) %} | 13 replace("-", "_")) %} |
| 14 | 14 |
| 15 {%- from "enum_macros.tmpl" import enum_decl %} |
| 16 {%- from "enum_macros.tmpl" import enum_stream_operator %} |
| 17 {%- from "enum_macros.tmpl" import is_known_enum_value %} |
| 18 {%- from "enum_macros.tmpl" import enum_hash %} |
| 19 |
| 20 {%- macro namespace_begin() %} |
| 21 {%- for namespace in namespaces_as_array %} |
| 22 namespace {{namespace}} { |
| 23 {%- endfor %} |
| 24 {%- if variant %} |
| 25 namespace {{variant}} { |
| 26 {%- endif %} |
| 27 {%- endmacro %} |
| 28 |
| 29 {%- macro namespace_end() %} |
| 30 {%- if variant %} |
| 31 } // namespace {{variant}} |
| 32 {%- endif %} |
| 33 {%- for namespace in namespaces_as_array|reverse %} |
| 34 } // namespace {{namespace}} |
| 35 {%- endfor %} |
| 36 {%- endmacro %} |
| 37 |
| 15 #ifndef {{header_guard}} | 38 #ifndef {{header_guard}} |
| 16 #define {{header_guard}} | 39 #define {{header_guard}} |
| 17 | 40 |
| 18 #include <stdint.h> | 41 #include <stdint.h> |
| 42 |
| 43 #include <functional> |
| 19 #include <ostream> | 44 #include <ostream> |
| 20 #include <type_traits> | 45 #include <type_traits> |
| 21 #include <utility> | 46 #include <utility> |
| 22 | 47 |
| 23 #include "base/callback.h" | 48 #include "base/callback.h" |
| 49 #include "base/optional.h" |
| 24 #include "base/strings/string_piece.h" | 50 #include "base/strings/string_piece.h" |
| 25 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" | 51 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" |
| 26 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" | 52 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" |
| 27 #include "mojo/public/cpp/bindings/associated_interface_request.h" | 53 #include "mojo/public/cpp/bindings/associated_interface_request.h" |
| 28 #include "mojo/public/cpp/bindings/interface_ptr.h" | 54 #include "mojo/public/cpp/bindings/interface_ptr.h" |
| 29 #include "mojo/public/cpp/bindings/interface_request.h" | 55 #include "mojo/public/cpp/bindings/interface_request.h" |
| 30 #include "mojo/public/cpp/bindings/lib/control_message_handler.h" | 56 #include "mojo/public/cpp/bindings/lib/control_message_handler.h" |
| 31 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" | 57 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" |
| 32 #include "mojo/public/cpp/bindings/lib/serialization.h" | 58 #include "mojo/public/cpp/bindings/lib/serialization.h" |
| 33 #include "mojo/public/cpp/bindings/map.h" | 59 #include "mojo/public/cpp/bindings/map.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 44 {%- else %} | 70 {%- else %} |
| 45 #include "{{import.module.path}}.h" | 71 #include "{{import.module.path}}.h" |
| 46 {%- endif %} | 72 {%- endif %} |
| 47 {%- endfor %} | 73 {%- endfor %} |
| 48 {%- if not for_blink %} | 74 {%- if not for_blink %} |
| 49 #include "mojo/public/cpp/bindings/array.h" | 75 #include "mojo/public/cpp/bindings/array.h" |
| 50 #include "mojo/public/cpp/bindings/string.h" | 76 #include "mojo/public/cpp/bindings/string.h" |
| 51 {%- else %} | 77 {%- else %} |
| 52 #include "mojo/public/cpp/bindings/wtf_array.h" | 78 #include "mojo/public/cpp/bindings/wtf_array.h" |
| 53 #include "mojo/public/cpp/bindings/wtf_map.h" | 79 #include "mojo/public/cpp/bindings/wtf_map.h" |
| 80 #include "third_party/WebKit/Source/wtf/Optional.h" |
| 54 #include "third_party/WebKit/Source/wtf/text/WTFString.h" | 81 #include "third_party/WebKit/Source/wtf/text/WTFString.h" |
| 55 {%- endif %} | 82 {%- endif %} |
| 56 | 83 |
| 57 {%- for header in extra_public_headers %} | 84 {%- for header in extra_public_headers %} |
| 58 #include "{{header}}" | 85 #include "{{header}}" |
| 59 {%- endfor %} | 86 {%- endfor %} |
| 60 | 87 |
| 61 {%- for namespace in namespaces_as_array %} | |
| 62 namespace {{namespace}} { | |
| 63 {%- endfor %} | |
| 64 {%- if variant %} | |
| 65 namespace {{variant}} { | |
| 66 {%- endif %} | |
| 67 | |
| 68 {#--- Enums #} | 88 {#--- Enums #} |
| 69 {% from "enum_macros.tmpl" import enum_decl -%} | 89 {%- if enums %} |
| 70 {% from "enum_macros.tmpl" import enum_stream_operator -%} | 90 {{namespace_begin()}} |
| 71 {% from "enum_macros.tmpl" import is_known_enum_value -%} | 91 {%- for enum in enums %} |
| 72 {%- for enum in enums %} | 92 {%- if enum|is_native_only_kind %} |
| 73 {%- if enum|is_native_only_kind %} | |
| 74 using {{enum.name}} = mojo::NativeEnum; | 93 using {{enum.name}} = mojo::NativeEnum; |
| 75 {%- else %} | 94 {%- else %} |
| 76 {{enum_decl(enum)}} | 95 {{enum_decl(enum)}} |
| 77 {{enum_stream_operator(enum)}} | 96 {{enum_stream_operator(enum)}} |
| 78 {{is_known_enum_value(enum)}} | 97 {{is_known_enum_value(enum)}} |
| 79 {%- endif %} | 98 {%- endif %} |
| 80 {%- endfor %} | 99 {%- endfor %} |
| 100 {{namespace_end()}} |
| 101 |
| 102 namespace std { |
| 103 |
| 104 {%- for enum in enums %} |
| 105 {%- if not enum|is_native_only_kind %} |
| 106 {{enum_hash(enum)}} |
| 107 {%- endif %} |
| 108 {%- endfor %} |
| 109 |
| 110 } // namespace std |
| 111 {%- endif %} |
| 112 |
| 113 {{namespace_begin()}} |
| 81 | 114 |
| 82 {#--- Constants #} | 115 {#--- Constants #} |
| 83 {%- for constant in module.constants %} | 116 {%- for constant in module.constants %} |
| 84 {#- To be consistent with constants defined inside interfaces, only make | 117 {#- To be consistent with constants defined inside interfaces, only make |
| 85 integral types compile-time constants. #} | 118 integral types compile-time constants. #} |
| 86 {%- if constant.kind|is_integral_kind %} | 119 {%- if constant.kind|is_integral_kind %} |
| 87 const {{constant.kind|cpp_pod_type}} {{constant.name}} = {{constant|constant_val
ue}}; | 120 const {{constant.kind|cpp_pod_type}} {{constant.name}} = {{constant|constant_val
ue}}; |
| 88 {%- else %} | 121 {%- else %} |
| 89 extern const {{constant.kind|cpp_pod_type}} {{constant.name}}; | 122 extern const {{constant.kind|cpp_pod_type}} {{constant.name}}; |
| 90 {%- endif %} | 123 {%- endif %} |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 {% if union|should_inline_union %} | 159 {% if union|should_inline_union %} |
| 127 typedef mojo::InlinedStructPtr<{{union.name}}> {{union.name}}Ptr; | 160 typedef mojo::InlinedStructPtr<{{union.name}}> {{union.name}}Ptr; |
| 128 {% else %} | 161 {% else %} |
| 129 typedef mojo::StructPtr<{{union.name}}> {{union.name}}Ptr; | 162 typedef mojo::StructPtr<{{union.name}}> {{union.name}}Ptr; |
| 130 {% endif %} | 163 {% endif %} |
| 131 {%- endfor %} | 164 {%- endfor %} |
| 132 | 165 |
| 133 {#--- Interfaces -#} | 166 {#--- Interfaces -#} |
| 134 {% for interface in interfaces %} | 167 {% for interface in interfaces %} |
| 135 {% include "interface_declaration.tmpl" %} | 168 {% include "interface_declaration.tmpl" %} |
| 169 |
| 170 {%- if interface.enums %} |
| 171 {{namespace_end()}} |
| 172 namespace std { |
| 173 |
| 174 {%- for enum in interface.enums %} |
| 175 {%- if not enum|is_native_only_kind %} |
| 176 {{enum_hash(enum)}} |
| 177 {%- endif %} |
| 178 {%- endfor %} |
| 179 |
| 180 } // namespace std |
| 181 {{namespace_begin()}} |
| 182 {%- endif %} |
| 183 |
| 184 {%- for enum in interface.enums %} |
| 185 {%- if not enum|is_native_only_kind %} |
| 186 {{enum_stream_operator(enum)}} |
| 187 {{is_known_enum_value(enum)}} |
| 188 {%- endif %} |
| 189 {%- endfor %} |
| 136 {%- endfor %} | 190 {%- endfor %} |
| 137 | 191 |
| 138 {#--- Interface Proxies -#} | 192 {#--- Interface Proxies -#} |
| 139 {% for interface in interfaces %} | 193 {% for interface in interfaces %} |
| 140 {% include "interface_proxy_declaration.tmpl" %} | 194 {% include "interface_proxy_declaration.tmpl" %} |
| 141 {%- endfor %} | 195 {%- endfor %} |
| 142 | 196 |
| 143 {#--- Interface Stubs -#} | 197 {#--- Interface Stubs -#} |
| 144 {% for interface in interfaces %} | 198 {% for interface in interfaces %} |
| 145 {% include "interface_stub_declaration.tmpl" %} | 199 {% include "interface_stub_declaration.tmpl" %} |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 237 |
| 184 {%- for union in unions %} | 238 {%- for union in unions %} |
| 185 {% include "wrapper_union_class_template_definition.tmpl" %} | 239 {% include "wrapper_union_class_template_definition.tmpl" %} |
| 186 {%- endfor %} | 240 {%- endfor %} |
| 187 | 241 |
| 188 {%- for struct in structs %} | 242 {%- for struct in structs %} |
| 189 {%- if not struct|is_native_only_kind %} | 243 {%- if not struct|is_native_only_kind %} |
| 190 {% include "wrapper_class_template_definition.tmpl" %} | 244 {% include "wrapper_class_template_definition.tmpl" %} |
| 191 {%- endif %} | 245 {%- endif %} |
| 192 | 246 |
| 247 {%- if struct.enums %} |
| 248 {{namespace_end()}} |
| 249 namespace std { |
| 250 |
| 251 {%- for enum in struct.enums %} |
| 252 {%- if not enum|is_native_only_kind %} |
| 253 {{enum_hash(enum)}} |
| 254 {%- endif %} |
| 255 {%- endfor %} |
| 256 |
| 257 } // namespace std |
| 258 {{namespace_begin()}} |
| 259 {%- endif %} |
| 260 |
| 193 {%- for enum in struct.enums %} | 261 {%- for enum in struct.enums %} |
| 194 {%- if not enum|is_native_only_kind %} | 262 {%- if not enum|is_native_only_kind %} |
| 195 {{enum_stream_operator(enum)}} | 263 {{enum_stream_operator(enum)}} |
| 196 {{is_known_enum_value(enum)}} | 264 {{is_known_enum_value(enum)}} |
| 197 {%- endif %} | |
| 198 {%- endfor %} | |
| 199 {%- endfor %} | |
| 200 | |
| 201 {%- for interface in interfaces %} | |
| 202 {%- for enum in interface.enums %} | |
| 203 {%- if not enum|is_native_only_kind %} | |
| 204 {{enum_stream_operator(enum)}} | |
| 205 {{is_known_enum_value(enum)}} | |
| 206 {%- endif %} | 265 {%- endif %} |
| 207 {%- endfor %} | 266 {%- endfor %} |
| 208 {%- endfor %} | 267 {%- endfor %} |
| 209 | 268 |
| 210 {%- if variant %} | 269 {{namespace_end()}} |
| 211 } // namespace {{variant}} | |
| 212 {%- endif %} | |
| 213 {%- for namespace in namespaces_as_array|reverse %} | |
| 214 } // namespace {{namespace}} | |
| 215 {%- endfor %} | |
| 216 | 270 |
| 217 namespace mojo { | 271 namespace mojo { |
| 218 | 272 |
| 219 {#--- Enum Serialization Helpers -#} | 273 {#--- Enum Serialization Helpers -#} |
| 220 {%- for enum in enums %} | 274 {%- for enum in enums %} |
| 221 {%- if not enum|is_native_only_kind %} | 275 {%- if not enum|is_native_only_kind %} |
| 222 {% include "enum_serialization_declaration.tmpl" %} | 276 {% include "enum_serialization_declaration.tmpl" %} |
| 223 {%- endif %} | 277 {%- endif %} |
| 224 {%- endfor %} | 278 {%- endfor %} |
| 225 | 279 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 249 {#--- Union Serialization Helpers -#} | 303 {#--- Union Serialization Helpers -#} |
| 250 {% if unions %} | 304 {% if unions %} |
| 251 {%- for union in unions %} | 305 {%- for union in unions %} |
| 252 {% include "union_serialization_declaration.tmpl" %} | 306 {% include "union_serialization_declaration.tmpl" %} |
| 253 {%- endfor %} | 307 {%- endfor %} |
| 254 {%- endif %} | 308 {%- endif %} |
| 255 | 309 |
| 256 } // namespace mojo | 310 } // namespace mojo |
| 257 | 311 |
| 258 #endif // {{header_guard}} | 312 #endif // {{header_guard}} |
| OLD | NEW |