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

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

Issue 1345263002: Generate Mojom Types in Go (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Use unexported functions instead of variables Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/generators/go_templates/struct.tmpl
diff --git a/mojo/public/tools/bindings/generators/go_templates/struct.tmpl b/mojo/public/tools/bindings/generators/go_templates/struct.tmpl
index 444ffdb26e4cb0eb0b24f02fa4f93e0beb5cf418..a3da35aa97c1507e94a74a86c049cf7c74b3d8ff 100644
--- a/mojo/public/tools/bindings/generators/go_templates/struct.tmpl
+++ b/mojo/public/tools/bindings/generators/go_templates/struct.tmpl
@@ -3,8 +3,10 @@
// found in the LICENSE file.
{% import "encoding_macros.tmpl" as encoding_macros %}
+{% import "mojom_type_macros.tmpl" as mojom_type_macros %}
+{% import "mojom_util_macros.tmpl" as util %}
-{% macro define(struct, exported=True) %}
+{% macro define(struct, typepkg, package, exported=True) %}
type {{struct|name(exported)}} struct {
{% for field in struct.fields %}
{{field|name(exported)}} {{field.kind|go_type}}
@@ -63,4 +65,16 @@ func (s *{{struct|name(exported)}}) Decode(decoder *bindings.Decoder) error {
return nil
}
+// String names and labels used by the MojomStruct types.
+var (
+ structName_{{struct|name}} = "{{struct|name}}"
+{% for field in struct.fields %}
+ structFieldName_{{struct|name}}_{{field|name}} = "{{field|name}}"
+{% endfor %}
+)
+
+func {{util.typeName(struct, typepkg, package)}}() {{typepkg}}MojomStruct {
+ return {{ mojom_type_macros.writeMojomType(typepkg, struct, package, exported) }}
+}
+
{% endmacro %}

Powered by Google App Engine
This is Rietveld 408576698