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

Side by Side Diff: mojom/generators/c/templates/interface.tmpl.go

Issue 2163793002: C bindings: Implement _Validate(), and some pre-requisites (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: address comments Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 package templates 5 package templates
6 6
7 const GenerateInterfaceDeclarations = ` 7 const GenerateInterfaceDeclarations = `
8 {{- /* . (dot) refers to the Go type |cgen.InterfaceTemplate| */ -}} 8 {{- /* . (dot) refers to the Go type |cgen.InterfaceTemplate| */ -}}
9 {{define "GenerateInterfaceDeclarations" -}} 9 {{define "GenerateInterfaceDeclarations" -}}
10 {{- $interface := . -}} 10 {{- $interface := . -}}
(...skipping 12 matching lines...) Expand all
23 {{end}} 23 {{end}}
24 24
25 {{range $message := $interface.Messages -}} 25 {{range $message := $interface.Messages -}}
26 // Message: {{$message.Name}} 26 // Message: {{$message.Name}}
27 27
28 #define {{$interface.Name}}_{{$message.Name}}__Ordinal \ 28 #define {{$interface.Name}}_{{$message.Name}}__Ordinal \
29 ((uint32_t){{$message.MessageOrdinal}}) 29 ((uint32_t){{$message.MessageOrdinal}})
30 #define {{$interface.Name}}_{{$message.Name}}__MinVersion \ 30 #define {{$interface.Name}}_{{$message.Name}}__MinVersion \
31 ((uint32_t){{$message.MinVersion}}) 31 ((uint32_t){{$message.MinVersion}})
32 32
33
34 struct {{$message.RequestStruct.Name}}; 33 struct {{$message.RequestStruct.Name}};
35 {{template "GenerateStructDeclarations" $message.RequestStruct}} 34 {{template "GenerateStructDeclarations" $message.RequestStruct}}
36 {{if ne $message.ResponseStruct.Name "" -}} 35 {{if ne $message.ResponseStruct.Name "" -}}
37 #define {{$interface.Name}}_{{$message.Name}}__HasResponse 1
38 struct {{$message.ResponseStruct.Name}}; 36 struct {{$message.ResponseStruct.Name}};
39 {{template "GenerateStructDeclarations" $message.ResponseStruct}} 37 {{template "GenerateStructDeclarations" $message.ResponseStruct}}
40 {{else}}
41 #define {{$interface.Name}}_{{$message.Name}}__HasResponse 0
42 {{end}} 38 {{end}}
43 {{end}} 39 {{end}}
44 {{end}} 40 {{end}}
45 ` 41 `
46 42
47 const GenerateInterfaceDefinitions = ` 43 const GenerateInterfaceDefinitions = `
48 {{- /* . (dot) refers to the Go type |cgen.InterfaceTemplate| */ -}} 44 {{- /* . (dot) refers to the Go type |cgen.InterfaceTemplate| */ -}}
49 {{define "GenerateInterfaceDefinitions" -}} 45 {{define "GenerateInterfaceDefinitions" -}}
50 {{- $interface := . -}} 46 {{- $interface := . -}}
51 {{range $const := $interface.Constants -}} 47 {{range $const := $interface.Constants -}}
52 const {{$const.Type}} {{$const.Name}} = {{$const.Value}}; 48 const {{$const.Type}} {{$const.Name}} = {{$const.Value}};
53 {{end -}} 49 {{end -}}
54 50
55 // Interface message struct definitions: 51 // Interface message struct definitions:
56 {{range $message := $interface.Messages -}} 52 {{range $message := $interface.Messages -}}
57 // Message: {{$message.Name}} 53 // Message: {{$message.Name}}
58 54
59 struct {{$message.RequestStruct.Name}}; 55 struct {{$message.RequestStruct.Name}};
60 {{template "GenerateStructDefinitions" $message.RequestStruct}} 56 {{template "GenerateStructDefinitions" $message.RequestStruct}}
61 {{if ne $message.ResponseStruct.Name "" -}} 57 {{if ne $message.ResponseStruct.Name "" -}}
62 struct {{$message.ResponseStruct.Name}}; 58 struct {{$message.ResponseStruct.Name}};
63 {{template "GenerateStructDefinitions" $message.ResponseStruct}} 59 {{template "GenerateStructDefinitions" $message.ResponseStruct}}
64 {{end}} 60 {{end}}
65 61
66 {{end}} 62 {{end}}
67 {{end}} 63 {{end}}
68 ` 64 `
OLDNEW
« no previous file with comments | « mojom/generators/c/cgen/type_translation.go ('k') | mojom/generators/c/templates/struct.tmpl.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698