summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/json_schema_compiler/dart_generator.py16
-rwxr-xr-xtools/json_schema_compiler/dart_generator_test.py15
-rw-r--r--tools/json_schema_compiler/dart_test/basic_event.dart40
-rw-r--r--tools/json_schema_compiler/dart_test/basic_event.idl10
-rw-r--r--tools/json_schema_compiler/dart_test/basic_function.dart29
-rw-r--r--tools/json_schema_compiler/dart_test/basic_function.idl13
-rw-r--r--tools/json_schema_compiler/dart_test/dictionaries.dart12
-rw-r--r--tools/json_schema_compiler/dart_test/enums.idl11
-rw-r--r--tools/json_schema_compiler/dart_test/events.dart282
-rw-r--r--tools/json_schema_compiler/dart_test/events.idl55
-rw-r--r--tools/json_schema_compiler/dart_test/functions.dart93
-rw-r--r--tools/json_schema_compiler/dart_test/functions.idl54
-rw-r--r--tools/json_schema_compiler/dart_test/operatable_type.dart49
-rw-r--r--tools/json_schema_compiler/dart_test/operatable_type.idl23
14 files changed, 588 insertions, 114 deletions
diff --git a/tools/json_schema_compiler/dart_generator.py b/tools/json_schema_compiler/dart_generator.py
index d40cc73..aa73124 100644
--- a/tools/json_schema_compiler/dart_generator.py
+++ b/tools/json_schema_compiler/dart_generator.py
@@ -208,16 +208,18 @@ class _Generator(object):
(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))
+ "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))
- .Sblock("for (var o in JS('List', '#.%s', this._jsObject)) {" %
- prop.name)
- .Append('__proxy_%s.add(new %s._proxy(o));' % (prop.name,
- self._GetDartType(prop.type_.item_type)))
+ .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);" % 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('}')
@@ -437,7 +439,7 @@ class _Generator(object):
(c.Sblock('%s %s(void callback(%s)) {' % (ret_type, event_func,
param_list))
.Concat(self._GenerateProxiedFunction(event, 'callback'))
- .Append('super.%s(callback);' % event_func)
+ .Append('super.%s(__proxy_callback);' % event_func)
.Eblock('}')
)
else:
diff --git a/tools/json_schema_compiler/dart_generator_test.py b/tools/json_schema_compiler/dart_generator_test.py
index 283918d..65ec7f1 100755
--- a/tools/json_schema_compiler/dart_generator_test.py
+++ b/tools/json_schema_compiler/dart_generator_test.py
@@ -50,12 +50,6 @@ class DartTest(unittest.TestCase):
# Increase the maximum diff amount to see the full diff on a failed test.
self.maxDiff = 2000
- def testBasicEvent(self):
- self._RunTest('basic_event')
-
- def testBasicFunction(self):
- self._RunTest('basic_function')
-
def testComments(self):
self._RunTest('comments')
@@ -68,6 +62,15 @@ class DartTest(unittest.TestCase):
def testEmptyType(self):
self._RunTest('empty_type')
+ def testEvents(self):
+ self._RunTest('enums')
+
+ def testEvents(self):
+ self._RunTest('events')
+
+ def testBasicFunction(self):
+ self._RunTest('functions')
+
def testOpratableType(self):
self._RunTest('operatable_type')
diff --git a/tools/json_schema_compiler/dart_test/basic_event.dart b/tools/json_schema_compiler/dart_test/basic_event.dart
deleted file mode 100644
index 905ab7f..0000000
--- a/tools/json_schema_compiler/dart_test/basic_event.dart
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2013, 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: basic_event
-
-part of chrome;
-/**
- * Events
- */
-
-/// Documentation for basicEvent.
-class Event_basic_event_basicEvent extends Event {
- void addListener(void callback()) => super.addListener(callback);
-
- void removeListener(void callback()) => super.removeListener(callback);
-
- bool hasListener(void callback()) => super.hasListener(callback);
-
- Event_basic_event_basicEvent(jsObject) : super._(jsObject, 0);
-}
-
-/**
- * Functions
- */
-
-class API_basic_event {
- /*
- * API connection
- */
- Object _jsObject;
-
- /*
- * Events
- */
- Event_basic_event_basicEvent basicEvent;
- API_basic_event(this._jsObject) {
- basicEvent = new Event_basic_event_basicEvent(JS('', '#.basicEvent', this._jsObject));
- }
-}
diff --git a/tools/json_schema_compiler/dart_test/basic_event.idl b/tools/json_schema_compiler/dart_test/basic_event.idl
deleted file mode 100644
index 8e5e13c..0000000
--- a/tools/json_schema_compiler/dart_test/basic_event.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 basic_event {
- interface Events {
- // Documentation for basicEvent.
- static void basicEvent();
- };
-};
diff --git a/tools/json_schema_compiler/dart_test/basic_function.dart b/tools/json_schema_compiler/dart_test/basic_function.dart
deleted file mode 100644
index 3eb7947..0000000
--- a/tools/json_schema_compiler/dart_test/basic_function.dart
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2013, 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: basic_function
-
-part of chrome;
-/**
- * Functions
- */
-
-class API_basic_function {
- /*
- * API connection
- */
- Object _jsObject;
-
- /*
- * Functions
- */
- /// Documentation for the basic function, foo().
- void foo() => JS('void', '#.foo()', this._jsObject);
-
- /// Documentation for the basic static function, staticFoo().
- void staticFoo() => JS('void', '#.staticFoo()', this._jsObject);
-
- API_basic_function(this._jsObject) {
- }
-}
diff --git a/tools/json_schema_compiler/dart_test/basic_function.idl b/tools/json_schema_compiler/dart_test/basic_function.idl
deleted file mode 100644
index 29f62be..0000000
--- a/tools/json_schema_compiler/dart_test/basic_function.idl
+++ /dev/null
@@ -1,13 +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 basic_function {
- interface Functions {
- // Documentation for the basic function, foo().
- void foo();
-
- // Documentation for the basic static function, staticFoo().
- static void staticFoo();
- };
-};
diff --git a/tools/json_schema_compiler/dart_test/dictionaries.dart b/tools/json_schema_compiler/dart_test/dictionaries.dart
index 770efa6..11f2e73 100644
--- a/tools/json_schema_compiler/dart_test/dictionaries.dart
+++ b/tools/json_schema_compiler/dart_test/dictionaries.dart
@@ -157,8 +157,10 @@ class DictionariesOuterType extends ChromeObject {
/// Documentation for the array of InnerTypes items.
List<DictionariesInnerType> get items {
List<DictionariesInnerType> __proxy_items = new List<DictionariesInnerType>();
- for (var o in JS('List', '#.items', this._jsObject)) {
- __proxy_items.add(new DictionariesInnerType._proxy(o));
+ int count = JS('int', '#.items.length', this._jsObject);
+ for (int i = 0; i < count; i++) {
+ var item = JS('', '#.items', this._jsObject);
+ __proxy_items.add(new DictionariesInnerType._proxy(item));
}
return __proxy_items;
}
@@ -170,8 +172,10 @@ class DictionariesOuterType extends ChromeObject {
/// Documentation for the optional array of Inner Types oitems.
List<DictionariesInnerType> get oitems {
List<DictionariesInnerType> __proxy_oitems = new List<DictionariesInnerType>();
- for (var o in JS('List', '#.oitems', this._jsObject)) {
- __proxy_oitems.add(new DictionariesInnerType._proxy(o));
+ int count = JS('int', '#.oitems.length', this._jsObject);
+ for (int i = 0; i < count; i++) {
+ var item = JS('', '#.oitems', this._jsObject);
+ __proxy_oitems.add(new DictionariesInnerType._proxy(item));
}
return __proxy_oitems;
}
diff --git a/tools/json_schema_compiler/dart_test/enums.idl b/tools/json_schema_compiler/dart_test/enums.idl
new file mode 100644
index 0000000..18ea85a
--- /dev/null
+++ b/tools/json_schema_compiler/dart_test/enums.idl
@@ -0,0 +1,11 @@
+// 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.
+
+namespace enums {
+ // A basic enumeration.
+ enum Enum1 { a, b };
+
+ // Another basic enumeration.
+ enum Enum2 { ab, bc, de, ef, fg, hi };
+};
diff --git a/tools/json_schema_compiler/dart_test/events.dart b/tools/json_schema_compiler/dart_test/events.dart
new file mode 100644
index 0000000..6aa5c07
--- /dev/null
+++ b/tools/json_schema_compiler/dart_test/events.dart
@@ -0,0 +1,282 @@
+// Copyright (c) 2013, 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)
+ 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)
+ this.entryArg = entryArg;
+ if (?stringArg)
+ this.stringArg = stringArg;
+ if (?intArg)
+ this.intArg = intArg;
+ if (?elements)
+ this.elements = elements;
+ if (?optionalEntryArg)
+ this.optionalEntryArg = optionalEntryArg;
+ if (?optionalStringArg)
+ this.optionalStringArg = optionalStringArg;
+ if (?optionalIntArg)
+ this.optionalIntArg = optionalIntArg;
+ if (?optionalElements)
+ 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);
+ __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);
+ __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) {
+ callback(new EventsEventArgument._proxy(argument));
+ }
+ }
+ super.addListener(__proxy_callback);
+ }
+
+ void removeListener(void callback(EventsEventArgument argument)) {
+ void __proxy_callback(argument) {
+ if (?callback) {
+ callback(new EventsEventArgument._proxy(argument));
+ }
+ }
+ super.removeListener(__proxy_callback);
+ }
+
+ bool hasListener(void callback(EventsEventArgument argument)) {
+ void __proxy_callback(argument) {
+ if (?callback) {
+ 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) {
+ callback(new EventsEventArgument._proxy(argument));
+ }
+ }
+ super.addListener(__proxy_callback);
+ }
+
+ void removeListener(void callback(EventsEventArgument argument)) {
+ void __proxy_callback(argument) {
+ if (?callback) {
+ callback(new EventsEventArgument._proxy(argument));
+ }
+ }
+ super.removeListener(__proxy_callback);
+ }
+
+ bool hasListener(void callback(EventsEventArgument argument)) {
+ void __proxy_callback(argument) {
+ if (?callback) {
+ 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
new file mode 100644
index 0000000..54c711a
--- /dev/null
+++ b/tools/json_schema_compiler/dart_test/events.idl
@@ -0,0 +1,55 @@
+// 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.
+
+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
new file mode 100644
index 0000000..6c31c81
--- /dev/null
+++ b/tools/json_schema_compiler/dart_test/functions.dart
@@ -0,0 +1,93 @@
+// Copyright (c) 2013, 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) {
+ 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
new file mode 100644
index 0000000..e2283c6
--- /dev/null
+++ b/tools/json_schema_compiler/dart_test/functions.idl
@@ -0,0 +1,54 @@
+// 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.
+
+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
index 9e3d708..d60c9d3 100644
--- a/tools/json_schema_compiler/dart_test/operatable_type.dart
+++ b/tools/json_schema_compiler/dart_test/operatable_type.dart
@@ -10,6 +10,39 @@ part of chrome;
* Types
*/
+class Operatable_typeDictType extends ChromeObject {
+ /*
+ * Public constructor
+ */
+ Operatable_typeDictType({int x, int y}) {
+ if (?x)
+ this.x = x;
+ if (?y)
+ 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
@@ -30,8 +63,20 @@ class Operatable_typeOperatableType extends ChromeObject {
/*
* Methods
*/
- /// Documentation for staticFoo.
- void staticFoo() => JS('void', '#.staticFoo()', this._jsObject);
+ /// 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));
}
diff --git a/tools/json_schema_compiler/dart_test/operatable_type.idl b/tools/json_schema_compiler/dart_test/operatable_type.idl
index 64dd382..74ce534 100644
--- a/tools/json_schema_compiler/dart_test/operatable_type.idl
+++ b/tools/json_schema_compiler/dart_test/operatable_type.idl
@@ -3,12 +3,29 @@
// found in the LICENSE file.
namespace operatable_type {
+ dictionary DictType {
+ int x;
+ int y;
+ };
+
// Documentation for OperatableType.
dictionary OperatableType {
// Documentation for the String t.
DOMString t;
- // Documentation for staticFoo.
- static void staticFoo();
+ // 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);
};
-};
+}; \ No newline at end of file