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

42
LINES

< > BotCompany Repo | #1022095 // call_withVarargs

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (5239L) is out of date.

1  
sO call_withVarargs(O o, S methodName, O... args) ctex {
2  
  if (o == null) null;
3  
  
4  
  if (o instanceof Class) {
5  
    Class c = (Class) o;
6  
    _MethodCache cache = callOpt_getCache(c);
7  
    
8  
    Method me = cache.findStaticMethod(methodName, args);
9  
    if (me != null)
10  
      ret invokeMethod(me, null, args);
11  
      
12  
    // try varargs
13  
    L<Method> methods = cache.cache.get(methodName);
14  
    if (methods != null) methodSearch: for (Method m : methods) {
15  
      continue unless m.isVarArgs();
16  
      continue unless isStaticMethod(m);
17  
      O[] newArgs = massageArgsForVarArgsCall(m, args);
18  
      if (newArgs != null)
19  
        ret invokeMethod(m, null, newArgs);
20  
    }
21  
    
22  
    fail("Method " + c.getName() + "." + methodName + "(" + formatArgumentClasses(args) + ") not found");
23  
  } else {
24  
    Class c = o.getClass();
25  
    _MethodCache cache = callOpt_getCache(c);
26  
27  
    Method me = cache.findMethod(methodName, args);
28  
    if (me != null)
29  
      ret invokeMethod(me, o, args);
30  
      
31  
    // try varargs
32  
    L<Method> methods = cache.cache.get(methodName);
33  
    if (methods != null) methodSearch: for (Method m : methods) {
34  
      continue unless m.isVarArgs();
35  
      O[] newArgs = massageArgsForVarArgsCall(m, args);
36  
      if (newArgs != null)
37  
        ret invokeMethod(m, o, newArgs);
38  
    }
39  
    
40  
    fail("Method " + c.getName() + "." + methodName + "(" + formatArgumentClasses(args) + ") not found");
41  
  }
42  
}

Author comment

Began life as a copy of #1018503

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1022095
Snippet name: call_withVarargs
Eternal ID of this version: #1022095/14
Text MD5: 3ec123cf8e1c87d09e15de35f307247d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-01-21 16:06:59
Source code size: 1436 bytes / 42 lines
Pitched / IR pitched: No / No
Views / Downloads: 408 / 509
Version history: 13 change(s)
Referenced in: [show references]