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

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

Issue 272323003: Mojo: Implement support for |Foo&| mojom syntax (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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: mojo/public/tools/bindings/generators/mojom_cpp_generator.py
diff --git a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
index 6b7492d5bccd9f3b43cc4872b713e95aea2b3e96..ceb14b3ca68a277fbc5dd8875fc4a150cfc10400 100644
--- a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
@@ -49,7 +49,8 @@ def GetCppType(kind):
return "%s_Data*" % GetNameForKind(kind, internal=True)
if isinstance(kind, mojom.Array):
return "mojo::internal::Array_Data<%s>*" % GetCppType(kind.kind)
- if isinstance(kind, mojom.Interface):
+ if isinstance(kind, mojom.Interface) or \
+ isinstance(kind, mojom.InterfaceRequest):
return "mojo::MessagePipeHandle"
if isinstance(kind, mojom.Enum):
return "int32_t"
@@ -71,6 +72,8 @@ def GetCppArrayArgWrapperType(kind):
return "mojo::Array<%s> " % GetCppArrayArgWrapperType(kind.kind)
if isinstance(kind, mojom.Interface):
raise Exception("Arrays of interfaces not yet supported!")
+ if isinstance(kind, mojom.InterfaceRequest):
+ raise Exception("Arrays of interface requests not yet supported!")
if kind.spec == 's':
return "mojo::String"
if kind.spec == 'h':
@@ -94,6 +97,8 @@ def GetCppResultWrapperType(kind):
return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind)
if isinstance(kind, mojom.Interface):
return "%sPtr" % kind.name
+ if isinstance(kind, mojom.InterfaceRequest):
+ return "mojo::InterfaceRequest<%s>" % kind.kind.name
if kind.spec == 's':
return "mojo::String"
if kind.spec == 'h':
@@ -117,6 +122,8 @@ def GetCppWrapperType(kind):
return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind)
if isinstance(kind, mojom.Interface):
return "mojo::ScopedMessagePipeHandle"
+ if isinstance(kind, mojom.InterfaceRequest):
+ raise Exception("InterfaceRequest fields not supported!")
if kind.spec == 's':
return "mojo::String"
if kind.spec == 'h':
@@ -138,6 +145,8 @@ def GetCppConstWrapperType(kind):
return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind)
if isinstance(kind, mojom.Interface):
return "%sPtr" % kind.name
+ if isinstance(kind, mojom.InterfaceRequest):
+ return "mojo::InterfaceRequest<%s>" % kind.kind.name
if isinstance(kind, mojom.Enum):
return GetNameForKind(kind)
if kind.spec == 's':
@@ -162,7 +171,8 @@ def GetCppFieldType(kind):
GetNameForKind(kind, internal=True))
if isinstance(kind, mojom.Array):
return "mojo::internal::ArrayPointer<%s>" % GetCppType(kind.kind)
- if isinstance(kind, mojom.Interface):
+ if isinstance(kind, mojom.Interface) or \
+ isinstance(kind, mojom.InterfaceRequest):
return "mojo::MessagePipeHandle"
if isinstance(kind, mojom.Enum):
return GetNameForKind(kind)
@@ -229,6 +239,7 @@ class Generator(generator.Generator):
"is_move_only_kind": generator.IsMoveOnlyKind,
"is_handle_kind": generator.IsHandleKind,
"is_interface_kind": generator.IsInterfaceKind,
+ "is_interface_request_kind": generator.IsInterfaceRequestKind,
"is_object_kind": generator.IsObjectKind,
"is_string_kind": generator.IsStringKind,
"is_array_kind": lambda kind: isinstance(kind, mojom.Array),

Powered by Google App Engine
This is Rietveld 408576698