Skip to content

Commit 0c890f0

Browse files
CFSworksrdb
authored andcommitted
interrogate: Export Python entry points with EXPORT_CLASS
Closes panda3d#505
1 parent 3be7c63 commit 0c890f0

File tree

2 files changed

+5
-48
lines changed

2 files changed

+5
-48
lines changed

dtool/src/interrogate/interfaceMakerPythonNative.cxx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,13 +1532,7 @@ write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def) {
15321532
<< " nullptr, nullptr, nullptr, nullptr\n"
15331533
<< "};\n"
15341534
<< "\n"
1535-
<< "#ifdef _WIN32\n"
1536-
<< "extern \"C\" __declspec(dllexport) PyObject *PyInit_" << def->module_name << "();\n"
1537-
<< "#elif __GNUC__ >= 4\n"
1538-
<< "extern \"C\" __attribute__((visibility(\"default\"))) PyObject *PyInit_" << def->module_name << "();\n"
1539-
<< "#else\n"
1540-
<< "extern \"C\" PyObject *PyInit_" << def->module_name << "();\n"
1541-
<< "#endif\n"
1535+
<< "extern \"C\" EXPORT_CLASS PyObject *PyInit_" << def->module_name << "();\n"
15421536
<< "\n"
15431537
<< "PyObject *PyInit_" << def->module_name << "() {\n"
15441538
<< " LibraryDef *refs[] = {&" << def->library_name << "_moddef, nullptr};\n"
@@ -1549,13 +1543,7 @@ write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def) {
15491543
<< "\n"
15501544
<< "#else // Python 2 case\n"
15511545
<< "\n"
1552-
<< "#ifdef _WIN32\n"
1553-
<< "extern \"C\" __declspec(dllexport) void init" << def->module_name << "();\n"
1554-
<< "#elif __GNUC__ >= 4\n"
1555-
<< "extern \"C\" __attribute__((visibility(\"default\"))) void init" << def->module_name << "();\n"
1556-
<< "#else\n"
1557-
<< "extern \"C\" void init" << def->module_name << "();\n"
1558-
<< "#endif\n"
1546+
<< "extern \"C\" EXPORT_CLASS void init" << def->module_name << "();\n"
15591547
<< "\n"
15601548
<< "void init" << def->module_name << "() {\n"
15611549
<< " LibraryDef *refs[] = {&" << def->library_name << "_moddef, nullptr};\n"

dtool/src/interrogate/interrogate_module.cxx

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -295,24 +295,10 @@ int write_python_table_native(std::ostream &out) {
295295

296296
out.put('\n');
297297

298-
out << "#if PY_MAJOR_VERSION >= 3 || !defined(NDEBUG)\n"
299-
<< "#ifdef _WIN32\n"
300-
<< "extern \"C\" __declspec(dllexport) PyObject *PyInit_" << library_name << "();\n"
301-
<< "#elif __GNUC__ >= 4\n"
302-
<< "extern \"C\" __attribute__((visibility(\"default\"))) PyObject *PyInit_" << library_name << "();\n"
303-
<< "#else\n"
304-
<< "extern \"C\" PyObject *PyInit_" << library_name << "();\n"
305-
<< "#endif\n"
306-
<< "#endif\n";
307-
308-
out << "#if PY_MAJOR_VERSION < 3 || !defined(NDEBUG)\n"
309-
<< "#ifdef _WIN32\n"
310-
<< "extern \"C\" __declspec(dllexport) void init" << library_name << "();\n"
311-
<< "#elif __GNUC__ >= 4\n"
312-
<< "extern \"C\" __attribute__((visibility(\"default\"))) void init" << library_name << "();\n"
298+
out << "#if PY_MAJOR_VERSION >= 3\n"
299+
<< "extern \"C\" EXPORT_CLASS PyObject *PyInit_" << library_name << "();\n"
313300
<< "#else\n"
314-
<< "extern \"C\" void init" << library_name << "();\n"
315-
<< "#endif\n"
301+
<< "extern \"C\" EXPORT_CLASS void init" << library_name << "();\n"
316302
<< "#endif\n";
317303

318304
out << "\n"
@@ -361,14 +347,6 @@ int write_python_table_native(std::ostream &out) {
361347
<< "}\n"
362348
<< "\n"
363349

364-
<< "#ifndef NDEBUG\n"
365-
<< "void init" << library_name << "() {\n"
366-
<< " PyErr_SetString(PyExc_ImportError, \"" << module_name << " was "
367-
<< "compiled for Python \" PY_VERSION \", which is incompatible "
368-
<< "with Python 2\");\n"
369-
<< "}\n"
370-
<< "#endif\n"
371-
372350
<< "#else // Python 2 case\n"
373351
<< "\n"
374352
<< "void init" << library_name << "() {\n";
@@ -402,15 +380,6 @@ int write_python_table_native(std::ostream &out) {
402380

403381
out << " }\n"
404382
<< "}\n"
405-
<< "\n"
406-
<< "#ifndef NDEBUG\n"
407-
<< "PyObject *PyInit_" << library_name << "() {\n"
408-
<< " PyErr_SetString(PyExc_ImportError, \"" << module_name << " was "
409-
<< "compiled for Python \" PY_VERSION \", which is incompatible "
410-
<< "with Python 3\");\n"
411-
<< " return nullptr;\n"
412-
<< "}\n"
413-
<< "#endif\n"
414383
<< "#endif\n"
415384
<< "\n";
416385

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy