Browse Source

[lua] shorten some utility methods to make output slightly smaller

Justin Donaldson 9 years ago
parent
commit
e3d56325c6
3 changed files with 10 additions and 10 deletions
  1. 5 5
      src/generators/genlua.ml
  2. 2 2
      std/lua/_lua/_hx_anon.lua
  3. 3 3
      std/lua/_lua/_hx_classes.lua

+ 5 - 5
src/generators/genlua.ml

@@ -731,7 +731,7 @@ and gen_expr ?(local=true) ctx e = begin
 		println ctx "end";
 		println ctx "end";
 		spr ctx "break end";
 		spr ctx "break end";
 	| TObjectDecl [] ->
 	| TObjectDecl [] ->
-		spr ctx "_hx_empty()";
+		spr ctx "_hx_e()";
 		ctx.separator <- true
 		ctx.separator <- true
 	| TObjectDecl fields ->
 	| TObjectDecl fields ->
 		spr ctx "_hx_o({__fields__={";
 		spr ctx "_hx_o({__fields__={";
@@ -1496,7 +1496,7 @@ let generate_class ctx c =
 
 
 	newline ctx;
 	newline ctx;
 	if (has_prototype ctx c) then begin
 	if (has_prototype ctx c) then begin
-		print ctx "%s.prototype = _hx_anon(" p;
+		print ctx "%s.prototype = _hx_a(" p;
 		let bend = open_block ctx in
 		let bend = open_block ctx in
 		newline ctx;
 		newline ctx;
 		let count = ref 0 in
 		let count = ref 0 in
@@ -1669,14 +1669,14 @@ let generate_type_forward ctx = function
 		if not c.cl_extern then begin
 		if not c.cl_extern then begin
 		    generate_package_create ctx c.cl_path;
 		    generate_package_create ctx c.cl_path;
 		    let p = s_path ctx c.cl_path in
 		    let p = s_path ctx c.cl_path in
-		    println ctx "%s = _hx_empty()" p;
+		    println ctx "%s = _hx_e()" p;
 		end
 		end
 	| TEnumDecl e when e.e_extern ->
 	| TEnumDecl e when e.e_extern ->
 		()
 		()
 	| TEnumDecl e ->
 	| TEnumDecl e ->
 		generate_package_create ctx e.e_path;
 		generate_package_create ctx e.e_path;
 		let p = s_path ctx e.e_path in
 		let p = s_path ctx e.e_path in
-		println ctx "%s = _hx_empty()" p;
+		println ctx "%s = _hx_e()" p;
 	| TTypeDecl _ | TAbstractDecl _ -> ()
 	| TTypeDecl _ | TAbstractDecl _ -> ()
 
 
 let set_current_class ctx c =
 let set_current_class ctx c =
@@ -1787,7 +1787,7 @@ let generate com =
 
 
 	let rec print_obj f root = (
 	let rec print_obj f root = (
 		let path = root ^ (path_to_brackets f.os_name) in
 		let path = root ^ (path_to_brackets f.os_name) in
-		print ctx "%s = %s or _hx_empty()" path path;
+		print ctx "%s = %s or _hx_e()" path path;
 		ctx.separator <- true;
 		ctx.separator <- true;
 		newline ctx;
 		newline ctx;
 		concat ctx ";" (fun g -> print_obj g path) f.os_fields
 		concat ctx ";" (fun g -> print_obj g path) f.os_fields

+ 2 - 2
std/lua/_lua/_hx_anon.lua

@@ -1,6 +1,6 @@
 local function _hx_anon_newindex(t,k,v) t.__fields__[k] = true; rawset(t,k,v); end
 local function _hx_anon_newindex(t,k,v) t.__fields__[k] = true; rawset(t,k,v); end
 local _hx_anon_mt = {__newindex=_hx_anon_newindex}
 local _hx_anon_mt = {__newindex=_hx_anon_newindex}
-local function _hx_anon(...)
+local function _hx_a(...)
   local __fields__ = {};
   local __fields__ = {};
   local ret = {__fields__ = __fields__};
   local ret = {__fields__ = __fields__};
   local max = select('#',...);
   local max = select('#',...);
@@ -15,7 +15,7 @@ local function _hx_anon(...)
   return setmetatable(ret, _hx_anon_mt)
   return setmetatable(ret, _hx_anon_mt)
 end
 end
 
 
-local function _hx_empty()
+local function _hx_e()
   return setmetatable({__fields__ = {}}, _hx_anon_mt)
   return setmetatable({__fields__ = {}}, _hx_anon_mt)
 end
 end
 
 

+ 3 - 3
std/lua/_lua/_hx_classes.lua

@@ -3,11 +3,11 @@ Int = (function() _hxClasses.Int = _hx_o({__fields__={__name__=true},__name__={"
 Dynamic = (function() 
 Dynamic = (function() 
 _hxClasses.Dynamic = _hx_o({__fields__={__name__=true},__name__={"Dynamic"}}); return _hxClasses.Dynamic end)();
 _hxClasses.Dynamic = _hx_o({__fields__={__name__=true},__name__={"Dynamic"}}); return _hxClasses.Dynamic end)();
 Float = (function() 
 Float = (function() 
-_hxClasses.Float = _hx_empty(); return _hxClasses.Float end)();
+_hxClasses.Float = _hx_e(); return _hxClasses.Float end)();
 Float.__name__ = {"Float"}
 Float.__name__ = {"Float"}
 Bool = (function() 
 Bool = (function() 
-_hxClasses.Bool = _hx_empty(); return _hxClasses.Bool end)();
+_hxClasses.Bool = _hx_e(); return _hxClasses.Bool end)();
 Bool.__ename__ = {"Bool"}
 Bool.__ename__ = {"Bool"}
 Class = (function() 
 Class = (function() 
 _hxClasses.Class = _hx_o({__fields__={__name__=true},__name__={"Class"}}); return _hxClasses.Class end)();
 _hxClasses.Class = _hx_o({__fields__={__name__=true},__name__={"Class"}}); return _hxClasses.Class end)();
-Enum = _hx_empty();
+Enum = _hx_e();