PY_pdbdata *PY_pdbdata_newobj(PY_pdbdata *obj, void *vr, char *type, long nitems, dimdes *dims, defstr *dp, PP_file *fileinfo, PY_defstr *dpobj, PyObject *parent) { if (obj == NULL) obj = (PY_pdbdata *) PyType_GenericAlloc(dpobj->ctor, 0); if (obj != NULL) {obj->data = vr; obj->type = type; obj->nitems = nitems; obj->dims = dims; obj->dp = dp; obj->fileinfo = fileinfo; obj->dpobj = dpobj; obj->parent = parent; /* are the data belong to us or someone else? */ if (parent == NULL) {SC_mark(vr, 1);} else Py_INCREF(parent); SC_mark(type, 1); if (dims != NULL) SC_mark(dims, 1); SC_mark(dp, 1); Py_INCREF(dpobj);}; return(obj);}
PyObject * function_python::create_function_adapter( const function_adapter_interface_ptr & _adapter, bool _native ) { uint32_t arity = _adapter->getArity(); PyMethodDef * method; if( _native == true ) { method = &m_method_native; } else { if( arity > 0 ) { method = &m_method_args; } else { method = &m_method_noargs; } } py_function_type * py_self = (py_function_type *)PyType_GenericAlloc( &m_function_type, 0 ); stdex::intrusive_ptr_setup( py_self->iadapter, _adapter ); PyObject * py_func = PyCFunction_New( method, (PyObject*)py_self ); Py_DECREF( (PyObject *)py_self ); return py_func; }
static PyGreenlet * PyGreenlet_New(PyObject *run, PyGreenlet *parent) { PyGreenlet* g = NULL; g = (PyGreenlet *) PyType_GenericAlloc(&PyGreenlet_Type, 0); if (g == NULL) { return NULL; } if (run != NULL) { Py_INCREF(run); g->run_info = run; } if (parent != NULL) { if (PyGreenlet_SetParent(g, parent)) { Py_DECREF(g); return NULL; } } else { if ((g->parent = PyGreenlet_GetCurrent()) == NULL) { Py_DECREF(g); return NULL; } } return g; }
PyTypeObject* PyStructSequence_NewType(PyStructSequence_Desc *desc) { PyTypeObject *result = (PyTypeObject*)PyType_GenericAlloc(&PyType_Type, 0); PyStructSequence_InitType(result, desc); return result; }
PyObject * PyDescr_NewAdaMethod(PyTypeObject *type, PyObject* cfunc, const char* name) { if (!adamethod_descr_initialized) { adamethod_descr_initialized = 1; memcpy (&PyAdaMethodDescr_Type, &PyMethodDescr_Type, sizeof (PyTypeObject)); PyAdaMethodDescr_Type.tp_basicsize = sizeof(PyAdaMethodDescrObject); PyAdaMethodDescr_Type.tp_descr_get = (descrgetfunc)adamethod_descr_get; } PyAdaMethodDescrObject *descr = (PyAdaMethodDescrObject*) PyType_GenericAlloc (&PyAdaMethodDescr_Type, 0); if (descr != NULL) { Py_XINCREF(type); PyDescr_TYPE(descr) = type; PyDescr_NAME(descr) = PyUnicode_InternFromString(name); if (PyDescr_NAME(descr) == NULL) { Py_DECREF(descr); descr = NULL; } } if (descr != NULL) { descr->cfunc = cfunc; } return (PyObject *)descr; }
/** \ingroup py_c */ static PyObject * rpmfi_alloc(PyTypeObject * subtype, int nitems) { PyObject * s = PyType_GenericAlloc(subtype, nitems); if (_rpmfi_debug < 0) fprintf(stderr, "*** rpmfi_alloc(%p,%d) ret %p\n", subtype, nitems, s); return s; }
//------------------------------------------------------------------------------------- PyObject* ScriptDefModule::createObject(void) { PyObject * pObject = PyType_GenericAlloc(scriptType_, 0); if (pObject == NULL) { PyErr_Print(); ERROR_MSG("ScriptDefModule::createObject: GenericAlloc is failed.\n"); } return pObject; }
PyObject* PyIOCPBuffer_New( LONG size ) { PyObject *new_buffer; new_buffer = PyType_GenericAlloc(&iocp_buffer_type, 0); if (new_buffer != NULL) { ((PyIOCPBufferObject *)new_buffer)->ptr_start = ( char *) PyMem_Malloc( (DWORD)size ); ((PyIOCPBufferObject *)new_buffer)->len = (DWORD)size; } return new_buffer; }
/* * Return a new method descriptor for the given method. */ PyObject *sipMethodDescr_New(PyMethodDef *pmd) { PyObject *descr = PyType_GenericAlloc(&sipMethodDescr_Type, 0); if (descr != NULL) { ((sipMethodDescr *)descr)->pmd = pmd; ((sipMethodDescr *)descr)->mixin_name = NULL; } return descr; }
// Handle the getting of a lazy attribute, ie. a native Qt signal. int qpycore_get_lazy_attr(const sipTypeDef *td, PyObject *dict) { pyqt4ClassTypeDef *ctd = (pyqt4ClassTypeDef *)td; const pyqt4QtSignal *sigs = ctd->qt4_signals; // Handle the trvial case. if (!sigs) return 0; QByteArray curr_name; qpycore_pyqtSignal *curr = 0; do { // See if we have come to the end of the current signal. if (curr && !is_signal_name(sigs->signature, curr_name.constData(), curr_name.size())) { if (PyDict_SetItemString(dict, curr_name.constData(), (PyObject *)curr) < 0) return -1; curr = 0; } // See if we need to create a new signal. if (!curr) { // Get the name. curr_name = sigs->signature; curr_name.truncate(curr_name.indexOf('(')); curr = (qpycore_pyqtSignal *)PyType_GenericAlloc(&qpycore_pyqtSignal_Type, 0); if (!curr) return -1; curr->master = curr; curr->non_signals = sigs->non_signals; curr->overloads = new QList<Chimera::Signature *>; } // Add the new overload. if (add_overload(curr, sigs->signature, sigs->docstring) < 0) { Py_DECREF((PyObject *)curr); return -1; } } while ((++sigs)->signature); // Save the last one. return PyDict_SetItemString(dict, curr_name.constData(), (PyObject *)curr); }
// Note that we don't expose the new method to python. We create // LinkedListIters in the factory methods firstIter() and lastIter() static LinkedListIterObject* LinkedListIterObject_new(LinkedListObject*list, LinkedListNode* node) { LinkedListIterObject* self; self = (LinkedListIterObject*)PyType_GenericAlloc(&LinkedListIterType, 0); if(self != NULL) { self->node = node; self->list = list; node->iter_count++; } return self; }
/* * Return a new method descriptor based on an existing one and a mixin name. */ PyObject *sipMethodDescr_Copy(PyObject *orig, PyObject *mixin_name) { PyObject *descr = PyType_GenericAlloc(&sipMethodDescr_Type, 0); if (descr != NULL) { ((sipMethodDescr *)descr)->pmd = ((sipMethodDescr *)orig)->pmd; ((sipMethodDescr *)descr)->mixin_name = mixin_name; Py_INCREF(mixin_name); } return descr; }
static PyKeyMapIteratorObject * _iter(PyKeyMapObject *keymap, int mode) { PyKeyMapIteratorObject *iter = (PyKeyMapIteratorObject *)PyType_GenericAlloc(&PyKeyMapIterator_Type, 0); if(!iter) return NULL; iter->kmi_keymap = keymap; iter->kmi_mode = mode; Py_INCREF(keymap); return iter; }
/* * Return a new variable descriptor based on an existing one and a mixin name. */ PyObject *sipVariableDescr_Copy(PyObject *orig, PyObject *mixin_name) { PyObject *descr = PyType_GenericAlloc(&sipVariableDescr_Type, 0); if (descr != NULL) { ((sipVariableDescr *)descr)->vd = ((sipVariableDescr *)orig)->vd; ((sipVariableDescr *)descr)->td = ((sipVariableDescr *)orig)->td; ((sipVariableDescr *)descr)->cod = ((sipVariableDescr *)orig)->cod; ((sipVariableDescr *)descr)->mixin_name = mixin_name; Py_INCREF(mixin_name); } return descr; }
/* * Return a new method descriptor for the given getter/setter. */ PyObject *sipVariableDescr_New(sipVariableDef *vd, const sipTypeDef *td, const sipContainerDef *cod) { PyObject *descr = PyType_GenericAlloc(&sipVariableDescr_Type, 0); if (descr != NULL) { ((sipVariableDescr *)descr)->vd = vd; ((sipVariableDescr *)descr)->td = td; ((sipVariableDescr *)descr)->cod = cod; ((sipVariableDescr *)descr)->mixin_name = NULL; } return descr; }
static PyObject * BBox_alloc(PyTypeObject *type, Py_ssize_t nitems) { PlanarBBoxObject *box; assert(PyType_IsSubtype(type, &PlanarBBoxType)); if (bbox_free_list != NULL) { box = (PlanarBBoxObject *)bbox_free_list; Py_INCREF(box); bbox_free_list = box->next_free; --bbox_free_size; return (PyObject *)box; } else { return PyType_GenericAlloc(type, nitems); } }
static PyDescrObject * descr_new(PyTypeObject *descrtype, PyTypeObject *type, const char *name) { PyDescrObject *descr; descr = (PyDescrObject *)PyType_GenericAlloc(descrtype, 0); if (descr != NULL) { Py_XINCREF(type); descr->d_type = type; descr->d_name = PyString_InternFromString(name); if (descr->d_name == NULL) { Py_DECREF(descr); descr = NULL; } } return descr; }
// Create a proxy for a bound introspected method. PyObject *qpycore_pyqtMethodProxy_New(QObject *qobject, int method_index, const QByteArray &py_name) { qpycore_pyqtMethodProxy *mp; mp = (qpycore_pyqtMethodProxy *)PyType_GenericAlloc( &qpycore_pyqtMethodProxy_Type, 0); if (!mp) return 0; mp->qobject = qobject; mp->method_index = method_index; mp->py_name = new QByteArray(py_name); return (PyObject *)mp; }
// Create a bound signal. PyObject *qpycore_pyqtBoundSignal_New(PyObject *unbound_signal, PyObject *bound_pyobject, QObject *bound_qobject, int signal_index) { qpycore_pyqtBoundSignal *bs = (qpycore_pyqtBoundSignal *)PyType_GenericAlloc(&qpycore_pyqtBoundSignal_Type, 0); if (bs) { Py_INCREF(unbound_signal); bs->unbound_signal = unbound_signal; bs->bound_pyobject = bound_pyobject; bs->bound_qobject = bound_qobject; bs->bound_overload = ((qpycore_pyqtSignal *)unbound_signal)->overloads->at(signal_index); } return (PyObject *)bs; }
static PyGreenlet* green_create_main(void) { PyGreenlet* gmain; PyObject* dict = PyThreadState_GetDict(); if (dict == NULL) { if (!PyErr_Occurred()) PyErr_NoMemory(); return NULL; } /* create the main greenlet for this thread */ gmain = (PyGreenlet*) PyType_GenericAlloc(&PyGreenlet_Type, 0); if (gmain == NULL) return NULL; gmain->stack_start = (char*) 1; gmain->stack_stop = (char*) -1; gmain->run_info = dict; Py_INCREF(dict); return gmain; }
static PyObject * Affine_alloc(PyTypeObject *type, Py_ssize_t nitems) { int i; polypaths_planar_overrideAffineObject *t; assert(PyType_IsSubtype(type, &polypaths_planar_overrideAffineType)); if (affine_free_list != NULL) { t = (polypaths_planar_overrideAffineObject *)affine_free_list; Py_INCREF(t); affine_free_list = t->next_free; --affine_free_size; for (i = 0; i < 6; i++) { t->m[i] = 0.0; } return (PyObject *)t; } else { return PyType_GenericAlloc(type, nitems); } }
static PyObject * call_PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems) { return PyType_GenericAlloc(type,nitems); }