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

Unified Diff: third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_cpp_generator.py

Issue 910883002: Update mojo sdk to rev 8af2ccff2eee4bfca1043015abee30482a030b30 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply 9f87aeadbda22441b7d469e596f7bd7d0d73e2a8 (https://codereview.chromium.org/908973002/) Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
diff --git a/third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_cpp_generator.py b/third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
index 34bba30e69be34948f5bd666dc76fbfc94388e61..8b7e2197c08b35824826ac7498b79cd43c82ac03 100644
--- a/third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
+++ b/third_party/mojo/src/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
@@ -283,6 +283,9 @@ def ShouldInlineStruct(struct):
return False
return True
+def ShouldInlineUnion(union):
+ return not any(mojom.IsMoveOnlyKind(field.kind) for field in union.fields)
+
def GetArrayValidateParams(kind):
if (not mojom.IsArrayKind(kind) and not mojom.IsMapKind(kind) and
not mojom.IsStringKind(kind)):
@@ -314,8 +317,6 @@ def GetMapValidateParams(value_kind):
'true' if element_is_nullable else 'false',
GetArrayValidateParams(value_kind))
-_HEADER_SIZE = 8
-
class Generator(generator.Generator):
cpp_filters = {
@@ -334,6 +335,7 @@ class Generator(generator.Generator):
"get_pad": pack.GetPad,
"has_callbacks": mojom.HasCallbacks,
"should_inline": ShouldInlineStruct,
+ "should_inline_union": ShouldInlineUnion,
"is_array_kind": mojom.IsArrayKind,
"is_cloneable_kind": mojom.IsCloneableKind,
"is_enum_kind": mojom.IsEnumKind,
@@ -347,11 +349,13 @@ class Generator(generator.Generator):
"is_string_kind": mojom.IsStringKind,
"is_struct_kind": mojom.IsStructKind,
"is_struct_with_handles": IsStructWithHandles,
+ "is_union_kind": mojom.IsUnionKind,
"struct_size": lambda ps: ps.GetTotalSize() + _HEADER_SIZE,
"struct_from_method": generator.GetStructFromMethod,
"response_struct_from_method": generator.GetResponseStructFromMethod,
"stylize_method": generator.StudlyCapsToCamel,
"to_all_caps": generator.CamelCaseToAllCaps,
+ "under_to_camel": generator.UnderToCamel,
}
def GetJinjaExports(self):
@@ -363,6 +367,7 @@ class Generator(generator.Generator):
"kinds": self.module.kinds,
"enums": self.module.enums,
"structs": self.GetStructs(),
+ "unions": self.module.unions,
"interfaces": self.module.interfaces,
}

Powered by Google App Engine
This is Rietveld 408576698