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: 333 / 6750
Version history: 14 change(s)
Referenced in: #1020737 - Import Standard Global Functions [Global Utils, Include]
#1025826 - Compact Module Include 2 [old]
#1027167 - Compact Module Include v3 (only including callF etc. when required, LIVE)
#1029928 - Compact Module Include v4 (LIVE for new code using cmodule2)
#1030953 - Compact Module Include for Gazelle BEA (edited by #1030951)
#1031187 - Compact Module Include v5 (LIVE for new code using cmodule5)
#1031642 - Compact Module Include for Gazelle BEA [failed extension]
#1031643 - Compact Module Include for Gazelle BEA [working backup]
#1032709 - Compact Module Include for Secret BEA
#1033506 - Compact Module Include Gazelle V
#1033884 - Compact Module Include Gazelle V [dev]