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

Function SWIG_Python_FixMethods

src/MeCab/MeCab_wrap.cpp:9813–9855  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9811 /* -----------------------------------------------------------------------------*/
9812
9813 SWIGINTERN void
9814 SWIG_Python_FixMethods(PyMethodDef *methods,
9815 swig_const_info *const_table,
9816 swig_type_info **types,
9817 swig_type_info **types_initial) {
9818 size_t i;
9819 for (i = 0; methods[i].ml_name; ++i) {
9820 const char *c = methods[i].ml_doc;
9821 if (!c) continue;
9822 c = strstr(c, "swig_ptr: ");
9823 if (c) {
9824 int j;
9825 swig_const_info *ci = 0;
9826 const char *name = c + 10;
9827 for (j = 0; const_table[j].type; ++j) {
9828 if (strncmp(const_table[j].name, name,
9829 strlen(const_table[j].name)) == 0) {
9830 ci = &(const_table[j]);
9831 break;
9832 }
9833 }
9834 if (ci) {
9835 void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
9836 if (ptr) {
9837 size_t shift = (ci->ptype) - types;
9838 swig_type_info *ty = types_initial[shift];
9839 size_t ldoc = (c - methods[i].ml_doc);
9840 size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
9841 char *ndoc = (char*)malloc(ldoc + lptr + 10);
9842 if (ndoc) {
9843 char *buff = ndoc;
9844 memcpy(buff, methods[i].ml_doc, ldoc);
9845 buff += ldoc;
9846 memcpy(buff, "swig_ptr: ", 10);
9847 buff += 10;
9848 SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
9849 methods[i].ml_doc = ndoc;
9850 }
9851 }
9852 }
9853 }
9854 }
9855 }
9856
9857 /* -----------------------------------------------------------------------------
9858 * Method creation and docstring support functions

Callers 1

MeCab_wrap.cppFile · 0.85

Calls 1

SWIG_PackVoidPtrFunction · 0.85

Tested by

no test coverage detected