Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

58
LINES

< > BotCompany Repo | #1020728 // callF + callMC + call using global utils (but we had to take out call because it now uses varargs)

JavaX fragment (include)

// No more "magic return type cast" because Java 8 breaks it
sO callF(O f, O... args) ctex {
  if (f instanceof S)
    ret callMC((S) f, args);
  ifclass DynamicCallable
    if (f instanceof DynamicCallable)
      ret f/DynamicCallable._dyn(args);
  endif
  ret x30_util.callF(f, args);
}

ifclass F0
  static <A> A callF(F0<A> f) {
    ret f == null ? null : f.get();
  }
endif

ifclass IF0
  static <A> A callF(IF0<A> f) {
    ret f == null ? null : f.get();
  }
endif

ifclass F1
  static <A, B> B callF(F1<A, B> f, A a) {
    ret f == null ? null : f.get(a);
  }
endif

ifclass IF1
  static <A, B> B callF(IF1<A, B> f, A a) {
    ret f == null ? null : f.get(a);
  }
endif

ifclass F2
  static <A, B, C> C callF(F2<A, B, C> f, A a, B b) {
    ret f == null ? null : f.get(a, b);
  }
endif

ifclass VF1
  static <A> void callF(VF1<A> f, A a) {
    if (f != null) f.get(a);
  }
endif

static O callMC(S method, O... args) {
  ret call(mc(), method, args);
}

static O call(O o) {
  ret callF(o);
}

sO call(O o, S method, O... args) {
  ret call_withVarargs(o, method, args);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): ayivmpnvhhik, bhatertpkbcr, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, jcllbfdqhrgy, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1020728
Snippet name: callF + callMC + call using global utils (but we had to take out call because it now uses varargs)
Eternal ID of this version: #1020728/15
Text MD5: aeb63d30a82f5d8b9670c1e29e229782
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-05-16 01:17:59
Source code size: 1138 bytes / 58 lines
Pitched / IR pitched: No / No
Views / Downloads: 259 / 6674
Version history: 14 change(s)
Referenced in: [show references]