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

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

Issue 2165233003: Mojo C++ bindings: provide data view for all object types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 79b3d3b00ffb195feb4e0ec54709dbbb619970a1..f4daef8f2321a8831ee2a4260efde15fa755067d 100644
--- a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
@@ -242,6 +242,20 @@ def GetCppWrapperParamType(kind):
return (cpp_wrapper_type if ShouldPassParamByValue(kind)
else "const %s&" % cpp_wrapper_type)
+def GetCppDataViewType(kind):
+ if mojom.IsEnumKind(kind):
+ return GetNameForKind(kind)
+ if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind):
+ return "%sDataView" % GetNameForKind(kind)
+ if mojom.IsArrayKind(kind):
+ return "mojo::ArrayDataView<%s>" % GetCppDataViewType(kind.kind)
+ if mojom.IsMapKind(kind):
+ return ("mojo::MapDataView<%s, %s>" % (GetCppDataViewType(kind.key_kind),
+ GetCppDataViewType(kind.value_kind)))
+ if mojom.IsStringKind(kind):
+ return "mojo::StringDataView"
+ return GetCppWrapperType(kind)
+
def GetCppFieldType(kind):
if mojom.IsStructKind(kind):
return ("mojo::internal::Pointer<%s>" %
@@ -412,6 +426,7 @@ class Generator(generator.Generator):
cpp_filters = {
"constant_value": ConstantValue,
"cpp_wrapper_param_type": GetCppWrapperParamType,
+ "cpp_data_view_type": GetCppDataViewType,
"cpp_field_type": GetCppFieldType,
"cpp_union_field_type": GetCppUnionFieldType,
"cpp_pod_type": GetCppPodType,
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698