-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathFunctionExposer.java
More file actions
54 lines (48 loc) · 1.62 KB
/
FunctionExposer.java
File metadata and controls
54 lines (48 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package org.python.expose.generate;
import org.objectweb.asm.Type;
import org.python.core.PyBuiltinClassMethodNarrow;
import org.python.core.PyBuiltinMethod;
public class FunctionExposer extends MethodExposer {
public FunctionExposer(Type onType,
int access,
String methodName,
String desc,
String typeName,
String[] asNames,
String[] defaults,
String doc) {
super(onType,
methodName,
Type.getArgumentTypes(desc),
Type.getReturnType(desc),
typeName,
asNames,
defaults,
isWide(desc) ? PyBuiltinMethod.class : PyBuiltinClassMethodNarrow.class,
doc,
true);
if ((access & ACC_STATIC) == 0) {
throwInvalid("@ExposedFunction can't be applied to non-static methods");
}
if (isWide(args)) {
if (defaults.length > 0) {
throwInvalid("Can't have defaults on a method that takes PyObject[], String[]");
}
}
}
@Override
protected void checkSelf() {
// noop
}
@Override
protected void makeCall() {
callStatic(onType, methodName, returnType, args);
}
@Override
protected void loadSelfAndThreadState() {
// noop
}
private static boolean isWide(String methDescriptor) {
return isWide(Type.getArgumentTypes(methDescriptor));
}
}