Browse Source

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 năm trước cách đây
mục cha
commit
1198179202
2 tập tin đã thay đổi với 2 bổ sung2 xóa
  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;