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

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

Issue 268363003: Mojo: Add support for constants to the IDL compiler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: JS export constants 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 8f48f8e06f94433128eab17d02eaac93646cfa72..c3aa73c1ae032420155d36bea07f308b46c373be 100644
--- a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
@@ -57,6 +57,11 @@ def GetCppType(kind):
return "mojo::internal::String_Data*"
return _kind_to_cpp_type[kind]
+def GetCppPodType(kind):
+ if kind.spec == 's':
+ return "char*"
+ return _kind_to_cpp_type[kind]
+
def GetCppArrayArgWrapperType(kind):
if isinstance(kind, (mojom.Struct, mojom.Enum)):
return GetNameForKind(kind)
@@ -148,15 +153,15 @@ def IsStructWithHandles(struct):
return False
def TranslateConstants(token, module):
- if isinstance(token, mojom.Constant):
- # Enum constants are constructed like:
- # Namespace::Struct::FIELD_NAME
+ if isinstance(token, (mojom.NamedValue, mojom.EnumValue)):
+ # Both variable and enum constants are constructed like:
+ # Namespace::Struct::CONSTANT_NAME
name = []
if token.imported_from:
name.extend(NamespaceToArray(token.namespace))
if token.parent_kind:
name.append(token.parent_kind.name)
- name.append(token.name[1])
+ name.append(token.name)
return "::".join(name)
return token
@@ -173,8 +178,9 @@ class Generator(generator.Generator):
cpp_filters = {
"cpp_const_wrapper_type": GetCppConstWrapperType,
"cpp_field_type": GetCppFieldType,
- "cpp_type": GetCppType,
+ "cpp_pod_type": GetCppPodType,
"cpp_result_type": GetCppResultWrapperType,
+ "cpp_type": GetCppType,
"cpp_wrapper_type": GetCppWrapperType,
"expression_to_text": ExpressionToText,
"get_pad": pack.GetPad,

Powered by Google App Engine
This is Rietveld 408576698