浏览代码

Lua: reference global symbols for global libs

(Picked this trick up from Oleg) Normally, you can access the table and
string helper methods by "table" and "string", respectively.  However,
it's possible that these symbols can be overwritten.  It's a
slightly safer bet to reference these libraries from the global
_G symbol instead, since that is a lot less likely to get
clobbered.
Justin Donaldson 10 年之前
父节点
当前提交
1198179202
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 1 1
      std/lua/LuaStringTools.hx
  2. 1 1
      std/lua/TableTools.hx

+ 1 - 1
std/lua/LuaStringTools.hx

@@ -1,5 +1,5 @@
 package lua;
-@:native("string") 
+@:native("_G.string") 
 extern class LuaStringTools {
 	public static function len(str:String) : Int;
 	public static function sub(str:String, start:Int, end:Int) : String;

+ 1 - 1
std/lua/TableTools.hx

@@ -1,6 +1,6 @@
 package lua;
 
-@:native("table") 
+@:native("_G.table") 
 extern class TableTools {
 	@:overload(function(table:Dynamic):Void{})
 	public static function concat(table:Dynamic, ?sep:String) : String;