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

Unified Diff: third_party/mojo/src/mojo/public/tools/bindings/generators/go_templates/union.tmpl

Issue 1157573002: Revert "Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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: third_party/mojo/src/mojo/public/tools/bindings/generators/go_templates/union.tmpl
diff --git a/third_party/mojo/src/mojo/public/tools/bindings/generators/go_templates/union.tmpl b/third_party/mojo/src/mojo/public/tools/bindings/generators/go_templates/union.tmpl
deleted file mode 100644
index ccb8d5decea4f8a6c942246e7d20fb516886b70e..0000000000000000000000000000000000000000
--- a/third_party/mojo/src/mojo/public/tools/bindings/generators/go_templates/union.tmpl
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-{% import "encoding_macros.tmpl" as encoding_macros %}
-
-
-{% macro define(union, exported=True) %}
-type {{union|name(exported)}} interface {
- Tag() uint32
- Interface() interface{}
- __Reflect(__{{union|name(exported)}}Reflect)
- Encode(encoder *bindings.Encoder) error
-}
-
-type __{{union|name(exported)}}Reflect struct {
-{% for field in union.fields %}
- {{field|name(exported)}} {{field.kind|go_type}}
-{% endfor %}
-}
-
-func Decode{{union|name(exported)}}(decoder *bindings.Decoder) ({{union|name(exported)}}, error) {
- header, err := decoder.StartUnion()
- if err != nil {
- return nil, err
- }
-
- if header.Size == 0 {
- return nil, nil
- }
-
- switch header.ElementsOrVersion {
-{% for field in union.fields %}
- case {{field.ordinal}}:
- var value {{union|name(exported)}}{{field|name(exported)}}
- value.decodeInternal(decoder)
- decoder.Finish()
- return &value, nil
-{% endfor %}
- }
-
- return nil, fmt.Errorf("Unknown tag %d in {{union|name(exported)}}", header.ElementsOrVersion);
-}
-
-{% for field in union.fields %}
-{%- set struct_name = union|name(exported) + field|name(exported) %}
-type {{struct_name}} struct { Value {{field.kind|go_type}} }
-func (u *{{struct_name}}) Tag() uint32 { return {{field.ordinal}} }
-func (u *{{struct_name}}) Interface() interface{} { return u.Value }
-func (u *{{struct_name}}) __Reflect(__{{union|name(exported)}}Reflect) {}
-
-func (u *{{struct_name}}) Encode(encoder *bindings.Encoder) error {
- encoder.StartUnion(u.Tag())
- {{encoding_macros.encode('u.Value', field.kind)|tab_indent()}}
- encoder.Finish()
- return nil
-}
-
-func (u *{{struct_name}}) decodeInternal(decoder *bindings.Decoder) error {
- {{encoding_macros.decode('u.Value', field.kind)|tab_indent()}}
- return nil
-}
-
-{% endfor %}
-
-{% endmacro %}

Powered by Google App Engine
This is Rietveld 408576698