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

Unified Diff: mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl

Issue 1508293004: Simplify Go's Mojom Type Generator (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Use hyphens in flag, not underscores Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/public/tools/bindings/generators/go_templates/mojom_type_macros.tmpl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl
diff --git a/mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl b/mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl
index d93f9024f3635af6c8ff60adb9cd2c047821e96e..fc130252c0f84681948da6545a3250de4e186906 100644
--- a/mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl
+++ b/mojo/public/tools/bindings/generators/go_templates/mojom_reference_macros.tmpl
@@ -3,18 +3,7 @@
// found in the LICENSE file.
{%- macro registerType(mapping, typepkg, pkg, type) -%}
-{%- if type|identifier|identifier_check('RegisterType') -%}{# Already printed out #}
-{%- elif type|package != '' -%} {# Don't print. That package will do it. #}
-{%- else -%}
-{{type|identifier|identifier_store('RegisterType')}}
-
-{%- if type|mojom_type(typepkg) != "" -%}{#- simple kind case: do nothing -#}
-{%- elif type|is_array -%}
-{{registerType(mapping, typepkg, pkg, type.kind)}}
-{%- elif type|is_map -%}
-{{registerType(mapping, typepkg, pkg, type.key_kind)}}
-{{registerType(mapping, typepkg, pkg, type.value_kind)}}
-{% elif type|is_enum %}
+{% if type|is_enum %}
{{mapping}}["{{type|mojom_type_identifier}}"] = &{{typepkg}}UserDefinedTypeEnumType{
Value: {{type|mojom_type_identifier}}(),
}
@@ -22,16 +11,10 @@
{{mapping}}["{{type|mojom_type_identifier}}"] = &{{typepkg}}UserDefinedTypeStructType{
Value: {{type|mojom_type_identifier}}(),
}
- {% for field in type.fields %}
-{{registerType(mapping, typepkg, pkg, field.kind)}}
- {% endfor %}
{% elif type|is_union %}
{{mapping}}["{{type|mojom_type_identifier}}"] = &{{typepkg}}UserDefinedTypeUnionType{
Value: {{type|mojom_type_identifier}}(),
}
- {% for field in type.fields %}
-{{registerType(mapping, typepkg, pkg, field.kind)}}
- {% endfor %}
{% elif type|is_interface %}
{{mapping}}["{{type|mojom_type_identifier}}"] = &{{typepkg}}UserDefinedTypeInterfaceType{
Value: {{type|mojom_type_identifier}}(),
@@ -42,10 +25,7 @@
{{registerType(mapping, typepkg, pkg, method.response_param_struct)}}
{%- endif %}
{%- endfor %}
-{% elif type|is_interface_request -%} {# No need to register anything #}
{%- else -%}
- ERROR: UNSUPPORTED TYPE
- {{type|identifier}}
-{%- endif -%}
+ {# Simple kinds, arrays, maps, and handles do not need to be registered. #}
{%- endif -%}
{%- endmacro -%}
« no previous file with comments | « no previous file | mojo/public/tools/bindings/generators/go_templates/mojom_type_macros.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698