| OLD | NEW |
| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 return "::".join(parts) | 98 return "::".join(parts) |
| 99 | 99 |
| 100 def GetFullMojomNameForKind(kind): | 100 def GetFullMojomNameForKind(kind): |
| 101 parts = GetNamePartsForKind(kind, True, False) | 101 parts = GetNamePartsForKind(kind, True, False) |
| 102 return ".".join(parts) | 102 return ".".join(parts) |
| 103 | 103 |
| 104 def IsTypemappedKind(kind): | 104 def IsTypemappedKind(kind): |
| 105 return hasattr(kind, "name") and \ | 105 return hasattr(kind, "name") and \ |
| 106 GetFullMojomNameForKind(kind) in _current_typemap | 106 GetFullMojomNameForKind(kind) in _current_typemap |
| 107 | 107 |
| 108 def IsCloneableKind(kind): |
| 109 return mojom.IsCloneableKind(kind, IsTypemappedKind) |
| 110 |
| 108 def IsNativeOnlyKind(kind): | 111 def IsNativeOnlyKind(kind): |
| 109 return mojom.IsStructKind(kind) and kind.native_only | 112 return mojom.IsStructKind(kind) and kind.native_only |
| 110 | 113 |
| 111 def GetNativeTypeName(typemapped_kind): | 114 def GetNativeTypeName(typemapped_kind): |
| 112 return _current_typemap[GetFullMojomNameForKind(typemapped_kind)]["typename"] | 115 return _current_typemap[GetFullMojomNameForKind(typemapped_kind)]["typename"] |
| 113 | 116 |
| 114 def DoesKindSupportEquality(kind): | 117 def DoesKindSupportEquality(kind): |
| 115 if IsTypemappedKind(kind): | 118 if IsTypemappedKind(kind): |
| 116 return False | 119 return False |
| 117 if mojom.IsStructKind(kind) and kind.native_only: | 120 if mojom.IsStructKind(kind) and kind.native_only: |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 "get_array_validate_params_ctor_args": GetArrayValidateParamsCtorArgs, | 473 "get_array_validate_params_ctor_args": GetArrayValidateParamsCtorArgs, |
| 471 "get_map_validate_params_ctor_args": GetMapValidateParamsCtorArgs, | 474 "get_map_validate_params_ctor_args": GetMapValidateParamsCtorArgs, |
| 472 "get_name_for_kind": GetNameForKind, | 475 "get_name_for_kind": GetNameForKind, |
| 473 "get_pad": pack.GetPad, | 476 "get_pad": pack.GetPad, |
| 474 "get_qualified_name_for_kind": GetQualifiedNameForKind, | 477 "get_qualified_name_for_kind": GetQualifiedNameForKind, |
| 475 "has_callbacks": mojom.HasCallbacks, | 478 "has_callbacks": mojom.HasCallbacks, |
| 476 "has_sync_methods": mojom.HasSyncMethods, | 479 "has_sync_methods": mojom.HasSyncMethods, |
| 477 "should_inline": ShouldInlineStruct, | 480 "should_inline": ShouldInlineStruct, |
| 478 "should_inline_union": ShouldInlineUnion, | 481 "should_inline_union": ShouldInlineUnion, |
| 479 "is_array_kind": mojom.IsArrayKind, | 482 "is_array_kind": mojom.IsArrayKind, |
| 480 "is_cloneable_kind": mojom.IsCloneableKind, | 483 "is_cloneable_kind": IsCloneableKind, |
| 481 "is_enum_kind": mojom.IsEnumKind, | 484 "is_enum_kind": mojom.IsEnumKind, |
| 482 "is_integral_kind": mojom.IsIntegralKind, | 485 "is_integral_kind": mojom.IsIntegralKind, |
| 483 "is_move_only_kind": mojom.IsMoveOnlyKind, | 486 "is_move_only_kind": mojom.IsMoveOnlyKind, |
| 484 "is_native_only_kind": IsNativeOnlyKind, | 487 "is_native_only_kind": IsNativeOnlyKind, |
| 485 "is_any_handle_kind": mojom.IsAnyHandleKind, | 488 "is_any_handle_kind": mojom.IsAnyHandleKind, |
| 486 "is_interface_kind": mojom.IsInterfaceKind, | 489 "is_interface_kind": mojom.IsInterfaceKind, |
| 487 "is_interface_request_kind": mojom.IsInterfaceRequestKind, | 490 "is_interface_request_kind": mojom.IsInterfaceRequestKind, |
| 488 "is_associated_interface_kind": mojom.IsAssociatedInterfaceKind, | 491 "is_associated_interface_kind": mojom.IsAssociatedInterfaceKind, |
| 489 "is_associated_interface_request_kind": | 492 "is_associated_interface_request_kind": |
| 490 mojom.IsAssociatedInterfaceRequestKind, | 493 mojom.IsAssociatedInterfaceRequestKind, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 def GenerateFiles(self, args): | 550 def GenerateFiles(self, args): |
| 548 global _current_typemap | 551 global _current_typemap |
| 549 _current_typemap = self.typemap | 552 _current_typemap = self.typemap |
| 550 suffix = "-%s" % self.variant if self.variant else "" | 553 suffix = "-%s" % self.variant if self.variant else "" |
| 551 self.Write(self.GenerateModuleHeader(), | 554 self.Write(self.GenerateModuleHeader(), |
| 552 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix))) | 555 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix))) |
| 553 self.Write(self.GenerateModuleInternalHeader(), | 556 self.Write(self.GenerateModuleInternalHeader(), |
| 554 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix))) | 557 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix))) |
| 555 self.Write(self.GenerateModuleSource(), | 558 self.Write(self.GenerateModuleSource(), |
| 556 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix))) | 559 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix))) |
| OLD | NEW |