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

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: 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
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 GetQualifiedGenericInterfaceName(interface_kind):
71 parts = []
72 parts.extend(NamespaceToArray(interface_kind.module.namespace))
73 parts.append(interface_kind.name)
74 return "::".join(parts)
75
70 def GetCppType(kind): 76 def GetCppType(kind):
71 if mojom.IsArrayKind(kind): 77 if mojom.IsArrayKind(kind):
72 return "mojo::internal::Array_Data<%s>*" % GetCppType(kind.kind) 78 return "mojo::internal::Array_Data<%s>*" % GetCppType(kind.kind)
73 if mojom.IsMapKind(kind): 79 if mojom.IsMapKind(kind):
74 return "mojo::internal::Map_Data<%s, %s>*" % ( 80 return "mojo::internal::Map_Data<%s, %s>*" % (
75 GetCppType(kind.key_kind), GetCppType(kind.value_kind)) 81 GetCppType(kind.key_kind), GetCppType(kind.value_kind))
76 if mojom.IsStructKind(kind): 82 if mojom.IsStructKind(kind):
77 return "%s_Data*" % GetNameForKind(kind, internal=True) 83 return "%s_Data*" % GetNameForKind(kind, internal=True)
78 if mojom.IsUnionKind(kind): 84 if mojom.IsUnionKind(kind):
79 return "%s_Data" % GetNameForKind(kind, internal=True) 85 return "%s_Data" % GetNameForKind(kind, internal=True)
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 "cpp_result_type": GetCppResultWrapperType, 389 "cpp_result_type": GetCppResultWrapperType,
384 "cpp_type": GetCppType, 390 "cpp_type": GetCppType,
385 "cpp_union_getter_return_type": GetUnionGetterReturnType, 391 "cpp_union_getter_return_type": GetUnionGetterReturnType,
386 "cpp_wrapper_type": GetCppWrapperType, 392 "cpp_wrapper_type": GetCppWrapperType,
387 "default_value": DefaultValue, 393 "default_value": DefaultValue,
388 "expression_to_text": ExpressionToText, 394 "expression_to_text": ExpressionToText,
389 "get_array_validate_params_ctor_args": GetArrayValidateParamsCtorArgs, 395 "get_array_validate_params_ctor_args": GetArrayValidateParamsCtorArgs,
390 "get_map_validate_params_ctor_args": GetMapValidateParamsCtorArgs, 396 "get_map_validate_params_ctor_args": GetMapValidateParamsCtorArgs,
391 "get_name_for_kind": GetNameForKind, 397 "get_name_for_kind": GetNameForKind,
392 "get_pad": pack.GetPad, 398 "get_pad": pack.GetPad,
399 "get_qualified_generic_interface_name": GetQualifiedGenericInterfaceName,
393 "has_callbacks": mojom.HasCallbacks, 400 "has_callbacks": mojom.HasCallbacks,
394 "should_inline": ShouldInlineStruct, 401 "should_inline": ShouldInlineStruct,
395 "should_inline_union": ShouldInlineUnion, 402 "should_inline_union": ShouldInlineUnion,
396 "is_array_kind": mojom.IsArrayKind, 403 "is_array_kind": mojom.IsArrayKind,
397 "is_cloneable_kind": mojom.IsCloneableKind, 404 "is_cloneable_kind": mojom.IsCloneableKind,
398 "is_enum_kind": mojom.IsEnumKind, 405 "is_enum_kind": mojom.IsEnumKind,
399 "is_integral_kind": mojom.IsIntegralKind, 406 "is_integral_kind": mojom.IsIntegralKind,
400 "is_move_only_kind": mojom.IsMoveOnlyKind, 407 "is_move_only_kind": mojom.IsMoveOnlyKind,
401 "is_any_handle_kind": mojom.IsAnyHandleKind, 408 "is_any_handle_kind": mojom.IsAnyHandleKind,
402 "is_interface_kind": mojom.IsInterfaceKind, 409 "is_interface_kind": mojom.IsInterfaceKind,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 return self.GetJinjaExports() 452 return self.GetJinjaExports()
446 453
447 def GenerateFiles(self, args): 454 def GenerateFiles(self, args):
448 suffix = "-%s" % self.variant if self.variant else "" 455 suffix = "-%s" % self.variant if self.variant else ""
449 self.Write(self.GenerateModuleHeader(), 456 self.Write(self.GenerateModuleHeader(),
450 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix))) 457 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix)))
451 self.Write(self.GenerateModuleInternalHeader(), 458 self.Write(self.GenerateModuleInternalHeader(),
452 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix))) 459 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix)))
453 self.Write(self.GenerateModuleSource(), 460 self.Write(self.GenerateModuleSource(),
454 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix))) 461 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix)))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698