+ simplify porting of DraftUtils module to Python3

This commit is contained in:
wmayer
2016-01-20 11:57:59 +01:00
parent d2f40c0251
commit 36d82133f1
2 changed files with 71 additions and 57 deletions

View File

@@ -29,25 +29,21 @@
#include <Base/Console.h>
#include <Base/Interpreter.h>
extern struct PyMethodDef DraftUtils_methods[];
PyDoc_STRVAR(module_DraftUtils_doc, "The DraftUtils module contains utility functions for the Draft module.");
namespace DraftUtils {
extern PyObject* initModule();
}
/* Python entry */
extern "C" {
void DraftUtilsExport initDraftUtils()
{
// load dependent module
try {
Base::Interpreter().loadModule("Part");
}
catch(const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
return;
}
Py_InitModule3("DraftUtils", DraftUtils_methods, module_DraftUtils_doc); /* mod name, table ptr */
Base::Console().Log("Loading DraftUtils module... done\n");
PyMODINIT_FUNC initDraftUtils()
{
// load dependent module
try {
Base::Interpreter().loadModule("Part");
}
} // extern "C"
catch(const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
return;
}
(void)DraftUtils::initModule();
Base::Console().Log("Loading DraftUtils module... done\n");
}