Skip to content

Commit

Permalink
+ simplify porting of Start module to Python3
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jan 17, 2016
1 parent a467612 commit d78d747
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 83 deletions.
24 changes: 16 additions & 8 deletions src/Mod/Start/App/AppStart.cpp
Expand Up @@ -28,21 +28,29 @@

#include <Base/Console.h>
#include <Base/Interpreter.h>
#include <CXX/Extensions.hxx>
#include <CXX/Objects.hxx>

#include "StartConfiguration.h"

extern struct PyMethodDef Start_methods[];
namespace Start {
class Module : public Py::ExtensionModule<Module>
{
public:
Module() : Py::ExtensionModule<Module>("Start")
{
initialize("This module is the Start module."); // register with Python
}

PyDoc_STRVAR(module_Start_doc,
"This module is the Start module.");
virtual ~Module() {}

private:
};
} // namespace Start

/* Python entry */
extern "C" {
void AppStartExport initStart()
PyMODINIT_FUNC initStart()
{
Py_InitModule3("Start", Start_methods, module_Start_doc); /* mod name, table ptr */
new Start::Module();
Base::Console().Log("Loading Start module... done\n");
}

} // extern "C"
33 changes: 0 additions & 33 deletions src/Mod/Start/App/AppStartPy.cpp

This file was deleted.

1 change: 0 additions & 1 deletion src/Mod/Start/App/CMakeLists.txt
Expand Up @@ -12,7 +12,6 @@ set(Start_LIBS

SET(Start_SRCS
AppStart.cpp
AppStartPy.cpp
PreCompiled.cpp
PreCompiled.h
StartConfiguration.h
Expand Down
26 changes: 19 additions & 7 deletions src/Mod/Start/Gui/AppStartGui.cpp
Expand Up @@ -26,6 +26,9 @@
# include <Python.h>
#endif

#include <CXX/Extensions.hxx>
#include <CXX/Objects.hxx>

#include <Base/Console.h>
#include <Base/Interpreter.h>
#include <Gui/Application.h>
Expand All @@ -46,13 +49,24 @@ void loadStartResource()
Gui::Translator::instance()->refresh();
}

/* registration table */
extern struct PyMethodDef StartGui_Import_methods[];
namespace StartGui {
class Module : public Py::ExtensionModule<Module>
{
public:
Module() : Py::ExtensionModule<Module>("StartGui")
{
initialize("This module is the StartGui module."); // register with Python
}

virtual ~Module() {}

private:
};
} // namespace StartGui


/* Python entry */
extern "C" {
void StartGuiExport initStartGui()
PyMODINIT_FUNC initStartGui()
{
if (!Gui::Application::Instance) {
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
Expand Down Expand Up @@ -81,7 +95,7 @@ void StartGuiExport initStartGui()
PyErr_Print();
}

(void) Py_InitModule("StartGui", StartGui_Import_methods); /* mod name, table ptr */
new StartGui::Module();
Base::Console().Log("Loading GUI of Start module... done\n");

// instantiating the commands
Expand All @@ -91,5 +105,3 @@ void StartGuiExport initStartGui()
// add resources and reloads the translators
loadStartResource();
}

} // extern "C" {
33 changes: 0 additions & 33 deletions src/Mod/Start/Gui/AppStartGuiPy.cpp

This file was deleted.

1 change: 0 additions & 1 deletion src/Mod/Start/Gui/CMakeLists.txt
Expand Up @@ -18,7 +18,6 @@ qt4_add_resources(Start_QRC_SRCS Resources/Start.qrc)
SET(StartGui_SRCS
${Start_QRC_SRCS}
AppStartGui.cpp
AppStartGuiPy.cpp
Command.cpp
PreCompiled.cpp
PreCompiled.h
Expand Down

0 comments on commit d78d747

Please sign in to comment.