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

Unified Diff: tools/json_schema_compiler/cpp_util.py

Issue 9456007: Add wider support to json_schema_compiler (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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: tools/json_schema_compiler/cpp_util.py
diff --git a/tools/json_schema_compiler/cpp_util.py b/tools/json_schema_compiler/cpp_util.py
index 83d526526105fb9aa166e6e90d6b9034622d5035..cb04507693bdb784be1e139ed56a54e815007b1c 100644
--- a/tools/json_schema_compiler/cpp_util.py
+++ b/tools/json_schema_compiler/cpp_util.py
@@ -55,9 +55,9 @@ def GetValueType(prop):
}[prop.type_]
-def CreateValueFromSingleProperty(prop, var):
- """Creates a Value given a single property. Use for everything except
- PropertyType.ARRAY.
+def CreateValueFromSingleProperty(prop, var, util_cc_helper):
not at google - send to devlin 2012/02/24 03:53:05 I don't think this method needs to be in cpp_util,
calamity 2012/02/24 15:10:40 Done.
+ """Creates a Value given a single property. Generated code passes ownership
+ to caller.
var: variable or variable*
"""
@@ -66,6 +66,10 @@ def CreateValueFromSingleProperty(prop, var):
return '%s->ToValue().release()' % var
else:
return '%s.ToValue().release()' % var
+ elif prop.type_ == PropertyType.ENUM:
+ return 'CreateEnumValue(%s).release()' % var
+ elif prop.type_ == PropertyType.ARRAY:
+ return '%s.release()' % util_cc_helper.CreateValueFromArray(prop, var)
elif prop.type_.is_fundamental:
if prop.optional:
var = '*' + var
@@ -80,7 +84,7 @@ def CreateValueFromSingleProperty(prop, var):
% repr(prop.type_))
def GetParameterDeclaration(param, type_):
- """Gets a const parameter declaration of a given model.Property and its C++
+ """Gets a parameter declaration of a given model.Property and its C++
type.
"""
if param.type_ in (PropertyType.REF, PropertyType.OBJECT, PropertyType.ARRAY,

Powered by Google App Engine
This is Rietveld 408576698