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, |