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

Unified Diff: tools/json_schema_compiler/model.py

Issue 10824002: JSON Schema Compiler supports functions as PropertyTypes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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/model.py
diff --git a/tools/json_schema_compiler/model.py b/tools/json_schema_compiler/model.py
index 5453e11c40a11a6abe9425d5df2a8e997ab726b5..2351ecd1f999b17bf7077c52d8baaeb00e09cd83 100644
--- a/tools/json_schema_compiler/model.py
+++ b/tools/json_schema_compiler/model.py
@@ -212,6 +212,8 @@ class Property(object):
# self.properties will already have some value from |_AddProperties|.
self.properties.update(type_.properties)
self.functions = type_.functions
+ elif json_type == 'function':
+ self.type_ = PropertyType.FUNCTION
elif json_type == 'binary':
self.type_ = PropertyType.BINARY
else:
@@ -293,6 +295,7 @@ class PropertyType(object):
REF = _Info(False, "REF")
CHOICES = _Info(False, "CHOICES")
OBJECT = _Info(False, "OBJECT")
+ FUNCTION = _Info(False, "FUNCTION")
BINARY = _Info(False, "BINARY")
ANY = _Info(False, "ANY")
ADDITIONAL_PROPERTIES = _Info(False, "ADDITIONAL_PROPERTIES")
@@ -350,16 +353,6 @@ def _AddProperties(model, json, from_json=False, from_client=False):
"""
model.properties = {}
for name, property_json in json.get('properties', {}).items():
- # TODO(calamity): support functions (callbacks) as properties. The model
- # doesn't support it yet because the h/cc generators don't -- this is
- # because we'd need to hook it into a base::Callback or something.
- #
- # However, pragmatically it's not necessary to support them anyway, since
- # the instances of functions-on-properties in the extension APIs are all
- # handled in pure Javascript on the render process (and .: never reach
- # C++ let alone the browser).
- if property_json.get('type') == 'function':
- continue
model.properties[name] = Property(
model,
name,

Powered by Google App Engine
This is Rietveld 408576698