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

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: reupload 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
« no previous file with comments | « tools/json_schema_compiler/cpp_type_generator_test.py ('k') | tools/json_schema_compiler/h_generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..fafc155b9fe7d7524d7436b896e0db5be1744448 100644
--- a/tools/json_schema_compiler/cpp_util.py
+++ b/tools/json_schema_compiler/cpp_util.py
@@ -51,36 +51,12 @@ def GetValueType(prop):
PropertyType.ENUM: 'Value::TYPE_STRING',
PropertyType.REF: 'Value::TYPE_DICTIONARY',
PropertyType.OBJECT: 'Value::TYPE_DICTIONARY',
- PropertyType.ARRAY: 'Value::TYPE_LIST'
+ PropertyType.ARRAY: 'Value::TYPE_LIST',
+ PropertyType.ANY: 'Value::TYPE_DICTIONARY',
}[prop.type_]
-
-def CreateValueFromSingleProperty(prop, var):
- """Creates a Value given a single property. Use for everything except
- PropertyType.ARRAY.
-
- var: variable or variable*
- """
- if prop.type_ in (PropertyType.REF, PropertyType.OBJECT):
- if prop.optional:
- return '%s->ToValue().release()' % var
- else:
- return '%s.ToValue().release()' % var
- elif prop.type_.is_fundamental:
- if prop.optional:
- var = '*' + var
- return {
- PropertyType.STRING: 'Value::CreateStringValue(%s)',
- PropertyType.BOOLEAN: 'Value::CreateBooleanValue(%s)',
- PropertyType.INTEGER: 'Value::CreateIntegerValue(%s)',
- PropertyType.DOUBLE: 'Value::CreateDoubleValue(%s)',
- }[prop.type_] % var
- else:
- raise NotImplementedError('Conversion of single %s to Value not implemented'
- % 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,
« no previous file with comments | « tools/json_schema_compiler/cpp_type_generator_test.py ('k') | tools/json_schema_compiler/h_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698