ソースを参照

[lua] drop lua_vanilla in favor of disable_unicode_strings

Justin Donaldson 5 年 前
コミット
6e830a78d5

+ 1 - 0
extra/CHANGES.txt

@@ -6,6 +6,7 @@
 	js : improve haxe.ds.StringMap implementation (#8909)
 	js : improve interface checking and make it more minifier-friendly (#9178)
     lua : improve error handling behavior when throwing objects/instances.
+    lua : drop lua_vanilla in favor of shared disable_unicode_strings flag
 
 	Standard Library:
 

+ 1 - 7
src-json/define.json

@@ -75,7 +75,7 @@
 		"name": "DisableUnicodeStrings",
 		"define": "disable_unicode_strings",
 		"doc": "Disable Unicode support in `String` type.",
-		"platforms": ["cpp"]
+		"platforms": ["cpp", "lua"]
 	},
 	{
 		"name": "Display",
@@ -342,12 +342,6 @@
 		"doc": "Enable the jit compiler for lua (version 5.2 only).",
 		"platforms": ["lua"]
 	},
-	{
-		"name": "LuaVanilla",
-		"define": "lua_vanilla",
-		"doc": "Generate code lacking compiled extern lib support (e.g. utf8).",
-		"platforms": ["lua"]
-	},
 	{
 		"name": "LuaVer",
 		"define": "lua_ver",

+ 2 - 1
src/context/common.ml

@@ -343,6 +343,7 @@ let get_config com =
 			pf_static = false;
 			pf_capture_policy = CPLoopVars;
 			pf_uses_utf16 = false;
+			pf_supports_unicode = not (defined Define.DisableUnicodeStrings);
 		}
 	| Neko ->
 		{
@@ -870,4 +871,4 @@ let adapt_defines_to_macro_context defines =
 
 let is_legacy_completion com = match com.json_out with
 	| None -> true
-	| Some api -> !ServerConfig.legacy_completion
+	| Some api -> !ServerConfig.legacy_completion

+ 3 - 3
src/generators/genlua.ml

@@ -47,8 +47,8 @@ type ctx = {
     mutable separator : bool;
     mutable found_expose : bool;
     mutable lua_jit : bool;
-    mutable lua_vanilla : bool;
     mutable lua_ver : float;
+    mutable disable_unicode_strings : bool;
 }
 
 type object_store = {
@@ -657,7 +657,7 @@ and gen_expr ?(local=true) ctx e = begin
         gen_value ctx x;
         print ctx "[1]"
     | TField (e, ef) when is_string_expr e && field_name ef = "length" ->
-        if ctx.lua_vanilla then (
+        if ctx.disable_unicode_strings then (
             spr ctx "#";
             gen_value ctx e;
         ) else (
@@ -1865,8 +1865,8 @@ let alloc_ctx com =
         type_accessor = (fun _ -> assert false);
         separator = false;
         found_expose = false;
+        disable_unicode_strings = Common.defined com Define.DisableUnicodeStrings;
         lua_jit = Common.defined com Define.LuaJit;
-        lua_vanilla = Common.defined com Define.LuaVanilla;
         lua_ver = try
                 float_of_string (PMap.find "lua_ver" com.defines.Define.values)
             with | Not_found -> 5.2;

+ 1 - 1
std/StringTools.hx

@@ -501,7 +501,7 @@ class StringTools {
 		#elseif hl
 		return @:privateAccess s.bytes.getUI16(index << 1);
 		#elseif lua
-		#if lua_vanilla
+		#if disable_unicode_strings
 		return lua.NativeStringTools.byte(s, index + 1);
 		#else
 		return lua.lib.luautf8.Utf8.byte(s, index + 1);

+ 1 - 1
std/lua/_std/String.hx

@@ -24,7 +24,7 @@ import lua.Lua;
 import lua.Table;
 import lua.Boot;
 
-#if lua_vanilla
+#if disable_unicode_strings
 private typedef BaseString = lua.NativeStringTools;
 #else
 private typedef BaseString = lua.lib.luautf8.Utf8;

+ 1 - 1
tests/runci/targets/Lua.hx

@@ -39,7 +39,7 @@ class Lua {
 
 		getLuaDependencies();
 
-		var variants = [[], ["-D", "lua-vanilla"]];
+		var variants = [[], ["-D", "disable_unicode_strings"]];
 		var luaFiles = [];
 
 		changeDirectory(unitDir);

+ 1 - 1
tests/unit/src/unitstd/Unicode.unit.hx

@@ -1,4 +1,4 @@
-#if target.unicode // neko and cpp with -D disable_unicode_strings will not be made Unicode compatible
+#if target.unicode // neko, cpp, and lua with -D disable_unicode_strings will not be made Unicode compatible
 
 
 var s = String.fromCharCode(0xE9);