diff --git a/src/Mod/Surface/App/AppSurface.cpp b/src/Mod/Surface/App/AppSurface.cpp
index f5dff3e7d4..526c049bc6 100644
--- a/src/Mod/Surface/App/AppSurface.cpp
+++ b/src/Mod/Surface/App/AppSurface.cpp
@@ -38,17 +38,31 @@
#include
-/* registration table */
-extern struct PyMethodDef Surface_methods[];
+namespace Surface {
+class Module : public Py::ExtensionModule
+{
+public:
+ Module() : Py::ExtensionModule("Surface")
+ {
+ initialize("This module is the Surface module."); // register with Python
+ }
-PyDoc_STRVAR(module_Surface_doc,
-"This module is the Surface module.");
+ virtual ~Module() {}
+
+private:
+};
+
+PyObject* initModule()
+{
+ return (new Module)->module().ptr();
+}
+
+} // namespace Surface
/* Python entry */
-extern "C" {
-void SurfaceExport initSurface() {
-
+PyMODINIT_FUNC initSurface()
+{
try {
Base::Interpreter().runString("import Part");
}
@@ -60,7 +74,7 @@ void SurfaceExport initSurface() {
// ADD YOUR CODE HERE
//
//
- (void) Py_InitModule3("Surface", Surface_methods, module_Surface_doc); /* mod name, table ptr */
+ (void) Surface::initModule();
Base::Console().Log("Loading Surface module... done\n");
// Add types to module
@@ -71,5 +85,3 @@ void SurfaceExport initSurface() {
Surface::BezSurf ::init();
Surface::BSplineSurf ::init();
}
-
-} // extern "C"
diff --git a/src/Mod/Surface/App/AppSurfacePy.cpp b/src/Mod/Surface/App/AppSurfacePy.cpp
deleted file mode 100644
index d62cd5f63d..0000000000
--- a/src/Mod/Surface/App/AppSurfacePy.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2014 Nathan Miller Nathan.A.Mill[at]gmail.com *
- * *
- * This file is part of the FreeCAD CAx development system. *
- * *
- * This library is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Library General Public *
- * License as published by the Free Software Foundation; either *
- * version 2 of the License, or (at your option) any later version. *
- * *
- * This library is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU Library General Public License for more details. *
- * *
- * You should have received a copy of the GNU Library General Public *
- * License along with this library; see the file COPYING.LIB. If not, *
- * write to the Free Software Foundation, Inc., 59 Temple Place, *
- * Suite 330, Boston, MA 02111-1307, USA *
- * *
- ***************************************************************************/
-
-
-#include "PreCompiled.h"
-#ifndef _PreComp_
-#endif
-
-#include
-
-#include
-#include
-#include
-
-
-/* registration table */
-struct PyMethodDef Surface_methods[] = {
- {NULL, NULL} /* end of table marker */
-};
diff --git a/src/Mod/Surface/App/CMakeLists.txt b/src/Mod/Surface/App/CMakeLists.txt
index 3595c5e661..622bad5ce9 100644
--- a/src/Mod/Surface/App/CMakeLists.txt
+++ b/src/Mod/Surface/App/CMakeLists.txt
@@ -21,7 +21,6 @@ set(Surface_LIBS
SET(Surface_SRCS
../FillType.h
AppSurface.cpp
- AppSurfacePy.cpp
PreCompiled.cpp
PreCompiled.h
FeatureBSurf.h
diff --git a/src/Mod/Surface/Gui/AppSurfaceGui.cpp b/src/Mod/Surface/Gui/AppSurfaceGui.cpp
index 2d9ce6b45f..f499b7b1a8 100644
--- a/src/Mod/Surface/Gui/AppSurfaceGui.cpp
+++ b/src/Mod/Surface/Gui/AppSurfaceGui.cpp
@@ -39,23 +39,36 @@
void CreateSurfaceCommands(void);
-/* registration table */
-extern struct PyMethodDef SurfaceGui_methods[];
+namespace SurfaceGui {
+class Module : public Py::ExtensionModule
+{
+public:
+ Module() : Py::ExtensionModule("SurfaceGui")
+ {
+ initialize("This module is the SurfaceGui module."); // register with Python
+ }
-PyDoc_STRVAR(module_SurfaceGui_doc,
-"This module is the SurfaceGui module.");
+ virtual ~Module() {}
+private:
+};
+
+PyObject* initModule()
+{
+ return (new Module)->module().ptr();
+}
+
+} // namespace SurfaceGui
/* Python entry */
-extern "C" {
-void SurfaceGuiExport initSurfaceGui()
+PyMODINIT_FUNC initSurfaceGui()
{
if (!Gui::Application::Instance) {
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
return;
}
-// Base::Interpreter().runString("import SurfaceGui"); infinite Python recursion comes
+ Base::Interpreter().runString("import Surface");
Base::Interpreter().runString("import PartGui");
// instanciating the commands
@@ -66,8 +79,6 @@ void SurfaceGuiExport initSurfaceGui()
// SurfaceGui::ViewProviderCut::init();
- (void) Py_InitModule3("SurfaceGui", SurfaceGui_methods, module_SurfaceGui_doc); /* mod name, table ptr */
+ (void) SurfaceGui::initModule();
Base::Console().Log("Loading GUI of Surface module... done\n");
}
-
-} // extern "C"
diff --git a/src/Mod/Surface/Gui/AppSurfaceGuiPy.cpp b/src/Mod/Surface/Gui/AppSurfaceGuiPy.cpp
deleted file mode 100644
index 5f0575947e..0000000000
--- a/src/Mod/Surface/Gui/AppSurfaceGuiPy.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2014 Nathan Miller *
- * *
- * This file is part of the FreeCAD CAx development system. *
- * *
- * This library is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Library General Public *
- * License as published by the Free Software Foundation; either *
- * version 2 of the License, or (at your option) any later version. *
- * *
- * This library is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU Library General Public License for more details. *
- * *
- * You should have received a copy of the GNU Library General Public *
- * License along with this library; see the file COPYING.LIB. If not, *
- * write to the Free Software Foundation, Inc., 59 Temple Place, *
- * Suite 330, Boston, MA 02111-1307, USA *
- * *
- ***************************************************************************/
-
-
-#include "PreCompiled.h"
-#ifndef _PreComp_
-#endif
-
-
-#include
-#include
-
-/* registration table */
-struct PyMethodDef SurfaceGui_methods[] = {
- {NULL, NULL} /* end of table marker */
-};
diff --git a/src/Mod/Surface/Gui/CMakeLists.txt b/src/Mod/Surface/Gui/CMakeLists.txt
index c39e801678..c8b9268f07 100644
--- a/src/Mod/Surface/Gui/CMakeLists.txt
+++ b/src/Mod/Surface/Gui/CMakeLists.txt
@@ -45,7 +45,6 @@ SET(SurfaceGui_SRCS
BSurf.h
../FillType.h
AppSurfaceGui.cpp
- AppSurfaceGuiPy.cpp
Command.cpp
PreCompiled.cpp
PreCompiled.h
diff --git a/src/Mod/Surface/Gui/Workbench.cpp b/src/Mod/Surface/Gui/Workbench.cpp
index f677681a22..eb6feb3fc3 100644
--- a/src/Mod/Surface/Gui/Workbench.cpp
+++ b/src/Mod/Surface/Gui/Workbench.cpp
@@ -46,7 +46,6 @@ Workbench::~Workbench()
Gui::MenuItem* Workbench::setupMenuBar() const
{
-
Gui::MenuItem* root = StdWorkbench::setupMenuBar();
Gui::MenuItem* item = root->findItem( "&Windows" );
diff --git a/src/Mod/Surface/InitGui.py b/src/Mod/Surface/InitGui.py
index 9944b2a2af..4541b9ddf8 100644
--- a/src/Mod/Surface/InitGui.py
+++ b/src/Mod/Surface/InitGui.py
@@ -2,7 +2,7 @@
# (c) 2001 Juergen Riegel LGPL
class SurfaceWorkbench ( Workbench ):
- "Surface workbench object"
+ "Surface workbench object"
Icon = """
/* XPM */
static char * Surface_Tools_Workbench_Main_xpm[] = {
@@ -72,26 +72,18 @@ class SurfaceWorkbench ( Workbench ):
" ",
" "};
"""
- MenuText = "Surface"
- ToolTip = "Surface workbench: Create and edit complex surfaces"
- def Initialize(self):
- # load the module
- import SurfaceGui
- import FreeCADGui
- import Surface
+ MenuText = "Surface"
+ ToolTip = "Surface workbench: Create and edit complex surfaces"
+ def Initialize(self):
+ # load the module
+ import SurfaceGui
+ import FreeCADGui
+ import Surface
- # Set path to icon labels
- FreeCADGui.addIconPath('./Gui/Resources/Icons/')
-
- def GetClassName(self):
- return "SurfaceGui::Workbench"
-
- def Activated(self):
- # do something here if needed...
- Msg ("SurfaceWorkbench.Activated()\n")
-
- def Deactivated(self):
- # do something here if needed...
- Msg ("SurfaceWorkbench.Deactivated()\n")
+ # Set path to icon labels
+ FreeCADGui.addIconPath('./Gui/Resources/Icons/')
+
+ def GetClassName(self):
+ return "SurfaceGui::Workbench"
Gui.addWorkbench(SurfaceWorkbench())