MCPcopy Create free account
hub / github.com/SamuraiT/mecab-python3 / SWIG_Python_NewPointerObj

Function SWIG_Python_NewPointerObj

src/MeCab/MeCab_wrap.cpp:2318–2368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2316/* Create a new pointer object */
2317
2318SWIGRUNTIME PyObject *
2319SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) {
2320 SwigPyClientData *clientdata;
2321 PyObject * robj;
2322 int own;
2323
2324 if (!ptr)
2325 return SWIG_Py_Void();
2326
2327 clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0;
2328 own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
2329 if (clientdata && clientdata->pytype) {
2330 SwigPyObject *newobj;
2331 if (flags & SWIG_BUILTIN_TP_INIT) {
2332 newobj = (SwigPyObject*) self;
2333 if (newobj->ptr) {
2334 PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0);
2335 while (newobj->next)
2336 newobj = (SwigPyObject *) newobj->next;
2337 newobj->next = next_self;
2338 newobj = (SwigPyObject *)next_self;
2339#ifdef SWIGPYTHON_BUILTIN
2340 newobj->dict = 0;
2341#endif
2342 }
2343 } else {
2344 newobj = PyObject_New(SwigPyObject, clientdata->pytype);
2345#ifdef SWIGPYTHON_BUILTIN
2346 newobj->dict = 0;
2347#endif
2348 }
2349 if (newobj) {
2350 newobj->ptr = ptr;
2351 newobj->ty = type;
2352 newobj->own = own;
2353 newobj->next = 0;
2354 return (PyObject*) newobj;
2355 }
2356 return SWIG_Py_Void();
2357 }
2358
2359 assert(!(flags & SWIG_BUILTIN_TP_INIT));
2360
2361 robj = SwigPyObject_New(ptr, type, own);
2362 if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
2363 PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
2364 Py_DECREF(robj);
2365 robj = inst;
2366 }
2367 return robj;
2368}
2369
2370/* Create a new packed object */
2371

Callers

nothing calls this directly

Calls 3

SWIG_Py_VoidFunction · 0.85
SwigPyObject_NewFunction · 0.85

Tested by

no test coverage detected