summaryrefslogtreecommitdiffstats
path: root/tools/json_schema_compiler/util_cc_helper.py
diff options
context:
space:
mode:
authorcalamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-28 05:51:44 +0000
committercalamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-28 05:51:44 +0000
commit25cbf601111a7c4bc0f24ea1e8fc8b0f688ce9d6 (patch)
tree1961d2f1f52421d8714f13ca91e8c615ea0f15cd /tools/json_schema_compiler/util_cc_helper.py
parente324f6b9b93237c1488694b2a94cff0f8ec85460 (diff)
downloadchromium_src-25cbf601111a7c4bc0f24ea1e8fc8b0f688ce9d6.zip
chromium_src-25cbf601111a7c4bc0f24ea1e8fc8b0f688ce9d6.tar.gz
chromium_src-25cbf601111a7c4bc0f24ea1e8fc8b0f688ce9d6.tar.bz2
json_schema_compiler: Added wider support for OBJECTs and ENUMs. Used the new 'dependencies' property in the jsons. Refactored to avoid code duplication. Added tests for new features and where tests were lacking.
BUG= TEST=unit_tests --gtest_filter=JsonSchemaCompiler* Review URL: http://codereview.chromium.org/9456007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123909 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/json_schema_compiler/util_cc_helper.py')
-rw-r--r--tools/json_schema_compiler/util_cc_helper.py34
1 files changed, 4 insertions, 30 deletions
diff --git a/tools/json_schema_compiler/util_cc_helper.py b/tools/json_schema_compiler/util_cc_helper.py
index fe4e858..18dcb02 100644
--- a/tools/json_schema_compiler/util_cc_helper.py
+++ b/tools/json_schema_compiler/util_cc_helper.py
@@ -56,48 +56,22 @@ class UtilCCHelper(object):
return val % sub
- def PopulateDictionaryFromArray(self, array_prop, src, name, dst):
- """Generates code to set dst.name to the array at src
+ def CreateValueFromArray(self, array_prop, src):
+ """Generates code to create a scoped_pt<Value> from the array at src.
src: std::vector or scoped_ptr<std::vector>
- dst: scoped_ptr<DictionaryValue>
"""
prop = array_prop.item_type
sub = {
'namespace': API_UTIL_NAMESPACE,
'src': src,
- 'name': name,
- 'dst': dst,
- 'type': self._type_manager.GetType(prop),
- }
-
- if array_prop.optional:
- val = ('%(namespace)s::PopulateDictionaryFromOptionalArray'
- '(%(src)s, "%(name)s", %(dst)s.get())')
- else:
- val = ('%(namespace)s::PopulateDictionaryFromArray'
- '(%(src)s, "%(name)s", %(dst)s.get())')
-
- return val % sub
-
- def PopulateListFromArray(self, array_prop, src, dst):
- """Generates code to set dst to the array at src
-
- src: std::vector or scoped_ptr<std::vector>
- dst: ListValue*
- """
- prop = array_prop.item_type
- sub = {
- 'namespace': API_UTIL_NAMESPACE,
- 'src': src,
- 'dst': dst,
'type': self._type_manager.GetType(prop),
}
if array_prop.optional:
- val = '%(namespace)s::PopulateListFromOptionalArray(%(src)s, %(dst)s)'
+ val = '%(namespace)s::CreateValueFromOptionalArray(%(src)s)'
else:
- val = '%(namespace)s::PopulateListFromArray(%(src)s, %(dst)s)'
+ val = '%(namespace)s::CreateValueFromArray(%(src)s)'
return val % sub