Function(PyType type, Pointer address) { super(type); this.library = null; this.name = "<anonymous>"; this.pointer = address; this.restype = type.__getattr__("_restype"); }
Function(PyType type, DynamicLibrary.Symbol sym) { super(type); this.library = sym.library; this.name = sym.name; this.pointer = sym; this.restype = type.__getattr__("_restype"); }
public StructOp(PyType type) { this.type = type; PyObject l = type.__getattr__("_jffi_type"); if (!(l instanceof StructLayout)) { throw Py.TypeError("invalid _jffi_type for " + type.fastGetName() + "; should be instance of jffi.StructLayout"); } this.layout = (StructLayout) l; }
static final StructLayout getStructLayout(PyType subtype) { PyObject jffi_type = subtype.__getattr__("_jffi_type"); if (!(jffi_type instanceof StructLayout)) { throw Py.TypeError("invalid _jffi_type for " + subtype.fastGetName() + "; should be instance of jffi.StructLayout"); } return (StructLayout) jffi_type; }
static final CType.Builtin getScalarType(PyType subtype) { PyObject jffi_type = subtype.__getattr__("_jffi_type"); if (!(jffi_type instanceof CType.Builtin)) { throw Py.TypeError("invalid _jffi_type for " + subtype.getName()); } return (CType.Builtin) jffi_type; }
static final CType.Array getArrayType(PyType subtype) { PyObject jffi_type = subtype.__getattr__("_jffi_type"); if (!(jffi_type instanceof CType.Array)) { throw Py.TypeError("invalid _jffi_type for " + subtype.getName()); } return (CType.Array) jffi_type; }
static final CType.Pointer getPointerType(PyType subtype) { PyObject jffi_type = subtype.__getattr__("_jffi_type"); if (!(jffi_type instanceof CType.Pointer)) { throw Py.TypeError("invalid _jffi_type for " + subtype.getName()); } return (CType.Pointer) jffi_type; }
public static void addGetattribute() { final PyObject objectGetattribute = PyObject.TYPE.__getattr__("__getattribute__"); PyBuiltinMethod meth = new PyBuiltinMethodNarrow("__getattribute__", 1) { @Override public PyObject __call__(PyObject name) { try { return objectGetattribute.__call__(self, name); } catch (PyException pye) { if (!pye.match(Py.AttributeError)) { throw pye; } } CustomizableMapHolder inst = Py.tojava(self, CustomizableMapHolder.class); return Py.java2py(inst.held.get(Py.tojava(name, String.class))); } }; PyType.fromClass(CustomizableMapHolder.class).addMethod(meth); } }