interrogate: Export Python entry points with EXPORT_CLASS

Closes #505
This commit is contained in:
Sam Edwards 2019-01-03 12:03:25 +01:00 committed by rdb
parent 3be7c63d42
commit 0c890f059d
2 changed files with 5 additions and 48 deletions

View File

@ -1532,13 +1532,7 @@ write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def) {
<< " nullptr, nullptr, nullptr, nullptr\n" << " nullptr, nullptr, nullptr, nullptr\n"
<< "};\n" << "};\n"
<< "\n" << "\n"
<< "#ifdef _WIN32\n" << "extern \"C\" EXPORT_CLASS PyObject *PyInit_" << def->module_name << "();\n"
<< "extern \"C\" __declspec(dllexport) PyObject *PyInit_" << def->module_name << "();\n"
<< "#elif __GNUC__ >= 4\n"
<< "extern \"C\" __attribute__((visibility(\"default\"))) PyObject *PyInit_" << def->module_name << "();\n"
<< "#else\n"
<< "extern \"C\" PyObject *PyInit_" << def->module_name << "();\n"
<< "#endif\n"
<< "\n" << "\n"
<< "PyObject *PyInit_" << def->module_name << "() {\n" << "PyObject *PyInit_" << def->module_name << "() {\n"
<< " LibraryDef *refs[] = {&" << def->library_name << "_moddef, nullptr};\n" << " LibraryDef *refs[] = {&" << def->library_name << "_moddef, nullptr};\n"
@ -1549,13 +1543,7 @@ write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def) {
<< "\n" << "\n"
<< "#else // Python 2 case\n" << "#else // Python 2 case\n"
<< "\n" << "\n"
<< "#ifdef _WIN32\n" << "extern \"C\" EXPORT_CLASS void init" << def->module_name << "();\n"
<< "extern \"C\" __declspec(dllexport) void init" << def->module_name << "();\n"
<< "#elif __GNUC__ >= 4\n"
<< "extern \"C\" __attribute__((visibility(\"default\"))) void init" << def->module_name << "();\n"
<< "#else\n"
<< "extern \"C\" void init" << def->module_name << "();\n"
<< "#endif\n"
<< "\n" << "\n"
<< "void init" << def->module_name << "() {\n" << "void init" << def->module_name << "() {\n"
<< " LibraryDef *refs[] = {&" << def->library_name << "_moddef, nullptr};\n" << " LibraryDef *refs[] = {&" << def->library_name << "_moddef, nullptr};\n"

View File

@ -295,24 +295,10 @@ int write_python_table_native(std::ostream &out) {
out.put('\n'); out.put('\n');
out << "#if PY_MAJOR_VERSION >= 3 || !defined(NDEBUG)\n" out << "#if PY_MAJOR_VERSION >= 3\n"
<< "#ifdef _WIN32\n" << "extern \"C\" EXPORT_CLASS PyObject *PyInit_" << library_name << "();\n"
<< "extern \"C\" __declspec(dllexport) PyObject *PyInit_" << library_name << "();\n"
<< "#elif __GNUC__ >= 4\n"
<< "extern \"C\" __attribute__((visibility(\"default\"))) PyObject *PyInit_" << library_name << "();\n"
<< "#else\n" << "#else\n"
<< "extern \"C\" PyObject *PyInit_" << library_name << "();\n" << "extern \"C\" EXPORT_CLASS void init" << library_name << "();\n"
<< "#endif\n"
<< "#endif\n";
out << "#if PY_MAJOR_VERSION < 3 || !defined(NDEBUG)\n"
<< "#ifdef _WIN32\n"
<< "extern \"C\" __declspec(dllexport) void init" << library_name << "();\n"
<< "#elif __GNUC__ >= 4\n"
<< "extern \"C\" __attribute__((visibility(\"default\"))) void init" << library_name << "();\n"
<< "#else\n"
<< "extern \"C\" void init" << library_name << "();\n"
<< "#endif\n"
<< "#endif\n"; << "#endif\n";
out << "\n" out << "\n"
@ -361,14 +347,6 @@ int write_python_table_native(std::ostream &out) {
<< "}\n" << "}\n"
<< "\n" << "\n"
<< "#ifndef NDEBUG\n"
<< "void init" << library_name << "() {\n"
<< " PyErr_SetString(PyExc_ImportError, \"" << module_name << " was "
<< "compiled for Python \" PY_VERSION \", which is incompatible "
<< "with Python 2\");\n"
<< "}\n"
<< "#endif\n"
<< "#else // Python 2 case\n" << "#else // Python 2 case\n"
<< "\n" << "\n"
<< "void init" << library_name << "() {\n"; << "void init" << library_name << "() {\n";
@ -402,15 +380,6 @@ int write_python_table_native(std::ostream &out) {
out << " }\n" out << " }\n"
<< "}\n" << "}\n"
<< "\n"
<< "#ifndef NDEBUG\n"
<< "PyObject *PyInit_" << library_name << "() {\n"
<< " PyErr_SetString(PyExc_ImportError, \"" << module_name << " was "
<< "compiled for Python \" PY_VERSION \", which is incompatible "
<< "with Python 3\");\n"
<< " return nullptr;\n"
<< "}\n"
<< "#endif\n"
<< "#endif\n" << "#endif\n"
<< "\n"; << "\n";