Просмотр исходного кода

use proper metadata for `@:const`

Simon Krajewski 10 лет назад
Родитель
Сommit
7b7f6ba8af
3 измененных файлов с 4 добавлено и 1 удалено
  1. 1 0
      ast.ml
  2. 2 0
      common.ml
  3. 1 1
      typeload.ml

+ 1 - 0
ast.ml

@@ -50,6 +50,7 @@ module Meta = struct
 		| ClassCode
 		| Commutative
 		| CompilerGenerated
+		| Const
 		| CoreApi
 		| CoreType
 		| CppFileCode

+ 2 - 0
common.ml

@@ -342,6 +342,7 @@ module MetaInfo = struct
 		| TTypedef
 		| TAnyField
 		| TExpr
+		| TTypeParameter
 
 	type meta_parameter =
 		| HasParam of string
@@ -372,6 +373,7 @@ module MetaInfo = struct
 		| ClassCode -> ":classCode",("Used to inject platform-native code into a class",[Platforms [Java;Cs]; UsedOn TClass])
 		| Commutative -> ":commutative",("Declares an abstract operator as commutative",[UsedOn TAbstractField])
 		| CompilerGenerated -> ":compilerGenerated",("Marks a field as generated by the compiler. Shouldn't be used by the end user",[Platforms [Java;Cs]])
+		| Const -> ":const",("Allows a type parameter to accept expression values",[UsedOn TTypeParameter])
 		| CoreApi -> ":coreApi",("Identifies this class as a core api class (forces Api check)",[UsedOnEither [TClass;TEnum;TTypedef;TAbstract]])
 		| CoreType -> ":coreType",("Identifies an abstract as core type so that it requires no implementation",[UsedOn TAbstract])
 		| CppFileCode -> ":cppFileCode",("Code to be injected into generated cpp file",[Platform Cpp])

+ 1 - 1
typeload.ml

@@ -415,7 +415,7 @@ let rec load_instance ctx t p allow_no_params =
 				| t :: tl1,(name,t2) :: tl2 ->
 					let check_const c =
 						let is_expression = (match t with TInst ({ cl_kind = KExpr _ },_) -> true | _ -> false) in
-						let expects_expression = name = "Const" || Meta.has (Meta.Custom ":const") c.cl_meta in
+						let expects_expression = name = "Const" || Meta.has Meta.Const c.cl_meta in
 						let accepts_expression = name = "Rest" in
 						if is_expression then begin
 							if not expects_expression && not accepts_expression then