Skip to content

Commit

Permalink
+ simplify porting of Inspection module to Python3
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jan 20, 2016
1 parent b5bf7d6 commit a07b9cd
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 95 deletions.
35 changes: 25 additions & 10 deletions src/Mod/Inspection/App/AppInspection.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
Expand All @@ -26,30 +26,45 @@
# include <Python.h>
#endif

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

#include <Base/Console.h>
#include "InspectionFeature.h"


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

virtual ~Module() {}

private:
};

PyDoc_STRVAR(module_Inspection_doc,
"This module is the Inspection module.");
PyObject* initModule()
{
return (new Module)->module().ptr();
}

} // namespace Inspection


/* Python entry */
extern "C" {
void InspectionExport initInspection() {
PyMODINIT_FUNC initInspection() {

// ADD YOUR CODE HERE
//
//
(void) Py_InitModule3("Inspection", Inspection_methods, module_Inspection_doc); /* mod name, table ptr */
(void)Inspection::initModule();
Base::Console().Log("Loading Inspection module... done\n");

Inspection::PropertyDistanceList ::init();
Inspection::Feature ::init();
Inspection::Group ::init();
}

} // extern "C"
38 changes: 0 additions & 38 deletions src/Mod/Inspection/App/AppInspectionPy.cpp

This file was deleted.

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

SET(Inspection_SRCS
AppInspection.cpp
AppInspectionPy.cpp
InspectionFeature.cpp
InspectionFeature.h
PreCompiled.cpp
Expand Down
35 changes: 25 additions & 10 deletions src/Mod/Inspection/Gui/AppInspectionGui.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
Expand All @@ -26,6 +26,9 @@
# include <Python.h>
#endif

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

#include <Base/Console.h>
#include <Gui/Application.h>

Expand All @@ -36,16 +39,30 @@
void CreateInspectionCommands(void);


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

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

private:
};

PyObject* initModule()
{
return (new Module)->module().ptr();
}

} // namespace InspectionGui


/* Python entry */
extern "C" {
void InspectionGuiExport initInspectionGui()
PyMODINIT_FUNC initInspectionGui()
{
if (!Gui::Application::Instance) {
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
Expand All @@ -62,8 +79,6 @@ void InspectionGuiExport initInspectionGui()
//
//

(void) Py_InitModule3("InspectionGui", InspectionGui_methods, module_InspectionGui_doc); /* mod name, table ptr */
(void)InspectionGui::initModule();
Base::Console().Log("Loading GUI of Inspection module... done\n");
}

} // extern "C"
35 changes: 0 additions & 35 deletions src/Mod/Inspection/Gui/AppInspectionGuiPy.cpp

This file was deleted.

1 change: 0 additions & 1 deletion src/Mod/Inspection/Gui/CMakeLists.txt
Expand Up @@ -39,7 +39,6 @@ SET(InspectionGui_SRCS
${Inspection_QRC_SRCS}
${Dialogs_SRCS}
AppInspectionGui.cpp
AppInspectionGuiPy.cpp
Command.cpp
PreCompiled.cpp
PreCompiled.h
Expand Down

0 comments on commit a07b9cd

Please sign in to comment.