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

Unified Diff: tools/json_schema_compiler/js_externs_generator.py

Issue 2650733002: Revert of Update json_schema_compiler to handle the Automation extension API (Closed)
Patch Set: Created 3 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/js_externs_generator.py
diff --git a/tools/json_schema_compiler/js_externs_generator.py b/tools/json_schema_compiler/js_externs_generator.py
index a5ef075ac260f574782cf4d06f974e3e662c0e79..065e4d3aaba8753b0ba415bd9871cb43c19c6830 100644
--- a/tools/json_schema_compiler/js_externs_generator.py
+++ b/tools/json_schema_compiler/js_externs_generator.py
@@ -30,7 +30,6 @@
class _Generator(object):
def __init__(self, namespace):
self._namespace = namespace
- self._class_name = None
self._js_util = JsUtil()
def Generate(self):
@@ -80,7 +79,7 @@
.Append(self._js_util.GetSeeLink(self._namespace.name, 'type',
js_type.simple_name))
.Eblock(' */'))
- c.Append('%s.%s = {' % (self._GetNamespace(), js_type.name))
+ c.Append('chrome.%s.%s = {' % (self._namespace.name, js_type.name))
def get_property_name(e):
# Enum properties are normified to be in ALL_CAPS_STYLE.
@@ -106,7 +105,7 @@
return any(prop.type_.property_type is PropertyType.FUNCTION
for prop in js_type.properties.values())
- def _AppendTypeJsDoc(self, c, js_type, optional=False):
+ def _AppendTypeJsDoc(self, c, js_type):
"""Appends the documentation for a type as a Code.
"""
c.Sblock(line='/**', line_prefix=' * ')
@@ -115,16 +114,9 @@
for line in js_type.description.splitlines():
c.Append(line)
- if js_type.jsexterns:
- for line in js_type.jsexterns.splitlines():
- c.Append(line)
-
is_constructor = self._IsTypeConstructor(js_type)
- if js_type.property_type is not PropertyType.OBJECT:
- self._js_util.AppendTypeJsDoc(c, self._namespace.name, js_type, optional)
- elif is_constructor:
- c.Comment('@constructor', comment_prefix = '', wrap_indent=4)
- c.Comment('@private', comment_prefix = '', wrap_indent=4)
+ if is_constructor:
+ c.Comment('@constructor', comment_prefix = ' * ', wrap_indent=4)
else:
self._AppendTypedef(c, js_type.properties)
@@ -132,21 +124,10 @@
js_type.simple_name))
c.Eblock(' */')
- var = '%s.%s' % (self._GetNamespace(), js_type.simple_name)
+ var = 'chrome.%s.%s' % (js_type.namespace.name, js_type.simple_name)
if is_constructor: var += ' = function() {}'
var += ';'
c.Append(var)
-
- if is_constructor:
- c.Append()
- self._class_name = js_type.name
- for prop in js_type.properties.values():
- if prop.type_.property_type is PropertyType.FUNCTION:
- self._AppendFunction(c, prop.type_.function)
- else:
- self._AppendTypeJsDoc(c, prop.type_, prop.optional)
- c.Append()
- self._class_name = None
def _AppendTypedef(self, c, properties):
"""Given an OrderedDict of properties, Appends code containing a @typedef.
@@ -169,8 +150,8 @@
"""
self._js_util.AppendFunctionJsDoc(c, self._namespace.name, function)
params = self._GetFunctionParams(function)
- c.Append('%s.%s = function(%s) {};' % (self._GetNamespace(),
- function.name, params))
+ c.Append('chrome.%s.%s = function(%s) {};' % (self._namespace.name,
+ function.name, params))
c.Append()
def _AppendEvent(self, c, event):
@@ -187,7 +168,7 @@
c.Append(self._js_util.GetSeeLink(self._namespace.name, 'event',
event.name))
c.Eblock(' */')
- c.Append('%s.%s;' % (self._GetNamespace(), event.name))
+ c.Append('chrome.%s.%s;' % (self._namespace.name, event.name))
c.Append()
def _AppendNamespaceObject(self, c):
@@ -212,17 +193,3 @@
if function.callback:
params.append(function.callback)
return ', '.join(param.name for param in params)
-
- def _GetNamespace(self):
- """Returns the namespace to be prepended to a top-level typedef.
-
- For example, it might return "chrome.namespace".
-
- Also optionally includes the class name if this is in the context
- of outputting the members of a class.
-
- For example, "chrome.namespace.ClassName.prototype"
- """
- if self._class_name:
- return 'chrome.%s.%s.prototype' % (self._namespace.name, self._class_name)
- return 'chrome.%s' % self._namespace.name
« no previous file with comments | « tools/json_schema_compiler/idl_schema_test.py ('k') | tools/json_schema_compiler/js_externs_generator_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698