本文整理汇总了C++中PyObject_NEW函数的典型用法代码示例。如果您正苦于以下问题:C++ PyObject_NEW函数的具体用法?C++ PyObject_NEW怎么用?C++ PyObject_NEW使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyObject_NEW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pycorba_any_new
PyObject *
pycorba_any_new(CORBA_any *any)
{
PyCORBA_Any *self;
self = PyObject_NEW(PyCORBA_Any, &PyCORBA_Any_Type);
if (!self)
return NULL;
self->any._type = (CORBA_TypeCode)CORBA_Object_duplicate((CORBA_Object)any->_type, NULL);
self->any._value = MateCORBA_copy_value(any->_value, any->_type);
self->any._release = CORBA_FALSE;
return (PyObject *)self;
}
示例2: pyjiterator_new
/*
* News up a pyjiterator, which is just a pyjobject for iterators.
*/
PyJiterator_Object* pyjiterator_new() {
/*
* MSVC requires tp_base to be set here
* See https://docs.python.org/2/extending/newtypes.html
*/
if(!PyJiterator_Type.tp_base) {
PyJiterator_Type.tp_base = &PyJobject_Type;
}
if(PyType_Ready(&PyJiterator_Type) < 0)
return NULL;
return PyObject_NEW(PyJiterator_Object, &PyJiterator_Type);
}
示例3: alloc_ClientObject
static ClientObject*
alloc_ClientObject(void)
{
ClientObject *client;
if (client_numfree) {
client = client_free_list[--client_numfree];
_Py_NewReference((PyObject *)client);
GDEBUG("use pooled %p", client);
}else{
client = PyObject_NEW(ClientObject, &ClientObjectType);
GDEBUG("alloc %p", client);
}
return client;
}
示例4: FileWrapperObject_new
static PyObject *
FileWrapperObject_new(PyObject *self, PyObject *filelike, size_t blksize)
{
FileWrapperObject *f;
f = PyObject_NEW(FileWrapperObject, &FileWrapperType);
if(f == NULL){
return NULL;
}
f->filelike = filelike;
Py_INCREF(f->filelike);
GDEBUG("alloc FileWrapperObject %p", f);
return (PyObject *)f;
}
示例5: ilugi_FromIdentityInfo
PyObject *
ilugi_FromIdentityInfo (ilu_IdentityInfo id)
{
IlugiObject * v = PyObject_NEW(IlugiObject, &Ilugi_Type);
if (v == 0)
return 0;
if (id->ii_type != ilu_GSSIdentity)
return 0;
v->id = id;
v->name = ILU_NIL;
v->localp = ilu_FALSE;
return (PyObject *) v;
}
示例6: _pygtk_style_helper_new
PyObject *
_pygtk_style_helper_new(GtkStyle *style, int type, gpointer array)
{
PyGtkStyleHelper_Object *self;
self = (PyGtkStyleHelper_Object *)PyObject_NEW(PyGtkStyleHelper_Object,
&PyGtkStyleHelper_Type);
if (self == NULL)
return NULL;
self->style = g_object_ref(style);
self->type = type;
self->array = array;
return (PyObject *)self;
}
示例7: _pygtk_tree_model_row_iter_new
PyObject *
_pygtk_tree_model_row_iter_new(GtkTreeModel *model, GtkTreeIter *parent_iter)
{
PyGtkTreeModelRowIter *self;
self = (PyGtkTreeModelRowIter *) PyObject_NEW(PyGtkTreeModelRowIter,
&PyGtkTreeModelRowIter_Type);
if (self == NULL)
return NULL;
self->model = g_object_ref(model);
/* iterate through child nodes */
self->has_more = gtk_tree_model_iter_children(self->model, &self->iter,
parent_iter);
return (PyObject *)self;
}
示例8: vectors_bezier_stroke_new
static PyObject *
vectors_bezier_stroke_new(PyGimpVectors *vectors, int stroke)
{
PyGimpVectorsStroke *self;
self = PyObject_NEW(PyGimpVectorsStroke, &PyGimpVectorsBezierStroke_Type);
if (self == NULL)
return NULL;
self->vectors_ID = vectors->ID;
self->stroke = stroke;
return (PyObject *)self;
}
示例9: pyglib_option_context_new
/**
* pyglib_option_context_new:
* @context: a GOptionContext
*
* Returns: A new GOptionContext wrapper.
*/
PyObject *
pyglib_option_context_new (GOptionContext *context)
{
PyGOptionContext *self;
self = (PyGOptionContext *)PyObject_NEW(PyGOptionContext,
&PyGOptionContext_Type);
if (self == NULL)
return NULL;
self->context = context;
self->main_group = NULL;
return (PyObject *)self;
}
示例10: PySwigPacked_FromDataAndDesc
SWIGRUNTIME PyObject *
PySwigPacked_FromDataAndDesc(void *ptr, size_t size, const char *desc)
{
PySwigPacked *self = PyObject_NEW(PySwigPacked, PySwigPacked_GetType());
if (self == NULL) {
return NULL;
} else {
void *pack = malloc(size);
memcpy(pack, ptr, size);
self->pack = pack;
self->desc = desc;
self->size = size;
return (PyObject *) self;
}
}
示例11: PySymbolicExpression
PyObject* PySymbolicExpression(triton::engines::symbolic::SymbolicExpression* symExpr) {
SymbolicExpression_Object* object;
if (symExpr == nullptr) {
Py_INCREF(Py_None);
return Py_None;
}
PyType_Ready(&SymbolicExpression_Type);
object = PyObject_NEW(SymbolicExpression_Object, &SymbolicExpression_Type);
if (object != NULL)
object->symExpr = symExpr;
return (PyObject*)object;
}
示例12: _pygtk_rc_style_helper_new
PyObject *
_pygtk_rc_style_helper_new(GtkRcStyle *rc_style, int type, gpointer array, GtkRcFlags is_set_flag)
{
PyGtkRcStyleHelper_Object *self;
self = (PyGtkRcStyleHelper_Object *)PyObject_NEW(PyGtkRcStyleHelper_Object,
&PyGtkRcStyleHelper_Type);
if (self == NULL)
return NULL;
self->rc_style = g_object_ref(rc_style);
self->type = type;
self->array = array;
self->is_set_flag = is_set_flag;
return (PyObject *)self;
}
示例13: newiciobject
static iciobject *
newiciobject(OSType creator)
{
iciobject *self;
OSStatus err;
self = PyObject_NEW(iciobject, &Icitype);
if (self == NULL)
return NULL;
if ((err=ICStart(&self->inst, creator)) != 0 ) {
(void)PyMac_Error(err);
PyObject_DEL(self);
return NULL;
}
return self;
}
示例14: createMyPyObject
static PyObject *
createMyPyObject (
PyObject * self_dummy,
PyObject * args ) {
MyPyObject * self;
char * string;
self = PyObject_NEW(MyPyObject, & MyPyObjectClass);
if (! self) {
return (NULL);
}
if (! (PyArg_ParseTuple(args, "|s", & string))) {
return ((void *) 0);
}
self->string = strdup(string);
return ((PyObject *) self);
}
示例15: pyglib_option_group_new
/**
* pyglib_option_group_new:
* @group: a GOptionGroup
*
* The returned GOptionGroup can't be used to set any hooks, translation domains
* or add entries. It's only intend is, to use for GOptionContext.add_group().
*
* Returns: the GOptionGroup wrapper.
*/
PyObject *
pyglib_option_group_new (GOptionGroup *group)
{
PyGOptionGroup *self;
self = (PyGOptionGroup *)PyObject_NEW(PyGOptionGroup,
&PyGOptionGroup_Type);
if (self == NULL)
return NULL;
self->group = group;
self->other_owner = TRUE;
self->is_in_context = FALSE;
return (PyObject *)self;
}