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

Unified Diff: tools/json_schema_compiler/json_schema.py

Issue 12041098: Initial commit of the Dart Chrome Extension APIs generators (Closed) Base URL: http://git.chromium.org/chromium/src.git@file_path_bugfix
Patch Set: Fixed minor style issues; added support for [nodart] IDL flag Created 7 years, 11 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
Index: tools/json_schema_compiler/json_schema.py
diff --git a/tools/json_schema_compiler/json_schema.py b/tools/json_schema_compiler/json_schema.py
index 370bc9b3cb35b917fbbe70f712a3d3908c207ce4..d0342b60fe8f66204768dea0b1ae2e7232fc73d2 100644
--- a/tools/json_schema_compiler/json_schema.py
+++ b/tools/json_schema_compiler/json_schema.py
@@ -9,22 +9,28 @@ import sys
import json_parse
import schema_util
-def DeleteNocompileNodes(item):
- def HasNocompile(thing):
- return json_parse.IsDict(thing) and thing.get('nocompile', False)
+# The text to look for, that means "do not generate" for each language.
+nocompile_text = {
+ 'dart': 'nodart',
+ 'c++': 'nocompile'
+}
+
+def DeleteNocompileNodes(item, lang='c++'):
not at google - send to devlin 2013/01/25 18:14:33 how about renaming this to DeleteNodes(item, key)
sashab 2013/01/29 08:27:13 Done; moved this language-specific decision to com
+ def HasNocompile(thing, lang):
+ return json_parse.IsDict(thing) and thing.get(nocompile_text[lang], False)
if json_parse.IsDict(item):
toDelete = []
for key, value in item.items():
- if HasNocompile(value):
+ if HasNocompile(value, lang):
toDelete.append(key)
else:
- DeleteNocompileNodes(value)
+ DeleteNocompileNodes(value, lang)
for key in toDelete:
del item[key]
elif type(item) == list:
- item[:] = [DeleteNocompileNodes(thing)
- for thing in item if not HasNocompile(thing)]
+ item[:] = [DeleteNocompileNodes(thing, lang)
+ for thing in item if not HasNocompile(thing, lang)]
return item

Powered by Google App Engine
This is Rietveld 408576698