+ simplify porting of Sandbox module to Python3
This commit is contained in:
parent
36383135a8
commit
bfdaa46feb
|
@ -146,24 +146,22 @@ public:
|
|||
Py::String m_value;
|
||||
};
|
||||
|
||||
} // namespace Sandbox
|
||||
|
||||
/* module functions */
|
||||
|
||||
class SandboxModule : public Py::ExtensionModule<SandboxModule>
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
{
|
||||
|
||||
public:
|
||||
SandboxModule() : Py::ExtensionModule<SandboxModule>("Sandbox")
|
||||
Module() : Py::ExtensionModule<Module>("Sandbox")
|
||||
{
|
||||
Sandbox::PythonBaseClass::init_type();
|
||||
Sandbox::DocumentProtectorPy::init_type();
|
||||
add_varargs_method("DocumentProtector",
|
||||
&SandboxModule::new_DocumentProtector,
|
||||
&Module::new_DocumentProtector,
|
||||
"DocumentProtector(Document)");
|
||||
Sandbox::DocumentObjectProtectorPy::init_type();
|
||||
add_varargs_method("DocumentObjectProtector",
|
||||
&SandboxModule::new_DocumentObjectProtector,
|
||||
&Module::new_DocumentObjectProtector,
|
||||
"DocumentObjectProtector(DocumentObject)");
|
||||
initialize("This module is the Sandbox module"); // register with Python
|
||||
|
||||
|
@ -172,7 +170,7 @@ public:
|
|||
d["PythonBaseClass"] = x;
|
||||
}
|
||||
|
||||
virtual ~SandboxModule() {}
|
||||
virtual ~Module() {}
|
||||
|
||||
private:
|
||||
Py::Object new_DocumentProtector(const Py::Tuple& args)
|
||||
|
@ -193,18 +191,17 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace Sandbox
|
||||
|
||||
|
||||
/* Python entry */
|
||||
extern "C" {
|
||||
void SandboxAppExport initSandbox() {
|
||||
PyMODINIT_FUNC initSandbox() {
|
||||
|
||||
Sandbox::DocumentProtector ::init();
|
||||
Sandbox::SandboxObject ::init();
|
||||
|
||||
// the following constructor call registers our extension module
|
||||
// with the Python runtime system
|
||||
(void)new SandboxModule;
|
||||
(void)new Sandbox::Module;
|
||||
Base::Console().Log("Loading Sandbox module... done\n");
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
|
|
@ -187,20 +187,21 @@ private:
|
|||
double radius;
|
||||
};
|
||||
|
||||
class SandboxModuleGui : public Py::ExtensionModule<SandboxModuleGui>
|
||||
namespace SandboxGui {
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
{
|
||||
|
||||
public:
|
||||
SandboxModuleGui() : Py::ExtensionModule<SandboxModuleGui>("SandboxGui")
|
||||
Module() : Py::ExtensionModule<Module>("SandboxGui")
|
||||
{
|
||||
add_varargs_method("interactiveFilletArc",&SandboxModuleGui::interactiveFilletArc,
|
||||
add_varargs_method("interactiveFilletArc",&Module::interactiveFilletArc,
|
||||
"Interactive fillet arc");
|
||||
add_varargs_method("xmlReader",&SandboxModuleGui::xmlReader,
|
||||
add_varargs_method("xmlReader",&Module::xmlReader,
|
||||
"Read XML");
|
||||
initialize("This module is the SandboxGui module"); // register with Python
|
||||
}
|
||||
|
||||
virtual ~SandboxModuleGui() {}
|
||||
virtual ~Module() {}
|
||||
|
||||
private:
|
||||
Py::Object interactiveFilletArc(const Py::Tuple& args)
|
||||
|
@ -238,10 +239,10 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace SandboxGui
|
||||
|
||||
/* Python entry */
|
||||
extern "C" {
|
||||
void SandboxGuiExport initSandboxGui()
|
||||
PyMODINIT_FUNC initSandboxGui()
|
||||
{
|
||||
if (!Gui::Application::Instance) {
|
||||
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
||||
|
@ -264,8 +265,6 @@ void SandboxGuiExport initSandboxGui()
|
|||
|
||||
// the following constructor call registers our extension module
|
||||
// with the Python runtime system
|
||||
(void)new SandboxModuleGui;
|
||||
(void)new SandboxGui::Module;
|
||||
Base::Console().Log("Loading GUI of Sandbox module... done\n");
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
|
Loading…
Reference in New Issue
Block a user