本文整理汇总了C++中PyObject_HEAD_INIT函数的典型用法代码示例。如果您正苦于以下问题:C++ PyObject_HEAD_INIT函数的具体用法?C++ PyObject_HEAD_INIT怎么用?C++ PyObject_HEAD_INIT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyObject_HEAD_INIT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ElfSymbolTable_dealloc
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 */
//.........这里部分代码省略.........
示例2: while
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 */
};
示例3: if
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,
示例4: PyObject_HEAD_INIT
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,
};
/*
示例5: PyObject_HEAD_INIT
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,
};
示例6: PyObject_HEAD_INIT
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 */
示例7: offsetof
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
//.........这里部分代码省略.........
示例8: spamlist_state_get
}
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 */
示例9: PyErr_SetString
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;
示例10: PyObject_HEAD_INIT
(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 */
示例11: Discovery
/*
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*/
示例12: premalloced_dealloc
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;
示例13: Comment
/* 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,
示例14: Py_INCREF
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,
};
示例15: SymbolicVariable_dealloc
//.........这里部分代码省略.........
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 */