Răsfoiți Sursa

[lua] changed __name__ and __ename__ to strings instead of tables (#8309)

Aleksandr Kuzmenko 6 ani în urmă
părinte
comite
6a0331f0c5
4 a modificat fișierele cu 8 adăugiri și 7 ștergeri
  1. 3 3
      src/generators/genlua.ml
  2. 1 0
      std/Math.hx
  3. 2 2
      std/lua/_std/Std.hx
  4. 2 2
      std/lua/_std/Type.hx

+ 3 - 3
src/generators/genlua.ml

@@ -1595,7 +1595,7 @@ let generate_class___name__ ctx c =
         let p = s_path ctx c.cl_path in
         let p = s_path ctx c.cl_path in
         print ctx "%s.__name__ = " p;
         print ctx "%s.__name__ = " p;
         if has_feature ctx "Type.getClassName" then
         if has_feature ctx "Type.getClassName" then
-            println ctx "{%s}" (String.concat "," (List.map (fun s -> Printf.sprintf "\"%s\"" (s_escape_lua s)) (fst c.cl_path @ [snd c.cl_path])))
+            println ctx "\"%s\"" (String.concat "." (List.map s_escape_lua (fst c.cl_path @ [snd c.cl_path])))
         else
         else
             println ctx "true";
             println ctx "true";
     end
     end
@@ -1706,7 +1706,7 @@ let generate_class ctx c =
 
 
 let generate_enum ctx e =
 let generate_enum ctx e =
     let p = s_path ctx e.e_path in
     let p = s_path ctx e.e_path in
-    let ename = List.map (fun s -> Printf.sprintf "\"%s\"" (s_escape_lua s)) (fst e.e_path @ [snd e.e_path]) in
+    let ename = List.map s_escape_lua (fst e.e_path @ [snd e.e_path]) in
 
 
     (* TODO: Unify the _hxClasses declaration *)
     (* TODO: Unify the _hxClasses declaration *)
     if has_feature ctx "Type.resolveEnum" then begin
     if has_feature ctx "Type.resolveEnum" then begin
@@ -1715,7 +1715,7 @@ let generate_enum ctx e =
     if has_feature ctx "lua.Boot.isEnum" then begin
     if has_feature ctx "lua.Boot.isEnum" then begin
         print ctx "_hxClasses[\"%s\"] = {" (dot_path e.e_path);
         print ctx "_hxClasses[\"%s\"] = {" (dot_path e.e_path);
         if has_feature ctx "lua.Boot.isEnum" then  begin
         if has_feature ctx "lua.Boot.isEnum" then  begin
-            print ctx " __ename__ = %s," (if has_feature ctx "Type.getEnumName" then "{" ^ String.concat "," ename ^ "}" else "true");
+            print ctx " __ename__ = %s," (if has_feature ctx "Type.getEnumName" then "\"" ^ String.concat "." ename ^ "\"" else "true");
         end;
         end;
         (* TODO :  Come up with a helper function for _hx_tab_array declarations *)
         (* TODO :  Come up with a helper function for _hx_tab_array declarations *)
         spr ctx " __constructs__ = _hx_tab_array({";
         spr ctx " __constructs__ = _hx_tab_array({";

+ 1 - 0
std/Math.hx

@@ -299,6 +299,7 @@ extern class Math
 		NEGATIVE_INFINITY = __global__["Number"].NEGATIVE_INFINITY;
 		NEGATIVE_INFINITY = __global__["Number"].NEGATIVE_INFINITY;
 		POSITIVE_INFINITY = __global__["Number"].POSITIVE_INFINITY;
 		POSITIVE_INFINITY = __global__["Number"].POSITIVE_INFINITY;
 	#else
 	#else
+		//TODO: Abandoned code block? Js has its own _std/Math.hx
 		Math.__name__ = ["Math"];
 		Math.__name__ = ["Math"];
 		Math.NaN = Number["NaN"];
 		Math.NaN = Number["NaN"];
 		Math.NEGATIVE_INFINITY = Number["NEGATIVE_INFINITY"];
 		Math.NEGATIVE_INFINITY = Number["NEGATIVE_INFINITY"];

+ 2 - 2
std/lua/_std/Std.hx

@@ -81,9 +81,9 @@ import lua.NativeStringTools;
 	}
 	}
 
 
 	static function __init__() : Void untyped {
 	static function __init__() : Void untyped {
-		__feature__("lua.Boot.isClass", String.__name__ = __feature__("Type.getClassName", __lua_table__(["String"]),true));
+		__feature__("lua.Boot.isClass", String.__name__ = __feature__("Type.getClassName", "String",true));
 		__feature__("Type.resolveClass",_hxClasses["Array"] = Array);
 		__feature__("Type.resolveClass",_hxClasses["Array"] = Array);
-		__feature__("lua.Boot.isClass",Array.__name__ = __feature__("Type.getClassName",__lua_table__(["Array"]),true));
+		__feature__("lua.Boot.isClass",Array.__name__ = __feature__("Type.getClassName","Array",true));
 	}
 	}
 
 
 }
 }

+ 2 - 2
std/lua/_std/Type.hx

@@ -55,12 +55,12 @@ enum ValueType {
 
 
 	public static function getClassName( c : Class<Dynamic> ) : String {
 	public static function getClassName( c : Class<Dynamic> ) : String {
 		if (untyped c.__name__ == null) return null;
 		if (untyped c.__name__ == null) return null;
-		return lua.Table.concat(untyped c.__name__,'.');
+		return untyped c.__name__;
 	}
 	}
 
 
 	public static function getEnumName( e : Enum<Dynamic> ) : String {
 	public static function getEnumName( e : Enum<Dynamic> ) : String {
 		if (untyped e.__ename__ == null) return null;
 		if (untyped e.__ename__ == null) return null;
-		return lua.Table.concat(untyped e.__ename__,'.');
+		return untyped e.__ename__;
 	}
 	}
 
 
 	public static function resolveClass( name : String ) : Class<Dynamic> untyped {
 	public static function resolveClass( name : String ) : Class<Dynamic> untyped {