ソースを参照

rename @:fakeEnum to @:enum for abstracts (closes #2356)

Simon Krajewski 11 年 前
コミット
9f1a25b1d6
5 ファイル変更9 行追加9 行削除
  1. 4 4
      matcher.ml
  2. 1 1
      std/haxe/macro/Build.hx
  3. 1 1
      tests/unit/MyAbstract.hx
  4. 2 2
      typeload.ml
  5. 1 1
      typer.ml

+ 4 - 4
matcher.ml

@@ -412,7 +412,7 @@ let to_pattern ctx e t =
 							| _ -> ());
 						let et = mk (TTypeExpr (TEnumDecl en)) (TAnon { a_fields = PMap.empty; a_status = ref (EnumStatics en) }) p in
 						mk (TField (et,FEnum (en,ef))) (apply_params en.e_types pl ef.ef_type) p
-					| TAbstract({a_impl = Some c} as a,_) when Meta.has Meta.FakeEnum a.a_meta ->
+					| TAbstract({a_impl = Some c} as a,_) when Meta.has Meta.Enum a.a_meta ->
 						let cf = PMap.find s c.cl_statics in
 						ignore(follow cf.cf_type);
 						let e = begin match cf.cf_expr with
@@ -760,7 +760,7 @@ let rec all_ctors mctx t =
 		h := PMap.add (CConst(TBool true)) Ast.null_pos !h;
 		h := PMap.add (CConst(TBool false)) Ast.null_pos !h;
 		h,false
-	| TAbstract({a_impl = Some c} as a,pl) when Meta.has Meta.FakeEnum a.a_meta ->
+	| TAbstract({a_impl = Some c} as a,pl) when Meta.has Meta.Enum a.a_meta ->
 		List.iter (fun cf ->
 			ignore(follow cf.cf_type);
 			if Meta.has Meta.Impl cf.cf_meta then match cf.cf_expr with
@@ -950,7 +950,7 @@ let convert_switch ctx st cases loop =
 		mk_index_call()
 	| TInst({cl_path = [],"Array"},_) as t ->
 		mk (TField (e_st,quick_field t "length")) ctx.t.tint p
-	| TAbstract(a,_) when Meta.has Meta.FakeEnum a.a_meta ->
+	| TAbstract(a,_) when Meta.has Meta.Enum a.a_meta ->
 		mk (TMeta((Meta.Exhaustive,[],p), e_st)) e_st.etype e_st.epos
 	| TAbstract({a_path = [],"Bool"},_) ->
 		mk (TMeta((Meta.Exhaustive,[],p), e_st)) e_st.etype e_st.epos
@@ -1235,7 +1235,7 @@ let match_expr ctx e cases def with_type p =
 				s_st_r false false st (Printf.sprintf "%s(%s)" ef.ef_name (st_args i (len - 1 - i) v))
 		in
 		let pat = match follow st.st_type with
-			| TAbstract({a_impl = Some cl} as a,_) when Meta.has Meta.FakeEnum a.a_meta ->
+			| TAbstract({a_impl = Some cl} as a,_) when Meta.has Meta.Enum a.a_meta ->
 				let rec s_pat pat = match pat.p_def with
 					| PCon ({c_def = CConst c},[]) ->
 						let cf = List.find (fun cf ->

+ 1 - 1
std/haxe/macro/Build.hx

@@ -28,7 +28,7 @@ import haxe.macro.Type;
 using haxe.macro.Tools;
 
 class Build {
-	macro static public function buildFakeEnum():Array<Field> {
+	macro static public function buildEnumAbstract():Array<Field> {
 		var fields = Context.getBuildFields();
 		var a = switch(Context.getLocalClass().get().kind) {
 			case KAbstractImpl(a): a;

+ 1 - 1
tests/unit/MyAbstract.hx

@@ -309,7 +309,7 @@ abstract MyDebugString(String) to String {
 }
 
 #if !macro
-@:fakeEnum
+@:enum
 abstract FakeEnumAbstract(Int) {
 	var NotFound = 404;
 	var MethodNotAllowed = 405;

+ 2 - 2
typeload.ml

@@ -194,8 +194,8 @@ let make_module ctx mpath file tdecls loadp =
 					List.iter (fun m -> match m with
 						| ((Meta.Build | Meta.CoreApi | Meta.Allow | Meta.Access),_,_) ->
 							c.cl_meta <- m :: c.cl_meta;
-						| (Meta.FakeEnum,_,_) ->
-							c.cl_meta <- (Meta.Build,[ECall((EField((EField((EField((EConst(Ident "haxe"),p),"macro"),p),"Build"),p),"buildFakeEnum"),p),[]),p],p) :: c.cl_meta;
+						| (Meta.Enum,_,_) ->
+							c.cl_meta <- (Meta.Build,[ECall((EField((EField((EField((EConst(Ident "haxe"),p),"macro"),p),"Build"),p),"buildEnumAbstract"),p),[]),p],p) :: c.cl_meta;
 						| (Meta.Expose,el,_) ->
 							c.cl_meta <- (Meta.Build,[ECall((EField((EField((EField((EConst(Ident "haxe"),p),"macro"),p),"Build"),p),"exposeUnderlyingFields"),p),el),p],p) :: c.cl_meta;
 						| _ ->

+ 1 - 1
typer.ml

@@ -2352,7 +2352,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
 						if ctx.untyped then raise Not_found;
 						with_type_error ctx with_type (string_error s e.e_names ("Identifier '" ^ s ^ "' is not part of enum " ^ s_type_path e.e_path)) p;
 						mk (TConst TNull) t p)
-				| TAbstract (a,pl) when has_meta Meta.FakeEnum a.a_meta ->
+				| TAbstract (a,pl) when has_meta Meta.Enum a.a_meta ->
 					let cimpl = (match a.a_impl with None -> assert false | Some c -> c) in
 					(try
 						let cf = PMap.find s cimpl.cl_statics in