Skip to content

Commit

Permalink
[lua] sidestep #7851 by including helper code directly in genlua
Browse files Browse the repository at this point in the history
  • Loading branch information
nadako committed Feb 26, 2019
1 parent defd505 commit 436ef40
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
19 changes: 15 additions & 4 deletions src/generators/genlua.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1944,13 +1944,24 @@ let generate com =
if has_feature ctx "Class" || has_feature ctx "Type.getClassName" then add_feature ctx "lua.Boot.isClass";
if has_feature ctx "Enum" || has_feature ctx "Type.getEnumName" then add_feature ctx "lua.Boot.isEnum";

let print_file path =
let file_content = Std.input_file ~bin:true path in
print ctx "%s\n" file_content;
in

(* table-to-array helper *)
print_file (Common.find_file com "lua/_lua/_hx_tab_array.lua");

(* lua workarounds for basic anonymous object functionality *)
print_file (Common.find_file com "lua/_lua/_hx_anon.lua");

(* class reflection metadata *)
print_file (Common.find_file com "lua/_lua/_hx_classes.lua");

let include_files = List.rev com.include_files in
List.iter (fun file ->
match file with
| path, "top" ->
let file_content = Std.input_file ~bin:true (fst file) in
print ctx "%s\n" file_content;
()
| path, "top" -> print_file path
| _ -> ()
) include_files;

Expand Down
6 changes: 0 additions & 6 deletions std/lua/_lua/_hx_apply.lua

This file was deleted.

4 changes: 0 additions & 4 deletions std/lua/_std/Array.hx
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,5 @@ class Array<T> {
this.length = len;
}
}
private static function __init__() : Void{
// table-to-array helper
haxe.macro.Compiler.includeFile("lua/_lua/_hx_tab_array.lua");
}

}
5 changes: 0 additions & 5 deletions std/lua/_std/Std.hx
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ import lua.NativeStringTools;
}

static function __init__() : Void untyped {
// lua workarounds for basic anonymous object functionality
haxe.macro.Compiler.includeFile("lua/_lua/_hx_anon.lua");

// class reflection metadata
haxe.macro.Compiler.includeFile("lua/_lua/_hx_classes.lua");
__feature__("lua.Boot.isClass", String.__name__ = __feature__("Type.getClassName", __lua_table__(["String"]),true));
__feature__("Type.resolveClass",_hxClasses["Array"] = Array);
__feature__("lua.Boot.isClass",Array.__name__ = __feature__("Type.getClassName",__lua_table__(["Array"]),true));
Expand Down

0 comments on commit 436ef40

Please sign in to comment.