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)

1  
// No more "magic return type cast" because Java 8 breaks it
2  
sO callF(O f, O... args) ctex {
3  
  if (f instanceof S)
4  
    ret callMC((S) f, args);
5  
  ifclass DynamicCallable
6  
    if (f instanceof DynamicCallable)
7  
      ret f/DynamicCallable._dyn(args);
8  
  endif
9  
  ret x30_util.callF(f, args);
10  
}
11  
12  
ifclass F0
13  
  static <A> A callF(F0<A> f) {
14  
    ret f == null ? null : f.get();
15  
  }
16  
endif
17  
18  
ifclass IF0
19  
  static <A> A callF(IF0<A> f) {
20  
    ret f == null ? null : f.get();
21  
  }
22  
endif
23  
24  
ifclass F1
25  
  static <A, B> B callF(F1<A, B> f, A a) {
26  
    ret f == null ? null : f.get(a);
27  
  }
28  
endif
29  
30  
ifclass IF1
31  
  static <A, B> B callF(IF1<A, B> f, A a) {
32  
    ret f == null ? null : f.get(a);
33  
  }
34  
endif
35  
36  
ifclass F2
37  
  static <A, B, C> C callF(F2<A, B, C> f, A a, B b) {
38  
    ret f == null ? null : f.get(a, b);
39  
  }
40  
endif
41  
42  
ifclass VF1
43  
  static <A> void callF(VF1<A> f, A a) {
44  
    if (f != null) f.get(a);
45  
  }
46  
endif
47  
48  
static O callMC(S method, O... args) {
49  
  ret call(mc(), method, args);
50  
}
51  
52  
static O call(O o) {
53  
  ret callF(o);
54  
}
55  
56  
sO call(O o, S method, O... args) {
57  
  ret call_withVarargs(o, method, args);
58  
}

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: 262 / 6677
Version history: 14 change(s)
Referenced in: [show references]