Browse Source

[js] also use simple dot path strings for enums (see #7141)

Dan Korostelev 7 years ago
parent
commit
df2df55a16
3 changed files with 4 additions and 7 deletions
  1. 1 2
      src/generators/genjs.ml
  2. 1 2
      std/haxe/macro/ExampleJSGenerator.hx
  3. 2 3
      std/js/_std/Type.hx

+ 1 - 2
src/generators/genjs.ml

@@ -1154,7 +1154,6 @@ let generate_enum ctx e =
 	let p = s_path ctx e.e_path in
 	let dotp = dot_path e.e_path in
 	let has_enum_feature = has_feature ctx "has_enum" in
-	let ename = List.map (fun s -> Printf.sprintf "\"%s\"" (Ast.s_escape s)) (fst e.e_path @ [snd e.e_path]) in
 	if ctx.js_flatten then
 		print ctx "var "
 	else
@@ -1166,7 +1165,7 @@ let generate_enum ctx e =
 	else if has_feature ctx "Type.resolveEnum" then
 		print ctx "$hxClasses[\"%s\"] = " (dot_path e.e_path));
 	spr ctx "{";
-	if has_feature ctx "js.Boot.isEnum" then print ctx " __ename__ : %s," (if has_feature ctx "Type.getEnumName" then "[" ^ String.concat "," ename ^ "]" else "true");
+	if has_feature ctx "js.Boot.isEnum" then print ctx " __ename__ : %s," (if has_feature ctx "Type.getEnumName" then "\"" ^ dotp ^ "\"" else "true");
 	print ctx " __constructs__ : [%s]" (String.concat "," (List.map (fun s -> Printf.sprintf "\"%s\"" s) e.e_names));
 	let bend =
 		if not as_objects then begin

+ 1 - 2
std/haxe/macro/ExampleJSGenerator.hx

@@ -169,9 +169,8 @@ class ExampleJSGenerator {
 	function genEnum( e : EnumType ) {
 		genPackage(e.pack);
 		var p = getPath(e);
-		var names = p.split(".").map(api.quoteString).join(",");
 		var constructs = e.names.map(api.quoteString).join(",");
-		print('$p = $$hxClasses[\'$p\'] = { __ename__ : [$names], __constructs__ : [$constructs] }');
+		print('$p = $$hxClasses[\'$p\'] = { __ename__ : '$p', __constructs__ : [$constructs] }');
 		newline();
 		for( c in e.constructs.keys() ) {
 			var c = e.constructs.get(c);

+ 2 - 3
std/js/_std/Type.hx

@@ -57,9 +57,8 @@ enum ValueType {
 		return untyped __define_feature__("Type.getClassName", c.__name__);
 	}
 
-	public static function getEnumName( e : Enum<Dynamic> ) : String {
-		var a : Array<String> = untyped e.__ename__;
-		return a.join(".");
+	public static inline function getEnumName( e : Enum<Dynamic> ) : String {
+		return untyped __define_feature__("Type.getEnumName", e.__ename__);
 	}
 
 	#if js_enums_as_arrays