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 years ago
parent
commit
1198179202
2 changed files with 2 additions and 2 deletions
  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;