From 6dbb8ad60d81a537b1d95de84cbd610146db2891 Mon Sep 17 00:00:00 2001 From: kohait Date: Tue, 19 Apr 2011 15:05:45 +0000 Subject: [PATCH] bazaar: BoostPyTest: first attemt to structurize the export, more to be done, cleanup of unnessecary using namespace's git-svn-id: svn://ultimatepp.org/upp/trunk@3360 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- bazaar/BoostPyTest/BoostPyTest.h | 6 +- bazaar/BoostPyTest/BoostPyTest.upp | 9 +-- bazaar/BoostPyTest/SliderCtrlPy.cpp | 29 -------- bazaar/BoostPyTest/SliderCtrlPy.h | 29 -------- bazaar/BoostPyTest/UppString.cpp | 13 ---- bazaar/BoostPyTest/UppValue.cpp | 18 ----- bazaar/BoostPyTest/init | 1 + bazaar/BoostPyTest/main.cpp | 20 ++---- bazaar/BoostPyTest/modules.cppi | 7 +- bazaar/BoostPyTest/world.cpp | 8 +++ bazaar/BoostPyTest/world.h | 7 +- bazaar/CoreBoostPy/Common.h | 8 +++ bazaar/CoreBoostPy/CoreBoostPy.cpp | 16 +++++ bazaar/CoreBoostPy/CoreBoostPy.h | 14 ++++ bazaar/CoreBoostPy/CoreBoostPy.upp | 15 ++++ bazaar/CoreBoostPy/GTypes.cpp | 68 +++++++++++++++++++ bazaar/CoreBoostPy/GTypes.h | 14 ++++ .../UppString.h => CoreBoostPy/String.cpp} | 25 +++---- bazaar/CoreBoostPy/String.h | 12 ++++ .../UppValue.h => CoreBoostPy/Value.cpp} | 33 +++++---- bazaar/CoreBoostPy/Value.h | 13 ++++ bazaar/CoreBoostPy/init | 5 ++ bazaar/CtrlLibBoostPy/Common.h | 8 +++ bazaar/CtrlLibBoostPy/CtrlCore.cpp | 21 ++++++ bazaar/CtrlLibBoostPy/CtrlCore.h | 12 ++++ bazaar/CtrlLibBoostPy/CtrlLibBoostPy.cpp | 17 +++++ bazaar/CtrlLibBoostPy/CtrlLibBoostPy.h | 14 ++++ bazaar/CtrlLibBoostPy/CtrlLibBoostPy.upp | 16 +++++ bazaar/CtrlLibBoostPy/SliderCtrl.cpp | 19 ++++++ bazaar/CtrlLibBoostPy/SliderCtrl.h | 12 ++++ bazaar/CtrlLibBoostPy/ValueCtrl.cpp | 16 +++++ bazaar/CtrlLibBoostPy/ValueCtrl.h | 13 ++++ bazaar/CtrlLibBoostPy/init | 6 ++ bazaar/Py/Py.cpp | 5 ++ bazaar/Py/Py.h | 1 - bazaar/Py/init.icpp | 4 ++ bazaar/PyCon/PyCon.h | 4 -- bazaar/PyConsoleCtrl/PyConsoleCtrl.h | 3 - 38 files changed, 381 insertions(+), 160 deletions(-) delete mode 100644 bazaar/BoostPyTest/SliderCtrlPy.cpp delete mode 100644 bazaar/BoostPyTest/SliderCtrlPy.h delete mode 100644 bazaar/BoostPyTest/UppString.cpp delete mode 100644 bazaar/BoostPyTest/UppValue.cpp create mode 100644 bazaar/CoreBoostPy/Common.h create mode 100644 bazaar/CoreBoostPy/CoreBoostPy.cpp create mode 100644 bazaar/CoreBoostPy/CoreBoostPy.h create mode 100644 bazaar/CoreBoostPy/CoreBoostPy.upp create mode 100644 bazaar/CoreBoostPy/GTypes.cpp create mode 100644 bazaar/CoreBoostPy/GTypes.h rename bazaar/{BoostPyTest/UppString.h => CoreBoostPy/String.cpp} (67%) create mode 100644 bazaar/CoreBoostPy/String.h rename bazaar/{BoostPyTest/UppValue.h => CoreBoostPy/Value.cpp} (86%) create mode 100644 bazaar/CoreBoostPy/Value.h create mode 100644 bazaar/CoreBoostPy/init create mode 100644 bazaar/CtrlLibBoostPy/Common.h create mode 100644 bazaar/CtrlLibBoostPy/CtrlCore.cpp create mode 100644 bazaar/CtrlLibBoostPy/CtrlCore.h create mode 100644 bazaar/CtrlLibBoostPy/CtrlLibBoostPy.cpp create mode 100644 bazaar/CtrlLibBoostPy/CtrlLibBoostPy.h create mode 100644 bazaar/CtrlLibBoostPy/CtrlLibBoostPy.upp create mode 100644 bazaar/CtrlLibBoostPy/SliderCtrl.cpp create mode 100644 bazaar/CtrlLibBoostPy/SliderCtrl.h create mode 100644 bazaar/CtrlLibBoostPy/ValueCtrl.cpp create mode 100644 bazaar/CtrlLibBoostPy/ValueCtrl.h create mode 100644 bazaar/CtrlLibBoostPy/init diff --git a/bazaar/BoostPyTest/BoostPyTest.h b/bazaar/BoostPyTest/BoostPyTest.h index 915a29d20..17e743a5d 100644 --- a/bazaar/BoostPyTest/BoostPyTest.h +++ b/bazaar/BoostPyTest/BoostPyTest.h @@ -5,9 +5,8 @@ using namespace boost::python; #include "world.h" -#include "SliderCtrlPy.h" -#include "UppString.h" -#include "UppValue.h" +#include +using namespace Upp; #define LAYOUTFILE #include @@ -21,7 +20,6 @@ public: void ExitHandler(); World w; - SliderCtrlPy slpy; }; #endif diff --git a/bazaar/BoostPyTest/BoostPyTest.upp b/bazaar/BoostPyTest/BoostPyTest.upp index cb6adb14a..1e45cce99 100644 --- a/bazaar/BoostPyTest/BoostPyTest.upp +++ b/bazaar/BoostPyTest/BoostPyTest.upp @@ -1,17 +1,12 @@ uses CtrlLib, PyConsoleCtrl, - ValueCtrl; + ValueCtrl, + CtrlLibBoostPy; file world.h, world.cpp, - SliderCtrlPy.h, - SliderCtrlPy.cpp, - UppString.h, - UppString.cpp, - UppValue.h, - UppValue.cpp, BoostPyTest.h, compile.txt, modules.cppi, diff --git a/bazaar/BoostPyTest/SliderCtrlPy.cpp b/bazaar/BoostPyTest/SliderCtrlPy.cpp deleted file mode 100644 index 40c4bb05b..000000000 --- a/bazaar/BoostPyTest/SliderCtrlPy.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "SliderCtrlPy.h" - -void export_UppCtrl() -{ - scope().attr("__doc__") = "ctrl module's docstring"; - class_("SliderCtrlPy", "A SliderCtrl wrapper", no_init) - .def("get", &SliderCtrlPy::Get) - .def("set", &SliderCtrlPy::Set) - ; -} - -void export_SliderCtrl() -{ - scope().attr("__doc__") = "SliderCtrl module's docstring"; - class_("SliderCtrl", "An Upp SliderCtrl", no_init) - .def("get", &SliderCtrl::GetData) - .def("set", &SliderCtrl::SetData) - ; -} - -void export_ValueCtrl() -{ - scope().attr("__doc__") = "ValueCtrl module's docstring"; - class_("ValueCtrl", "An Upp ValueCtrl", no_init) - .def("get", &ValueCtrl::GetData) - .def("set", &ValueCtrl::SetData) - ; -} - diff --git a/bazaar/BoostPyTest/SliderCtrlPy.h b/bazaar/BoostPyTest/SliderCtrlPy.h deleted file mode 100644 index 4ee4fba9f..000000000 --- a/bazaar/BoostPyTest/SliderCtrlPy.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _BoostPyTest_SliderCtrlPy_h_ -#define _BoostPyTest_SliderCtrlPy_h_ - -#include -using namespace boost::python; - -#include -using namespace Upp; - -#include - -//A wrapped instance - -struct SliderCtrlPy -{ - SliderCtrlPy(SliderCtrl& o) : o(o) {} - - void Set(const int& d) { o.SetData(d); } - int Get() const { return o.GetData(); } - - SliderCtrl& o; -}; - -//fw -void export_UppCtrl(); -void export_SliderCtrl(); //relys on Value export -void export_ValueCtrl(); //relys on Value export - -#endif diff --git a/bazaar/BoostPyTest/UppString.cpp b/bazaar/BoostPyTest/UppString.cpp deleted file mode 100644 index 9c37f647e..000000000 --- a/bazaar/BoostPyTest/UppString.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "UppString.h" - -String Stringhello() { return String( "my new custom string" ); } -std::size_t Stringsize(const String& s) { return s.GetLength(); } - -void export_UppString() -{ - to_python_converter(); - String_from_python_str(); - def("hello", Stringhello); - def("size", Stringsize); -} - diff --git a/bazaar/BoostPyTest/UppValue.cpp b/bazaar/BoostPyTest/UppValue.cpp deleted file mode 100644 index c5fad9ff1..000000000 --- a/bazaar/BoostPyTest/UppValue.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "UppValue.h" - -Value Valuehelloval() { return 2244; } -int Valuedoubleit(const Value& v) { return int(v) * 2; } - -void export_UppValue() -{ - to_python_converter(); - Value_from_python(); - def("helloval", Valuehelloval); - def("doubleit", Valuedoubleit); -} - -void export_UppValueArray() -{ - to_python_converter(); - ValueArray_from_python(); -} diff --git a/bazaar/BoostPyTest/init b/bazaar/BoostPyTest/init index c57aa9a73..9aa5ffb6e 100644 --- a/bazaar/BoostPyTest/init +++ b/bazaar/BoostPyTest/init @@ -3,4 +3,5 @@ #include "CtrlLib/init" #include "PyConsoleCtrl/init" #include "ValueCtrl/init" +#include "CtrlLibBoostPy/init" #endif diff --git a/bazaar/BoostPyTest/main.cpp b/bazaar/BoostPyTest/main.cpp index 64690d63a..f59959fba 100644 --- a/bazaar/BoostPyTest/main.cpp +++ b/bazaar/BoostPyTest/main.cpp @@ -4,9 +4,9 @@ #include "modules.cppi" BoostPyTest::BoostPyTest() - : slpy(sl) { CtrlLayout(*this, "Boost Test"); + Sizeable().Zoomable(); //bool b = Py_IsInitialized(); @@ -44,7 +44,6 @@ BoostPyTest::BoostPyTest() main_namespace["upp"] = upp_module; sl.SetData(50); - scope(upp_module).attr("slpy") = ptr(&slpy); scope(upp_module).attr("sl") = ptr(&sl); vc.SetData(123); @@ -56,20 +55,11 @@ BoostPyTest::BoostPyTest() "p.set('Some Greet Text')\n" "print p.greet()\n" - "print upp.slpy.get()\n" - "upp.slpy.set(23)\n" - - "print upp.hello()\n" - "print upp.size('TestString')\n" + "upp.sl.setdata(75)\n" + "print upp.sl.getdata()\n" - "print upp.helloval()\n" - "print upp.doubleit(256)\n" - - "print upp.sl.get()\n" - "upp.sl.set(75)\n" - - "upp.vc.set(range(10))\n" - "upp.vc.get()\n" + "upp.vc.setdata(range(10))\n" + "print upp.vc.getdata()\n" ; con.cmd.SetData(sc); diff --git a/bazaar/BoostPyTest/modules.cppi b/bazaar/BoostPyTest/modules.cppi index 86a65232d..c0d3f75e1 100644 --- a/bazaar/BoostPyTest/modules.cppi +++ b/bazaar/BoostPyTest/modules.cppi @@ -7,10 +7,5 @@ BOOST_PYTHON_MODULE(hello) BOOST_PYTHON_MODULE(upp) { - export_UppCtrl(); - export_UppString(); - export_UppValue(); - export_UppValueArray(); - export_SliderCtrl(); - export_ValueCtrl(); + export_CtrlLib(); } diff --git a/bazaar/BoostPyTest/world.cpp b/bazaar/BoostPyTest/world.cpp index 95a089422..340eaad00 100644 --- a/bazaar/BoostPyTest/world.cpp +++ b/bazaar/BoostPyTest/world.cpp @@ -1,6 +1,11 @@ #include "world.h" +using namespace boost::python; + +NAMESPACE_UPP void export_world() +{ +ONCELOCK { scope().attr("__doc__") = "Hello module's docstring"; class_("World", "A simple world") @@ -8,3 +13,6 @@ void export_world() .def("set", &World::set) ; } +} + +END_UPP_NAMESPACE diff --git a/bazaar/BoostPyTest/world.h b/bazaar/BoostPyTest/world.h index 35405cfba..ed60e9ada 100644 --- a/bazaar/BoostPyTest/world.h +++ b/bazaar/BoostPyTest/world.h @@ -2,9 +2,6 @@ #define _BoostPyTest_world_h_ #include -using namespace boost::python; - -//A Simple class struct World { @@ -13,6 +10,10 @@ struct World std::string msg; }; +NAMESPACE_UPP + void export_world(); +END_UPP_NAMESPACE + #endif diff --git a/bazaar/CoreBoostPy/Common.h b/bazaar/CoreBoostPy/Common.h new file mode 100644 index 000000000..b04778f4f --- /dev/null +++ b/bazaar/CoreBoostPy/Common.h @@ -0,0 +1,8 @@ +#ifndef _CoreBoostPy_Common_h_ +#define _CoreBoostPy_Common_h_ + +#include + +#include + +#endif diff --git a/bazaar/CoreBoostPy/CoreBoostPy.cpp b/bazaar/CoreBoostPy/CoreBoostPy.cpp new file mode 100644 index 000000000..cb84246d0 --- /dev/null +++ b/bazaar/CoreBoostPy/CoreBoostPy.cpp @@ -0,0 +1,16 @@ +#include "CoreBoostPy.h" + +NAMESPACE_UPP + +void export_Core() +{ +ONCELOCK +{ + export_GTypes(); + export_String(); + export_Value(); + export_ValueArray(); +} +} + +END_UPP_NAMESPACE diff --git a/bazaar/CoreBoostPy/CoreBoostPy.h b/bazaar/CoreBoostPy/CoreBoostPy.h new file mode 100644 index 000000000..fdcb7d461 --- /dev/null +++ b/bazaar/CoreBoostPy/CoreBoostPy.h @@ -0,0 +1,14 @@ +#ifndef _CoreBoostPy_CoreBoostPy_h_ +#define _CoreBoostPy_CoreBoostPy_h_ + +#include "GTypes.h" +#include "String.h" +#include "Value.h" + +NAMESPACE_UPP + +void export_Core(); + +END_UPP_NAMESPACE + +#endif diff --git a/bazaar/CoreBoostPy/CoreBoostPy.upp b/bazaar/CoreBoostPy/CoreBoostPy.upp new file mode 100644 index 000000000..0395e779d --- /dev/null +++ b/bazaar/CoreBoostPy/CoreBoostPy.upp @@ -0,0 +1,15 @@ +uses + Core, + Py; + +file + Common.h, + GTypes.h, + GTypes.cpp, + String.h, + String.cpp, + Value.h, + Value.cpp, + CoreBoostPy.h, + CoreBoostPy.cpp; + diff --git a/bazaar/CoreBoostPy/GTypes.cpp b/bazaar/CoreBoostPy/GTypes.cpp new file mode 100644 index 000000000..91c248d11 --- /dev/null +++ b/bazaar/CoreBoostPy/GTypes.cpp @@ -0,0 +1,68 @@ +#include "GTypes.h" +using namespace boost::python; + +NAMESPACE_UPP + +//Color + +struct Color_to_python +{ + static PyObject* convert(const Color& c) + { + list l; + l.append(object(c.GetR())); + l.append(object(c.GetG())); + l.append(object(c.GetB())); + return incref(l.ptr()); //need to create a list + } +}; + +struct Color_from_python +{ + Color_from_python() + { + converter::registry::push_back(&convertible, &construct, type_id()); + } + + static void* convertible(PyObject* po) + { + if(PyList_Check(po)) return po; + return 0; + } + + static void construct(PyObject* po, converter::rvalue_from_python_stage1_data* data) + { + void* d = ((converter::rvalue_from_python_storage*)data)->storage.bytes; + + list l(handle<>(borrowed(po))); + assert(len(l)==3); + int r,g,b; + r = extract(l[0]); + g = extract(l[1]); + b = extract(l[2]); + new(d) Color(r,g,b); + + data->convertible = d; + } +}; + +void export_Color() +{ +ONCELOCK +{ + to_python_converter(); + Color_from_python(); +} +} + +// + +void export_GTypes() +{ +ONCELOCK +{ + export_Color(); +} +} + +END_UPP_NAMESPACE diff --git a/bazaar/CoreBoostPy/GTypes.h b/bazaar/CoreBoostPy/GTypes.h new file mode 100644 index 000000000..174b24fc4 --- /dev/null +++ b/bazaar/CoreBoostPy/GTypes.h @@ -0,0 +1,14 @@ +#ifndef _CoreBoostPy_GTypes_h_ +#define _CoreBoostPy_GTypes_h_ + +#include "Common.h" + +NAMESPACE_UPP + +void export_Color(); + +void export_GTypes(); + +END_UPP_NAMESPACE + +#endif diff --git a/bazaar/BoostPyTest/UppString.h b/bazaar/CoreBoostPy/String.cpp similarity index 67% rename from bazaar/BoostPyTest/UppString.h rename to bazaar/CoreBoostPy/String.cpp index 85b7c39c0..6c1bf9166 100644 --- a/bazaar/BoostPyTest/UppString.h +++ b/bazaar/CoreBoostPy/String.cpp @@ -1,13 +1,7 @@ -#ifndef _BoostPyTest_UppString_h_ -#define _BoostPyTest_UppString_h_ - -#include +#include "String.h" using namespace boost::python; -#include -using namespace Upp; - -//a convertable instance +NAMESPACE_UPP struct String_to_python_str { @@ -39,10 +33,13 @@ struct String_from_python_str } }; -String Stringhello(); //tests to-python -std::size_t Stringsize(const String& s); //tests from-python +void export_String() +{ +ONCELOCK +{ + to_python_converter(); + String_from_python_str(); +} +} -//fw -void export_UppString(); - -#endif +END_UPP_NAMESPACE diff --git a/bazaar/CoreBoostPy/String.h b/bazaar/CoreBoostPy/String.h new file mode 100644 index 000000000..93d0fa7f5 --- /dev/null +++ b/bazaar/CoreBoostPy/String.h @@ -0,0 +1,12 @@ +#ifndef _CoreBoostPy_String_h_ +#define _CoreBoostPy_String_h_ + +#include "Common.h" + +NAMESPACE_UPP + +void export_String(); + +END_UPP_NAMESPACE + +#endif diff --git a/bazaar/BoostPyTest/UppValue.h b/bazaar/CoreBoostPy/Value.cpp similarity index 86% rename from bazaar/BoostPyTest/UppValue.h rename to bazaar/CoreBoostPy/Value.cpp index 21e31fe45..5ed6fa131 100644 --- a/bazaar/BoostPyTest/UppValue.h +++ b/bazaar/CoreBoostPy/Value.cpp @@ -1,13 +1,7 @@ -#ifndef _BoostPyTest_UppValue_h_ -#define _BoostPyTest_UppValue_h_ - -#include +#include "Value.h" using namespace boost::python; -#include -using namespace Upp; - -//a convertable instance +NAMESPACE_UPP struct Value_to_python { @@ -104,8 +98,14 @@ struct Value_from_python } }; -Value Valuehelloval(); //tests to-python -int Valuedoubleit(const Value& v); //tests from-python +void export_Value() +{ +ONCELOCK +{ + to_python_converter(); + Value_from_python(); +} +} //ValueArray @@ -148,8 +148,13 @@ struct ValueArray_from_python } }; -//fw -void export_UppValue(); -void export_UppValueArray(); +void export_ValueArray() +{ +ONCELOCK +{ + to_python_converter(); + ValueArray_from_python(); +} +} -#endif +END_UPP_NAMESPACE \ No newline at end of file diff --git a/bazaar/CoreBoostPy/Value.h b/bazaar/CoreBoostPy/Value.h new file mode 100644 index 000000000..4485bfb10 --- /dev/null +++ b/bazaar/CoreBoostPy/Value.h @@ -0,0 +1,13 @@ +#ifndef _CoreBoostPy_Value_h_ +#define _CoreBoostPy_Value_h_ + +#include "Common.h" + +NAMESPACE_UPP + +void export_Value(); +void export_ValueArray(); + +END_UPP_NAMESPACE + +#endif diff --git a/bazaar/CoreBoostPy/init b/bazaar/CoreBoostPy/init new file mode 100644 index 000000000..2129f6c40 --- /dev/null +++ b/bazaar/CoreBoostPy/init @@ -0,0 +1,5 @@ +#ifndef _CoreBoostPy_icpp_init_stub +#define _CoreBoostPy_icpp_init_stub +#include "Core/init" +#include "Py/init" +#endif diff --git a/bazaar/CtrlLibBoostPy/Common.h b/bazaar/CtrlLibBoostPy/Common.h new file mode 100644 index 000000000..e19d0c5c6 --- /dev/null +++ b/bazaar/CtrlLibBoostPy/Common.h @@ -0,0 +1,8 @@ +#ifndef _CtrlLibBoostPy_Common_h_ +#define _CtrlLibBoostPy_Common_h_ + +#include + +#include + +#endif diff --git a/bazaar/CtrlLibBoostPy/CtrlCore.cpp b/bazaar/CtrlLibBoostPy/CtrlCore.cpp new file mode 100644 index 000000000..788b78620 --- /dev/null +++ b/bazaar/CtrlLibBoostPy/CtrlCore.cpp @@ -0,0 +1,21 @@ +#include "CtrlCore.h" +using namespace boost::python; + +NAMESPACE_UPP + +Value CtrlGetData(const Ctrl& c) { return c.GetData(); } +void CtrlSetData(Ctrl& c, const Value& data) { c.SetData(data); } + +void export_CtrlCore() +{ +ONCELOCK +{ + scope().attr("__doc__") = "Ctrl's docstring"; + class_("Ctrl", "An Upp Ctrl", no_init) + .def("getdata", CtrlGetData) + .def("setdata", CtrlSetData) + ; +} +} + +END_UPP_NAMESPACE diff --git a/bazaar/CtrlLibBoostPy/CtrlCore.h b/bazaar/CtrlLibBoostPy/CtrlCore.h new file mode 100644 index 000000000..471859eb9 --- /dev/null +++ b/bazaar/CtrlLibBoostPy/CtrlCore.h @@ -0,0 +1,12 @@ +#ifndef _CtrlLibBoostPy_CtrlCore_h_ +#define _CtrlLibBoostPy_CtrlCore_h_ + +#include "Common.h" + +NAMESPACE_UPP + +void export_CtrlCore(); + +END_UPP_NAMESPACE + +#endif diff --git a/bazaar/CtrlLibBoostPy/CtrlLibBoostPy.cpp b/bazaar/CtrlLibBoostPy/CtrlLibBoostPy.cpp new file mode 100644 index 000000000..f3100fc55 --- /dev/null +++ b/bazaar/CtrlLibBoostPy/CtrlLibBoostPy.cpp @@ -0,0 +1,17 @@ +#include "CtrlLibBoostPy.h" + +NAMESPACE_UPP + +void export_CtrlLib() +{ +ONCELOCK +{ + export_Core(); + + export_CtrlCore(); + export_SliderCtrl(); + export_ValueCtrl(); +} +} + +END_UPP_NAMESPACE diff --git a/bazaar/CtrlLibBoostPy/CtrlLibBoostPy.h b/bazaar/CtrlLibBoostPy/CtrlLibBoostPy.h new file mode 100644 index 000000000..6cfc18744 --- /dev/null +++ b/bazaar/CtrlLibBoostPy/CtrlLibBoostPy.h @@ -0,0 +1,14 @@ +#ifndef _CtrlLibBoostPy_CtrlLibBoostPy_h_ +#define _CtrlLibBoostPy_CtrlLibBoostPy_h_ + +#include "CtrlCore.h" +#include "SliderCtrl.h" +#include "ValueCtrl.h" + +NAMESPACE_UPP + +void export_CtrlLib(); + +END_UPP_NAMESPACE + +#endif diff --git a/bazaar/CtrlLibBoostPy/CtrlLibBoostPy.upp b/bazaar/CtrlLibBoostPy/CtrlLibBoostPy.upp new file mode 100644 index 000000000..1b19e207d --- /dev/null +++ b/bazaar/CtrlLibBoostPy/CtrlLibBoostPy.upp @@ -0,0 +1,16 @@ +uses + CtrlLib, + Py, + CoreBoostPy; + +file + Common.h, + CtrlCore.h, + CtrlCore.cpp, + SliderCtrl.h, + SliderCtrl.cpp, + ValueCtrl.h, + ValueCtrl.cpp, + CtrlLibBoostPy.h, + CtrlLibBoostPy.cpp; + diff --git a/bazaar/CtrlLibBoostPy/SliderCtrl.cpp b/bazaar/CtrlLibBoostPy/SliderCtrl.cpp new file mode 100644 index 000000000..cc2fddb74 --- /dev/null +++ b/bazaar/CtrlLibBoostPy/SliderCtrl.cpp @@ -0,0 +1,19 @@ +#include "SliderCtrl.h" +using namespace boost::python; + +NAMESPACE_UPP + +void export_SliderCtrl() +{ +ONCELOCK +{ + scope().attr("__doc__") = "SliderCtrl's docstring"; + class_, SliderCtrl, boost::noncopyable>("SliderCtrl", "An Upp SliderCtrl", no_init) + .def("inc", &SliderCtrl::Inc) + .def("dec", &SliderCtrl::Dec) + .def("step", &SliderCtrl::GetStep) + ; +} +} + +END_UPP_NAMESPACE diff --git a/bazaar/CtrlLibBoostPy/SliderCtrl.h b/bazaar/CtrlLibBoostPy/SliderCtrl.h new file mode 100644 index 000000000..8738cf3f1 --- /dev/null +++ b/bazaar/CtrlLibBoostPy/SliderCtrl.h @@ -0,0 +1,12 @@ +#ifndef _CtrlLibBoostPy_SliderCtrl_h_ +#define _CtrlLibBoostPy_SliderCtrl_h_ + +#include "Common.h" + +NAMESPACE_UPP + +void export_SliderCtrl(); + +END_UPP_NAMESPACE + +#endif diff --git a/bazaar/CtrlLibBoostPy/ValueCtrl.cpp b/bazaar/CtrlLibBoostPy/ValueCtrl.cpp new file mode 100644 index 000000000..da6e652e5 --- /dev/null +++ b/bazaar/CtrlLibBoostPy/ValueCtrl.cpp @@ -0,0 +1,16 @@ +#include "ValueCtrl.h" +using namespace boost::python; + +NAMESPACE_UPP + +void export_ValueCtrl() +{ +ONCELOCK +{ + scope().attr("__doc__") = "ValueCtrl module's docstring"; + class_, ValueCtrl, boost::noncopyable>("ValueCtrl", "An Upp ValueCtrl", no_init) + ; +} +} + +END_UPP_NAMESPACE diff --git a/bazaar/CtrlLibBoostPy/ValueCtrl.h b/bazaar/CtrlLibBoostPy/ValueCtrl.h new file mode 100644 index 000000000..816b1b120 --- /dev/null +++ b/bazaar/CtrlLibBoostPy/ValueCtrl.h @@ -0,0 +1,13 @@ +#ifndef _CtrlLibBoostPy_ValueCtrl_h_ +#define _CtrlLibBoostPy_ValueCtrl_h_ + +#include "Common.h" +#include + +NAMESPACE_UPP + +void export_ValueCtrl(); + +END_UPP_NAMESPACE + +#endif diff --git a/bazaar/CtrlLibBoostPy/init b/bazaar/CtrlLibBoostPy/init new file mode 100644 index 000000000..aef294377 --- /dev/null +++ b/bazaar/CtrlLibBoostPy/init @@ -0,0 +1,6 @@ +#ifndef _CtrlLibBoostPy_icpp_init_stub +#define _CtrlLibBoostPy_icpp_init_stub +#include "CtrlLib/init" +#include "Py/init" +#include "CoreBoostPy/init" +#endif diff --git a/bazaar/Py/Py.cpp b/bazaar/Py/Py.cpp index 105cab5b3..6a595e8cd 100644 --- a/bazaar/Py/Py.cpp +++ b/bazaar/Py/Py.cpp @@ -1,2 +1,7 @@ #include "Py.h" +using namespace boost::python; + +NAMESPACE_UPP + +END_UPP_NAMESPACE diff --git a/bazaar/Py/Py.h b/bazaar/Py/Py.h index 6f176dcc1..60ef4d5ab 100644 --- a/bazaar/Py/Py.h +++ b/bazaar/Py/Py.h @@ -18,6 +18,5 @@ #endif #include -using namespace Upp; #endif diff --git a/bazaar/Py/init.icpp b/bazaar/Py/init.icpp index 5e6a5b499..b7f936dca 100644 --- a/bazaar/Py/init.icpp +++ b/bazaar/Py/init.icpp @@ -1,5 +1,7 @@ #include "Py.h" +NAMESPACE_UPP + INITBLOCK { Py_Initialize(); @@ -9,3 +11,5 @@ EXITBLOCK { Py_Finalize(); } + +END_UPP_NAMESPACE diff --git a/bazaar/PyCon/PyCon.h b/bazaar/PyCon/PyCon.h index 9949dcc96..230f247ee 100644 --- a/bazaar/PyCon/PyCon.h +++ b/bazaar/PyCon/PyCon.h @@ -2,10 +2,6 @@ #define _PyCon_PyCon_h_ #include - -#include -using namespace Upp; - #include class PyCon diff --git a/bazaar/PyConsoleCtrl/PyConsoleCtrl.h b/bazaar/PyConsoleCtrl/PyConsoleCtrl.h index 82ec5cabc..7261068c6 100644 --- a/bazaar/PyConsoleCtrl/PyConsoleCtrl.h +++ b/bazaar/PyConsoleCtrl/PyConsoleCtrl.h @@ -3,9 +3,6 @@ #include -#include -using namespace Upp; - #define LAYOUTFILE #include