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

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

Issue 1524693002: [mojo] Add GenericInterface_ to interface class variants (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bindings-2-typemaps
Patch Set: merge Created 5 years 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
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/module.h.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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 parts = [] 60 parts = []
61 if kind.imported_from: 61 if kind.imported_from:
62 parts.extend(NamespaceToArray(kind.imported_from["namespace"])) 62 parts.extend(NamespaceToArray(kind.imported_from["namespace"]))
63 if internal: 63 if internal:
64 parts.append("internal") 64 parts.append("internal")
65 if kind.parent_kind: 65 if kind.parent_kind:
66 parts.append(kind.parent_kind.name) 66 parts.append(kind.parent_kind.name)
67 parts.append(kind.name) 67 parts.append(kind.name)
68 return "::".join(parts) 68 return "::".join(parts)
69 69
70 def GetQualifiedNameForKind(kind):
71 # Always start with an empty part to force a leading "::" on output.
72 parts = [""]
73 parts.extend(NamespaceToArray(kind.module.namespace))
74 parts.append(kind.name)
75 return "::".join(parts)
76
70 def GetCppType(kind): 77 def GetCppType(kind):
71 if mojom.IsArrayKind(kind): 78 if mojom.IsArrayKind(kind):
72 return "mojo::internal::Array_Data<%s>*" % GetCppType(kind.kind) 79 return "mojo::internal::Array_Data<%s>*" % GetCppType(kind.kind)
73 if mojom.IsMapKind(kind): 80 if mojom.IsMapKind(kind):
74 return "mojo::internal::Map_Data<%s, %s>*" % ( 81 return "mojo::internal::Map_Data<%s, %s>*" % (
75 GetCppType(kind.key_kind), GetCppType(kind.value_kind)) 82 GetCppType(kind.key_kind), GetCppType(kind.value_kind))
76 if mojom.IsStructKind(kind): 83 if mojom.IsStructKind(kind):
77 return "%s_Data*" % GetNameForKind(kind, internal=True) 84 return "%s_Data*" % GetNameForKind(kind, internal=True)
78 if mojom.IsUnionKind(kind): 85 if mojom.IsUnionKind(kind):
79 return "%s_Data" % GetNameForKind(kind, internal=True) 86 return "%s_Data" % GetNameForKind(kind, internal=True)
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 "cpp_result_type": GetCppResultWrapperType, 390 "cpp_result_type": GetCppResultWrapperType,
384 "cpp_type": GetCppType, 391 "cpp_type": GetCppType,
385 "cpp_union_getter_return_type": GetUnionGetterReturnType, 392 "cpp_union_getter_return_type": GetUnionGetterReturnType,
386 "cpp_wrapper_type": GetCppWrapperType, 393 "cpp_wrapper_type": GetCppWrapperType,
387 "default_value": DefaultValue, 394 "default_value": DefaultValue,
388 "expression_to_text": ExpressionToText, 395 "expression_to_text": ExpressionToText,
389 "get_array_validate_params_ctor_args": GetArrayValidateParamsCtorArgs, 396 "get_array_validate_params_ctor_args": GetArrayValidateParamsCtorArgs,
390 "get_map_validate_params_ctor_args": GetMapValidateParamsCtorArgs, 397 "get_map_validate_params_ctor_args": GetMapValidateParamsCtorArgs,
391 "get_name_for_kind": GetNameForKind, 398 "get_name_for_kind": GetNameForKind,
392 "get_pad": pack.GetPad, 399 "get_pad": pack.GetPad,
400 "get_qualified_name_for_kind": GetQualifiedNameForKind,
393 "has_callbacks": mojom.HasCallbacks, 401 "has_callbacks": mojom.HasCallbacks,
394 "should_inline": ShouldInlineStruct, 402 "should_inline": ShouldInlineStruct,
395 "should_inline_union": ShouldInlineUnion, 403 "should_inline_union": ShouldInlineUnion,
396 "is_array_kind": mojom.IsArrayKind, 404 "is_array_kind": mojom.IsArrayKind,
397 "is_cloneable_kind": mojom.IsCloneableKind, 405 "is_cloneable_kind": mojom.IsCloneableKind,
398 "is_enum_kind": mojom.IsEnumKind, 406 "is_enum_kind": mojom.IsEnumKind,
399 "is_integral_kind": mojom.IsIntegralKind, 407 "is_integral_kind": mojom.IsIntegralKind,
400 "is_move_only_kind": mojom.IsMoveOnlyKind, 408 "is_move_only_kind": mojom.IsMoveOnlyKind,
401 "is_any_handle_kind": mojom.IsAnyHandleKind, 409 "is_any_handle_kind": mojom.IsAnyHandleKind,
402 "is_interface_kind": mojom.IsInterfaceKind, 410 "is_interface_kind": mojom.IsInterfaceKind,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 return self.GetJinjaExports() 453 return self.GetJinjaExports()
446 454
447 def GenerateFiles(self, args): 455 def GenerateFiles(self, args):
448 suffix = "-%s" % self.variant if self.variant else "" 456 suffix = "-%s" % self.variant if self.variant else ""
449 self.Write(self.GenerateModuleHeader(), 457 self.Write(self.GenerateModuleHeader(),
450 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix))) 458 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix)))
451 self.Write(self.GenerateModuleInternalHeader(), 459 self.Write(self.GenerateModuleInternalHeader(),
452 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix))) 460 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix)))
453 self.Write(self.GenerateModuleSource(), 461 self.Write(self.GenerateModuleSource(),
454 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix))) 462 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix)))
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698