Skip to content

Commit

Permalink
Make ext module typespecs to use PyMODINIT_FUNC that is essential for…
Browse files Browse the repository at this point in the history
… mingw32 and c++ code combination to work correctly.
  • Loading branch information
pearu committed Apr 24, 2006
1 parent 926f18d commit c553166
Show file tree
Hide file tree
Showing 31 changed files with 49 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Lib/integrate/_odepackmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static struct PyMethodDef odepack_module_methods[] = {
{"odeint", (PyCFunction) odepack_odeint, METH_VARARGS|METH_KEYWORDS, doc_odeint},
{NULL, NULL, 0, NULL}
};
DL_EXPORT(void) init_odepack() {
PyMODINIT_FUNC init_odepack(void) {
PyObject *m, *d, *s;
m = Py_InitModule("_odepack", odepack_module_methods);
import_array();
Expand Down
2 changes: 1 addition & 1 deletion Lib/integrate/_quadpackmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static struct PyMethodDef quadpack_module_methods[] = {
{"_qawce", quadpack_qawce, METH_VARARGS, doc_qawce},
{NULL, NULL, 0, NULL}
};
DL_EXPORT(void) init_quadpack() {
PyMODINIT_FUNC init_quadpack(void) {
PyObject *m, *d, *s;
m = Py_InitModule("_quadpack", quadpack_module_methods);
import_array();
Expand Down
2 changes: 1 addition & 1 deletion Lib/interpolate/_fitpackmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static struct PyMethodDef fitpack_module_methods[] = {
{"_bispev", fitpack_bispev, METH_VARARGS, doc_bispev},
{NULL, NULL, 0, NULL}
};
DL_EXPORT(void) init_fitpack(void) {
PyMODINIT_FUNC init_fitpack(void) {
PyObject *m, *d, *s;
m = Py_InitModule("_fitpack", fitpack_module_methods);
import_array();
Expand Down
2 changes: 1 addition & 1 deletion Lib/io/numpyiomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ static struct PyMethodDef numpyio_methods[] = {
{NULL, NULL}
};

DL_EXPORT(void) initnumpyio(void)
PyMODINIT_FUNC initnumpyio(void)
{
PyObject *m, *d;

Expand Down
2 changes: 1 addition & 1 deletion Lib/lib/blas/atlas_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extern "C" {
#endif
#include "Python.h"
static PyMethodDef module_methods[] = { {NULL,NULL} };
DL_EXPORT(void) initatlas_version(void) {
PyMODINIT_FUNC initatlas_version(void) {
PyObject *m = NULL;
#if defined(NO_ATLAS_INFO)
printf("NO ATLAS INFO AVAILABLE\n");
Expand Down
2 changes: 1 addition & 1 deletion Lib/lib/lapack/atlas_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extern "C" {
#endif
#include "Python.h"
static PyMethodDef module_methods[] = { {NULL,NULL} };
DL_EXPORT(void) initatlas_version(void) {
PyMODINIT_FUNC initatlas_version(void) {
PyObject *m = NULL;
#if defined(NO_ATLAS_INFO)
printf("NO ATLAS INFO AVAILABLE\n");
Expand Down
2 changes: 1 addition & 1 deletion Lib/linalg/atlas_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extern "C" {
#endif
#include "Python.h"
static PyMethodDef module_methods[] = { {NULL,NULL} };
DL_EXPORT(void) initatlas_version(void) {
PyMODINIT_FUNC initatlas_version(void) {
PyObject *m = NULL;
#if defined(NO_ATLAS_INFO)
printf("NO ATLAS INFO AVAILABLE\n");
Expand Down
2 changes: 1 addition & 1 deletion Lib/linsolve/_csuperlumodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ static PyMethodDef cSuperLU_Methods[] = {
};


DL_EXPORT(void)
PyMODINIT_FUNC
init_csuperlu(void)
{
Py_InitModule("_csuperlu", cSuperLU_Methods);
Expand Down
2 changes: 1 addition & 1 deletion Lib/linsolve/_dsuperlumodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static PyMethodDef dSuperLU_Methods[] = {
};


DL_EXPORT(void)
PyMODINIT_FUNC
init_dsuperlu(void)
{
PyObject *m, *d;
Expand Down
2 changes: 1 addition & 1 deletion Lib/linsolve/_ssuperlumodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ static PyMethodDef sSuperLU_Methods[] = {
{NULL, NULL}
};

DL_EXPORT(void)
PyMODINIT_FUNC
init_ssuperlu(void)
{
Py_InitModule("_ssuperlu", sSuperLU_Methods);
Expand Down
2 changes: 1 addition & 1 deletion Lib/linsolve/_zsuperlumodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ static PyMethodDef zSuperLU_Methods[] = {


/* This should be imported first */
DL_EXPORT(void)
PyMODINIT_FUNC
init_zsuperlu(void)
{

Expand Down
2 changes: 1 addition & 1 deletion Lib/ndimage/src/nd_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ static PyMethodDef methods[] = {
{NULL, NULL, 0, NULL}
};

DL_EXPORT(void) init_nd_image(void)
PyMODINIT_FUNC init_nd_image(void)
{
Py_InitModule("_nd_image", methods);
import_libnumarray();
Expand Down
2 changes: 1 addition & 1 deletion Lib/optimize/_minpackmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static struct PyMethodDef minpack_module_methods[] = {
{"_chkder", minpack_chkder, METH_VARARGS, doc_chkder},
{NULL, NULL, 0, NULL}
};
DL_EXPORT(void) init_minpack(void) {
PyMODINIT_FUNC init_minpack(void) {
PyObject *m, *d, *s;
m = Py_InitModule("_minpack", minpack_module_methods);
import_array();
Expand Down
2 changes: 1 addition & 1 deletion Lib/optimize/tnc/moduleTNC.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ static PyMethodDef moduleTNC_methods[] =
{NULL, NULL}
};

DL_EXPORT(void) initmoduleTNC(void)
PyMODINIT_FUNC initmoduleTNC(void)
{
(void) Py_InitModule("moduleTNC", moduleTNC_methods);
}
2 changes: 1 addition & 1 deletion Lib/optimize/zeros.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Zerosmethods[] = {
{NULL, NULL}
};

DL_EXPORT(void) init_zeros(void)
PyMODINIT_FUNC init_zeros(void)
{
double tol;

Expand Down
2 changes: 1 addition & 1 deletion Lib/sandbox/delaunay/_delaunay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ static PyMethodDef delaunay_methods[] = {
};


DL_EXPORT(void) init_delaunay()
PyMODINIT_FUNC init_delaunay(void)
{
PyObject* m;
m = Py_InitModule3("_delaunay", delaunay_methods,
Expand Down
2 changes: 1 addition & 1 deletion Lib/sandbox/netcdf/_netcdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2064,7 +2064,7 @@ static PyMethodDef netcdf_methods[] = {

/* Module initialization */

DL_EXPORT(void)
PyMODINIT_FUNC
init_netcdf(void)
{
PyObject *m, *d;
Expand Down
2 changes: 1 addition & 1 deletion Lib/sandbox/netcdf/demomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static PyMethodDef demo_methods[] = {

/* Module initialization */

DL_EXPORT(void) initdemo(void)
PyMODINIT_FUNC initdemo(void)
{
PyObject *module;
PyObject *netcdf, *netcdf_dict;
Expand Down
2 changes: 1 addition & 1 deletion Lib/sandbox/odr/__odrpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ static PyMethodDef methods[] = {
{NULL, NULL},
};

DL_EXPORT(void) init__odrpack(void)
PyMODINIT_FUNC init__odrpack(void)
{
PyObject *m, *d;

Expand Down
2 changes: 1 addition & 1 deletion Lib/sandbox/pysparse/src/itsolversmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ The result is tuple with 3 elements:\n\
\n\
";

DL_EXPORT(void)
PyMODINIT_FUNC
inititsolvers(void)
{
PyObject *m;
Expand Down
2 changes: 1 addition & 1 deletion Lib/sandbox/pysparse/src/jdsymmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ static PyMethodDef jdsym_methods[] = {
static char module_doc[] = "This module ...\n\
";

DL_EXPORT(void)
PyMODINIT_FUNC
initjdsym(void) {
PyObject *m;

Expand Down
2 changes: 1 addition & 1 deletion Lib/sandbox/pysparse/src/preconmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ static PyMethodDef precon_methods[] = {
};


DL_EXPORT(void)
PyMODINIT_FUNC
initprecon(void)
{
PyObject *m, *d;
Expand Down
2 changes: 1 addition & 1 deletion Lib/sandbox/pysparse/src/spmatrixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ static PyMethodDef spmatrix_methods[] = {
{NULL, NULL} /* sentinel */
};

DL_EXPORT(void)
PyMODINIT_FUNC
initspmatrix(void)
{
PyObject *m, *d;
Expand Down
2 changes: 1 addition & 1 deletion Lib/sandbox/pysparse/src/superlumodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ static PyMethodDef precon_methods[] = {
};


DL_EXPORT(void)
PyMODINIT_FUNC
initsuperlu(void)
{
PyObject *m, *d;
Expand Down
2 changes: 1 addition & 1 deletion Lib/sandbox/pysparse/src/umfpackmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ static PyMethodDef precon_methods[] = {
};


DL_EXPORT(void)
PyMODINIT_FUNC
initumfpack(void)
{
PyObject *m, *d;
Expand Down
2 changes: 1 addition & 1 deletion Lib/sandbox/xplt/pygist/gistCmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -9349,7 +9349,7 @@ static struct PyMethodDef gist_methods[] =
/* Initialize the module. This should be the only symbol with
external linkage. */

DL_EXPORT(void) initgistC (void)
PyMODINIT_FUNC initgistC (void)
{
PyObject *m, *d, *sys_path;
int i, n;
Expand Down
2 changes: 1 addition & 1 deletion Lib/sandbox/xplt/pygist/gistfuncsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ static char arrayfns_module_documentation[] =
""
;

DL_EXPORT(void)
PyMODINIT_FUNC
initgistfuncs(void)
{
PyObject *m, *d;
Expand Down
2 changes: 1 addition & 1 deletion Lib/signal/sigtoolsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,7 @@ static struct PyMethodDef toolbox_module_methods[] = {

/* Initialization function for the module (*must* be called initsigtools) */

DL_EXPORT(void) initsigtools(void) {
PyMODINIT_FUNC initsigtools(void) {
PyObject *m, *d;

/* Create the module and add the functions */
Expand Down
2 changes: 1 addition & 1 deletion Lib/signal/splinemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ static struct PyMethodDef toolbox_module_methods[] = {

/* Initialization function for the module (*must* be called initXXXXX) */

DL_EXPORT(void) initspline(void) {
PyMODINIT_FUNC initspline(void) {
PyObject *m, *d, *s;

/* Create the module and add the functions */
Expand Down
2 changes: 1 addition & 1 deletion Lib/special/_cephesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ static struct PyMethodDef methods[] = {
};


DL_EXPORT(void) init_cephes(void) {
PyMODINIT_FUNC init_cephes(void) {
PyObject *m, *d, *s;

/* Create the module and add the functions */
Expand Down
26 changes: 19 additions & 7 deletions Lib/weave/ext_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,24 @@ def __init__(self,name,compiler=''):
def add_function(self,func):
self.functions.append(func)
def module_code(self):
code = '\n'.join([self.warning_code(),
self.header_code(),
self.support_code(),
self.function_code(),
self.python_function_definition_code(),
self.module_init_code()])
code = '\n'.join([
"""\
#ifdef __CPLUSPLUS__
extern "C" {
#endif
""",
self.warning_code(),
self.header_code(),
self.support_code(),
self.function_code(),
self.python_function_definition_code(),
self.module_init_code(),
"""\
#ifdef __CPLUSCPLUS__
}
#endif
"""
])
return code

def arg_specs(self):
Expand Down Expand Up @@ -272,7 +284,7 @@ def python_function_definition_code(self):
def module_init_code(self):
init_code_list = self.build_information().module_init_code()
init_code = indent(''.join(init_code_list),4)
code = 'DL_EXPORT(void) init%s(void)\n' \
code = 'PyMODINIT_FUNC init%s(void)\n' \
'{\n' \
'%s' \
' (void) Py_InitModule("%s", compiled_methods);\n' \
Expand Down

0 comments on commit c553166

Please sign in to comment.