diff options
author | benwells <benwells@chromium.org> | 2015-01-21 06:09:45 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-21 14:11:14 +0000 |
commit | 0eeb6a9a3b410797f88f487c2fe80170273f2723 (patch) | |
tree | f53a1819513a5a5e9d1ad1c5d38b65cf8118dd55 /tools/json_schema_compiler | |
parent | f555fec2b8769deb962f7b36271aa950c19a5eeb (diff) | |
download | chromium_src-0eeb6a9a3b410797f88f487c2fe80170273f2723.zip chromium_src-0eeb6a9a3b410797f88f487c2fe80170273f2723.tar.gz chromium_src-0eeb6a9a3b410797f88f487c2fe80170273f2723.tar.bz2 |
Remove dart generator code from json schema compiler.
This isn't used by anything.
BUG=448704
Review URL: https://codereview.chromium.org/843213003
Cr-Commit-Position: refs/heads/master@{#312343}
Diffstat (limited to 'tools/json_schema_compiler')
19 files changed, 2 insertions, 2049 deletions
diff --git a/tools/json_schema_compiler/compiler.py b/tools/json_schema_compiler/compiler.py index 0b14d29..0d4b264 100755 --- a/tools/json_schema_compiler/compiler.py +++ b/tools/json_schema_compiler/compiler.py @@ -24,7 +24,6 @@ import sys from cpp_bundle_generator import CppBundleGenerator from cpp_generator import CppGenerator from cpp_type_generator import CppTypeGenerator -from dart_generator import DartGenerator import json_schema from cpp_namespace_environment import CppNamespaceEnvironment from model import Model @@ -32,14 +31,13 @@ from schema_loader import SchemaLoader # Names of supported code generators, as specified on the command-line. # First is default. -GENERATORS = ['cpp', 'cpp-bundle-registration', 'cpp-bundle-schema', 'dart'] +GENERATORS = ['cpp', 'cpp-bundle-registration', 'cpp-bundle-schema'] def GenerateSchema(generator_name, file_paths, root, destdir, cpp_namespace_pattern, - dart_overrides_dir, impl_dir, include_rules): # Merge the source files into a single list of schemas. @@ -117,11 +115,6 @@ def GenerateSchema(generator_name, ('%s.h' % filename_base, cpp_generator.h_generator), ('%s.cc' % filename_base, cpp_generator.cc_generator) ] - elif generator_name == 'dart': - generators = [ - ('%s.dart' % namespace.unix_name, DartGenerator( - dart_overrides_dir)) - ] else: raise Exception('Unrecognised generator %s' % generator_name) @@ -159,8 +152,6 @@ if __name__ == '__main__': choices=GENERATORS, help='The generator to use to build the output code. Supported values are' ' %s' % GENERATORS) - parser.add_option('-D', '--dart-overrides-dir', dest='dart_overrides_dir', - help='Adds custom dart from files in the given directory (Dart only).') parser.add_option('-i', '--impl-dir', dest='impl_dir', help='The root path of all API implementations') parser.add_option('-I', '--include-rules', @@ -192,7 +183,6 @@ if __name__ == '__main__': shlex.split(opts.include_rules)) result = GenerateSchema(opts.generator, file_paths, opts.root, opts.destdir, - opts.namespace, opts.dart_overrides_dir, - opts.impl_dir, include_rules) + opts.namespace, opts.impl_dir, include_rules) if not opts.destdir: print result diff --git a/tools/json_schema_compiler/dart_generator.py b/tools/json_schema_compiler/dart_generator.py deleted file mode 100644 index 74ffd11..0000000 --- a/tools/json_schema_compiler/dart_generator.py +++ /dev/null @@ -1,763 +0,0 @@ -# Copyright (c) 2012 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -""" -Generator language component for compiler.py that adds Dart language support. -""" - -from code import Code -from model import Function, PropertyType -from schema_util import StripNamespace - -import os -from datetime import datetime - -LICENSE = ( -"""// Copyright (c) %s, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file.""" % - datetime.now().year) - -class DartGenerator(object): - def __init__(self, dart_overrides_dir=None): - self._dart_overrides_dir = dart_overrides_dir - - def Generate(self, namespace): - return _Generator(namespace, self._dart_overrides_dir).Generate() - - -class _Generator(object): - """A .dart generator for a namespace. - """ - - def __init__(self, namespace, dart_overrides_dir=None): - self._namespace = namespace - # TODO(sashab): Once inline type definitions start being added to - # self._types, make a _FindType(self, type_) function that looks at - # self._namespace.types. - self._types = namespace.types - - # Build a dictionary of Type Name --> Custom Dart code. - self._type_overrides = {} - if dart_overrides_dir is not None: - for filename in os.listdir(dart_overrides_dir): - if filename.startswith(namespace.unix_name): - with open(os.path.join(dart_overrides_dir, filename)) as f: - # Split off the namespace and file extension, leaving just the type. - type_path = '.'.join(filename.split('.')[1:-1]) - self._type_overrides[type_path] = f.read() - - # TODO(sashab): Add all inline type definitions to the global Types - # dictionary here, so they have proper names, and are implemented along with - # all other types. Also update the parameters/members with these types - # to reference these new types instead. - - def Generate(self): - """Generates a Code object with the .dart for the entire namespace. - """ - c = Code() - (c.Append(LICENSE) - .Append() - .Append('// Generated from namespace: %s' % self._namespace.name) - .Append() - .Append('part of chrome;')) - - if self._types: - (c.Append() - .Append('/**') - .Append(' * Types') - .Append(' */') - .Append() - ) - for type_ in self._types.values(): - # Check for custom dart for this whole type. - override = self._GetOverride([type_.name], document_with=type_) - c.Cblock(override if override is not None else self._GenerateType(type_)) - - if self._namespace.events: - (c.Append('/**') - .Append(' * Events') - .Append(' */') - .Append() - ) - for event_name in self._namespace.events: - c.Cblock(self._GenerateEvent(self._namespace.events[event_name])) - - (c.Append('/**') - .Append(' * Functions') - .Append(' */') - .Append() - ) - c.Cblock(self._GenerateMainClass()) - - return c - - def _GenerateType(self, type_): - """Given a Type object, returns the Code with the .dart for this - type's definition. - - Assumes this type is a Parameter Type (creatable by user), and creates an - object that extends ChromeObject. All parameters are specifiable as named - arguments in the constructor, and all methods are wrapped with getters and - setters that hide the JS() implementation. - """ - c = Code() - - # Since enums are just treated as strings for now, don't generate their - # type. - # TODO(sashab): Find a nice way to wrap enum objects. - if type_.property_type is PropertyType.ENUM: - return c - - (c.Concat(self._GenerateDocumentation(type_)) - .Sblock('class %(type_name)s extends ChromeObject {') - ) - - # Check whether this type has function members. If it does, don't allow - # public construction. - add_public_constructor = all(not self._IsFunction(p.type_) - for p in type_.properties.values()) - constructor_fields = [self._GeneratePropertySignature(p) - for p in type_.properties.values()] - - if add_public_constructor: - (c.Append('/*') - .Append(' * Public constructor') - .Append(' */') - .Sblock('%(type_name)s({%(constructor_fields)s}) {') - ) - - for prop_name in type_.properties: - (c.Sblock('if (%s != null)' % prop_name) - .Append('this.%s = %s;' % (prop_name, prop_name)) - .Eblock() - ) - (c.Eblock('}') - .Append() - ) - - (c.Append('/*') - .Append(' * Private constructor') - .Append(' */') - .Append('%(type_name)s._proxy(_jsObject) : super._proxy(_jsObject);') - ) - - # Add an accessor (getter & setter) for each property. - properties = [p for p in type_.properties.values() - if not self._IsFunction(p.type_)] - if properties: - (c.Append() - .Append('/*') - .Append(' * Public accessors') - .Append(' */') - ) - for prop in properties: - override = self._GetOverride([type_.name, prop.name], document_with=prop) - c.Concat(override if override is not None - else self._GenerateGetterAndSetter(type_, prop)) - - # Now add all the methods. - methods = [t for t in type_.properties.values() - if self._IsFunction(t.type_)] - if methods: - (c.Append() - .Append('/*') - .Append(' * Methods') - .Append(' */') - ) - for prop in methods: - # Check if there's an override for this method. - override = self._GetOverride([type_.name, prop.name], document_with=prop) - c.Cblock(override if override is not None - else self._GenerateFunction(prop.type_.function)) - - (c.Eblock('}') - .Substitute({ - 'type_name': self._AddPrefix(type_.simple_name), - 'constructor_fields': ', '.join(constructor_fields) - }) - ) - - return c - - def _GenerateGetterAndSetter(self, type_, prop): - """Given a Type and Property, returns the Code object for the getter and - setter for that property. - """ - c = Code() - override = self._GetOverride([type_.name, prop.name, '.get'], - document_with=prop) - c.Cblock(override if override is not None - else self._GenerateGetter(type_, prop)) - override = self._GetOverride([type_.name, prop.name, '.set']) - c.Cblock(override if override is not None - else self._GenerateSetter(prop)) - return c - - def _GenerateGetter(self, type_, prop): - """Given a Type and Property, returns the Code object for the getter for - that property. - - Also adds the documentation for this property before the method. - """ - c = Code() - c.Concat(self._GenerateDocumentation(prop)) - - type_name = self._GetDartType(prop.type_) - if (self._IsBaseType(prop.type_)): - c.Append("%s get %s => JS('%s', '#.%s', this._jsObject);" % - (type_name, prop.name, type_name, prop.name)) - elif self._IsSerializableObjectType(prop.type_): - c.Append("%s get %s => new %s._proxy(JS('', '#.%s', " - "this._jsObject));" % - (type_name, prop.name, type_name, prop.name)) - elif self._IsListOfSerializableObjects(prop.type_): - (c.Sblock('%s get %s {' % (type_name, prop.name)) - .Append('%s __proxy_%s = new %s();' % (type_name, prop.name, - type_name)) - .Append("int count = JS('int', '#.%s.length', this._jsObject);" % - prop.name) - .Sblock("for (int i = 0; i < count; i++) {") - .Append("var item = JS('', '#.%s[#]', this._jsObject, i);" % prop.name) - .Append('__proxy_%s.add(new %s._proxy(item));' % (prop.name, - self._GetDartType(prop.type_.item_type))) - .Eblock('}') - .Append('return __proxy_%s;' % prop.name) - .Eblock('}') - ) - elif self._IsObjectType(prop.type_): - # TODO(sashab): Think of a way to serialize generic Dart objects. - if type_name in self._types: - c.Append("%s get %s => new %s._proxy(JS('%s', '#.%s', " - "this._jsObject));" % - (type_name, prop.name, type_name, type_name, prop.name)) - else: - c.Append("%s get %s => JS('%s', '#.%s', this._jsObject);" % - (type_name, prop.name, type_name, prop.name)) - else: - raise Exception( - "Could not generate wrapper for %s.%s: unserializable type %s" % - (type_.name, prop.name, type_name) - ) - return c - - def _GenerateSetter(self, prop): - """Given a Property, returns the Code object for the setter for - that property. - """ - c = Code() - type_name = self._GetDartType(prop.type_) - wrapped_name = prop.name - if not self._IsBaseType(prop.type_): - wrapped_name = 'convertArgument(%s)' % prop.name - - (c.Sblock("void set %s(%s %s) {" % (prop.name, type_name, prop.name)) - .Append("JS('void', '#.%s = #', this._jsObject, %s);" % - (prop.name, wrapped_name)) - .Eblock("}") - ) - return c - - def _GenerateDocumentation(self, prop): - """Given an object, generates the documentation for this object (as a - code string) and returns the Code object. - - Returns an empty code object if the object has no documentation. - - Uses triple-quotes for the string. - """ - c = Code() - if prop.description is not None: - for line in prop.description.split('\n'): - c.Comment(line, comment_prefix='/// ') - return c - - def _GenerateFunction(self, f): - """Returns the Code object for the given function. - """ - c = Code() - c.Concat(self._GenerateDocumentation(f)) - - if not self._NeedsProxiedCallback(f): - c.Append("%s => %s;" % (self._GenerateFunctionSignature(f), - self._GenerateProxyCall(f))) - return c - - (c.Sblock("%s {" % self._GenerateFunctionSignature(f)) - .Concat(self._GenerateProxiedFunction(f.callback, f.callback.name)) - .Append('%s;' % self._GenerateProxyCall(f)) - .Eblock('}') - ) - - return c - - def _GenerateProxiedFunction(self, f, callback_name): - """Given a function (assumed to be a callback), generates the proxied - version of this function, which calls |callback_name| if it is defined. - - Returns a Code object. - """ - c = Code() - proxied_params = [] - # A list of Properties, containing List<*> objects that need proxying for - # their members (by copying out each member and proxying it). - lists_to_proxy = [] - for p in f.params: - if self._IsBaseType(p.type_): - proxied_params.append(p.name) - elif self._IsSerializableObjectType(p.type_): - proxied_params.append('new %s._proxy(%s)' % ( - self._GetDartType(p.type_), p.name)) - elif self._IsListOfSerializableObjects(p.type_): - proxied_params.append('__proxy_%s' % p.name) - lists_to_proxy.append(p) - elif self._IsObjectType(p.type_): - # TODO(sashab): Find a way to build generic JS objects back in Dart. - proxied_params.append('%s' % p.name) - elif p.type_.property_type is PropertyType.ARRAY: - # TODO(sashab): This might be okay - what if this is a list of - # FileEntry elements? In this case, a basic list will proxy the objects - # fine. - proxied_params.append('%s' % p.name) - else: - raise Exception( - "Cannot automatically create proxy; can't wrap %s, type %s" % ( - self._GenerateFunctionSignature(f), self._GetDartType(p.type_))) - - (c.Sblock("void __proxy_callback(%s) {" % ', '.join(p.name for p in - f.params)) - .Sblock('if (%s != null) {' % callback_name) - ) - - # Add the proxied lists. - for list_to_proxy in lists_to_proxy: - (c.Append("%s __proxy_%s = new %s();" % ( - self._GetDartType(list_to_proxy.type_), - list_to_proxy.name, - self._GetDartType(list_to_proxy.type_))) - .Sblock("for (var o in %s) {" % list_to_proxy.name) - .Append('__proxy_%s.add(new %s._proxy(o));' % (list_to_proxy.name, - self._GetDartType(list_to_proxy.type_.item_type))) - .Eblock("}") - ) - - (c.Append("%s(%s);" % (callback_name, ', '.join(proxied_params))) - .Eblock('}') - .Eblock('}') - ) - return c - - def _NeedsProxiedCallback(self, f): - """Given a function, returns True if this function's callback needs to be - proxied, False if not. - - Function callbacks need to be proxied if they have at least one - non-base-type parameter. - """ - return f.callback and self._NeedsProxy(f.callback) - - def _NeedsProxy(self, f): - """Given a function, returns True if it needs to be proxied, False if not. - - A function needs to be proxied if any of its members are non-base types. - This means that, when the function object is passed to Javascript, it - needs to be wrapped in a "proxied" call that converts the JS inputs to Dart - objects explicitly, before calling the real function with these new objects. - """ - return any(not self._IsBaseType(p.type_) for p in f.params) - - def _GenerateProxyCall(self, function, call_target='this._jsObject'): - """Given a function, generates the code to call that function via JS(). - Returns a string. - - |call_target| is the name of the object to call the function on. The default - is this._jsObject. - - e.g. - JS('void', '#.resizeTo(#, #)', this._jsObject, width, height) - JS('void', '#.setBounds(#)', this._jsObject, convertArgument(bounds)) - """ - n_params = len(function.params) - if function.callback: - n_params += 1 - - return_type_str = self._GetDartType(function.returns) - params = [] - - # If this object is serializable, don't convert the type from JS - pass the - # JS object straight into the proxy. - if self._IsSerializableObjectType(function.returns): - params.append("''") - else: - params.append("'%s'" % return_type_str) - - params.append("'#.%s(%s)'" % (function.name, ', '.join(['#'] * n_params))) - params.append(call_target) - - for param in function.params: - if not self._IsBaseType(param.type_): - params.append('convertArgument(%s)' % param.name) - else: - params.append(param.name) - if function.callback: - # If this isn't a base type, we need a proxied callback. - callback_name = function.callback.name - if self._NeedsProxiedCallback(function): - callback_name = "__proxy_callback" - params.append('convertDartClosureToJS(%s, %s)' % (callback_name, - len(function.callback.params))) - - # If the object is serializable, call the proxy constructor for this type. - proxy_call = 'JS(%s)' % ', '.join(params) - if self._IsSerializableObjectType(function.returns): - proxy_call = 'new %s._proxy(%s)' % (return_type_str, proxy_call) - - return proxy_call - - def _GenerateEvent(self, event): - """Given a Function object, returns the Code with the .dart for this event, - represented by the function. - - All events extend the Event base type. - """ - c = Code() - - # Add documentation for this event. - (c.Concat(self._GenerateDocumentation(event)) - .Sblock('class Event_%(event_name)s extends Event {') - ) - - # If this event needs a proxy, all calls need to be proxied. - needs_proxy = self._NeedsProxy(event) - - # Override Event callback type definitions. - for ret_type, event_func in (('void', 'addListener'), - ('void', 'removeListener'), - ('bool', 'hasListener')): - param_list = self._GenerateParameterList(event.params, event.callback, - convert_optional=True) - if needs_proxy: - (c.Sblock('%s %s(void callback(%s)) {' % (ret_type, event_func, - param_list)) - .Concat(self._GenerateProxiedFunction(event, 'callback')) - .Append('super.%s(__proxy_callback);' % event_func) - .Eblock('}') - ) - else: - c.Append('%s %s(void callback(%s)) => super.%s(callback);' % - (ret_type, event_func, param_list, event_func)) - c.Append() - - # Generate the constructor. - (c.Append('Event_%(event_name)s(jsObject) : ' - 'super._(jsObject, %(param_num)d);') - .Eblock('}') - .Substitute({ - 'event_name': self._namespace.unix_name + '_' + event.name, - 'param_num': len(event.params) - }) - ) - - return c - - def _GenerateMainClass(self): - """Generates the main class for this file, which links to all functions - and events. - - Returns a code object. - """ - c = Code() - (c.Sblock('class API_%s {' % self._namespace.unix_name) - .Append('/*') - .Append(' * API connection') - .Append(' */') - .Append('Object _jsObject;') - ) - - # Add events. - if self._namespace.events: - (c.Append() - .Append('/*') - .Append(' * Events') - .Append(' */') - ) - for event_name in self._namespace.events: - c.Append('Event_%s_%s %s;' % (self._namespace.unix_name, event_name, - event_name)) - - # Add functions. - if self._namespace.functions: - (c.Append() - .Append('/*') - .Append(' * Functions') - .Append(' */') - ) - for function in self._namespace.functions.values(): - # Check for custom dart for this whole property. - override = self._GetOverride([function.name], document_with=function) - c.Cblock(override if override is not None - else self._GenerateFunction(function)) - - # Add the constructor. - c.Sblock('API_%s(this._jsObject) {' % self._namespace.unix_name) - - # Add events to constructor. - for event_name in self._namespace.events: - c.Append("%s = new Event_%s_%s(JS('', '#.%s', this._jsObject));" % - (event_name, self._namespace.unix_name, event_name, event_name)) - - (c.Eblock('}') - .Eblock('}') - ) - return c - - def _GeneratePropertySignature(self, prop): - """Given a property, returns a signature for that property. - Recursively generates the signature for callbacks. - Returns a String for the given property. - - e.g. - bool x - void onClosed() - void doSomething(bool x, void callback([String x])) - """ - if self._IsFunction(prop.type_): - return self._GenerateFunctionSignature(prop.type_.function) - return '%(type)s %(name)s' % { - 'type': self._GetDartType(prop.type_), - 'name': prop.simple_name - } - - def _GenerateFunctionSignature(self, function, convert_optional=False): - """Given a function object, returns the signature for that function. - Recursively generates the signature for callbacks. - Returns a String for the given function. - - If convert_optional is True, changes optional parameters to be required. - - e.g. - void onClosed() - bool isOpen([String type]) - void doSomething(bool x, void callback([String x])) - """ - sig = '%(return_type)s %(name)s(%(params)s)' - - if function.returns: - return_type = self._GetDartType(function.returns) - else: - return_type = 'void' - - return sig % { - 'return_type': return_type, - 'name': function.simple_name, - 'params': self._GenerateParameterList(function.params, - function.callback, - convert_optional=convert_optional) - } - - def _GenerateParameterList(self, - params, - callback=None, - convert_optional=False): - """Given a list of function parameters, generates their signature (as a - string). - - e.g. - [String type] - bool x, void callback([String x]) - - If convert_optional is True, changes optional parameters to be required. - Useful for callbacks, where optional parameters are treated as required. - """ - # Params lists (required & optional), to be joined with commas. - # TODO(sashab): Don't assume optional params always come after required - # ones. - params_req = [] - params_opt = [] - for param in params: - p_sig = self._GeneratePropertySignature(param) - if param.optional and not convert_optional: - params_opt.append(p_sig) - else: - params_req.append(p_sig) - - # Add the callback, if it exists. - if callback: - c_sig = self._GenerateFunctionSignature(callback, convert_optional=True) - if callback.optional: - params_opt.append(c_sig) - else: - params_req.append(c_sig) - - # Join the parameters with commas. - # Optional parameters have to be in square brackets, e.g.: - # - # required params | optional params | output - # [] | [] | '' - # [x, y] | [] | 'x, y' - # [] | [a, b] | '[a, b]' - # [x, y] | [a, b] | 'x, y, [a, b]' - if params_opt: - params_opt[0] = '[%s' % params_opt[0] - params_opt[-1] = '%s]' % params_opt[-1] - param_sets = [', '.join(params_req), ', '.join(params_opt)] - - # The 'if p' part here is needed to prevent commas where there are no - # parameters of a certain type. - # If there are no optional parameters, this prevents a _trailing_ comma, - # e.g. '(x, y,)'. Similarly, if there are no required parameters, this - # prevents a leading comma, e.g. '(, [a, b])'. - return ', '.join(p for p in param_sets if p) - - def _GetOverride(self, key_chain, document_with=None): - """Given a list of keys, joins them with periods and searches for them in - the custom dart overrides. - If there is an override for that key, finds the override code and returns - the Code object. If not, returns None. - - If document_with is not None, adds the documentation for this property - before the override code. - """ - c = Code() - contents = self._type_overrides.get('.'.join(key_chain)) - if contents is None: - return None - - if document_with is not None: - c.Concat(self._GenerateDocumentation(document_with)) - for line in contents.strip('\n').split('\n'): - c.Append(line) - return c - - def _AddPrefix(self, name): - """Given the name of a type, prefixes the namespace (as camelcase) and - returns the new name. - """ - # TODO(sashab): Split the dart library into multiple files, avoiding the - # need for this prefixing. - return ('%s%s' % ( - ''.join(s.capitalize() for s in self._namespace.name.split('.')), - name)) - - def _IsFunction(self, type_): - """Given a model.Type, returns whether this type is a function. - """ - return type_.property_type == PropertyType.FUNCTION - - def _IsSerializableObjectType(self, type_): - """Given a model.Type, returns whether this type is a serializable object. - Serializable objects are custom types defined in this namespace. - - If this object is a reference to something not in this namespace, assumes - its a serializable object. - """ - if type_ is None: - return False - if type_.property_type is PropertyType.CHOICES: - return all(self._IsSerializableObjectType(c) for c in type_.choices) - if type_.property_type is PropertyType.REF: - if type_.ref_type in self._types: - return self._IsObjectType(self._types[type_.ref_type]) - return True - if (type_.property_type == PropertyType.OBJECT - and type_.instance_of in self._types): - return self._IsObjectType(self._types[type_.instance_of]) - return False - - def _IsObjectType(self, type_): - """Given a model.Type, returns whether this type is an object. - """ - return (self._IsSerializableObjectType(type_) - or type_.property_type in [PropertyType.OBJECT, PropertyType.ANY]) - - def _IsListOfSerializableObjects(self, type_): - """Given a model.Type, returns whether this type is a list of serializable - objects (or regular objects, if this list is treated as a type - in this - case, the item type was defined inline). - - If this type is a reference to something not in this namespace, assumes - it is not a list of serializable objects. - """ - if type_.property_type is PropertyType.CHOICES: - return all(self._IsListOfSerializableObjects(c) for c in type_.choices) - if type_.property_type is PropertyType.REF: - if type_.ref_type in self._types: - return self._IsListOfSerializableObjects(self._types[type_.ref_type]) - return False - return (type_.property_type is PropertyType.ARRAY and - (self._IsSerializableObjectType(type_.item_type))) - - def _IsListOfBaseTypes(self, type_): - """Given a model.Type, returns whether this type is a list of base type - objects (PropertyType.REF types). - """ - if type_.property_type is PropertyType.CHOICES: - return all(self._IsListOfBaseTypes(c) for c in type_.choices) - return (type_.property_type is PropertyType.ARRAY and - self._IsBaseType(type_.item_type)) - - def _IsBaseType(self, type_): - """Given a model.type_, returns whether this type is a base type - (string, number, boolean, or a list of these). - - If type_ is a Choices object, returns True if all possible choices are base - types. - """ - # TODO(sashab): Remove 'Choices' as a base type once they are wrapped in - # native Dart classes. - if type_.property_type is PropertyType.CHOICES: - return all(self._IsBaseType(c) for c in type_.choices) - return ( - (self._GetDartType(type_) in ['bool', 'num', 'int', 'double', 'String']) - or (type_.property_type is PropertyType.ARRAY - and self._IsBaseType(type_.item_type)) - ) - - def _GetDartType(self, type_): - """Given a model.Type object, returns its type as a Dart string. - """ - if type_ is None: - return 'void' - - prop_type = type_.property_type - if prop_type is PropertyType.REF: - if type_.ref_type in self._types: - return self._GetDartType(self._types[type_.ref_type]) - # TODO(sashab): If the type is foreign, it might have to be imported. - return StripNamespace(type_.ref_type) - elif prop_type is PropertyType.BOOLEAN: - return 'bool' - elif prop_type is PropertyType.INTEGER: - return 'int' - elif prop_type is PropertyType.INT64: - return 'num' - elif prop_type is PropertyType.DOUBLE: - return 'double' - elif prop_type is PropertyType.STRING: - return 'String' - elif prop_type is PropertyType.ENUM: - return 'String' - elif prop_type is PropertyType.CHOICES: - # TODO(sashab): Think of a nice way to generate code for Choices objects - # in Dart. - return 'Object' - elif prop_type is PropertyType.ANY: - return 'Object' - elif prop_type is PropertyType.OBJECT: - # TODO(sashab): type_.name is the name of the function's parameter for - # inline types defined in functions. Think of a way to generate names - # for this, or remove all inline type definitions at the start. - if type_.instance_of is not None: - return type_.instance_of - if not isinstance(type_.parent, Function): - return self._AddPrefix(type_.name) - return 'Object' - elif prop_type is PropertyType.FUNCTION: - return 'Function' - elif prop_type is PropertyType.ARRAY: - return 'List<%s>' % self._GetDartType(type_.item_type) - elif prop_type is PropertyType.BINARY: - return 'String' - else: - raise NotImplementedError(prop_type) - diff --git a/tools/json_schema_compiler/dart_generator_test.py b/tools/json_schema_compiler/dart_generator_test.py deleted file mode 100755 index 2005e7e..0000000 --- a/tools/json_schema_compiler/dart_generator_test.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2012 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import os -import sys -import unittest - -from compiler import GenerateSchema - -# If --rebase is passed to this test, this is set to True, indicating the test -# output should be re-generated for each test (rather than running the tests -# themselves). -REBASE_MODE = False - -# The directory containing the input and expected output files corresponding -# to each test name. -TESTS_DIR = 'dart_test' - -class DartTest(unittest.TestCase): - - def _RunTest(self, test_filename): - '''Given the name of a test, runs compiler.py on the file: - TESTS_DIR/test_filename.idl - and compares it to the output in the file: - TESTS_DIR/test_filename.dart - ''' - file_rel = os.path.join(TESTS_DIR, test_filename) - - output_dir = None - if REBASE_MODE: - output_dir = TESTS_DIR - output_code = GenerateSchema('dart', ['%s.idl' % file_rel], TESTS_DIR, - output_dir, '', None, None, []) - - if not REBASE_MODE: - with open('%s.dart' % file_rel) as f: - expected_output = f.read() - # Remove the first line of the output code (as it contains the filename). - # Also remove all blank lines, ignoring them from the comparison. - # Compare with lists instead of strings for clearer diffs (especially with - # whitespace) when a test fails. - self.assertEqual([l for l in expected_output.split('\n') if l], - [l for l in output_code.split('\n')[1:] if l]) - - def setUp(self): - # Increase the maximum diff amount to see the full diff on a failed test. - self.maxDiff = 2000 - - def testComments(self): - self._RunTest('comments') - - def testDictionaries(self): - self._RunTest('dictionaries') - - def testEmptyNamespace(self): - self._RunTest('empty_namespace') - - def testEmptyType(self): - self._RunTest('empty_type') - - def testEvents(self): - self._RunTest('events') - - def testBasicFunction(self): - self._RunTest('functions') - - def testOpratableType(self): - self._RunTest('operatable_type') - - def testTags(self): - self._RunTest('tags') - - -if __name__ == '__main__': - if '--rebase' in sys.argv: - print "Running in rebase mode." - REBASE_MODE = True - sys.argv.remove('--rebase') - unittest.main() diff --git a/tools/json_schema_compiler/dart_test/comments.dart b/tools/json_schema_compiler/dart_test/comments.dart deleted file mode 100644 index 2dd7bb8..0000000 --- a/tools/json_schema_compiler/dart_test/comments.dart +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// Generated from namespace: comments - -part of chrome; -/** - * Functions - */ - -class API_comments { - /* - * API connection - */ - Object _jsObject; - - /* - * Functions - */ - /// <p>There's a blank line at the start of this comment.</p><p>Documentation - /// for basicFunction. BasicFunction() is a great function. There is a newline - /// after this.</p><p>It works like so: +-----+ | | +--+ - /// | | | | +-----+ --> +--+</p><p>Some other stuff here. - /// This paragraph starts with whitespace. Overall, its a great function. - /// There's also a blank line at the end of this comment.</p> - void basicFunction() => JS('void', '#.basicFunction()', this._jsObject); - - API_comments(this._jsObject) { - } -} diff --git a/tools/json_schema_compiler/dart_test/comments.idl b/tools/json_schema_compiler/dart_test/comments.idl deleted file mode 100644 index 7ac1474..0000000 --- a/tools/json_schema_compiler/dart_test/comments.idl +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This comment is for the comments namespace. -namespace comments { - // This comments the "Functions" block, and should be ignored. - interface Functions { - // This comment is separated by at least one blank line from the start of - // the function, and should be ignored. - - // - // There's a blank line at the start of this comment. - // - // Documentation for basicFunction. - // BasicFunction() is a great function. - // There is a newline after this. - // - // It works like so: - // +-----+ - // | | +--+ - // | | | | - // +-----+ --> +--+ - // - // Some other stuff here. - // This paragraph starts with whitespace. - // Overall, its a great function. - // There's also a blank line at the end of this comment. - // - static void basicFunction(); - }; -}; diff --git a/tools/json_schema_compiler/dart_test/dictionaries.dart b/tools/json_schema_compiler/dart_test/dictionaries.dart deleted file mode 100644 index ae03f2f..0000000 --- a/tools/json_schema_compiler/dart_test/dictionaries.dart +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// Generated from namespace: dictionaries - -part of chrome; - -/** - * Types - */ - -class DictionariesInnerType extends ChromeObject { - /* - * Public constructor - */ - DictionariesInnerType({String s, int b, int i, int l, double d, FileEntry f, String os, int ob, int oi, int ol, double od, FileEntry of}) { - if (s != null) - this.s = s; - if (b != null) - this.b = b; - if (i != null) - this.i = i; - if (l != null) - this.l = l; - if (d != null) - this.d = d; - if (f != null) - this.f = f; - if (os != null) - this.os = os; - if (ob != null) - this.ob = ob; - if (oi != null) - this.oi = oi; - if (ol != null) - this.ol = ol; - if (od != null) - this.od = od; - if (of != null) - this.of = of; - } - - /* - * Private constructor - */ - DictionariesInnerType._proxy(_jsObject) : super._proxy(_jsObject); - - /* - * Public accessors - */ - /// Documentation for the String s. - String get s => JS('String', '#.s', this._jsObject); - - void set s(String s) { - JS('void', '#.s = #', this._jsObject, s); - } - - /// Documentation for the boolean b. - int get b => JS('int', '#.b', this._jsObject); - - void set b(int b) { - JS('void', '#.b = #', this._jsObject, b); - } - - /// Documentation for the int i. - int get i => JS('int', '#.i', this._jsObject); - - void set i(int i) { - JS('void', '#.i = #', this._jsObject, i); - } - - /// Documentation for the long l. - int get l => JS('int', '#.l', this._jsObject); - - void set l(int l) { - JS('void', '#.l = #', this._jsObject, l); - } - - /// Documentation for the double d. - double get d => JS('double', '#.d', this._jsObject); - - void set d(double d) { - JS('void', '#.d = #', this._jsObject, d); - } - - /// Documentation for the file entry f. - FileEntry get f => JS('FileEntry', '#.f', this._jsObject); - - void set f(FileEntry f) { - JS('void', '#.f = #', this._jsObject, convertArgument(f)); - } - - /// Documentation for the optional String s. - String get os => JS('String', '#.os', this._jsObject); - - void set os(String os) { - JS('void', '#.os = #', this._jsObject, os); - } - - /// Documentation for the optional boolean ob. - int get ob => JS('int', '#.ob', this._jsObject); - - void set ob(int ob) { - JS('void', '#.ob = #', this._jsObject, ob); - } - - /// Documentation for the optional int i. - int get oi => JS('int', '#.oi', this._jsObject); - - void set oi(int oi) { - JS('void', '#.oi = #', this._jsObject, oi); - } - - /// Documentation for the optional long l. - int get ol => JS('int', '#.ol', this._jsObject); - - void set ol(int ol) { - JS('void', '#.ol = #', this._jsObject, ol); - } - - /// Documentation for the optional double d. - double get od => JS('double', '#.od', this._jsObject); - - void set od(double od) { - JS('void', '#.od = #', this._jsObject, od); - } - - /// Documentation for the optional file entry f. - FileEntry get of => JS('FileEntry', '#.of', this._jsObject); - - void set of(FileEntry of) { - JS('void', '#.of = #', this._jsObject, convertArgument(of)); - } - -} - -class DictionariesOuterType extends ChromeObject { - /* - * Public constructor - */ - DictionariesOuterType({List<DictionariesInnerType> items, List<DictionariesInnerType> oitems}) { - if (items != null) - this.items = items; - if (oitems != null) - this.oitems = oitems; - } - - /* - * Private constructor - */ - DictionariesOuterType._proxy(_jsObject) : super._proxy(_jsObject); - - /* - * Public accessors - */ - /// Documentation for the array of InnerTypes items. - List<DictionariesInnerType> get items { - List<DictionariesInnerType> __proxy_items = new List<DictionariesInnerType>(); - int count = JS('int', '#.items.length', this._jsObject); - for (int i = 0; i < count; i++) { - var item = JS('', '#.items[#]', this._jsObject, i); - __proxy_items.add(new DictionariesInnerType._proxy(item)); - } - return __proxy_items; - } - - void set items(List<DictionariesInnerType> items) { - JS('void', '#.items = #', this._jsObject, convertArgument(items)); - } - - /// Documentation for the optional array of Inner Types oitems. - List<DictionariesInnerType> get oitems { - List<DictionariesInnerType> __proxy_oitems = new List<DictionariesInnerType>(); - int count = JS('int', '#.oitems.length', this._jsObject); - for (int i = 0; i < count; i++) { - var item = JS('', '#.oitems[#]', this._jsObject, i); - __proxy_oitems.add(new DictionariesInnerType._proxy(item)); - } - return __proxy_oitems; - } - - void set oitems(List<DictionariesInnerType> oitems) { - JS('void', '#.oitems = #', this._jsObject, convertArgument(oitems)); - } - -} - -class DictionariesComplexType extends ChromeObject { - /* - * Public constructor - */ - DictionariesComplexType({int i, DictionariesComplexType c}) { - if (i != null) - this.i = i; - if (c != null) - this.c = c; - } - - /* - * Private constructor - */ - DictionariesComplexType._proxy(_jsObject) : super._proxy(_jsObject); - - /* - * Public accessors - */ - /// Documentation for the int i. - int get i => JS('int', '#.i', this._jsObject); - - void set i(int i) { - JS('void', '#.i = #', this._jsObject, i); - } - - /// Documentation for the ComplexType c. - DictionariesComplexType get c => new DictionariesComplexType._proxy(JS('', '#.c', this._jsObject)); - - void set c(DictionariesComplexType c) { - JS('void', '#.c = #', this._jsObject, convertArgument(c)); - } - -} - -/** - * Functions - */ - -class API_dictionaries { - /* - * API connection - */ - Object _jsObject; - API_dictionaries(this._jsObject) { - } -} diff --git a/tools/json_schema_compiler/dart_test/dictionaries.idl b/tools/json_schema_compiler/dart_test/dictionaries.idl deleted file mode 100644 index 1eb9e25..0000000 --- a/tools/json_schema_compiler/dart_test/dictionaries.idl +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This comment is for the dictionaries namespace. -namespace dictionaries { - // Documentation for ComplexType. - dictionary InnerType { - // Documentation for the String s. - DOMString s; - - // Documentation for the boolean b. - int b; - - // Documentation for the int i. - int i; - - // Documentation for the long l. - long l; - - // Documentation for the double d. - double d; - - // Documentation for the file entry f. - [instanceOf=FileEntry] object f; - - // Documentation for the optional String s. - DOMString? os; - - // Documentation for the optional boolean ob. - int ob; - - // Documentation for the optional int i. - int? oi; - - // Documentation for the optional long l. - long? ol; - - // Documentation for the optional double d. - double? od; - - // Documentation for the optional file entry f. - [instanceOf=FileEntry] object? of; - }; - - dictionary OuterType { - // Documentation for the array of InnerTypes items. - InnerType[] items; - - // Documentation for the optional array of Inner Types oitems. - InnerType[]? oitems; - }; - - dictionary ComplexType { - // Documentation for the int i. - int i; - - // Documentation for the ComplexType c. - ComplexType c; - }; -}; diff --git a/tools/json_schema_compiler/dart_test/empty_namespace.dart b/tools/json_schema_compiler/dart_test/empty_namespace.dart deleted file mode 100644 index b731877..0000000 --- a/tools/json_schema_compiler/dart_test/empty_namespace.dart +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// Generated from namespace: empty_namespace - -part of chrome; -/** - * Functions - */ - -class API_empty_namespace { - /* - * API connection - */ - Object _jsObject; - API_empty_namespace(this._jsObject) { - } -} diff --git a/tools/json_schema_compiler/dart_test/empty_namespace.idl b/tools/json_schema_compiler/dart_test/empty_namespace.idl deleted file mode 100644 index 824de2d..0000000 --- a/tools/json_schema_compiler/dart_test/empty_namespace.idl +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// An empty comment is required for an empty namespace. -namespace empty_namespace { -}; diff --git a/tools/json_schema_compiler/dart_test/empty_type.dart b/tools/json_schema_compiler/dart_test/empty_type.dart deleted file mode 100644 index f875392..0000000 --- a/tools/json_schema_compiler/dart_test/empty_type.dart +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// Generated from namespace: empty_type - -part of chrome; - -/** - * Types - */ - -class Empty_typeEmptyType extends ChromeObject { - /* - * Public constructor - */ - Empty_typeEmptyType({}) { - } - - /* - * Private constructor - */ - Empty_typeEmptyType._proxy(_jsObject) : super._proxy(_jsObject); -} - -/** - * Functions - */ - -class API_empty_type { - /* - * API connection - */ - Object _jsObject; - API_empty_type(this._jsObject) { - } -} diff --git a/tools/json_schema_compiler/dart_test/empty_type.idl b/tools/json_schema_compiler/dart_test/empty_type.idl deleted file mode 100644 index 9d7de6f..0000000 --- a/tools/json_schema_compiler/dart_test/empty_type.idl +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Namespace-level comment for EmptyType. -namespace empty_type { - // Documentation for EmptyType. - dictionary EmptyType { - }; -}; diff --git a/tools/json_schema_compiler/dart_test/events.dart b/tools/json_schema_compiler/dart_test/events.dart deleted file mode 100644 index c8a9286..0000000 --- a/tools/json_schema_compiler/dart_test/events.dart +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// Generated from namespace: events - -part of chrome; - -/** - * Types - */ - -class EventsEventArgumentElement extends ChromeObject { - /* - * Public constructor - */ - EventsEventArgumentElement({String elementStringArg}) { - if (elementStringArg != null) - this.elementStringArg = elementStringArg; - } - - /* - * Private constructor - */ - EventsEventArgumentElement._proxy(_jsObject) : super._proxy(_jsObject); - - /* - * Public accessors - */ - String get elementStringArg => JS('String', '#.elementStringArg', this._jsObject); - - void set elementStringArg(String elementStringArg) { - JS('void', '#.elementStringArg = #', this._jsObject, elementStringArg); - } - -} - -class EventsEventArgument extends ChromeObject { - /* - * Public constructor - */ - EventsEventArgument({FileEntry entryArg, String stringArg, int intArg, List<EventsEventArgumentElement> elements, FileEntry optionalEntryArg, String optionalStringArg, int optionalIntArg, List<EventsEventArgumentElement> optionalElements}) { - if (entryArg != null) - this.entryArg = entryArg; - if (stringArg != null) - this.stringArg = stringArg; - if (intArg != null) - this.intArg = intArg; - if (elements != null) - this.elements = elements; - if (optionalEntryArg != null) - this.optionalEntryArg = optionalEntryArg; - if (optionalStringArg != null) - this.optionalStringArg = optionalStringArg; - if (optionalIntArg != null) - this.optionalIntArg = optionalIntArg; - if (optionalElements != null) - this.optionalElements = optionalElements; - } - - /* - * Private constructor - */ - EventsEventArgument._proxy(_jsObject) : super._proxy(_jsObject); - - /* - * Public accessors - */ - /// A file entry - FileEntry get entryArg => JS('FileEntry', '#.entryArg', this._jsObject); - - void set entryArg(FileEntry entryArg) { - JS('void', '#.entryArg = #', this._jsObject, convertArgument(entryArg)); - } - - /// A string - String get stringArg => JS('String', '#.stringArg', this._jsObject); - - void set stringArg(String stringArg) { - JS('void', '#.stringArg = #', this._jsObject, stringArg); - } - - /// A primitive - int get intArg => JS('int', '#.intArg', this._jsObject); - - void set intArg(int intArg) { - JS('void', '#.intArg = #', this._jsObject, intArg); - } - - /// An array - List<EventsEventArgumentElement> get elements { - List<EventsEventArgumentElement> __proxy_elements = new List<EventsEventArgumentElement>(); - int count = JS('int', '#.elements.length', this._jsObject); - for (int i = 0; i < count; i++) { - var item = JS('', '#.elements[#]', this._jsObject, i); - __proxy_elements.add(new EventsEventArgumentElement._proxy(item)); - } - return __proxy_elements; - } - - void set elements(List<EventsEventArgumentElement> elements) { - JS('void', '#.elements = #', this._jsObject, convertArgument(elements)); - } - - /// Optional file entry - FileEntry get optionalEntryArg => JS('FileEntry', '#.optionalEntryArg', this._jsObject); - - void set optionalEntryArg(FileEntry optionalEntryArg) { - JS('void', '#.optionalEntryArg = #', this._jsObject, convertArgument(optionalEntryArg)); - } - - /// A string - String get optionalStringArg => JS('String', '#.optionalStringArg', this._jsObject); - - void set optionalStringArg(String optionalStringArg) { - JS('void', '#.optionalStringArg = #', this._jsObject, optionalStringArg); - } - - /// A primitive - int get optionalIntArg => JS('int', '#.optionalIntArg', this._jsObject); - - void set optionalIntArg(int optionalIntArg) { - JS('void', '#.optionalIntArg = #', this._jsObject, optionalIntArg); - } - - /// An array - List<EventsEventArgumentElement> get optionalElements { - List<EventsEventArgumentElement> __proxy_optionalElements = new List<EventsEventArgumentElement>(); - int count = JS('int', '#.optionalElements.length', this._jsObject); - for (int i = 0; i < count; i++) { - var item = JS('', '#.optionalElements[#]', this._jsObject, i); - __proxy_optionalElements.add(new EventsEventArgumentElement._proxy(item)); - } - return __proxy_optionalElements; - } - - void set optionalElements(List<EventsEventArgumentElement> optionalElements) { - JS('void', '#.optionalElements = #', this._jsObject, convertArgument(optionalElements)); - } - -} - -/** - * Events - */ - -/// Documentation for the first basic event. -class Event_events_firstBasicEvent extends Event { - void addListener(void callback()) => super.addListener(callback); - - void removeListener(void callback()) => super.removeListener(callback); - - bool hasListener(void callback()) => super.hasListener(callback); - - Event_events_firstBasicEvent(jsObject) : super._(jsObject, 0); -} - -/// Documentation for the second basic event. -class Event_events_secondBasicEvent extends Event { - void addListener(void callback()) => super.addListener(callback); - - void removeListener(void callback()) => super.removeListener(callback); - - bool hasListener(void callback()) => super.hasListener(callback); - - Event_events_secondBasicEvent(jsObject) : super._(jsObject, 0); -} - -/// Documentation for an event with a non-optional primitive argument. -class Event_events_nonOptionalPrimitiveArgEvent extends Event { - void addListener(void callback(int argument)) => super.addListener(callback); - - void removeListener(void callback(int argument)) => super.removeListener(callback); - - bool hasListener(void callback(int argument)) => super.hasListener(callback); - - Event_events_nonOptionalPrimitiveArgEvent(jsObject) : super._(jsObject, 1); -} - -/// Documentation for an event with an optional primitive argument. -class Event_events_optionalPrimitiveArgEvent extends Event { - void addListener(void callback(int argument)) => super.addListener(callback); - - void removeListener(void callback(int argument)) => super.removeListener(callback); - - bool hasListener(void callback(int argument)) => super.hasListener(callback); - - Event_events_optionalPrimitiveArgEvent(jsObject) : super._(jsObject, 1); -} - -/// Documentation for an event with a non-optional dictionary argument. -class Event_events_nonOptionalDictArgEvent extends Event { - void addListener(void callback(EventsEventArgument argument)) { - void __proxy_callback(argument) { - if (callback != null) { - callback(new EventsEventArgument._proxy(argument)); - } - } - super.addListener(__proxy_callback); - } - - void removeListener(void callback(EventsEventArgument argument)) { - void __proxy_callback(argument) { - if (callback != null) { - callback(new EventsEventArgument._proxy(argument)); - } - } - super.removeListener(__proxy_callback); - } - - bool hasListener(void callback(EventsEventArgument argument)) { - void __proxy_callback(argument) { - if (callback != null) { - callback(new EventsEventArgument._proxy(argument)); - } - } - super.hasListener(__proxy_callback); - } - - Event_events_nonOptionalDictArgEvent(jsObject) : super._(jsObject, 1); -} - -/// Documentation for an event with a optional dictionary argument. -class Event_events_optionalDictArgEvent extends Event { - void addListener(void callback(EventsEventArgument argument)) { - void __proxy_callback(argument) { - if (callback != null) { - callback(new EventsEventArgument._proxy(argument)); - } - } - super.addListener(__proxy_callback); - } - - void removeListener(void callback(EventsEventArgument argument)) { - void __proxy_callback(argument) { - if (callback != null) { - callback(new EventsEventArgument._proxy(argument)); - } - } - super.removeListener(__proxy_callback); - } - - bool hasListener(void callback(EventsEventArgument argument)) { - void __proxy_callback(argument) { - if (callback != null) { - callback(new EventsEventArgument._proxy(argument)); - } - } - super.hasListener(__proxy_callback); - } - - Event_events_optionalDictArgEvent(jsObject) : super._(jsObject, 1); -} - -/** - * Functions - */ - -class API_events { - /* - * API connection - */ - Object _jsObject; - - /* - * Events - */ - Event_events_firstBasicEvent firstBasicEvent; - Event_events_secondBasicEvent secondBasicEvent; - Event_events_nonOptionalPrimitiveArgEvent nonOptionalPrimitiveArgEvent; - Event_events_optionalPrimitiveArgEvent optionalPrimitiveArgEvent; - Event_events_nonOptionalDictArgEvent nonOptionalDictArgEvent; - Event_events_optionalDictArgEvent optionalDictArgEvent; - API_events(this._jsObject) { - firstBasicEvent = new Event_events_firstBasicEvent(JS('', '#.firstBasicEvent', this._jsObject)); - secondBasicEvent = new Event_events_secondBasicEvent(JS('', '#.secondBasicEvent', this._jsObject)); - nonOptionalPrimitiveArgEvent = new Event_events_nonOptionalPrimitiveArgEvent(JS('', '#.nonOptionalPrimitiveArgEvent', this._jsObject)); - optionalPrimitiveArgEvent = new Event_events_optionalPrimitiveArgEvent(JS('', '#.optionalPrimitiveArgEvent', this._jsObject)); - nonOptionalDictArgEvent = new Event_events_nonOptionalDictArgEvent(JS('', '#.nonOptionalDictArgEvent', this._jsObject)); - optionalDictArgEvent = new Event_events_optionalDictArgEvent(JS('', '#.optionalDictArgEvent', this._jsObject)); - } -} diff --git a/tools/json_schema_compiler/dart_test/events.idl b/tools/json_schema_compiler/dart_test/events.idl deleted file mode 100644 index f1fb4b6..0000000 --- a/tools/json_schema_compiler/dart_test/events.idl +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This comment is for the events namespace. -namespace events { - dictionary EventArgumentElement { - DOMString elementStringArg; - }; - - dictionary EventArgument { - // A file entry - [instanceOf=FileEntry] object entryArg; - - // A string - DOMString stringArg; - - // A primitive - int intArg; - - // An array - EventArgumentElement[] elements; - - // Optional file entry - [instanceOf=FileEntry] object? optionalEntryArg; - - // A string - DOMString? optionalStringArg; - - // A primitive - int? optionalIntArg; - - // An array - EventArgumentElement[]? optionalElements; - }; - - interface Events { - // Documentation for the first basic event. - static void firstBasicEvent(); - - // Documentation for the second basic event. - static void secondBasicEvent(); - - // Documentation for an event with a non-optional primitive argument. - static void nonOptionalPrimitiveArgEvent(int argument); - - // Documentation for an event with an optional primitive argument. - static void optionalPrimitiveArgEvent(optional int argument); - - // Documentation for an event with a non-optional dictionary argument. - static void nonOptionalDictArgEvent(EventArgument argument); - - // Documentation for an event with a optional dictionary argument. - static void optionalDictArgEvent(EventArgument argument); - }; -}; diff --git a/tools/json_schema_compiler/dart_test/functions.dart b/tools/json_schema_compiler/dart_test/functions.dart deleted file mode 100644 index 7ee9db9..0000000 --- a/tools/json_schema_compiler/dart_test/functions.dart +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// Generated from namespace: functions - -part of chrome; - -/** - * Types - */ - -class FunctionsDictType extends ChromeObject { - /* - * Private constructor - */ - FunctionsDictType._proxy(_jsObject) : super._proxy(_jsObject); - - /* - * Public accessors - */ - /// A field. - int get a => JS('int', '#.a', this._jsObject); - - void set a(int a) { - JS('void', '#.a = #', this._jsObject, a); - } - - - /* - * Methods - */ - /// A parameter. - void voidFunc() => JS('void', '#.voidFunc()', this._jsObject); - -} - -/** - * Functions - */ - -class API_functions { - /* - * API connection - */ - Object _jsObject; - - /* - * Functions - */ - /// Simple function. - void voidFunc() => JS('void', '#.voidFunc()', this._jsObject); - - /// Function taking a non-optional argument. - void argFunc(String s) => JS('void', '#.argFunc(#)', this._jsObject, s); - - /// Function taking an optional argument. - void optionalArgFunc([String s]) => JS('void', '#.optionalArgFunc(#)', this._jsObject, s); - - /// Function taking a non-optional dictionary argument. - void dictArgFunc(FunctionsDictType d) => JS('void', '#.dictArgFunc(#)', this._jsObject, convertArgument(d)); - - /// Function taking an optional dictionary argument. - void optionalDictArgFunc([FunctionsDictType d]) => JS('void', '#.optionalDictArgFunc(#)', this._jsObject, convertArgument(d)); - - /// Function taking an entry argument. - void entryArgFunc(Object entry) => JS('void', '#.entryArgFunc(#)', this._jsObject, convertArgument(entry)); - - /// Function taking a simple callback. - void callbackFunc(void c()) => JS('void', '#.callbackFunc(#)', this._jsObject, convertDartClosureToJS(c, 0)); - - /// Function taking an optional simple callback. - void optionalCallbackFunc([void c()]) => JS('void', '#.optionalCallbackFunc(#)', this._jsObject, convertDartClosureToJS(c, 0)); - - /// Function taking a primitive callback. - void primitiveCallbackFunc(void c(int i)) => JS('void', '#.primitiveCallbackFunc(#)', this._jsObject, convertDartClosureToJS(c, 1)); - - /// Function taking a dictionary callback. - void dictCallbackFunc(void c(DictType dict)) { - void __proxy_callback(dict) { - if (c != null) { - c(new DictType._proxy(dict)); - } - } - JS('void', '#.dictCallbackFunc(#)', this._jsObject, convertDartClosureToJS(__proxy_callback, 1)); - } - - /// Function returning a dictionary. - FunctionsDictType dictRetFunc() => new FunctionsDictType._proxy(JS('', '#.dictRetFunc()', this._jsObject)); - - API_functions(this._jsObject) { - } -} diff --git a/tools/json_schema_compiler/dart_test/functions.idl b/tools/json_schema_compiler/dart_test/functions.idl deleted file mode 100644 index e303d0d..0000000 --- a/tools/json_schema_compiler/dart_test/functions.idl +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A comment for the functions namespace. -namespace functions { - callback SimpleCallback = void (); - - callback PrimitiveCallback = void (int i); - - callback DictCallback = void ([instanceOf=DictType] object dict); - - dictionary DictType { - // A field. - int a; - - // A parameter. - static void voidFunc(); - }; - - interface Functions { - // Simple function. - static void voidFunc(); - - // Function taking a non-optional argument. - static void argFunc(DOMString s); - - // Function taking an optional argument. - static void optionalArgFunc(optional DOMString s); - - // Function taking a non-optional dictionary argument. - static void dictArgFunc(DictType d); - - // Function taking an optional dictionary argument. - static void optionalDictArgFunc(optional DictType d); - - // Function taking an entry argument. - static void entryArgFunc([intanceOf=FileEntry] object entry); - - // Function taking a simple callback. - static void callbackFunc(SimpleCallback c); - - // Function taking an optional simple callback. - static void optionalCallbackFunc(optional SimpleCallback c); - - // Function taking a primitive callback. - static void primitiveCallbackFunc(PrimitiveCallback c); - - // Function taking a dictionary callback. - static void dictCallbackFunc(DictCallback c); - - // Function returning a dictionary. - static DictType dictRetFunc(); - }; -}; diff --git a/tools/json_schema_compiler/dart_test/operatable_type.dart b/tools/json_schema_compiler/dart_test/operatable_type.dart deleted file mode 100644 index 550e4d5..0000000 --- a/tools/json_schema_compiler/dart_test/operatable_type.dart +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// Generated from namespace: operatable_type - -part of chrome; - -/** - * Types - */ - -class Operatable_typeDictType extends ChromeObject { - /* - * Public constructor - */ - Operatable_typeDictType({int x, int y}) { - if (x != null) - this.x = x; - if (y != null) - this.y = y; - } - - /* - * Private constructor - */ - Operatable_typeDictType._proxy(_jsObject) : super._proxy(_jsObject); - - /* - * Public accessors - */ - int get x => JS('int', '#.x', this._jsObject); - - void set x(int x) { - JS('void', '#.x = #', this._jsObject, x); - } - - int get y => JS('int', '#.y', this._jsObject); - - void set y(int y) { - JS('void', '#.y = #', this._jsObject, y); - } - -} - -class Operatable_typeOperatableType extends ChromeObject { - /* - * Private constructor - */ - Operatable_typeOperatableType._proxy(_jsObject) : super._proxy(_jsObject); - - /* - * Public accessors - */ - /// Documentation for the String t. - String get t => JS('String', '#.t', this._jsObject); - - void set t(String t) { - JS('void', '#.t = #', this._jsObject, t); - } - - - /* - * Methods - */ - /// Function returning nothing, taking nothing. - void voidFunc() => JS('void', '#.voidFunc()', this._jsObject); - - /// Function returning primitive type. - int intRetFunc() => new int._proxy(JS('', '#.intRetFunc()', this._jsObject)); - - /// Function returning dictionary. - Operatable_typeDictType dictRetFunc() => new Operatable_typeDictType._proxy(JS('', '#.dictRetFunc()', this._jsObject)); - - /// Function taking primitive type. - void intArgFunc(int i) => JS('void', '#.intArgFunc(#)', this._jsObject, i); - - /// Function taking dict type. - void dictArgFunc(Operatable_typeDictType d) => JS('void', '#.dictArgFunc(#)', this._jsObject, convertArgument(d)); - -} - -/** - * Functions - */ - -class API_operatable_type { - /* - * API connection - */ - Object _jsObject; - API_operatable_type(this._jsObject) { - } -} diff --git a/tools/json_schema_compiler/dart_test/operatable_type.idl b/tools/json_schema_compiler/dart_test/operatable_type.idl deleted file mode 100644 index 9c5f53c..0000000 --- a/tools/json_schema_compiler/dart_test/operatable_type.idl +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Top-level namespace-comment for operatableType -namespace operatable_type { - dictionary DictType { - int x; - int y; - }; - - // Documentation for OperatableType. - dictionary OperatableType { - // Documentation for the String t. - DOMString t; - - // Function returning nothing, taking nothing. - static void voidFunc(); - - // Function returning primitive type. - static int intRetFunc(); - - // Function returning dictionary. - static DictType dictRetFunc(); - - // Function taking primitive type. - static void intArgFunc(int i); - - // Function taking dict type. - static void dictArgFunc(DictType d); - }; -}; diff --git a/tools/json_schema_compiler/dart_test/tags.dart b/tools/json_schema_compiler/dart_test/tags.dart deleted file mode 100644 index a18436b..0000000 --- a/tools/json_schema_compiler/dart_test/tags.dart +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// Generated from namespace: tags - -part of chrome; - -/** - * Types - */ - -class TagsInlineDoc extends ChromeObject { - /* - * Public constructor - */ - TagsInlineDoc({}) { - } - - /* - * Private constructor - */ - TagsInlineDoc._proxy(_jsObject) : super._proxy(_jsObject); -} - -class TagsNodoc extends ChromeObject { - /* - * Public constructor - */ - TagsNodoc({}) { - } - - /* - * Private constructor - */ - TagsNodoc._proxy(_jsObject) : super._proxy(_jsObject); -} - -class TagsNocompile extends ChromeObject { - /* - * Public constructor - */ - TagsNocompile({}) { - } - - /* - * Private constructor - */ - TagsNocompile._proxy(_jsObject) : super._proxy(_jsObject); -} - -class TagsPlainDict extends ChromeObject { - /* - * Public constructor - */ - TagsPlainDict({int inline_doc, String nodoc, double nocompile, fileEntry instance_of_tag}) { - if (inline_doc != null) - this.inline_doc = inline_doc; - if (nodoc != null) - this.nodoc = nodoc; - if (nocompile != null) - this.nocompile = nocompile; - if (instance_of_tag != null) - this.instance_of_tag = instance_of_tag; - } - - /* - * Private constructor - */ - TagsPlainDict._proxy(_jsObject) : super._proxy(_jsObject); - - /* - * Public accessors - */ - /// This int has the property [inline_doc]. - int get inline_doc => JS('int', '#.inline_doc', this._jsObject); - - void set inline_doc(int inline_doc) { - JS('void', '#.inline_doc = #', this._jsObject, inline_doc); - } - - /// This String has the property [nodoc]. - String get nodoc => JS('String', '#.nodoc', this._jsObject); - - void set nodoc(String nodoc) { - JS('void', '#.nodoc = #', this._jsObject, nodoc); - } - - /// This double has the property [nocompile]. - double get nocompile => JS('double', '#.nocompile', this._jsObject); - - void set nocompile(double nocompile) { - JS('void', '#.nocompile = #', this._jsObject, nocompile); - } - - /// This object has the property [instanceOf=fileEntry]. - fileEntry get instance_of_tag => JS('fileEntry', '#.instance_of_tag', this._jsObject); - - void set instance_of_tag(fileEntry instance_of_tag) { - JS('void', '#.instance_of_tag = #', this._jsObject, convertArgument(instance_of_tag)); - } - -} - -/** - * Functions - */ - -class API_tags { - /* - * API connection - */ - Object _jsObject; - API_tags(this._jsObject) { - } -} diff --git a/tools/json_schema_compiler/dart_test/tags.idl b/tools/json_schema_compiler/dart_test/tags.idl deleted file mode 100644 index 7a029cd..0000000 --- a/tools/json_schema_compiler/dart_test/tags.idl +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A comment describing tags. -namespace tags { - // This dictionary has the property [inline_doc]. - [inline_doc] dictionary InlineDoc { - }; - - // This dictionary has the property [nodoc]. - [nodoc] dictionary Nodoc { - }; - - // This dictionary has the property [nocompile]. - [nocompile] dictionary Nocompile { - }; - - // This dictionary has no tags on the dictionary itself. - dictionary PlainDict { - // This int has the property [inline_doc]. - [inline_doc] int inline_doc; - - // This String has the property [nodoc]. - [nodoc] String nodoc; - - // This double has the property [nocompile]. - [nocompile] double nocompile; - - // This object has the property [instanceOf=fileEntry]. - [instanceOf=fileEntry] object instance_of_tag; - }; -}; |