Skip to content

Instantly share code, notes, and snippets.

@a14n
Created March 4, 2015 20:54
Show Gist options
  • Save a14n/fee492ff44a275bde5c4 to your computer and use it in GitHub Desktop.
Save a14n/fee492ff44a275bde5c4 to your computer and use it in GitHub Desktop.
@Namespace('z.y.x')
library js.example.js_proxy;
import 'package:js/js.dart';
part 'example.g.dart';
@JsProxy()
abstract class _JsFoo {
_JsFoo();
int i;
num k1, k2;
int j = null;
bool get l;
String get a;
void set a(String a);
String get b => '';
void set b(String b) {}
m1();
void m2();
String m3();
String m4(int a);
int m5(int a, b);
}
// GENERATED CODE - DO NOT MODIFY BY HAND
// 2015-03-04T20:52:08.638Z
part of js.example.js_proxy;
// **************************************************************************
// Generator: Instance of 'JsProxyGenerator'
// Target: abstract class _JsFoo
// **************************************************************************
class JsFoo extends JsInterface {
JsFoo.created(JsObject o) : super.created(o);
JsFoo() : this.created(new JsObject(getPath('z.y.x.JsFoo')));
void set i(int _i) {
toJs(this)['_i'] = toJs(_i);
}
int get i => toDart(toJs(this)['i']) as int;
void set k2(num _k2) {
toJs(this)['_k2'] = toJs(_k2);
}
num get k2 => toDart(toJs(this)['k2']) as num;
void set k1(num _k1) {
toJs(this)['_k1'] = toJs(_k1);
}
num get k1 => toDart(toJs(this)['k1']) as num;
int j = null;
bool get l => toDart(toJs(this)['l']) as bool;
String get a => toDart(toJs(this)['a']) as String;
void set a(String a) {
toJs(this)['a'] = toJs(a);
}
String get b => '';
void set b(String b) {}
m1() => toDart(toJs(this).callMethod('m1')) as dynamic;
void m2() {
toJs(this).callMethod('m2');
}
String m3() => toDart(toJs(this).callMethod('m3')) as String;
String m4(int a) =>
toDart(toJs(this).callMethod('m4', [a].map(toJs).toList())) as String;
int m5(int a, b) =>
toDart(toJs(this).callMethod('m5', [a, b].map(toJs).toList())) as int;
}
// **************************************************************************
// Generator: Instance of 'InitializeJavascriptGenerator'
// Target: abstract class _JsFoo
// **************************************************************************
void initializeJavaScript({List<String> exclude, List<String> include}) {
bool accept(String name) => (include != null && include.contains(name)) ||
(include == null && exclude != null && !exclude.contains(name));
void register(String name, JsInterface f(JsObject o)) =>
registerFactoryForJsConstructor(getPath(name), f);
void mayRegister(String name, JsInterface f(JsObject o)) {
if (accept(name)) register(name, f);
}
mayRegister('z.y.x.JsFoo', (o) => new JsFoo.created(o));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment