瀏覽代碼

[cs] only generate __hx_constructs when Type.getEnumConstructs is there

Dan Korostelev 8 年之前
父節點
當前提交
0b1a62e73a
共有 1 個文件被更改,包括 6 次插入4 次删除
  1. 6 4
      src/generators/gencommon/enumToClass2.ml

+ 6 - 4
src/generators/gencommon/enumToClass2.ml

@@ -68,10 +68,12 @@ struct
 		let basic = gen.gcon.basic in
 
 		(* add constructs field (for reflection) *)
-		let cf_constructs = mk_class_field "__hx_constructs" (gen.gclasses.nativearray basic.tstring) true pos (Var { v_read = AccNormal; v_write = AccNever }) [] in
-		cf_constructs.cf_meta <- (Meta.ReadOnly,[],pos) :: (Meta.Protected,[],pos) :: cf_constructs.cf_meta;
-		cf_constructs.cf_expr <- Some (mk_nativearray_decl gen basic.tstring (List.map (fun s -> ExprBuilder.make_string gen.gcon s pos) en.e_names) pos);
-		add_static cl_enum cf_constructs;
+		if has_feature gen.gcon "Type.getEnumConstructs" then begin
+			let cf_constructs = mk_class_field "__hx_constructs" (gen.gclasses.nativearray basic.tstring) true pos (Var { v_read = AccNormal; v_write = AccNever }) [] in
+			cf_constructs.cf_meta <- (Meta.ReadOnly,[],pos) :: (Meta.Protected,[],pos) :: cf_constructs.cf_meta;
+			cf_constructs.cf_expr <- Some (mk_nativearray_decl gen basic.tstring (List.map (fun s -> ExprBuilder.make_string gen.gcon s pos) en.e_names) pos);
+			add_static cl_enum cf_constructs
+		end;
 
 		(* add the class to the module *)
 		gen.gadd_to_module (TClassDecl cl_enum) max_dep;