Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl

Issue 923033003: Implement unions as members of structs. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 {#--- Union Forward Declarations -#} 56 {#--- Union Forward Declarations -#}
57 {% for union in unions %} 57 {% for union in unions %}
58 class {{union.name}}; 58 class {{union.name}};
59 {% if union|should_inline_union %} 59 {% if union|should_inline_union %}
60 typedef mojo::InlinedStructPtr<{{union.name}}> {{union.name}}Ptr; 60 typedef mojo::InlinedStructPtr<{{union.name}}> {{union.name}}Ptr;
61 {% else %} 61 {% else %}
62 typedef mojo::StructPtr<{{union.name}}> {{union.name}}Ptr; 62 typedef mojo::StructPtr<{{union.name}}> {{union.name}}Ptr;
63 {% endif %} 63 {% endif %}
64 {%- endfor %} 64 {%- endfor %}
65 65
66 {#--- Unions must be declared first because they can be members of structs #}
yzshen1 2015/02/17 19:34:35 Do we need to distinguish between "inlined unions"
azani 2015/02/18 00:27:57 I don't think so. Unions are never inlined in unio
67 {#--- Unions #}
68 {% for union in unions %}
69 {% include "wrapper_union_class_declaration.tmpl" %}
70 {%- endfor %}
71
66 {#--- NOTE: Non-inlined structs may have pointers to inlined structs, so we #} 72 {#--- NOTE: Non-inlined structs may have pointers to inlined structs, so we #}
67 {#--- need to fully define inlined structs ahead of the others. #} 73 {#--- need to fully define inlined structs ahead of the others. #}
68 74
69 {#--- Inlined structs #} 75 {#--- Inlined structs #}
70 {% for struct in structs %} 76 {% for struct in structs %}
71 {% if struct|should_inline %} 77 {% if struct|should_inline %}
72 {% include "wrapper_class_declaration.tmpl" %} 78 {% include "wrapper_class_declaration.tmpl" %}
73 {% endif %} 79 {% endif %}
74 {%- endfor %} 80 {%- endfor %}
75 81
76 {#--- Non-inlined structs #} 82 {#--- Non-inlined structs #}
77 {% for struct in structs %} 83 {% for struct in structs %}
78 {% if not struct|should_inline %} 84 {% if not struct|should_inline %}
79 {% include "wrapper_class_declaration.tmpl" %} 85 {% include "wrapper_class_declaration.tmpl" %}
80 {% endif %} 86 {% endif %}
81 {%- endfor %} 87 {%- endfor %}
82 88
83 {#--- Unions #}
84 {% for union in unions %}
85 {% include "wrapper_union_class_declaration.tmpl" %}
86 {%- endfor %}
87
88 {#--- Interfaces -#} 89 {#--- Interfaces -#}
89 {% for interface in interfaces %} 90 {% for interface in interfaces %}
90 {% include "interface_declaration.tmpl" %} 91 {% include "interface_declaration.tmpl" %}
91 {%- endfor %} 92 {%- endfor %}
92 93
93 {#--- Interface Proxies -#} 94 {#--- Interface Proxies -#}
94 {% for interface in interfaces %} 95 {% for interface in interfaces %}
95 {% include "interface_proxy_declaration.tmpl" %} 96 {% include "interface_proxy_declaration.tmpl" %}
96 {%- endfor %} 97 {%- endfor %}
97 98
(...skipping 25 matching lines...) Expand all
123 {% for union in unions %} 124 {% for union in unions %}
124 {{ serialization_macros.declare_serialization(union.name) }} 125 {{ serialization_macros.declare_serialization(union.name) }}
125 {%- endfor %} 126 {%- endfor %}
126 {%- endif %} 127 {%- endif %}
127 128
128 {%- for namespace in namespaces_as_array|reverse %} 129 {%- for namespace in namespaces_as_array|reverse %}
129 } // namespace {{namespace}} 130 } // namespace {{namespace}}
130 {%- endfor %} 131 {%- endfor %}
131 132
132 #endif // {{header_guard}} 133 #endif // {{header_guard}}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698