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

[java] added suppress warnings: deprecation for some deprecated api uses. Fixes Issue #861

Caue Waneck 13 лет назад
Родитель
Сommit
e7ec003e39
3 измененных файлов с 20 добавлено и 2 удалено
  1. 16 1
      genjava.ml
  2. 3 0
      std/StringTools.hx
  3. 1 1
      std/java/_std/Date.hx

+ 16 - 1
genjava.ml

@@ -1307,9 +1307,24 @@ let configure gen =
         false
     in
     
+    let rec loop_meta meta acc =
+      match meta with
+        | (":SuppressWarnings", [Ast.EConst (Ast.String w),_],_) :: meta -> loop_meta meta (w :: acc)
+        | _ :: meta -> loop_meta meta acc
+        | _ -> acc
+    in
+    
+    let suppress_warnings = loop_meta cl.cl_meta [ "rawtypes"; "unchecked" ] in
+    
     write w "import haxe.root.*;";
     newline w;
-    write w "@SuppressWarnings(value={\"rawtypes\", \"unchecked\"})";
+    write w "@SuppressWarnings(value={";
+    let first = ref true in
+    List.iter (fun s ->
+      (if !first then first := false else write w ", ");
+      print w "\"%s\"" (escape s)
+    ) suppress_warnings;
+    write w "})";
     newline w;
     
     let clt, access, modifiers = get_class_modifiers cl.cl_meta (if cl.cl_interface then "interface" else "class") "public" [] in

+ 3 - 0
std/StringTools.hx

@@ -30,6 +30,9 @@
 	the standard [String] of being bloated and thus increasing the size of
 	each application using it.
 **/
+#if java
+@:SuppressWarnings("deprecation")
+#end
 class StringTools {
 
 	/**

+ 1 - 1
std/java/_std/Date.hx

@@ -5,7 +5,7 @@ import haxe.Int64;
  * ...
  * @author waneck
  */
-
+@:SuppressWarnings("deprecation")
 class Date 
 {
 	private var date:java.util.Date;