Index: mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl |
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl |
index a600f531f70344e5bca4f48b787c4f12f63b0008..279f937bfb35c4777bc74330474aefa3d67f20f7 100644 |
--- a/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl |
+++ b/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl |
@@ -169,14 +169,8 @@ typedef mojo::StructPtr<{{union.name}}> {{union.name}}Ptr; |
{% include "interface_response_validator_declaration.tmpl" %} |
{%- endfor %} |
-{#--- Unions must be declared first because they can be members of structs #} |
-{#--- Unions #} |
-{% for union in unions %} |
-{% include "wrapper_union_class_declaration.tmpl" %} |
-{%- endfor %} |
- |
-{#--- NOTE: Non-inlined structs may have pointers to inlined structs, so we #} |
-{#--- need to fully define inlined structs ahead of the others. #} |
+{#--- NOTE: Unions and non-inlined structs may have pointers to inlined structs, |
+ so we need to fully define inlined structs ahead of the others. #} |
{#--- Inlined structs #} |
{% for struct in structs %} |
@@ -186,6 +180,13 @@ typedef mojo::StructPtr<{{union.name}}> {{union.name}}Ptr; |
{% endif %} |
{%- endfor %} |
+{#--- Unions must be declared before non-inlined structs because they can be |
+ members of structs. #} |
+{#--- Unions #} |
+{% for union in unions %} |
+{% include "wrapper_union_class_declaration.tmpl" %} |
+{%- endfor %} |
+ |
{#--- Non-inlined structs #} |
{% for struct in structs %} |
{% if not struct|should_inline and not struct|is_native_only_kind %} |
@@ -194,7 +195,15 @@ typedef mojo::StructPtr<{{union.name}}> {{union.name}}Ptr; |
{% endif %} |
{%- endfor %} |
+{%- for union in unions %} |
+{% include "wrapper_union_class_template_definition.tmpl" %} |
+{%- endfor %} |
+ |
{%- for struct in structs %} |
+{%- if not struct|is_native_only_kind %} |
+{% include "wrapper_class_template_definition.tmpl" %} |
+{%- endif %} |
+ |
{%- for enum in struct.enums %} |
{{enum_stream_operator(enum)}} |
{{is_known_enum_value(enum)}} |