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

Function SWIG_Python_NewShadowInstance

src/MeCab/MeCab_wrap.cpp:2228–2276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2226*/
2227
2228SWIGRUNTIME PyObject*
2229SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
2230{
2231 PyObject *inst = 0;
2232 PyObject *newraw = data->newraw;
2233 if (newraw) {
2234 inst = PyObject_Call(newraw, data->newargs, NULL);
2235 if (inst) {
2236#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
2237 PyObject **dictptr = _PyObject_GetDictPtr(inst);
2238 if (dictptr != NULL) {
2239 PyObject *dict = *dictptr;
2240 if (dict == NULL) {
2241 dict = PyDict_New();
2242 *dictptr = dict;
2243 PyDict_SetItem(dict, SWIG_This(), swig_this);
2244 }
2245 }
2246#else
2247 PyObject *key = SWIG_This();
2248 PyObject_SetAttr(inst, key, swig_this);
2249#endif
2250 }
2251 } else {
2252#if PY_VERSION_HEX >= 0x03000000
2253 PyObject *empty_args = PyTuple_New(0);
2254 if (empty_args) {
2255 PyObject *empty_kwargs = PyDict_New();
2256 if (empty_kwargs) {
2257 inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs);
2258 Py_DECREF(empty_kwargs);
2259 if (inst) {
2260 PyObject_SetAttr(inst, SWIG_This(), swig_this);
2261 Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
2262 }
2263 }
2264 Py_DECREF(empty_args);
2265 }
2266#else
2267 PyObject *dict = PyDict_New();
2268 if (dict) {
2269 PyDict_SetItem(dict, SWIG_This(), swig_this);
2270 inst = PyInstance_NewRaw(data->newargs, dict);
2271 Py_DECREF(dict);
2272 }
2273#endif
2274 }
2275 return inst;
2276}
2277
2278SWIGRUNTIME void
2279SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)

Callers 1

Calls 1

SWIG_ThisFunction · 0.85

Tested by

no test coverage detected