Function.hx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (C)2005-2012 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. package java.internal;
  23. import java.internal.Runtime;
  24. /**
  25. * These classes are automatically generated by the compiler. They are only
  26. * here so there is an option for e.g. defining them as externs if you are compiling
  27. * in modules (untested)
  28. *
  29. * @author waneck
  30. */
  31. @:abstract @:nativeGen @:native("haxe.lang.Function") @:keep private class Function
  32. {
  33. function new(arity:Int, type:Int)
  34. {
  35. }
  36. }
  37. @:nativeGen @:native("haxe.lang.VarArgsBase") @:keep private class VarArgsBase extends Function
  38. {
  39. public function __hx_invokeDynamic(dynArgs:Array<Dynamic>):Dynamic
  40. {
  41. throw "Abstract implementation";
  42. return null;
  43. }
  44. }
  45. @:nativeGen @:native('haxe.lang.VarArgsFunction') @:keep class VarArgsFunction extends VarArgsBase
  46. {
  47. private var fun:Array<Dynamic>->Dynamic;
  48. public function new(fun)
  49. {
  50. super(-1, -1);
  51. this.fun = fun;
  52. }
  53. override public function __hx_invokeDynamic(dynArgs:Array<Dynamic>):Dynamic
  54. {
  55. return fun(dynArgs);
  56. }
  57. }
  58. @:nativeGen @:native('haxe.lang.Closure') @:keep class Closure extends VarArgsBase
  59. {
  60. private var obj:Dynamic;
  61. private var field:String;
  62. public function new(obj:Dynamic, field)
  63. {
  64. super(-1, -1);
  65. this.obj = obj;
  66. this.field = field;
  67. }
  68. override public function __hx_invokeDynamic(dynArgs:Array<Dynamic>):Dynamic
  69. {
  70. return Runtime.callField(obj, field, dynArgs);
  71. }
  72. }