Browse Source

[java] Conversion functions to/from java.lang.Class

Cauê Waneck 11 years ago
parent
commit
d845d33849
1 changed files with 16 additions and 1 deletions
  1. 16 1
      std/java/Lib.hx

+ 16 - 1
std/java/Lib.hx

@@ -46,7 +46,7 @@ package java;
 	}
 	}
 
 
 	/**
 	/**
-		Gets the native System.Type from the supplied object. Will throw an exception in case of null being passed.
+		Gets the native java.lang.Class from the supplied object. Will throw an exception in case of null being passed.
 	**/
 	**/
 	@:functionCode('
 	@:functionCode('
 		return (java.lang.Class<T>) obj.getClass();
 		return (java.lang.Class<T>) obj.getClass();
@@ -55,6 +55,21 @@ package java;
 	{
 	{
 		return null;
 		return null;
 	}
 	}
+	/**
+		Returns a Class<> equivalent to the native java.lang.Class type.
+	**/
+	public static inline function fromNativeType<T>(t:java.lang.Class<T>):Class<T>
+	{
+		return untyped t;
+	}
+
+	/**
+		Returns a java.lang.Class equivalent to the Haxe Class<> type.
+	**/
+	public static inline function toNativeType<T>(cl:Class<T>):java.lang.Class<T>
+	{
+		return untyped cl;
+	}
 
 
 	/**
 	/**
 		Returns a Haxe Array of a native Array.
 		Returns a Haxe Array of a native Array.