Lib.hx 761 B

123456789101112131415161718192021222324252627282930313233343536
  1. package java;
  2. import java.lang.Class;
  3. /**
  4. * ...
  5. * @author waneck
  6. */
  7. //we cannot use the java package for custom classes, so we're redefining it as "haxe.java.Lib"
  8. @:native('haxe.java.Lib') class Lib
  9. {
  10. public static function toNativeReadOnlyArray<T>(arr:Array<T>, equalLengthRequired:Bool):NativeArray<T>
  11. {
  12. var native:NativeArray<T> = untyped arr.__a;
  13. if (native.length == arr.length)
  14. {
  15. return native;
  16. } else {
  17. return null;
  18. }
  19. }
  20. public static function toNativeType<T>(cl:Class<T>):java.lang.Class<T>
  21. {
  22. return untyped cl.nativeType();
  23. }
  24. @:functionBody('
  25. return (java.lang.Class<T>) obj.getClass();
  26. ')
  27. public static function getNativeType<T>(obj:T):java.lang.Class<T>
  28. {
  29. return null;
  30. }
  31. }