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

Function SWIG_Python_ConvertFunctionPtr

src/MeCab/MeCab_wrap.cpp:2176–2201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2174/* Convert a function ptr value */
2175
2176SWIGRUNTIME int
2177SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
2178 if (!PyCFunction_Check(obj)) {
2179 return SWIG_ConvertPtr(obj, ptr, ty, 0);
2180 } else {
2181 void *vptr = 0;
2182 swig_cast_info *tc;
2183
2184 /* here we get the method pointer for callbacks */
2185 const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
2186 const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
2187 if (desc)
2188 desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
2189 if (!desc)
2190 return SWIG_ERROR;
2191 tc = SWIG_TypeCheck(desc,ty);
2192 if (tc) {
2193 int newmemory = 0;
2194 *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
2195 assert(!newmemory); /* newmemory handling not yet implemented */
2196 } else {
2197 return SWIG_ERROR;
2198 }
2199 return SWIG_OK;
2200 }
2201}
2202
2203/* Convert a packed pointer value */
2204

Callers

nothing calls this directly

Calls 2

SWIG_UnpackVoidPtrFunction · 0.85
SWIG_TypeCastFunction · 0.85

Tested by

no test coverage detected