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

Unified Diff: tools/json_schema_compiler/idl_schema.py

Issue 23549025: Clean up JSON Schema Compiler. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Removed enum test and added blank lines. Created 7 years, 3 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/h_generator.py ('k') | tools/json_schema_compiler/idl_schema_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/idl_schema.py
diff --git a/tools/json_schema_compiler/idl_schema.py b/tools/json_schema_compiler/idl_schema.py
index 0556236be4fa25bb35cdc4ac5d5514f2b3465397..44a4a55eaec8e06523919a621c9e450aeaa6637e 100644
--- a/tools/json_schema_compiler/idl_schema.py
+++ b/tools/json_schema_compiler/idl_schema.py
@@ -10,7 +10,6 @@ import re
import sys
from json_parse import OrderedDict
-import schema_util
# This file is a peer to json_schema.py. Each of these files understands a
# certain format describing APIs (either JSON or IDL), reads files written
@@ -85,6 +84,7 @@ def ProcessComment(comment):
.replace('\n', ''))
return (parent_comment, params)
+
class Callspec(object):
'''
Given a Callspec node representing an IDL function declaration, converts into
@@ -106,7 +106,7 @@ class Callspec(object):
# Instead we infer any object return values to be optional.
# TODO(asargent): fix the IDL parser to support optional return types.
if return_type.get('type') == 'object' or '$ref' in return_type:
- return_type['optional'] = True;
+ return_type['optional'] = True
for node in self.node.children:
parameter = Param(node).process(callbacks)
if parameter['name'] in self.comment:
@@ -114,6 +114,7 @@ class Callspec(object):
parameters.append(parameter)
return (self.node.GetName(), parameters, return_type)
+
class Param(object):
'''
Given a Param node representing a function parameter, converts into a Python
@@ -127,6 +128,7 @@ class Param(object):
self.node,
{'name': self.node.GetName()}).process(callbacks)
+
class Dictionary(object):
'''
Given an IDL Dictionary node, converts into a Python dictionary that the JSON
@@ -151,6 +153,7 @@ class Dictionary(object):
return result
+
class Member(object):
'''
Given an IDL dictionary or interface member, converts into a name/value pair
@@ -204,6 +207,7 @@ class Member(object):
properties['enum'] = enum_values
return name, properties
+
class Typeref(object):
'''
Given a TYPEREF property representing the type of dictionary member or
@@ -350,6 +354,7 @@ class Namespace(object):
members.append(properties)
return members
+
class IDLSchema(object):
'''
Given a list of IDLNodes and IDLAttributes, converts into a Python list
@@ -390,6 +395,7 @@ class IDLSchema(object):
sys.exit('Did not process %s %s' % (node.cls, node))
return namespaces
+
def Load(filename):
'''
Given the filename of an IDL file, parses it and returns an equivalent
@@ -404,6 +410,7 @@ def Load(filename):
idl_schema = IDLSchema(idl)
return idl_schema.process()
+
def Main():
'''
Dump a json serialization of parse result for the IDL files whose names
@@ -413,5 +420,6 @@ def Main():
schema = Load(filename)
print json.dumps(schema, indent=2)
+
if __name__ == '__main__':
Main()
« no previous file with comments | « tools/json_schema_compiler/h_generator.py ('k') | tools/json_schema_compiler/idl_schema_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698