|
@@ -231,7 +231,13 @@ class ExampleJSGenerator {
|
|
public function generate() {
|
|
public function generate() {
|
|
print("var $_, $hxClasses = $hxClasses || {}, $estr = function() { return js.Boot.__string_rec(this,''); }");
|
|
print("var $_, $hxClasses = $hxClasses || {}, $estr = function() { return js.Boot.__string_rec(this,''); }");
|
|
newline();
|
|
newline();
|
|
- print("function $bind(o,m) { var f = function(){ return f.method.apply(f.scope, arguments); }; f.scope = o; f.method = m; return f; };");
|
|
|
|
|
|
+ print(
|
|
|
|
+ #if (js_es < 5)
|
|
|
|
+ "function $bind(o,m) { if( m == null ) return null; if( m.__id__ == null ) m.__id__ = $global.$haxeUID++; var f; if( o.hx__closures__ == null ) o.hx__closures__ = {}; else f = o.hx__closures__[m.__id__]; if( f == null ) { f = function(){ return f.method.apply(f.scope, arguments); }; f.scope = o; f.method = m; o.hx__closures__[m.__id__] = f; } return f; }"
|
|
|
|
+ #else
|
|
|
|
+ "function $bind(o,m) { if( m == null ) return null; if( m.__id__ == null ) m.__id__ = $global.$haxeUID++; var f; if( o.hx__closures__ == null ) o.hx__closures__ = {}; else f = o.hx__closures__[m.__id__]; if( f == null ) { f = m.bind(o); o.hx__closures__[m.__id__] = f; } return f; }"
|
|
|
|
+ #end
|
|
|
|
+ );
|
|
newline();
|
|
newline();
|
|
for (t in api.types)
|
|
for (t in api.types)
|
|
genType(t);
|
|
genType(t);
|