MCPcopy Create free account
hub / github.com/cvxpy/cvxpy / SWIG_Python_NewPointerObj

Function SWIG_Python_NewPointerObj

cvxpy/cvxcore/python/cvxcore_wrap.cxx:2802–2859  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2800/* Create a new pointer object */
2801
2802SWIGRUNTIME PyObject *
2803SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) {
2804 SwigPyClientData *clientdata;
2805 PyObject * robj;
2806 int own;
2807
2808 if (!ptr)
2809 return SWIG_Py_Void();
2810
2811 clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0;
2812 own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
2813 if (clientdata && clientdata->pytype) {
2814 SwigPyObject *newobj;
2815 if (flags & SWIG_BUILTIN_TP_INIT) {
2816 newobj = (SwigPyObject*) self;
2817 if (newobj->ptr) {
2818#ifndef Py_LIMITED_API
2819 allocfunc alloc = clientdata->pytype->tp_alloc;
2820#else
2821 allocfunc alloc = (allocfunc)PyType_GetSlot(clientdata->pytype, Py_tp_alloc);
2822#endif
2823 PyObject *next_self = alloc(clientdata->pytype, 0);
2824 while (newobj->next)
2825 newobj = (SwigPyObject *) newobj->next;
2826 newobj->next = next_self;
2827 newobj = (SwigPyObject *)next_self;
2828#ifdef SWIGPYTHON_BUILTIN
2829 newobj->dict = 0;
2830#endif
2831 }
2832 } else {
2833 newobj = PyObject_New(SwigPyObject, clientdata->pytype);
2834#ifdef SWIGPYTHON_BUILTIN
2835 if (newobj) {
2836 newobj->dict = 0;
2837 }
2838#endif
2839 }
2840 if (newobj) {
2841 newobj->ptr = ptr;
2842 newobj->ty = type;
2843 newobj->own = own;
2844 newobj->next = 0;
2845 return (PyObject*) newobj;
2846 }
2847 return SWIG_Py_Void();
2848 }
2849
2850 assert(!(flags & SWIG_BUILTIN_TP_INIT));
2851
2852 robj = SwigPyObject_New(ptr, type, own);
2853 if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
2854 PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
2855 Py_DECREF(robj);
2856 robj = inst;
2857 }
2858 return robj;
2859}

Callers

nothing calls this directly

Calls 3

SWIG_Py_VoidFunction · 0.85
SwigPyObject_NewFunction · 0.85

Tested by

no test coverage detected