-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathBaseTypeBuilder.java
More file actions
89 lines (72 loc) · 2.2 KB
/
BaseTypeBuilder.java
File metadata and controls
89 lines (72 loc) · 2.2 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
88
89
package org.python.expose;
import org.python.core.PyBuiltinMethod;
import org.python.core.PyDataDescr;
import org.python.core.PyMethodDescr;
import org.python.core.PyNewWrapper;
import org.python.core.PyObject;
import org.python.core.PyStringMap;
import org.python.core.PyType;
public class BaseTypeBuilder implements TypeBuilder {
private PyNewWrapper newWrapper;
private PyBuiltinMethod[] meths;
private PyDataDescr[] descrs;
private Class<? extends PyObject> typeClass;
private Class<?> baseClass;
private String name;
private boolean isBaseType;
private String doc;
public BaseTypeBuilder(String name,
Class<? extends PyObject> typeClass,
Class<?> baseClass,
boolean isBaseType,
String doc,
PyBuiltinMethod[] meths,
PyDataDescr[] descrs,
PyNewWrapper newWrapper) {
this.typeClass = typeClass;
this.baseClass = baseClass;
this.isBaseType = isBaseType;
this.doc = doc;
this.name = name;
this.descrs = descrs;
this.meths = meths;
this.newWrapper = newWrapper;
}
@Override
public PyObject getDict(PyType type) {
PyStringMap dict = new PyStringMap();
for(PyBuiltinMethod func : meths) {
PyMethodDescr pmd = func.makeDescriptor(type);
dict.__setitem__(pmd.getName(), pmd);
}
for(PyDataDescr descr : descrs) {
descr.setType(type);
dict.__setitem__(descr.getName(), descr);
}
if (newWrapper != null) {
dict.__setitem__("__new__", newWrapper);
newWrapper.setWrappedType(type);
}
return dict;
}
@Override
public String getName() {
return name;
}
@Override
public Class<? extends PyObject> getTypeClass() {
return typeClass;
}
@Override
public Class<?> getBase() {
return baseClass;
}
@Override
public boolean getIsBaseType() {
return isBaseType;
}
@Override
public String getDoc() {
return doc;
}
}