-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathPyBuiltinMethodNarrow.java
More file actions
87 lines (75 loc) · 2.44 KB
/
PyBuiltinMethodNarrow.java
File metadata and controls
87 lines (75 loc) · 2.44 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package org.python.core;
public abstract class PyBuiltinMethodNarrow extends PyBuiltinMethod {
/**
* Creates a method for the given name that takes no arguments.
*/
protected PyBuiltinMethodNarrow(String name) {
this(name, 0);
}
/**
* Creates a method for the <code>name</code> that takes exactly <code>numArgs</code> arguments.
*/
protected PyBuiltinMethodNarrow(String name, int numArgs) {
this(name, numArgs, numArgs);
}
/**
* Creates a method for the given name that takes at least <code>minArgs</code> and at most
* <code>maxArgs</code> arguments.
*/
protected PyBuiltinMethodNarrow(String name, int minArgs, int maxArgs) {
super(null, new DefaultInfo(name, minArgs, maxArgs));
}
protected PyBuiltinMethodNarrow(PyObject self, Info info) {
super(self, info);
}
protected PyBuiltinMethodNarrow(PyType type, PyObject self, Info info) {
super(type, self, info);
}
@Override
public PyObject __call__(PyObject[] args, String[] keywords) {
if(keywords.length != 0) {
throw info.unexpectedCall(args.length, true);
}
return __call__(args);
}
@Override
public PyObject __call__(PyObject[] args) {
switch(args.length){
case 0:
return __call__();
case 1:
return __call__(args[0]);
case 2:
return __call__(args[0], args[1]);
case 3:
return __call__(args[0], args[1], args[2]);
case 4:
return __call__(args[0], args[1], args[2], args[3]);
default:
throw info.unexpectedCall(args.length, false);
}
}
@Override
public PyObject __call__() {
throw info.unexpectedCall(0, false);
}
@Override
public PyObject __call__(PyObject arg0) {
throw info.unexpectedCall(1, false);
}
@Override
public PyObject __call__(PyObject arg0, PyObject arg1) {
throw info.unexpectedCall(2, false);
}
@Override
public PyObject __call__(PyObject arg0, PyObject arg1, PyObject arg2) {
throw info.unexpectedCall(3, false);
}
@Override
public PyObject __call__(PyObject arg0,
PyObject arg1,
PyObject arg2,
PyObject arg3) {
throw info.unexpectedCall(4, false);
}
}