Re-organise some generate Python code for method creation and docstring support
Fix ‘PyMethodDef* SWIG_PythonGetProxyDoc(const char*)’ declared ‘static’ but never defined [-Wunused-function] Closes #1448
This commit is contained in:
parent
a0720885bd
commit
43438b66ab
4 changed files with 64 additions and 55 deletions
|
|
@ -24,44 +24,6 @@ typedef struct swig_const_info {
|
||||||
swig_type_info **ptype;
|
swig_type_info **ptype;
|
||||||
} swig_const_info;
|
} swig_const_info;
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* Function to find the method definition with the correct docstring for the
|
|
||||||
* proxy module as opposed to the low-level API
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
SWIGRUNTIME PyMethodDef *SWIG_PythonGetProxyDoc(const char *name);
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* Wrapper of PyInstanceMethod_New() used in Python 3
|
|
||||||
* It is exported to the generated module, used for -fastproxy
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
SWIGRUNTIME PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) {
|
|
||||||
if (PyCFunction_Check(func)) {
|
|
||||||
PyCFunctionObject *funcobj = (PyCFunctionObject *)func;
|
|
||||||
PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name);
|
|
||||||
if (ml)
|
|
||||||
func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module);
|
|
||||||
}
|
|
||||||
#if PY_VERSION_HEX >= 0x03000000
|
|
||||||
return PyInstanceMethod_New(func);
|
|
||||||
#else
|
|
||||||
return PyMethod_New(func, NULL, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* Wrapper of PyStaticMethod_New()
|
|
||||||
* It is exported to the generated module, used for -fastproxy
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
SWIGRUNTIME PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) {
|
|
||||||
if (PyCFunction_Check(func)) {
|
|
||||||
PyCFunctionObject *funcobj = (PyCFunctionObject *)func;
|
|
||||||
PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name);
|
|
||||||
if (ml)
|
|
||||||
func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module);
|
|
||||||
}
|
|
||||||
return PyStaticMethod_New(func);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -298,6 +298,64 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Method creation and docstring support functions
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Function to find the method definition with the correct docstring for the
|
||||||
|
* proxy module as opposed to the low-level API
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name) {
|
||||||
|
/* Find the function in the modified method table */
|
||||||
|
size_t offset = 0;
|
||||||
|
int found = 0;
|
||||||
|
while (SwigMethods_proxydocs[offset].ml_meth != NULL) {
|
||||||
|
if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) {
|
||||||
|
found = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
offset++;
|
||||||
|
}
|
||||||
|
/* Use the copy with the modified docstring if available */
|
||||||
|
return found ? &SwigMethods_proxydocs[offset] : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Wrapper of PyInstanceMethod_New() used in Python 3
|
||||||
|
* It is exported to the generated module, used for -fastproxy
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) {
|
||||||
|
if (PyCFunction_Check(func)) {
|
||||||
|
PyCFunctionObject *funcobj = (PyCFunctionObject *)func;
|
||||||
|
PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name);
|
||||||
|
if (ml)
|
||||||
|
func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module);
|
||||||
|
}
|
||||||
|
#if PY_VERSION_HEX >= 0x03000000
|
||||||
|
return PyInstanceMethod_New(func);
|
||||||
|
#else
|
||||||
|
return PyMethod_New(func, NULL, NULL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Wrapper of PyStaticMethod_New()
|
||||||
|
* It is exported to the generated module, used for -fastproxy
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) {
|
||||||
|
if (PyCFunction_Check(func)) {
|
||||||
|
PyCFunctionObject *funcobj = (PyCFunctionObject *)func;
|
||||||
|
PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name);
|
||||||
|
if (ml)
|
||||||
|
func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module);
|
||||||
|
}
|
||||||
|
return PyStaticMethod_New(func);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -213,6 +213,12 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Method creation and docstring support functions */
|
||||||
|
|
||||||
|
SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name);
|
||||||
|
SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func);
|
||||||
|
SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func);
|
||||||
|
|
||||||
/* The python void return value */
|
/* The python void return value */
|
||||||
|
|
||||||
SWIGRUNTIMEINLINE PyObject *
|
SWIGRUNTIMEINLINE PyObject *
|
||||||
|
|
|
||||||
|
|
@ -834,23 +834,6 @@ public:
|
||||||
Append(methods_proxydocs, "};\n");
|
Append(methods_proxydocs, "};\n");
|
||||||
Printf(f_wrappers, "%s\n", methods_proxydocs);
|
Printf(f_wrappers, "%s\n", methods_proxydocs);
|
||||||
|
|
||||||
/* Need to define the function to find the proxy documentation after the proxy docs themselves */
|
|
||||||
Printv(f_wrappers, "SWIGRUNTIME PyMethodDef *SWIG_PythonGetProxyDoc(const char *name)\n",
|
|
||||||
"{\n",
|
|
||||||
" /* Find the function in the modified method table */\n",
|
|
||||||
" size_t offset = 0;\n",
|
|
||||||
" int found = 0;\n",
|
|
||||||
" while (SwigMethods_proxydocs[offset].ml_meth != NULL) {\n",
|
|
||||||
" if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) {\n",
|
|
||||||
" found = 1;\n",
|
|
||||||
" break;\n",
|
|
||||||
" }\n",
|
|
||||||
" offset++;\n",
|
|
||||||
" }\n",
|
|
||||||
" /* Use the copy with the modified docstring if available */\n",
|
|
||||||
" return found ? &SwigMethods_proxydocs[offset] : NULL;\n",
|
|
||||||
"}\n", NIL);
|
|
||||||
|
|
||||||
if (builtin) {
|
if (builtin) {
|
||||||
Dump(f_builtins, f_wrappers);
|
Dump(f_builtins, f_wrappers);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue