+ move module Python stuff into C++ class
This commit is contained in:
parent
e82a780774
commit
b1ea3f70da
|
@ -28,12 +28,24 @@
|
|||
|
||||
#include <Base/Console.h>
|
||||
|
||||
#include <CXX/Extensions.hxx>
|
||||
#include <CXX/Objects.hxx>
|
||||
|
||||
/* registration table */
|
||||
extern struct PyMethodDef _TEMPLATE__methods[];
|
||||
|
||||
PyDoc_STRVAR(module__TEMPLATE__doc,
|
||||
"This module is the _TEMPLATE_ module.");
|
||||
namespace _TEMPLATE_ {
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
{
|
||||
public:
|
||||
Module() : Py::ExtensionModule<Module>("_TEMPLATE_")
|
||||
{
|
||||
initialize("This module is the _TEMPLATE_ module."); // register with Python
|
||||
}
|
||||
|
||||
virtual ~Module() {}
|
||||
|
||||
private:
|
||||
};
|
||||
} // namespace _TEMPLATE_
|
||||
|
||||
|
||||
/* Python entry */
|
||||
|
@ -43,7 +55,7 @@ void _TEMPLATE_AppExport init_TEMPLATE_() {
|
|||
// ADD YOUR CODE HERE
|
||||
//
|
||||
//
|
||||
(void) Py_InitModule3("_TEMPLATE_", _TEMPLATE__methods, module__TEMPLATE__doc); /* mod name, table ptr */
|
||||
new _TEMPLATE_::Module();
|
||||
Base::Console().Log("Loading _TEMPLATE_ module... done\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
|
||||
* *
|
||||
* 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 <Python.h>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <Base/Exception.h>
|
||||
|
||||
|
||||
/* registration table */
|
||||
struct PyMethodDef _TEMPLATE__methods[] = {
|
||||
{NULL, NULL} /* end of table marker */
|
||||
};
|
|
@ -13,7 +13,6 @@ set(_TEMPLATE__LIBS
|
|||
|
||||
SET(_TEMPLATE__SRCS
|
||||
App_TEMPLATE_.cpp
|
||||
App_TEMPLATE_Py.cpp
|
||||
PreCompiled.cpp
|
||||
PreCompiled.h
|
||||
)
|
||||
|
|
|
@ -31,15 +31,27 @@
|
|||
|
||||
#include "Workbench.h"
|
||||
|
||||
#include <CXX/Extensions.hxx>
|
||||
#include <CXX/Objects.hxx>
|
||||
|
||||
// use a different name to CreateCommand()
|
||||
void Create_TEMPLATE_Commands(void);
|
||||
|
||||
|
||||
/* registration table */
|
||||
extern struct PyMethodDef _TEMPLATE_Gui_methods[];
|
||||
namespace _TEMPLATE_Gui {
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
{
|
||||
public:
|
||||
Module() : Py::ExtensionModule<Module>("_TEMPLATE_Gui")
|
||||
{
|
||||
initialize("This module is the _TEMPLATE_Gui module."); // register with Python
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(module__TEMPLATE_Gui_doc,
|
||||
"This module is the _TEMPLATE_Gui module.");
|
||||
virtual ~Module() {}
|
||||
|
||||
private:
|
||||
};
|
||||
} // namespace _TEMPLATE_Gui
|
||||
|
||||
|
||||
/* Python entry */
|
||||
|
@ -58,8 +70,7 @@ void _TEMPLATE_GuiExport init_TEMPLATE_Gui()
|
|||
// ADD YOUR CODE HERE
|
||||
//
|
||||
//
|
||||
|
||||
(void) Py_InitModule3("_TEMPLATE_Gui", _TEMPLATE_Gui_methods, module__TEMPLATE_Gui_doc); /* mod name, table ptr */
|
||||
new _TEMPLATE_Gui::Module();
|
||||
Base::Console().Log("Loading GUI of _TEMPLATE_ module... done\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) YEAR YOUR NAME <Your e-mail address> *
|
||||
* *
|
||||
* 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 <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
|
||||
/* registration table */
|
||||
struct PyMethodDef _TEMPLATE_Gui_methods[] = {
|
||||
{NULL, NULL} /* end of table marker */
|
||||
};
|
|
@ -20,7 +20,6 @@ qt4_add_resources(_TEMPLATE__QRC_SRCS Resources/_TEMPLATE_.qrc)
|
|||
SET(_TEMPLATE_Gui_SRCS
|
||||
${_TEMPLATE__QRC_SRCS}
|
||||
App_TEMPLATE_Gui.cpp
|
||||
App_TEMPLATE_GuiPy.cpp
|
||||
Command.cpp
|
||||
PreCompiled.cpp
|
||||
PreCompiled.h
|
||||
|
|
Loading…
Reference in New Issue
Block a user