|
@@ -1024,6 +1024,7 @@ let generate_enum ctx e =
|
|
print ctx "{";
|
|
print ctx "{";
|
|
if has_feature ctx "js.Boot.isEnum" then print ctx " __ename__ : %s," (if has_feature ctx "Type.getEnumName" then "[" ^ String.concat "," ename ^ "]" else "true");
|
|
if has_feature ctx "js.Boot.isEnum" then print ctx " __ename__ : %s," (if has_feature ctx "Type.getEnumName" then "[" ^ String.concat "," ename ^ "]" else "true");
|
|
print ctx " __constructs__ : [%s] }" (String.concat "," (List.map (fun s -> Printf.sprintf "\"%s\"" s) e.e_names));
|
|
print ctx " __constructs__ : [%s] }" (String.concat "," (List.map (fun s -> Printf.sprintf "\"%s\"" s) e.e_names));
|
|
|
|
+ ctx.separator <- true;
|
|
newline ctx;
|
|
newline ctx;
|
|
List.iter (fun n ->
|
|
List.iter (fun n ->
|
|
let f = PMap.find n e.e_constrs in
|
|
let f = PMap.find n e.e_constrs in
|
|
@@ -1032,6 +1033,7 @@ let generate_enum ctx e =
|
|
| TFun (args,_) ->
|
|
| TFun (args,_) ->
|
|
let sargs = String.concat "," (List.map (fun (n,_,_) -> ident n) args) in
|
|
let sargs = String.concat "," (List.map (fun (n,_,_) -> ident n) args) in
|
|
print ctx "function(%s) { var $x = [\"%s\",%d,%s]; $x.__enum__ = %s; $x.toString = $estr; return $x; }" sargs f.ef_name f.ef_index sargs p;
|
|
print ctx "function(%s) { var $x = [\"%s\",%d,%s]; $x.__enum__ = %s; $x.toString = $estr; return $x; }" sargs f.ef_name f.ef_index sargs p;
|
|
|
|
+ ctx.separator <- true;
|
|
| _ ->
|
|
| _ ->
|
|
print ctx "[\"%s\",%d]" f.ef_name f.ef_index;
|
|
print ctx "[\"%s\",%d]" f.ef_name f.ef_index;
|
|
newline ctx;
|
|
newline ctx;
|
|
@@ -1207,14 +1209,12 @@ let generate com =
|
|
if has_feature ctx "use.$iterator" then begin
|
|
if has_feature ctx "use.$iterator" then begin
|
|
add_feature ctx "use.$bind";
|
|
add_feature ctx "use.$bind";
|
|
print ctx "function $iterator(o) { if( o instanceof Array ) return function() { return HxOverrides.iter(o); }; return typeof(o.iterator) == 'function' ? $bind(o,o.iterator) : o.iterator; }";
|
|
print ctx "function $iterator(o) { if( o instanceof Array ) return function() { return HxOverrides.iter(o); }; return typeof(o.iterator) == 'function' ? $bind(o,o.iterator) : o.iterator; }";
|
|
- ctx.separator <- true;
|
|
|
|
newline ctx;
|
|
newline ctx;
|
|
end;
|
|
end;
|
|
if has_feature ctx "use.$bind" then begin
|
|
if has_feature ctx "use.$bind" then begin
|
|
print ctx "var $_, $fid = 0";
|
|
print ctx "var $_, $fid = 0";
|
|
newline ctx;
|
|
newline ctx;
|
|
print ctx "function $bind(o,m) { if( m == null ) return null; if( m.__id__ == null ) m.__id__ = $fid++; 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; }";
|
|
print ctx "function $bind(o,m) { if( m == null ) return null; if( m.__id__ == null ) m.__id__ = $fid++; 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; }";
|
|
- ctx.separator <- true;
|
|
|
|
newline ctx;
|
|
newline ctx;
|
|
end;
|
|
end;
|
|
List.iter (gen_block ~after:true ctx) (List.rev ctx.inits);
|
|
List.iter (gen_block ~after:true ctx) (List.rev ctx.inits);
|