summaryrefslogtreecommitdiffstats
path: root/tools/json_schema_compiler/idl_schema.py
diff options
context:
space:
mode:
authorpenghuang@chromium.org <penghuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-14 20:06:50 +0000
committerpenghuang@chromium.org <penghuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-14 20:06:50 +0000
commit0796c78cdf00480f61dd0c9c88020d4f617199bf (patch)
tree8aeff3c881fd930000fc856ebbcc9ebead0cb450 /tools/json_schema_compiler/idl_schema.py
parent8ee5a16de174a3acb3d1eedd90a2286a1a5a8cbd (diff)
downloadchromium_src-0796c78cdf00480f61dd0c9c88020d4f617199bf.zip
chromium_src-0796c78cdf00480f61dd0c9c88020d4f617199bf.tar.gz
chromium_src-0796c78cdf00480f61dd0c9c88020d4f617199bf.tar.bz2
Support enum in idl file.
BUG=127658 TEST=Manually Review URL: https://chromiumcodereview.appspot.com/10389078 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136957 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/json_schema_compiler/idl_schema.py')
-rw-r--r--tools/json_schema_compiler/idl_schema.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/json_schema_compiler/idl_schema.py b/tools/json_schema_compiler/idl_schema.py
index 09794b2..8e46d12 100644
--- a/tools/json_schema_compiler/idl_schema.py
+++ b/tools/json_schema_compiler/idl_schema.py
@@ -97,6 +97,28 @@ class Dictionary(object):
'properties': properties,
'type': 'object' }
+class Enum(object):
+ '''
+ Given an IDL Enum node, converts into a Python dictionary that the JSON
+ schema compiler expects to see.
+ '''
+ def __init__(self, enum_node):
+ self.node = enum_node
+
+ def process(self, callbacks):
+ enum = []
+ for node in self.node.children:
+ if node.cls == 'EnumItem':
+ name = node.GetName()
+ enum.append(name)
+ else:
+ sys.exit("Did not process %s %s" % (node.cls, node))
+ return { "id" : self.node.GetName(),
+ 'enum': enum,
+ 'type': 'string' }
+
+
+
class Member(object):
'''
Given an IDL dictionary or interface member, converts into a name/value pair
@@ -215,6 +237,8 @@ class Namespace(object):
self.functions = self.process_interface(node)
elif cls == "Interface" and node.GetName() == "Events":
self.events = self.process_interface(node)
+ elif cls == "Enum":
+ self.types.append(Enum(node).process(self.callbacks))
else:
sys.exit("Did not process %s %s" % (node.cls, node))