summaryrefslogtreecommitdiffstats
path: root/tools/json_schema_compiler/h_generator.py
diff options
context:
space:
mode:
authorbenjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-11 21:03:26 +0000
committerbenjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-11 21:03:26 +0000
commit9d27318a0a0dbbb7312b8026be240d8def439406 (patch)
treecc6cf11ea0fbb4f6ea2eb62c3bc41d49864d2e7a /tools/json_schema_compiler/h_generator.py
parentdf66ed60b88d0331b3bd815622a77047cdc1e0d8 (diff)
downloadchromium_src-9d27318a0a0dbbb7312b8026be240d8def439406.zip
chromium_src-9d27318a0a0dbbb7312b8026be240d8def439406.tar.gz
chromium_src-9d27318a0a0dbbb7312b8026be240d8def439406.tar.bz2
Switch the downloads API over to IDL/json_schema_compiler
Modify ppapi/generators/idl_parser.py to 0: not require a file-level comment (but generate the same parse tree structure), 1: actually support ext_attrs (modifiers) for dictionaries, and 2: support [ext_attr=(symbols|values)]. Modify json_schema_compiler to 0: use "base::Value" and any_helper.ANY_CLASS instead of Value and Any in order to support ArrayBuffers named |value| or |any|, 1: actually test that namespaces and dictionaries are sorted correctly, 2: fix HGenerator._FieldDependencyOrder(), 3: support [inline_doc] on dictionaries and enums, 4: support descriptions on enums, 5: support documentation_permissions_required, 6: support [legalValues=(values...)]. Review URL: https://chromiumcodereview.appspot.com/10639020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146201 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/json_schema_compiler/h_generator.py')
-rw-r--r--tools/json_schema_compiler/h_generator.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/tools/json_schema_compiler/h_generator.py b/tools/json_schema_compiler/h_generator.py
index b5801ef..30a357d 100644
--- a/tools/json_schema_compiler/h_generator.py
+++ b/tools/json_schema_compiler/h_generator.py
@@ -5,8 +5,6 @@
from code import Code
from model import PropertyType
import cpp_util
-import model
-import os
import schema_util
class HGenerator(object):
@@ -110,7 +108,8 @@ class HGenerator(object):
raise ValueError("Illegal circular dependency via cycle " +
", ".join(map(lambda x: x.name, path + [type_])))
for prop in type_.properties.values():
- if not prop.optional and prop.type_ == PropertyType.REF:
+ if (prop.type_ == PropertyType.REF and
+ schema_util.GetNamespace(prop.ref_type) == self._namespace.name):
ExpandType(path + [type_], self._namespace.types[prop.ref_type])
if not type_ in dependency_order:
dependency_order.append(type_)
@@ -177,7 +176,6 @@ class HGenerator(object):
if type_.description:
c.Comment(type_.description)
c.Append('typedef std::string %(classname)s;')
- c.Substitute({'classname': classname})
else:
if type_.description:
c.Comment(type_.description)
@@ -189,18 +187,18 @@ class HGenerator(object):
.Concat(self._GenerateFields(type_.properties.values()))
)
if type_.from_json:
- (c.Comment('Populates a %s object from a Value. Returns'
+ (c.Comment('Populates a %s object from a base::Value. Returns'
' whether |out| was successfully populated.' % classname)
- .Append(
- 'static bool Populate(const Value& value, %(classname)s* out);')
+ .Append('static bool Populate(const base::Value& value, '
+ '%(classname)s* out);')
.Append()
)
if type_.from_client:
- (c.Comment('Returns a new DictionaryValue representing the'
+ (c.Comment('Returns a new base::DictionaryValue representing the'
' serialized form of this %s object. Passes '
'ownership to caller.' % classname)
- .Append('scoped_ptr<DictionaryValue> ToValue() const;')
+ .Append('scoped_ptr<base::DictionaryValue> ToValue() const;')
)
(c.Eblock()
@@ -238,7 +236,8 @@ class HGenerator(object):
.Concat(self._GenerateFields(function.params))
.Append('~Params();')
.Append()
- .Append('static scoped_ptr<Params> Create(const ListValue& args);')
+ .Append('static scoped_ptr<Params> Create('
+ 'const base::ListValue& args);')
.Eblock()
.Sblock(' private:')
.Append('Params();')
@@ -273,7 +272,7 @@ class HGenerator(object):
enum_name,
prop,
prop.enum_values))
- c.Append('static scoped_ptr<Value> CreateEnumValue(%s %s);' %
+ c.Append('static scoped_ptr<base::Value> CreateEnumValue(%s %s);' %
(enum_name, prop.unix_name))
return c
@@ -285,7 +284,7 @@ class HGenerator(object):
c.Sblock('namespace Result {')
params = function.callback.params
if not params:
- c.Append('Value* Create();')
+ c.Append('base::Value* Create();')
else:
c.Concat(self._GeneratePropertyStructures(params))
@@ -297,11 +296,12 @@ class HGenerator(object):
if param.description:
c.Comment(param.description)
if param.type_ == PropertyType.ANY:
- c.Comment("Value* Result::Create(Value*) not generated "
+ c.Comment("base::Value* Result::Create(base::Value*) not generated "
"because it's redundant.")
continue
- c.Append('Value* Create(const %s);' % cpp_util.GetParameterDeclaration(
- param, self._cpp_type_generator.GetType(param)))
+ c.Append('base::Value* Create(const %s);' %
+ cpp_util.GetParameterDeclaration(
+ param, self._cpp_type_generator.GetType(param)))
c.Eblock('};')
return c