OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 {% import "struct.tmpl" as struct_macros %} | 5 {% import "struct.tmpl" as struct_macros %} |
6 {% import "mojom_type_macros.tmpl" as mojom_type_macros %} | |
7 | 6 |
8 {%- macro declare_params(struct) %} | 7 {%- macro declare_params(struct) %} |
9 {%- for field in struct.fields -%} | 8 {%- for field in struct.fields -%} |
10 {{field|name(False)}} {{field.kind|go_type}}{% if not loop.last %}, {% e
ndif %} | 9 {{field|name(False)}} {{field.kind|go_type}}{% if not loop.last %}, {% e
ndif %} |
11 {%- endfor %} | 10 {%- endfor %} |
12 {%- endmacro %} | 11 {%- endmacro %} |
13 | 12 |
14 | 13 |
15 | 14 |
16 {% macro declare_request_params(method) %} | 15 {% macro declare_request_params(method) %} |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 type {{interface|name}}_Factory interface { | 69 type {{interface|name}}_Factory interface { |
71 Create(request {{interface|name}}_Request) | 70 Create(request {{interface|name}}_Request) |
72 } | 71 } |
73 | 72 |
74 {% if interface.service_name %} | 73 {% if interface.service_name %} |
75 func (f *{{interface|name}}_ServiceFactory) Name() string { | 74 func (f *{{interface|name}}_ServiceFactory) Name() string { |
76 return {{interface|name(False)}}_Name | 75 return {{interface|name(False)}}_Name |
77 } | 76 } |
78 {% endif %} | 77 {% endif %} |
79 | 78 |
| 79 // TODO(rudominer) This should only be defined for top-level interfaces. |
80 func (f *{{interface|name}}_ServiceFactory) ServiceDescription() {{descpkg}}Serv
iceDescription { | 80 func (f *{{interface|name}}_ServiceFactory) ServiceDescription() {{descpkg}}Serv
iceDescription { |
81 return &{{interface|name}}_ServiceDescription{} | 81 return &{{interface|name}}_ServiceDescription{} |
82 } | 82 } |
83 | 83 |
84 func (f *{{interface|name}}_ServiceFactory) Create(messagePipe system.MessagePip
eHandle) { | 84 func (f *{{interface|name}}_ServiceFactory) Create(messagePipe system.MessagePip
eHandle) { |
85 request := {{interface|name}}_Request{bindings.NewMessagePipeHandleOwner
(messagePipe)} | 85 request := {{interface|name}}_Request{bindings.NewMessagePipeHandleOwner
(messagePipe)} |
86 f.Delegate.Create(request) | 86 f.Delegate.Create(request) |
87 } | 87 } |
88 | 88 |
89 // CreateMessagePipeFor{{interface|name}} creates a message pipe for use with th
e | 89 // CreateMessagePipeFor{{interface|name}} creates a message pipe for use with th
e |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 type {{interface|name(False)}}_Stub struct { | 176 type {{interface|name(False)}}_Stub struct { |
177 connector *bindings.Connector | 177 connector *bindings.Connector |
178 impl {{interface|name}} | 178 impl {{interface|name}} |
179 } | 179 } |
180 | 180 |
181 func New{{interface|name}}Stub(r {{interface|name}}_Request, impl {{interface|na
me}}, waiter bindings.AsyncWaiter) *bindings.Stub { | 181 func New{{interface|name}}Stub(r {{interface|name}}_Request, impl {{interface|na
me}}, waiter bindings.AsyncWaiter) *bindings.Stub { |
182 connector := bindings.NewConnector(r.PassMessagePipe(), waiter) | 182 connector := bindings.NewConnector(r.PassMessagePipe(), waiter) |
183 return bindings.NewStub(connector, &{{interface|name(False)}}_Stub{conne
ctor, impl}) | 183 return bindings.NewStub(connector, &{{interface|name(False)}}_Stub{conne
ctor, impl}) |
184 } | 184 } |
185 | 185 |
186 {{ mojom_type_macros.writeMojomTypeDef(typepkg, interface, pkg, exported) }} | |
187 | 186 |
188 func (f *{{interface|name}}_Request) ServiceDescription() {{descpkg}}ServiceDesc
ription { | 187 func (f *{{interface|name}}_Request) ServiceDescription() {{descpkg}}ServiceDesc
ription { |
189 return &{{interface|name}}_ServiceDescription{} | 188 return &{{interface|name}}_ServiceDescription{} |
190 } | 189 } |
191 | 190 |
192 | 191 |
193 type {{interface|name}}_ServiceDescription struct{} | 192 type {{interface|name}}_ServiceDescription struct{} |
194 | 193 |
195 {% if should_gen_mojom_types -%} | 194 {% if should_gen_mojom_types and interface.service_name-%} |
196 func (sd *{{interface|name}}_ServiceDescription) GetTopLevelInterface() (outMojo
mInterface {{typepkg}}MojomInterface, err error) { | 195 func (sd *{{interface|name}}_ServiceDescription) GetTopLevelInterface() (outMojo
mInterface {{typepkg}}MojomInterface, err error) { |
197 » return {{interface|mojom_type_identifier}}(), nil | 196 » interfaceTypeKey := runtimeTypeInfo__.ServicesByName["{{interface.servic
e_name}}"].TopLevelInterface |
| 197 » userDefinedType := runtimeTypeInfo__.TypeMap[interfaceTypeKey].(*{{typep
kg}}UserDefinedTypeInterfaceType) |
| 198 » return userDefinedType.Value, nil |
198 } | 199 } |
199 | 200 |
200 func (sd *{{interface|name}}_ServiceDescription) GetTypeDefinition(inTypeKey str
ing) (outType mojom_types.UserDefinedType, err error) { | 201 func (sd *{{interface|name}}_ServiceDescription) GetTypeDefinition(inTypeKey str
ing) (outType mojom_types.UserDefinedType, err error) { |
201 if udt, ok := GetAllMojomTypeDefinitions()[inTypeKey]; ok { | 202 if udt, ok := GetAllMojomTypeDefinitions()[inTypeKey]; ok { |
202 return udt, nil | 203 return udt, nil |
203 } | 204 } |
204 return nil, fmt.Errorf("%s_ServiceDescription does not recognize %s", "{
{interface|name}}", inTypeKey) | 205 return nil, fmt.Errorf("%s_ServiceDescription does not recognize %s", "{
{interface|name}}", inTypeKey) |
205 } | 206 } |
206 | 207 |
207 func (sd *{{interface|name}}_ServiceDescription) GetAllTypeDefinitions() (outDef
initions *map[string]mojom_types.UserDefinedType, err error) { | 208 func (sd *{{interface|name}}_ServiceDescription) GetAllTypeDefinitions() (outDef
initions *map[string]mojom_types.UserDefinedType, err error) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 default: | 279 default: |
279 return &bindings.ValidationError{ | 280 return &bindings.ValidationError{ |
280 bindings.MessageHeaderUnknownMethod, | 281 bindings.MessageHeaderUnknownMethod, |
281 fmt.Sprintf("unknown method %v", message.Header.Type), | 282 fmt.Sprintf("unknown method %v", message.Header.Type), |
282 } | 283 } |
283 } | 284 } |
284 return | 285 return |
285 } | 286 } |
286 | 287 |
287 {% endmacro %} | 288 {% endmacro %} |
OLD | NEW |