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

Side by Side Diff: mojo/public/tools/bindings/generators/mojom_cpp_generator.py

Issue 376383002: Mojo: Add support for InterfacePtr as a struct member (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: retry Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/struct_serialization_definition.tmpl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 """Generates C++ source files from a mojom.Module.""" 5 """Generates C++ source files from a mojom.Module."""
6 6
7 import mojom.generate.generator as generator 7 import mojom.generate.generator as generator
8 import mojom.generate.module as mojom 8 import mojom.generate.module as mojom
9 import mojom.generate.pack as pack 9 import mojom.generate.pack as pack
10 from mojom.generate.template_expander import UseJinja 10 from mojom.generate.template_expander import UseJinja
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return _kind_to_cpp_type[kind] 121 return _kind_to_cpp_type[kind]
122 122
123 def GetCppWrapperType(kind): 123 def GetCppWrapperType(kind):
124 if isinstance(kind, mojom.Enum): 124 if isinstance(kind, mojom.Enum):
125 return GetNameForKind(kind) 125 return GetNameForKind(kind)
126 if isinstance(kind, mojom.Struct): 126 if isinstance(kind, mojom.Struct):
127 return "%sPtr" % GetNameForKind(kind) 127 return "%sPtr" % GetNameForKind(kind)
128 if isinstance(kind, (mojom.Array, mojom.FixedArray)): 128 if isinstance(kind, (mojom.Array, mojom.FixedArray)):
129 return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind) 129 return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind)
130 if isinstance(kind, mojom.Interface): 130 if isinstance(kind, mojom.Interface):
131 return "mojo::ScopedMessagePipeHandle" 131 return "%sPtr" % GetNameForKind(kind)
132 if isinstance(kind, mojom.InterfaceRequest): 132 if isinstance(kind, mojom.InterfaceRequest):
133 raise Exception("InterfaceRequest fields not supported!") 133 raise Exception("InterfaceRequest fields not supported!")
134 if kind.spec == 's': 134 if kind.spec == 's':
135 return "mojo::String" 135 return "mojo::String"
136 if kind.spec == 'h': 136 if kind.spec == 'h':
137 return "mojo::ScopedHandle" 137 return "mojo::ScopedHandle"
138 if kind.spec == 'h:d:c': 138 if kind.spec == 'h:d:c':
139 return "mojo::ScopedDataPipeConsumerHandle" 139 return "mojo::ScopedDataPipeConsumerHandle"
140 if kind.spec == 'h:d:p': 140 if kind.spec == 'h:d:p':
141 return "mojo::ScopedDataPipeProducerHandle" 141 return "mojo::ScopedDataPipeProducerHandle"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 279
280 @UseJinja("cpp_templates/module.cc.tmpl", filters=cpp_filters) 280 @UseJinja("cpp_templates/module.cc.tmpl", filters=cpp_filters)
281 def GenerateModuleSource(self): 281 def GenerateModuleSource(self):
282 return self.GetJinjaExports() 282 return self.GetJinjaExports()
283 283
284 def GenerateFiles(self, args): 284 def GenerateFiles(self, args):
285 self.Write(self.GenerateModuleHeader(), "%s.h" % self.module.name) 285 self.Write(self.GenerateModuleHeader(), "%s.h" % self.module.name)
286 self.Write(self.GenerateModuleInternalHeader(), 286 self.Write(self.GenerateModuleInternalHeader(),
287 "%s-internal.h" % self.module.name) 287 "%s-internal.h" % self.module.name)
288 self.Write(self.GenerateModuleSource(), "%s.cc" % self.module.name) 288 self.Write(self.GenerateModuleSource(), "%s.cc" % self.module.name)
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/struct_serialization_definition.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698