namespace python { //! ElfSymbolTable destructor. void ElfSymbolTable_dealloc(PyObject* self) { std::cout << std::flush; delete PyElfSymbolTable_AsElfSymbolTable(self); Py_DECREF(self); } static PyObject* ElfSymbolTable_getIdxname(PyObject* self, PyObject* noarg) { try { return PyLong_FromUint32(PyElfSymbolTable_AsElfSymbolTable(self)->getIdxname()); } catch (const triton::exceptions::Exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* ElfSymbolTable_getInfo(PyObject* self, PyObject* noarg) { try { return PyLong_FromUint32(PyElfSymbolTable_AsElfSymbolTable(self)->getInfo()); } catch (const triton::exceptions::Exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* ElfSymbolTable_getName(PyObject* self, PyObject* noarg) { try { return PyString_FromString(PyElfSymbolTable_AsElfSymbolTable(self)->getName().c_str()); } catch (const triton::exceptions::Exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* ElfSymbolTable_getOther(PyObject* self, PyObject* noarg) { try { return PyLong_FromUint32(PyElfSymbolTable_AsElfSymbolTable(self)->getOther()); } catch (const triton::exceptions::Exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* ElfSymbolTable_getShndx(PyObject* self, PyObject* noarg) { try { return PyLong_FromUint32(PyElfSymbolTable_AsElfSymbolTable(self)->getShndx()); } catch (const triton::exceptions::Exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* ElfSymbolTable_getSize(PyObject* self, PyObject* noarg) { try { return PyLong_FromUint64(PyElfSymbolTable_AsElfSymbolTable(self)->getSize()); } catch (const triton::exceptions::Exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* ElfSymbolTable_getValue(PyObject* self, PyObject* noarg) { try { return PyLong_FromUint64(PyElfSymbolTable_AsElfSymbolTable(self)->getValue()); } catch (const triton::exceptions::Exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } //! ElfSymbolTable methods. PyMethodDef ElfSymbolTable_callbacks[] = { {"getIdxname", ElfSymbolTable_getIdxname, METH_NOARGS, ""}, {"getInfo", ElfSymbolTable_getInfo, METH_NOARGS, ""}, {"getName", ElfSymbolTable_getName, METH_NOARGS, ""}, {"getOther", ElfSymbolTable_getOther, METH_NOARGS, ""}, {"getShndx", ElfSymbolTable_getShndx, METH_NOARGS, ""}, {"getSize", ElfSymbolTable_getSize, METH_NOARGS, ""}, {"getValue", ElfSymbolTable_getValue, METH_NOARGS, ""}, {nullptr, nullptr, 0, nullptr} }; PyTypeObject ElfSymbolTable_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ "ElfSymbolTable", /* tp_name */ sizeof(ElfSymbolTable_Object), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)ElfSymbolTable_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ "ElfSymbolTable objects", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ ElfSymbolTable_callbacks, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ 0, /* tp_del */ 0 /* tp_version_tag */ }; PyObject* PyElfSymbolTable(const triton::format::elf::ElfSymbolTable& sym) { ElfSymbolTable_Object* object; PyType_Ready(&ElfSymbolTable_Type); object = PyObject_NEW(ElfSymbolTable_Object, &ElfSymbolTable_Type); if (object != NULL) object->sym = new triton::format::elf::ElfSymbolTable(sym); return (PyObject*)object; } }; /* python namespace */
char temp[128]; int i = 0; while (v->vars[i]) { if (strcmp(v->vars[i]->name,n) == 0) { return (*v->vars[i]->set_attr)(p); } i++; } sprintf(temp,"C global variable %s not found.", n); PyErr_SetString(PyExc_NameError,temp); return 1; } statichere PyTypeObject varlinktype = { /* PyObject_HEAD_INIT(&PyType_Type) Note : This doesn't work on some machines */ PyObject_HEAD_INIT(0) 0, "varlink", /* Type name */ sizeof(swig_varlinkobject), /* Basic size */ 0, /* Itemsize */ 0, /* Deallocator */ (printfunc) swig_varlink_print, /* Print */ (getattrfunc) swig_varlink_getattr, /* get attr */ (setattrfunc) swig_varlink_setattr, /* Set attr */ 0, /* tp_compare */ (reprfunc) swig_varlink_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_mapping*/ 0, /* tp_hash */ };
else if (!strcmp(attr, "selected")) { PyObject *ret; GList *tmp; gint i; ret = PyTuple_New(g_list_length(self->data->selected)); for (i = 0, tmp = self->data->selected; tmp; i++, tmp = tmp->next) PyTuple_SetItem(ret, i, PyDiaObject_New((DiaObject *)tmp->data)); return ret; } return Py_FindMethod(PyDiaDiagramData_Methods, (PyObject *)self, attr); } PyTypeObject PyDiaDiagramData_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, "dia.DiagramData", sizeof(PyDiaDiagramData), 0, (destructor)PyDiaDiagramData_Dealloc, (printfunc)0, (getattrfunc)PyDiaDiagramData_GetAttr, (setattrfunc)0, (cmpfunc)PyDiaDiagramData_Compare, (reprfunc)0, 0, 0, 0, (hashfunc)PyDiaDiagramData_Hash, (ternaryfunc)0,
static PyMethodDef twopence_commandMethods[] = { { "suppressOutput", (PyCFunction) Command_suppressOutput, METH_VARARGS | METH_KEYWORDS, "Do not display command's output to screen" }, { "setenv", (PyCFunction) Command_setenv, METH_VARARGS | METH_KEYWORDS, "Set an environment variable to be passed to the command" }, { "unsetenv", (PyCFunction) Command_unsetenv, METH_VARARGS | METH_KEYWORDS, "Unset an environment variable" }, { NULL } }; PyTypeObject twopence_CommandType = { PyObject_HEAD_INIT(NULL) .tp_name = "twopence.Command", .tp_basicsize = sizeof(twopence_Command), .tp_flags = Py_TPFLAGS_DEFAULT, .tp_doc = "Twopence command", .tp_methods = twopence_commandMethods, .tp_init = (initproc) Command_init, .tp_new = Command_new, .tp_dealloc = (destructor) Command_dealloc, .tp_getattr = (getattrfunc) Command_getattr, .tp_setattr = (setattrfunc) Command_setattr, }; /*
METH_VARARGS | METH_KEYWORDS, }, { "get_configs", (PyCFunction)decoder_get_configs_meth, METH_VARARGS | METH_KEYWORDS, }, { "parse_config", (PyCFunction)decoder_parse_config, METH_VARARGS | METH_KEYWORDS, }, { "reset", (PyCFunction)decoder_reset, METH_VARARGS | METH_KEYWORDS, }, { "new_scan", (PyCFunction)decoder_new_scan, METH_VARARGS | METH_KEYWORDS, }, { "set_handler", (PyCFunction)decoder_set_handler, METH_VARARGS | METH_KEYWORDS, }, { "decode_width", (PyCFunction)decoder_decode_width, METH_VARARGS | METH_KEYWORDS, }, { NULL, }, }; PyTypeObject zbarDecoder_Type = { PyObject_HEAD_INIT(NULL) .tp_name = "zbar.Decoder", .tp_doc = decoder_doc, .tp_basicsize = sizeof(zbarDecoder), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, .tp_new = (newfunc)decoder_new, .tp_traverse = (traverseproc)decoder_traverse, .tp_clear = (inquiry)decoder_clear, .tp_dealloc = (destructor)decoder_dealloc, .tp_getset = decoder_getset, .tp_methods = decoder_methods, };
0, /*sq_ass_slice*/ 0 /*sq_contains*/ }; // ---------------------------------------------------------------- static PyBufferProcs vcstring_as_buffer = { (getreadbufferproc)vcstring_buffer_getreadbuf, 0, (getsegcountproc)vcstring_buffer_getsegcount, 0, }; // ---------------------------------------------------------------- static PyTypeObject VCStringType = { PyObject_HEAD_INIT(NULL) 0, VCSTRING_NAME, sizeof(PyVCStringObject), 0, (destructor)VCString_Del, //tp_dealloc 0, //tp_print 0, //tp_getattr 0, //tp_setattr 0, //tp_compare 0, //tp_repr 0, //tp_as_number &vcstring_as_sequence, //tp_as_sequence 0, //tp_as_mapping 0, /* tp_hash */ 0, /* tp_call */
/* Integer object implementation */ #include "Python.h" #include <ctype.h> long PyInt_GetMax(void) { return LONG_MAX; /* To initialize sys.maxint */ } /* Standard Booleans */ PyIntObject _Py_ZeroStruct = { PyObject_HEAD_INIT(&PyInt_Type) 0 }; PyIntObject _Py_TrueStruct = { PyObject_HEAD_INIT(&PyInt_Type) 1 }; /* Return 1 if exception raised, 0 if caller should retry using longs */ static int err_ovf(char *msg) { if (PyErr_Warn(PyExc_OverflowWarning, msg) < 0) { if (PyErr_ExceptionMatches(PyExc_OverflowWarning)) PyErr_SetString(PyExc_OverflowError, msg);
namespace boost { namespace python { namespace objects { struct enum_object { PyIntObject base_object; PyObject* name; }; static PyMemberDef enum_members[] = { {"name", T_OBJECT_EX, offsetof(enum_object,name),READONLY, 0}, {0, 0, 0, 0, 0} }; extern "C" { static PyObject* enum_repr(PyObject* self_) { enum_object* self = downcast<enum_object>(self_); if (!self->name) { return PyString_FromFormat("%s(%ld)", self_->ob_type->tp_name, PyInt_AS_LONG(self_)); } else { char* name = PyString_AsString(self->name); if (name == 0) return 0; return PyString_FromFormat("%s.%s", self_->ob_type->tp_name, name); } } static PyObject* enum_str(PyObject* self_) { enum_object* self = downcast<enum_object>(self_); if (!self->name) { return PyInt_Type.tp_str(self_); } else { return incref(self->name); } } } static PyTypeObject enum_type_object = { PyObject_HEAD_INIT(0) // &PyType_Type 0, "Boost.Python.enum", sizeof(enum_object), /* tp_basicsize */ 0, /* tp_itemsize */ 0, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ enum_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ enum_str, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ enum_members, /* tp_members */ 0, /* tp_getset */ 0, //&PyInt_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #if PYTHON_API_VERSION >= 1012 0 /* tp_del */ #endif }; object module_prefix(); namespace { object new_enum_type(char const* name) { if (enum_type_object.tp_dict == 0) { enum_type_object.ob_type = incref(&PyType_Type); enum_type_object.tp_base = &PyInt_Type; if (PyType_Ready(&enum_type_object)) throw_error_already_set(); } type_handle metatype(borrowed(&PyType_Type)); type_handle base(borrowed(&enum_type_object)); // suppress the instance __dict__ in these enum objects. There // may be a slicker way, but this'll do for now. dict d; d["__slots__"] = tuple(); d["values"] = dict(); object module_name = module_prefix(); if (module_name) module_name += '.'; object result = (object(metatype))( module_name + name, make_tuple(base), d); scope().attr(name) = result; return result; } } enum_base::enum_base( char const* name , converter::to_python_function_t to_python , converter::convertible_function convertible , converter::constructor_function construct , type_info id ) : object(new_enum_type(name)) { converter::registration& converters = const_cast<converter::registration&>( converter::registry::lookup(id)); converters.m_class_object = downcast<PyTypeObject>(this->ptr()); converter::registry::insert(to_python, id); converter::registry::insert(convertible, construct, id); } void enum_base::add_value(char const* name_, long value) { // Convert name to Python string object name(name_); // Create a new enum instance by calling the class with a value object x = (*this)(value); // Store the object in the enum class (*this).attr(name_) = x; dict d = extract<dict>(this->attr("values"))(); d[value] = x; // Set the name field in the new enum instanec enum_object* p = downcast<enum_object>(x.ptr()); Py_XDECREF(p->name); p->name = incref(name.ptr()); } void enum_base::export_values() { dict d = extract<dict>(this->attr("values"))(); list values = d.values(); scope current; for (unsigned i = 0, max = len(values); i < max; ++i) { api::setattr(current, object(values[i].attr("name")), values[i]); } } PyObject* enum_base::to_python(PyTypeObject* type_, long x) { object type((type_handle(borrowed(type_)))); dict d = extract<dict>(type.attr("values"))(); object v = d.get(x, object()); return incref( (v == object() ? type(x) : v).ptr()); } }}} // namespace boost::python::object
} static PyObject * spamlist_state_get(spamlistobject *self) { return PyInt_FromLong(self->state); } static PyGetSetDef spamlist_getsets[] = { {"state", (getter)spamlist_state_get, NULL, PyDoc_STR("an int variable for demonstration purposes")}, {0} }; static PyTypeObject spamlist_type = { PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type)) 0, "xxsubtype.spamlist", sizeof(spamlistobject), 0, 0, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */
PyErr_SetString(PyExc_TypeError, "header.type can only be set to a single-character value"); return -1; } self->hline->type = (int)(p[0]); return 0; } PyErr_Format(PyExc_AttributeError, "Attribute: %s is not settable", name); return -1; } static PyTypeObject ExPy_Header_Line = { PyObject_HEAD_INIT(NULL) /* Workaround problem with Cygwin/GCC, by setting to &PyType_Type at runtime */ 0, /*ob_size*/ "ExPy Header Line", /*tp_name*/ sizeof(expy_header_line_t), /*tp_size*/ 0, /*tp_itemsize*/ expy_header_line_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc) expy_header_line_getattr, /*tp_getattr*/ (setattrfunc) expy_header_line_setattr, /*tp_setattr*/ }; PyObject * expy_create_header_line(header_line *p) { expy_header_line_t * result;
(PyCFunction)Track_starred, METH_VARARGS | METH_KEYWORDS, "Get/set the starred property of the track"}, {"is_autolinked", (PyCFunction)Track_is_autolinked, METH_NOARGS, "Returns whether this track is a link to another track"}, {"playable", (PyCFunction)Track_get_playable, METH_NOARGS, "Return the actual track that will be played if this track is played"}, {NULL} }; PyTypeObject TrackType = { PyObject_HEAD_INIT(NULL) 0, /*ob_size */ "spotify.Track", /*tp_name */ sizeof(Track), /*tp_basicsize */ 0, /*tp_itemsize */ (destructor) Track_dealloc, /*tp_dealloc */ 0, /*tp_print */ 0, /*tp_getattr */ 0, /*tp_setattr */ 0, /*tp_compare */ 0, /*tp_repr */ 0, /*tp_as_number */ 0, /*tp_as_sequence */ 0, /*tp_as_mapping */ 0, /*tp_hash */ 0, /*tp_call */ Track_str, /*tp_str */
/* TODO: Path MTU Discovery (RFC1191) PyObject *icmp_radv; PyObject *icmp_mask; */ {"packet", T_OBJECT, offsetof(ICMPObject, data), READONLY, "Raw packet data"}, { NULL } }; PyTypeObject ICMP_Type = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "pycap.protocol.icmp", /*tp_name*/ sizeof(ICMPObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)ICMPObject_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ (reprfunc)ICMPObject_str, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/
typedef struct { PyObject_HEAD void *data; } premalloced_object; static void premalloced_dealloc(premalloced_object *self) { free(self->data); Py_TYPE(self)->tp_free((PyObject *) self); } static PyTypeObject premalloced_type = { PyObject_HEAD_INIT(NULL) .tp_name = "premalloced", .tp_basicsize = sizeof(premalloced_object), .tp_dealloc = (destructor)premalloced_dealloc, .tp_flags = Py_TPFLAGS_DEFAULT, .tp_doc = "Pre-malloc'd memory" }; static PyObject *premalloced_new(void *data) { premalloced_object *obj = PyObject_New(premalloced_object, &premalloced_type); if (obj) obj->data = data; else free(data); return (PyObject *) obj;
/* No additional interface members defined */ /** Type Object ********************************************************/ static char comment_doc[] = "\ Comment(ownerDocument, data) -> Comment object\n\ \n\ This interface represents the content of a comment, i.e., all the characters\n\ between the starting '<!--' and ending '-->'."; PyTypeObject DomletteComment_Type = { /* PyObject_HEAD */ PyObject_HEAD_INIT(NULL) /* ob_size */ 0, /* tp_name */ DOMLETTE_PACKAGE "Comment", /* tp_basicsize */ sizeof(PyCommentObject), /* tp_itemsize */ 0, /* tp_dealloc */ (destructor) 0, /* tp_print */ (printfunc) 0, /* tp_getattr */ (getattrfunc) 0, /* tp_setattr */ (setattrfunc) 0, /* tp_compare */ (cmpfunc) 0, /* tp_repr */ (reprfunc) 0, /* tp_as_number */ (PyNumberMethods *) 0, /* tp_as_sequence */ (PySequenceMethods *) 0, /* tp_as_mapping */ (PyMappingMethods *) 0, /* tp_hash */ (hashfunc) 0, /* tp_call */ (ternaryfunc) 0,
Py_INCREF((PyObject*)symbol_NONE); return(symbol_NONE); } return(zbarSymbol_LookupEnum(sym)); } static PyMethodDef scanner_methods[] = { { "reset", (PyCFunction)scanner_reset, METH_VARARGS | METH_KEYWORDS, }, { "new_scan", (PyCFunction)scanner_new_scan, METH_VARARGS | METH_KEYWORDS, }, { "scan_y", (PyCFunction)scanner_scan_y, METH_VARARGS | METH_KEYWORDS, }, { NULL, }, }; PyTypeObject zbarScanner_Type = { PyObject_HEAD_INIT(NULL) .tp_name = "zbar.Scanner", .tp_doc = scanner_doc, .tp_basicsize = sizeof(zbarScanner), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, .tp_new = (newfunc)scanner_new, .tp_traverse = (traverseproc)scanner_traverse, .tp_clear = (inquiry)scanner_clear, .tp_dealloc = (destructor)scanner_dealloc, .tp_getset = scanner_getset, .tp_methods = scanner_methods, };
namespace python { //! SymbolicVariable destructor. void SymbolicVariable_dealloc(PyObject* self) { std::cout << std::flush; Py_DECREF(self); } static PyObject* SymbolicVariable_getKind(PyObject* self, PyObject* noarg) { try { return PyLong_FromUint32(PySymbolicVariable_AsSymbolicVariable(self)->getKind()); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* SymbolicVariable_getName(PyObject* self, PyObject* noarg) { try { return Py_BuildValue("s", PySymbolicVariable_AsSymbolicVariable(self)->getName().c_str()); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* SymbolicVariable_getId(PyObject* self, PyObject* noarg) { try { return PyLong_FromUsize(PySymbolicVariable_AsSymbolicVariable(self)->getId()); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* SymbolicVariable_getKindValue(PyObject* self, PyObject* noarg) { try { return PyLong_FromUint64(PySymbolicVariable_AsSymbolicVariable(self)->getKindValue()); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* SymbolicVariable_getBitSize(PyObject* self, PyObject* noarg) { try { return PyLong_FromUint32(PySymbolicVariable_AsSymbolicVariable(self)->getSize()); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* SymbolicVariable_getComment(PyObject* self, PyObject* noarg) { try { return Py_BuildValue("s", PySymbolicVariable_AsSymbolicVariable(self)->getComment().c_str()); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* SymbolicVariable_getConcreteValue(PyObject* self, PyObject* noarg) { try { return PyLong_FromUint512(PySymbolicVariable_AsSymbolicVariable(self)->getConcreteValue()); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* SymbolicVariable_setComment(PyObject* self, PyObject* comment) { try { if (!PyString_Check(comment)) return PyErr_Format(PyExc_TypeError, "SymbolicVariable::setComment(): Expected a string as argument."); PySymbolicVariable_AsSymbolicVariable(self)->setComment(PyString_AsString(comment)); Py_INCREF(Py_None); return Py_None; } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* SymbolicVariable_setConcreteValue(PyObject* self, PyObject* value) { try { if (!PyLong_Check(value) && !PyInt_Check(value)) return PyErr_Format(PyExc_TypeError, "SymbolicVariable::setConcretevalue(): Expected an integer as argument."); PySymbolicVariable_AsSymbolicVariable(self)->setConcreteValue(PyLong_AsUint512(value)); Py_INCREF(Py_None); return Py_None; } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static int SymbolicVariable_print(PyObject* self) { std::cout << PySymbolicVariable_AsSymbolicVariable(self); return 0; } static PyObject* SymbolicVariable_str(PyObject* self) { try { std::stringstream str; str << PySymbolicVariable_AsSymbolicVariable(self); return PyString_FromFormat("%s", str.str().c_str()); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } //! SymbolicVariable methods. PyMethodDef SymbolicVariable_callbacks[] = { {"getBitSize", SymbolicVariable_getBitSize, METH_NOARGS, ""}, {"getComment", SymbolicVariable_getComment, METH_NOARGS, ""}, {"getConcreteValue", SymbolicVariable_getConcreteValue, METH_NOARGS, ""}, {"getId", SymbolicVariable_getId, METH_NOARGS, ""}, {"getKind", SymbolicVariable_getKind, METH_NOARGS, ""}, {"getKindValue", SymbolicVariable_getKindValue, METH_NOARGS, ""}, {"getName", SymbolicVariable_getName, METH_NOARGS, ""}, {"setComment", SymbolicVariable_setComment, METH_O, ""}, {"setConcreteValue", SymbolicVariable_setConcreteValue, METH_O, ""}, {nullptr, nullptr, 0, nullptr} }; PyTypeObject SymbolicVariable_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size*/ "SymbolicVariable", /* tp_name*/ sizeof(SymbolicVariable_Object), /* tp_basicsize*/ 0, /* tp_itemsize*/ (destructor)SymbolicVariable_dealloc, /* tp_dealloc*/ (printfunc)SymbolicVariable_print, /* tp_print*/ 0, /* tp_getattr*/ 0, /* tp_setattr*/ 0, /* tp_compare*/ 0, /* tp_repr*/ 0, /* tp_as_number*/ 0, /* tp_as_sequence*/ 0, /* tp_as_mapping*/ 0, /* tp_hash */ 0, /* tp_call*/ (reprfunc)SymbolicVariable_str, /* tp_str*/ 0, /* tp_getattro*/ 0, /* tp_setattro*/ 0, /* tp_as_buffer*/ Py_TPFLAGS_DEFAULT, /* tp_flags*/ "SymbolicVariable objects", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ SymbolicVariable_callbacks, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ 0, /* tp_del */ 0 /* tp_version_tag */ }; PyObject* PySymbolicVariable(triton::engines::symbolic::SymbolicVariable* symVar) { SymbolicVariable_Object* object; if (symVar == nullptr) return PyErr_Format(PyExc_TypeError, "PySymbolicVariable(): symVar cannot be null."); PyType_Ready(&SymbolicVariable_Type); object = PyObject_NEW(SymbolicVariable_Object, &SymbolicVariable_Type); if (object != NULL) object->symVar = symVar; return (PyObject*)object; } }; /* python namespace */
namespace python { //! Memory destructor. void MemoryOperand_dealloc(PyObject* self) { std::cout << std::flush; delete PyMemoryOperand_AsMemoryOperand(self); Py_DECREF(self); } static PyObject* MemoryOperand_getAddress(PyObject* self, PyObject* noarg) { try { return PyLong_FromUint(PyMemoryOperand_AsMemoryOperand(self)->getAddress()); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_getLeaAst(PyObject* self, PyObject* noarg) { try { if (PyMemoryOperand_AsMemoryOperand(self)->getLeaAst() == nullptr) { Py_INCREF(Py_None); return Py_None; } return PyAstNode(PyMemoryOperand_AsMemoryOperand(self)->getLeaAst()); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_getBaseRegister(PyObject* self, PyObject* noarg) { try { triton::arch::RegisterOperand reg(PyMemoryOperand_AsMemoryOperand(self)->getBaseRegister()); return PyRegisterOperand(reg); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_getBitSize(PyObject* self, PyObject* noarg) { try { return Py_BuildValue("k", PyMemoryOperand_AsMemoryOperand(self)->getBitSize()); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_getBitvector(PyObject* self, PyObject* noarg) { try { return PyBitvector(*PyMemoryOperand_AsMemoryOperand(self)); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_getConcreteValue(PyObject* self, PyObject* noarg) { try { return PyLong_FromUint512(PyMemoryOperand_AsMemoryOperand(self)->getConcreteValue()); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_getDisplacement(PyObject* self, PyObject* noarg) { try { triton::arch::ImmediateOperand imm(PyMemoryOperand_AsMemoryOperand(self)->getDisplacement()); return PyImmediateOperand(imm); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_getIndexRegister(PyObject* self, PyObject* noarg) { try { triton::arch::RegisterOperand reg(PyMemoryOperand_AsMemoryOperand(self)->getIndexRegister()); return PyRegisterOperand(reg); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_getScale(PyObject* self, PyObject* noarg) { try { triton::arch::ImmediateOperand imm(PyMemoryOperand_AsMemoryOperand(self)->getScale()); return PyImmediateOperand(imm); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_getSegmentRegister(PyObject* self, PyObject* noarg) { try { triton::arch::RegisterOperand reg(PyMemoryOperand_AsMemoryOperand(self)->getSegmentRegister()); return PyRegisterOperand(reg); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_getSize(PyObject* self, PyObject* noarg) { try { return Py_BuildValue("k", PyMemoryOperand_AsMemoryOperand(self)->getSize()); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_getType(PyObject* self, PyObject* noarg) { try { return Py_BuildValue("k", PyMemoryOperand_AsMemoryOperand(self)->getType()); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_isTrusted(PyObject* self, PyObject* noarg) { try { if (PyMemoryOperand_AsMemoryOperand(self)->isTrusted()) Py_RETURN_TRUE; Py_RETURN_FALSE; } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_setBaseRegister(PyObject* self, PyObject* reg) { try { triton::arch::MemoryOperand *mem; if (!PyRegisterOperand_Check(reg)) return PyErr_Format(PyExc_TypeError, "Memory::setBaseRegister(): Expected a Register as argument."); mem = PyMemoryOperand_AsMemoryOperand(self); mem->setBaseRegister(*PyRegisterOperand_AsRegisterOperand(reg)); Py_INCREF(Py_None); return Py_None; } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_setConcreteValue(PyObject* self, PyObject* value) { try { triton::arch::MemoryOperand *mem; if (!PyLong_Check(value) && !PyInt_Check(value)) return PyErr_Format(PyExc_TypeError, "Memory::setConcretevalue(): Expected an integer as argument."); mem = PyMemoryOperand_AsMemoryOperand(self); mem->setConcreteValue(PyLong_AsUint512(value)); Py_INCREF(Py_None); return Py_None; } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_setDisplacement(PyObject* self, PyObject* imm) { try { triton::arch::MemoryOperand *mem; if (!PyImmediateOperand_Check(imm)) return PyErr_Format(PyExc_TypeError, "Memory::setDisplacement(): Expected an Immediate as argument."); mem = PyMemoryOperand_AsMemoryOperand(self); mem->setDisplacement(*PyImmediateOperand_AsImmediateOperand(imm)); Py_INCREF(Py_None); return Py_None; } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_setIndexRegister(PyObject* self, PyObject* reg) { try { triton::arch::MemoryOperand *mem; if (!PyRegisterOperand_Check(reg)) return PyErr_Format(PyExc_TypeError, "Memory::setIndexRegister(): Expected a Register as argument."); mem = PyMemoryOperand_AsMemoryOperand(self); mem->setIndexRegister(*PyRegisterOperand_AsRegisterOperand(reg)); Py_INCREF(Py_None); return Py_None; } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_setScale(PyObject* self, PyObject* imm) { try { triton::arch::MemoryOperand *mem; if (!PyImmediateOperand_Check(imm)) return PyErr_Format(PyExc_TypeError, "Memory::setScale(): Expected an Immediate as argument."); mem = PyMemoryOperand_AsMemoryOperand(self); mem->setScale(*PyImmediateOperand_AsImmediateOperand(imm)); Py_INCREF(Py_None); return Py_None; } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_setSegmentRegister(PyObject* self, PyObject* reg) { try { triton::arch::MemoryOperand *mem; if (!PyRegisterOperand_Check(reg)) return PyErr_Format(PyExc_TypeError, "Memory::setSegmentRegister(): Expected a Register as argument."); mem = PyMemoryOperand_AsMemoryOperand(self); mem->setSegmentRegister(*PyRegisterOperand_AsRegisterOperand(reg)); Py_INCREF(Py_None); return Py_None; } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* MemoryOperand_setTrust(PyObject* self, PyObject* flag) { try { if (!PyBool_Check(flag)) return PyErr_Format(PyExc_TypeError, "Memory::setTrust(): Expected a boolean as argument."); PyMemoryOperand_AsMemoryOperand(self)->setTrust(PyObject_IsTrue(flag)); Py_INCREF(Py_None); return Py_None; } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static int MemoryOperand_print(PyObject* self) { std::cout << PyMemoryOperand_AsMemoryOperand(self); return 0; } static PyObject* MemoryOperand_str(PyObject* self) { try { std::stringstream str; str << PyMemoryOperand_AsMemoryOperand(self); return PyString_FromFormat("%s", str.str().c_str()); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } //! Memory methods. PyMethodDef MemoryOperand_callbacks[] = { {"getAddress", MemoryOperand_getAddress, METH_NOARGS, ""}, {"getBaseRegister", MemoryOperand_getBaseRegister, METH_NOARGS, ""}, {"getBitSize", MemoryOperand_getBitSize, METH_NOARGS, ""}, {"getBitvector", MemoryOperand_getBitvector, METH_NOARGS, ""}, {"getConcreteValue", MemoryOperand_getConcreteValue, METH_NOARGS, ""}, {"getDisplacement", MemoryOperand_getDisplacement, METH_NOARGS, ""}, {"getIndexRegister", MemoryOperand_getIndexRegister, METH_NOARGS, ""}, {"getLeaAst", MemoryOperand_getLeaAst, METH_NOARGS, ""}, {"getScale", MemoryOperand_getScale, METH_NOARGS, ""}, {"getSegmentRegister", MemoryOperand_getSegmentRegister, METH_NOARGS, ""}, {"getSize", MemoryOperand_getSize, METH_NOARGS, ""}, {"getType", MemoryOperand_getType, METH_NOARGS, ""}, {"isTrusted", MemoryOperand_isTrusted, METH_NOARGS, ""}, {"setBaseRegister", MemoryOperand_setBaseRegister, METH_O, ""}, {"setConcreteValue", MemoryOperand_setConcreteValue, METH_O, ""}, {"setDisplacement", MemoryOperand_setDisplacement, METH_O, ""}, {"setIndexRegister", MemoryOperand_setIndexRegister, METH_O, ""}, {"setScale", MemoryOperand_setScale, METH_O, ""}, {"setSegmentRegister", MemoryOperand_setSegmentRegister, METH_O, ""}, {"setTrust", MemoryOperand_setTrust, METH_O, ""}, {nullptr, nullptr, 0, nullptr} }; PyTypeObject MemoryOperand_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size*/ "Memory", /* tp_name*/ sizeof(MemoryOperand_Object), /* tp_basicsize*/ 0, /* tp_itemsize*/ (destructor)MemoryOperand_dealloc, /* tp_dealloc*/ (printfunc)MemoryOperand_print, /* tp_print*/ 0, /* tp_getattr*/ 0, /* tp_setattr*/ 0, /* tp_compare*/ 0, /* tp_repr*/ 0, /* tp_as_number*/ 0, /* tp_as_sequence*/ 0, /* tp_as_mapping*/ 0, /* tp_hash */ 0, /* tp_call*/ (reprfunc)MemoryOperand_str, /* tp_str*/ 0, /* tp_getattro*/ 0, /* tp_setattro*/ 0, /* tp_as_buffer*/ Py_TPFLAGS_DEFAULT, /* tp_flags*/ "Memory objects", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ MemoryOperand_callbacks, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ }; PyObject* PyMemoryOperand(const triton::arch::MemoryOperand& mem) { MemoryOperand_Object* object; PyType_Ready(&MemoryOperand_Type); object = PyObject_NEW(MemoryOperand_Object, &MemoryOperand_Type); if (object != NULL) object->mem = new triton::arch::MemoryOperand(mem); return (PyObject*)object; } }; /* python namespace */
namespace python { //! Bitvector destructor. void Bitvector_dealloc(PyObject* self) { std::cout << std::flush; Py_DECREF(self); } static PyObject* Bitvector_getHigh(PyObject* self, PyObject* noarg) { try { return PyLong_FromUint32(PyBitvector_AsHigh(self)); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* Bitvector_getLow(PyObject* self, PyObject* noarg) { try { return PyLong_FromUint32(PyBitvector_AsLow(self)); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static PyObject* Bitvector_getVectorSize(PyObject* self, PyObject* noarg) { try { triton::uint32 vectorSize = ((PyBitvector_AsHigh(self) - PyBitvector_AsLow(self)) + 1); return PyLong_FromUint32(vectorSize); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } static int Bitvector_print(PyObject* self) { std::cout << "bv[" << std::dec << PyBitvector_AsHigh(self) << ".." << PyBitvector_AsLow(self) << "]"; return 0; } static PyObject* Bitvector_str(PyObject* self) { try { return PyString_FromFormat("bv[%d..%d]", PyBitvector_AsHigh(self), PyBitvector_AsLow(self)); } catch (const std::exception& e) { return PyErr_Format(PyExc_TypeError, "%s", e.what()); } } //! Bitvector methods. PyMethodDef Bitvector_callbacks[] = { {"getHigh", Bitvector_getHigh, METH_NOARGS, ""}, {"getLow", Bitvector_getLow, METH_NOARGS, ""}, {"getVectorSize", Bitvector_getVectorSize, METH_NOARGS, ""}, {nullptr, nullptr, 0, nullptr} }; PyTypeObject Bitvector_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ "Bitvector", /* tp_name */ sizeof(Bitvector_Object), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)Bitvector_dealloc, /* tp_dealloc */ (printfunc)Bitvector_print, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ (reprfunc)Bitvector_str, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ "Bitvector objects", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ Bitvector_callbacks, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ 0, /* tp_del */ 0 /* tp_version_tag */ }; PyObject* PyBitvector(const triton::arch::Immediate& imm) { Bitvector_Object* object; PyType_Ready(&Bitvector_Type); object = PyObject_NEW(Bitvector_Object, &Bitvector_Type); if (object != NULL) { object->high = imm.getHigh(); object->low = imm.getLow(); } return (PyObject*)object; } PyObject* PyBitvector(const triton::arch::MemoryAccess& mem) { Bitvector_Object* object; PyType_Ready(&Bitvector_Type); object = PyObject_NEW(Bitvector_Object, &Bitvector_Type); if (object != NULL) { object->high = mem.getHigh(); object->low = mem.getLow(); } return (PyObject*)object; } PyObject* PyBitvector(const triton::arch::Register& reg) { Bitvector_Object* object; PyType_Ready(&Bitvector_Type); object = PyObject_NEW(Bitvector_Object, &Bitvector_Type); if (object != NULL) { object->high = reg.getHigh(); object->low = reg.getLow(); } return (PyObject*)object; } PyObject* PyBitvector(triton::uint32 high, triton::uint32 low) { Bitvector_Object* object; PyType_Ready(&Bitvector_Type); object = PyObject_NEW(Bitvector_Object, &Bitvector_Type); if (object != NULL) { object->high = high; object->low = low; } return (PyObject*)object; } }; /* python namespace */
return NULL; } // Py_INCREF(Py_True); // return True not None for backward compat // return Py_True; // Py_RETURN_TRUE; return PyBool_FromLong(static_cast<long>(true)); } static PyMethodDef ImageExport_methods[] = { {const_cast<char*>("save"), (PyCFunction)ImageExport_save, METH_NOARGS, imgexp_save__doc__}, {const_cast<char*>("saveAs"), (PyCFunction)ImageExport_saveAs, METH_VARARGS, imgexp_saveas__doc__}, {NULL, (PyCFunction)(0), 0, NULL} // sentinel }; PyTypeObject ImageExport_Type = { PyObject_HEAD_INIT(NULL) // PyObject_VAR_HEAD 0, const_cast<char*>("ImageExport"), // char *tp_name; /* For printing, in format "<module>.<name>" */ sizeof(ImageExport), // int tp_basicsize, /* For allocation */ 0, // int tp_itemsize; /* For allocation */ (destructor) ImageExport_dealloc, // destructor tp_dealloc; 0, // printfunc tp_print; 0, // getattrfunc tp_getattr; 0, // setattrfunc tp_setattr; 0, // cmpfunc tp_compare; 0, // reprfunc tp_repr; 0, // PyNumberMethods *tp_as_number; 0, // PySequenceMethods *tp_as_sequence; 0, // PyMappingMethods *tp_as_mapping; 0, // hashfunc tp_hash; 0, // ternaryfunc tp_call;
namespace IcePy { PyTypeObject ConnectionInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ PyObject_HEAD_INIT(0) 0, /* ob_size */ STRCAST("IcePy.ConnectionInfo"), /* tp_name */ sizeof(ConnectionInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ (destructor)connectionInfoDealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ ConnectionInfoGetters, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ (newfunc)connectionInfoNew, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; PyTypeObject IPConnectionInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ PyObject_HEAD_INIT(0) 0, /* ob_size */ STRCAST("IcePy.IPConnectionInfo"), /* tp_name */ sizeof(ConnectionInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ (destructor)connectionInfoDealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ IPConnectionInfoGetters, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ (newfunc)connectionInfoNew, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; PyTypeObject TCPConnectionInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ PyObject_HEAD_INIT(0) 0, /* ob_size */ STRCAST("IcePy.TCPConnectionInfo"),/* tp_name */ sizeof(ConnectionInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ (destructor)connectionInfoDealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ (newfunc)connectionInfoNew, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; PyTypeObject UDPConnectionInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ PyObject_HEAD_INIT(0) 0, /* ob_size */ STRCAST("IcePy.UDPConnectionInfo"),/* tp_name */ sizeof(ConnectionInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ (destructor)connectionInfoDealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ UDPConnectionInfoGetters, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ (newfunc)connectionInfoNew, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; }
cdefer_DeferredMetaType_set_debug, "DEPRECATED: use getDebugging/setDebugging instead"}, }; /* The default tp_setattro assumes that to support setattr, the * instances have to be on the heap... */ static int cdefer_DeferredMetaType_setattro(PyObject *type, PyObject *name, PyObject *value) { return PyObject_GenericSetAttr(type, name, value); } static PyTypeObject cdefer_DeferredMetaType = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "cdefer._DeferredClass", /*tp_name*/ 0, /*tp_basicsize*/ 0, /*tp_itemsize*/ 0, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/
Py_DECREF(self->owner); self->ob_type->tp_free((PyObject*)self); } static PyGetSetDef cp_dev_attribs[] = { {"bus", (getter)cp_dev_bus, NULL, "xfr.bus()\n" "Retrieves bus number of device."}, {"addr", (getter)cp_dev_addr, NULL, "xfr.addr()\n" "Retrieves USB device address."}, {NULL, } }; static PyTypeObject dev_pytype = { PyObject_HEAD_INIT(NULL) .tp_name = MODNAME ".dev", .tp_basicsize = sizeof(struct cp_dev), .tp_flags = Py_TPFLAGS_DEFAULT, .tp_new = PyType_GenericNew, .tp_init = (initproc)cp_dev_init, .tp_dealloc = (destructor)cp_dev_dealloc, .tp_getset = cp_dev_attribs, .tp_doc = "CCI device list entry", }; static int cp_devlist_init(struct cp_devlist *self, PyObject *args, PyObject *kwds) { self->list = libccid_get_device_list(&self->nmemb); return 0; }
return PyString_FromString("None"); } /* ARGUSED */ static void none_dealloc(PyObject* ignore) { /* This should never get called, but we also don't want to SEGV if * we accidently decref None out of existance. */ Py_FatalError("deallocating None"); } static PyTypeObject PyNone_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, "NoneType", 0, 0, none_dealloc, /*tp_dealloc*/ /*never called*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ none_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ };
(binaryfunc)NULL, /* nb_xor */ (binaryfunc)NULL, /* nb_or */ (coercion)PgVersion_coerce, /* nb_coerce */ (unaryfunc)NULL, /* nb_int */ (unaryfunc)NULL, /* nb_long */ (unaryfunc)NULL, /* nb_float */ (unaryfunc)NULL, /* nb_oct */ (unaryfunc)NULL /* nb_hex */ }; /*--------------------------------------------------------------------------*/ static char PgVersion_Type_Doc[] = "This is the type of PgVersion objects"; PyTypeObject PgVersion_Type = { PyObject_HEAD_INIT(NULL) (Py_ssize_t)NULL, /* ob_size */ MODULE_NAME ".PgVersion", /* tp_name */ sizeof(PgVersion), /* tp_basicsize */ (Py_ssize_t)NULL, /* tp_itemsize */ (destructor)PgVersion_dealloc, /* tp_dealloc */ (printfunc)NULL, /* tp_print */ (getattrfunc)PgVersion_getattr, /* tp_getattr */ (setattrfunc)PgVersion_setattr, /* tp_setattr */ (cmpfunc)PgVersion_cmp, /* tp_compare */ (reprfunc)PgVersion_repr, /* tp_repr */ &ver_as_number, /* tp_as_number */ NULL, /* tp_as_sequence */ &ver_as_mapping, /* tp_as_mapping */ (hashfunc)NULL, /* tp_hash */ (ternaryfunc)NULL, /* tp_call */ (reprfunc)NULL, /* tp_str */
Py_CLEAR(super->message); if(!value) value = PyString_FromString(""); else Py_INCREF(value); super->message = value; return(0); } static PyGetSetDef exc_getset[] = { { "message", (getter)exc_get_message, (setter)exc_set_message, }, { NULL, }, }; PyTypeObject zbarException_Type = { PyObject_HEAD_INIT(NULL) .tp_name = "zbar.Exception", .tp_basicsize = sizeof(zbarException), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, .tp_init = (initproc)exc_init, .tp_traverse = (traverseproc)exc_traverse, .tp_clear = (inquiry)exc_clear, .tp_dealloc = (destructor)exc_dealloc, .tp_str = (reprfunc)exc_str, .tp_getset = exc_getset, }; PyObject* zbarErr_Set (PyObject *self) { const void *zobj = ((zbarProcessor*)self)->zproc;
TypeInfo::TypeInfo(const std::type_info& ti) : swigType(NULL), parentType(NULL), typeIndex(ti) { static PyTypeObject py_type_object_header = { PyObject_HEAD_INIT(NULL) 0}; static int size = (long*)&(py_type_object_header.tp_name) - (long*)&py_type_object_header; memcpy(&(this->pythonType), &py_type_object_header, size); }
static PyMemberDef Runtime_members[] = { {NULL} }; static PyMethodDef Runtime_methods[] = { { "new_context", (PyCFunction)Runtime_new_context, METH_VARARGS | METH_KEYWORDS, "Create a new JavaScript Context." }, {NULL} }; PyTypeObject _RuntimeType = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "spidermonkey.Runtime", /*tp_name*/ sizeof(Runtime), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor)Runtime_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/
namespace cocaine { namespace dealer { class client; class client_object_t { public: PyObject_HEAD static PyObject* construct(PyTypeObject * type, PyObject * args, PyObject * kwargs); static int initialize(client_object_t * self, PyObject * args, PyObject * kwargs); static void destruct(client_object_t * self); static PyObject* send(client_object_t * self, PyObject * args, PyObject * kwargs); public: client * m_client; }; static PyMethodDef client_object_methods[] = { { "send", (PyCFunction)client_object_t::send, METH_KEYWORDS, "Sends a message to the cloud." }, { NULL, NULL, 0, NULL } }; static PyTypeObject client_object_type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ "cocaine.client.Client", /* tp_name */ sizeof(client_object_t), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)client_object_t::destruct, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ "Client", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ client_object_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ (initproc)client_object_t::initialize, /* tp_init */ 0, /* tp_alloc */ client_object_t::construct /* tp_new */ }; }}
static int TreeSet_init(PyObject *self, PyObject *args, PyObject *kwds) { PyObject *v = NULL; if (!PyArg_ParseTuple(args, "|O:" MOD_NAME_PREFIX "TreeSet", &v)) return -1; if (v) return _TreeSet_update((BTree *)self, v); else return 0; } static PyTypeObject TreeSetType = { PyObject_HEAD_INIT(NULL) /* PyPersist_Type */ 0, /* ob_size */ MODULE_NAME MOD_NAME_PREFIX "TreeSet",/* tp_name */ sizeof(BTree), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)BTree_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ &BTree_as_number_for_nonzero, /* tp_as_number */ &TreeSet_as_sequence, /* tp_as_sequence */ &TreeSet_as_mapping, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */
.mp_length = (lenfunc) key_length, .mp_subscript = (binaryfunc) key_subscript }; static PyMethodDef key_methods[] = { {"__sizeof__", (PyCFunction)key_sizeof, METH_NOARGS, ""}, {"from_hex", (PyCFunction)key_from_hex, METH_VARARGS|METH_CLASS, ""}, {"from_raw", (PyCFunction)key_from_raw, METH_VARARGS|METH_CLASS, ""}, {"to_raw", (PyCFunction)key_to_raw, METH_VARARGS, ""}, {"to_hex", (PyCFunction)key_to_hex, METH_VARARGS|METH_KEYWORDS, ""}, {"prefix_bound",(PyCFunction)key_prefix_bound, METH_NOARGS, ""}, {0, 0, 0, 0} }; static PyTypeObject KeyType = { PyObject_HEAD_INIT(NULL) .tp_name = "acid._keylib.Key", .tp_basicsize = sizeof(Key), .tp_itemsize = 1, .tp_iter = (getiterfunc) key_iter, .tp_hash = (hashfunc) key_hash, .tp_richcompare = (richcmpfunc) key_richcompare, .tp_new = key_new, .tp_dealloc = (destructor) key_dealloc, .tp_repr = (reprfunc) key_repr, .tp_flags = Py_TPFLAGS_DEFAULT, .tp_doc = "acid._keylib.Key", .tp_methods = key_methods, .tp_as_sequence = &key_seq_methods, .tp_as_mapping = &key_mapping_methods };