Explorar o código

[xml] mark generic field instances as `@:genericInstance` and omit these from XML output

Simon Krajewski %!s(int64=10) %!d(string=hai) anos
pai
achega
c50c316a68
Modificáronse 4 ficheiros con 12 adicións e 4 borrados
  1. 1 0
      ast.ml
  2. 1 0
      common.ml
  3. 9 3
      genxml.ml
  4. 1 1
      typer.ml

+ 1 - 0
ast.ml

@@ -77,6 +77,7 @@ module Meta = struct
 		| FunctionTailCode
 		| FunctionTailCode
 		| Generic
 		| Generic
 		| GenericBuild
 		| GenericBuild
+		| GenericInstance
 		| Getter
 		| Getter
 		| Hack
 		| Hack
 		| HaxeGeneric
 		| HaxeGeneric

+ 1 - 0
common.ml

@@ -391,6 +391,7 @@ module MetaInfo = struct
 		| FunctionTailCode -> ":functionTailCode",("",[Platform Cpp])
 		| FunctionTailCode -> ":functionTailCode",("",[Platform Cpp])
 		| Generic -> ":generic",("Marks a class or class field as generic so each type parameter combination generates its own type/field",[UsedOnEither [TClass;TClassField]])
 		| Generic -> ":generic",("Marks a class or class field as generic so each type parameter combination generates its own type/field",[UsedOnEither [TClass;TClassField]])
 		| GenericBuild -> ":genericBuild",("Builds instances of a type using the specified macro",[UsedOn TClass])
 		| GenericBuild -> ":genericBuild",("Builds instances of a type using the specified macro",[UsedOn TClass])
+		| GenericInstance -> ":genericInstance",("Internally used to mark instances of @:generic methods",[UsedOn TClassField;Internal])
 		| Getter -> ":getter",("Generates a native getter function on the given field",[HasParam "Class field name";UsedOn TClassField;Platform Flash])
 		| Getter -> ":getter",("Generates a native getter function on the given field",[HasParam "Class field name";UsedOn TClassField;Platform Flash])
 		| Hack -> ":hack",("Allows extending classes marked as @:final",[UsedOn TClass])
 		| Hack -> ":hack",("Allows extending classes marked as @:final",[UsedOn TClass])
 		| HaxeGeneric -> ":haxeGeneric",("Used internally to annotate non-native generic classes",[Platform Cs; UsedOnEither[TClass;TEnum]; Internal])
 		| HaxeGeneric -> ":haxeGeneric",("Used internally to annotate non-native generic classes",[Platform Cs; UsedOnEither[TClass;TEnum]; Internal])

+ 9 - 3
genxml.ml

@@ -207,10 +207,16 @@ let rec gen_type_decl com pos t =
 	let m = (t_infos t).mt_module in
 	let m = (t_infos t).mt_module in
 	match t with
 	match t with
 	| TClassDecl c ->
 	| TClassDecl c ->
-		let stats = List.map (gen_field ["static","1"]) (List.filter (fun cf -> cf.cf_name <> "__meta__") c.cl_ordered_statics) in
+		let stats = List.filter (fun cf ->
+			cf.cf_name <> "__meta__" && not (Meta.has Meta.GenericInstance cf.cf_meta)
+		) c.cl_ordered_statics in
+		let stats = List.map (gen_field ["static","1"]) stats in
+		let fields = List.filter (fun cf ->
+			not (Meta.has Meta.GenericInstance cf.cf_meta)
+		) c.cl_ordered_fields in
 		let fields = (match c.cl_super with
 		let fields = (match c.cl_super with
-			| None -> List.map (fun f -> f,[]) c.cl_ordered_fields
-			| Some (csup,_) -> List.map (fun f -> if exists f csup then (f,["override","1"]) else (f,[])) c.cl_ordered_fields
+			| None -> List.map (fun f -> f,[]) fields
+			| Some (csup,_) -> List.map (fun f -> if exists f csup then (f,["override","1"]) else (f,[])) fields
 		) in
 		) in
 		let fields = List.map (fun (f,att) -> gen_field att f) fields in
 		let fields = List.map (fun (f,att) -> gen_field att f) fields in
 		let constr = (match c.cl_constructor with None -> [] | Some f -> [gen_field [] f]) in
 		let constr = (match c.cl_constructor with None -> [] | Some f -> [gen_field [] f]) in

+ 1 - 1
typer.ml

@@ -1824,7 +1824,7 @@ let unify_int ctx e k =
 				| Meta.Generic -> false
 				| Meta.Generic -> false
 				| _ -> true
 				| _ -> true
 			) cf.cf_meta in
 			) cf.cf_meta in
-			cf2.cf_meta <- (Meta.NoCompletion,[],p) :: (Meta.NoUsing,[],p) :: metadata;
+			cf2.cf_meta <- (Meta.NoCompletion,[],p) :: (Meta.NoUsing,[],p) :: (Meta.GenericInstance,[],p) :: metadata;
 			cf2
 			cf2
 		in
 		in
 		let e = if stat then type_type ctx c.cl_path p else e in
 		let e = if stat then type_type ctx c.cl_path p else e in