diff --git a/bazaar/BoostPyTest/main.cpp b/bazaar/BoostPyTest/main.cpp index 5d97cc771..d3204916b 100644 --- a/bazaar/BoostPyTest/main.cpp +++ b/bazaar/BoostPyTest/main.cpp @@ -43,6 +43,8 @@ BoostPyTest::BoostPyTest() object upp_module = import("upp"); main_namespace["upp"] = upp_module; + scope(upp_module).attr("app") = ptr((TopWindow*)this); + sl.SetData(50); scope(upp_module).attr("sl") = ptr(&sl); @@ -60,7 +62,7 @@ BoostPyTest::BoostPyTest() "p = hello.World()\n" "p.set('Some Greet Text')\n" - "print p.greet()\n" + "print p.get()\n" "upp.sl.data = 75\n" "print upp.sl.data\n" @@ -74,15 +76,20 @@ BoostPyTest::BoostPyTest() "c = upp.Color(123,124,125)\n" "print c\n" - //"upp.vc.data = c\n" + "pp = p\n" + "p.set('Hi')\n" + "print p\n" + "print pp\n" + + //"upp.vc.data = c\n" "import time\n" "upp.pr.reset()\n" "upp.pr.create()\n" "upp.pr.canceled()\n" "i = 0\n" - "while i < 10:\n" + "while i < 3:\n" " print i\n" " upp.pr.text = str(i)\n" " i = i+1\n" @@ -96,6 +103,12 @@ BoostPyTest::BoostPyTest() " print 'MyCallback, would could work with p.greet or lambda: as well'\n" "upp.sl.whenaction = ff\n" + "sl2 = upp.SliderCtrl()\n" + "sl2.rightpos(0,200)\n" + "sl2.bottompos(0,40)\n" + "sl2.whenaction = ff\n" + "sl2.data = 12\n" + "upp.app.add(sl2)\n" ; con.cmd.SetData(sc); diff --git a/bazaar/BoostPyTest/world.cpp b/bazaar/BoostPyTest/world.cpp index 0acc58fac..424d3eff5 100644 --- a/bazaar/BoostPyTest/world.cpp +++ b/bazaar/BoostPyTest/world.cpp @@ -9,11 +9,20 @@ void export_world() { ONCELOCK { - class_("World", "A simple world") - .def("__str__", &World::greet) //somehow works only for print not for general return as string echo + class_("World", "A simple world") + //.def(init()) + .def("__str__", &World::get) //somehow works only for print not for general return as string echo .def("greet", &World::greet) + .def("get", &World::get) .def("set", &World::set) ; + + class_, boost::noncopyable >("Universe", "A simple Universe") + //.def(init()) + .def("__str__", &Universe::getg) //somehow works only for print not for general return as string echo + .def("getg", &Universe::getg) + .def("setg", &Universe::setg) + ; } } diff --git a/bazaar/BoostPyTest/world.h b/bazaar/BoostPyTest/world.h index ed60e9ada..8e0b0ab6e 100644 --- a/bazaar/BoostPyTest/world.h +++ b/bazaar/BoostPyTest/world.h @@ -6,8 +6,32 @@ struct World { void set(std::string msg) { this->msg = msg; } - std::string greet() const { return msg; } + std::string get() const { return msg; } std::string msg; + + void greet() + { + PySys_WriteStdout("%.100s", msg.data()); + } + + World() {} +protected: + World(const World& w) { + msg = w.msg; + } +}; + +struct Universe : public World +{ + double g; + void setg(double _g) { g = _g; } + double getg() const { return g; } + + Universe() { g = 9.81; } + +#if 0 + Universe(const Universe& u) : World(u), g(u.g) {} +#endif }; NAMESPACE_UPP diff --git a/bazaar/CoreBoostPy/Callback.cpp b/bazaar/CoreBoostPy/Callback.cpp index ebbbfd5fb..f59abfea6 100644 --- a/bazaar/CoreBoostPy/Callback.cpp +++ b/bazaar/CoreBoostPy/Callback.cpp @@ -11,12 +11,10 @@ struct CallbackActionPy : public CallbackAction { bool CallbackIsValid(const Callback& c) { return c; } -#if 0 struct Callback_to_python //FIXME translation of Callback internals to python { - static PyObject* convert(const Callback& s) { return incref(object(s.Begin()).ptr()); } + static PyObject* convert(const Callback& s) { return incref(object(s).ptr()); } }; -#endif struct Callback_from_python { @@ -30,6 +28,7 @@ struct Callback_from_python if(po == Py_None) return po; if(PyFunction_Check(po)) return po; if(PyCallable_Check(po) && PyMethod_Self(po)) return po; + if(extract(po).check()) return po; return 0; } @@ -51,6 +50,14 @@ struct Callback_from_python { new(d) Callback(new CallbackActionPy(po)); } +#if 1 //actually isnt used anywhere so far + else + if(extract(po).check()) + { + Callback& c = extract(po); + new(d) Callback(c); + } +#endif else { throw_error_already_set(); //FIXME dont know type, which to throw? @@ -64,10 +71,11 @@ void export_Callback() { ONCELOCK { - //to_python_converter(); + //to_python_converter(); Callback_from_python(); - class_("Point", "Upp Callback") + class_("Callback", "Upp Callback") + .def(init()) .def("clear", &Callback::Clear) .def("valid", &CallbackIsValid) .def("__call__", &Callback::Execute) diff --git a/bazaar/CtrlLibBoostPy/CtrlCore.cpp b/bazaar/CtrlLibBoostPy/CtrlCore.cpp index d483a899a..2118a3647 100644 --- a/bazaar/CtrlLibBoostPy/CtrlCore.cpp +++ b/bazaar/CtrlLibBoostPy/CtrlCore.cpp @@ -97,7 +97,7 @@ ONCELOCK { export_Core(); export_LogPos(); - class_("Ctrl", "Upp Ctrl", no_init) + class_("Ctrl", "Upp Ctrl") .def("posleft", &Ctrl::PosLeft) .staticmethod("posleft") @@ -163,6 +163,11 @@ ONCELOCK .add_property("transparent", &Ctrl::IsTransparent, &CtrlTransparent) .add_property("tip", &Ctrl::GetTip, &CtrlSetTip) + .def("add", &Ctrl::Add) + .def("addchild", (void (Ctrl::*)(Ctrl*))&Ctrl::AddChild) + .def("addchildafter", (void (Ctrl::*)(Ctrl*, Ctrl*))&Ctrl::AddChild) + .def("addchildbefore", &Ctrl::AddChildBefore) + .def("__str__", &CtrlToString) ; @@ -215,7 +220,7 @@ ONCELOCK .value("idexit", _IDEXIT) ; - class_, TopWindow, boost::noncopyable>("TopWindow", "Upp TopWindow", no_init) + class_, boost::noncopyable>("TopWindow", "Upp TopWindow", no_init) .def("backup", &TopWindow::Backup) .def("restore", &TopWindow::Restore) .def("break", &TopWindow::Break) diff --git a/bazaar/CtrlLibBoostPy/EditCtrl.cpp b/bazaar/CtrlLibBoostPy/EditCtrl.cpp index 81c7a60a6..183028449 100644 --- a/bazaar/CtrlLibBoostPy/EditCtrl.cpp +++ b/bazaar/CtrlLibBoostPy/EditCtrl.cpp @@ -7,37 +7,37 @@ void export_EditCtrl() { ONCELOCK { - class_, EditField, boost::noncopyable>("EditField", "Upp EditField", no_init) + class_, boost::noncopyable>("EditField", "Upp EditField") ; - class_, EditString, boost::noncopyable>("EditString", "Upp EditString", no_init) + class_, boost::noncopyable>("EditString", "Upp EditString") ; - class_, EditInt, boost::noncopyable>("EditInt", "Upp EditInt", no_init) + class_, boost::noncopyable>("EditInt", "Upp EditInt") ; - class_, EditInt64, boost::noncopyable>("EditInt64", "Upp EditInt64", no_init) + class_, boost::noncopyable>("EditInt64", "Upp EditInt64") ; - class_, EditDouble, boost::noncopyable>("EditDouble", "Upp EditDouble", no_init) + class_, boost::noncopyable>("EditDouble", "Upp EditDouble") ; - class_, EditStringNotNull, boost::noncopyable>("EditStringNotNull", "Upp EditStringNotNull", no_init) + class_, boost::noncopyable>("EditStringNotNull", "Upp EditStringNotNull") ; - class_, EditIntNotNull, boost::noncopyable>("EditIntNotNull", "Upp EditIntNotNull", no_init) + class_, boost::noncopyable>("EditIntNotNull", "Upp EditIntNotNull") ; - class_, EditInt64NotNull, boost::noncopyable>("EditInt64NotNull", "Upp EditInt64NotNull", no_init) + class_, boost::noncopyable>("EditInt64NotNull", "Upp EditInt64NotNull") ; - class_, EditDoubleNotNull, boost::noncopyable>("EditDoubleNotNull", "Upp EditDoubleNotNull", no_init) + class_, boost::noncopyable>("EditDoubleNotNull", "Upp EditDoubleNotNull") ; - class_, EditIntSpin, boost::noncopyable>("EditIntSpin", "Upp EditIntSpin", no_init) + class_, boost::noncopyable>("EditIntSpin", "Upp EditIntSpin") ; - class_, EditInt64Spin, boost::noncopyable>("EditInt64Spin", "Upp EditInt64Spin", no_init) + class_, boost::noncopyable>("EditInt64Spin", "Upp EditInt64Spin") ; - class_, EditDoubleSpin, boost::noncopyable>("EditDoubleSpin", "Upp EditDoubleSpin", no_init) + class_, boost::noncopyable>("EditDoubleSpin", "Upp EditDoubleSpin") ; - class_, EditIntNotNullSpin, boost::noncopyable>("EditIntNotNullSpin", "Upp EditIntNotNullSpin", no_init) + class_, boost::noncopyable>("EditIntNotNullSpin", "Upp EditIntNotNullSpin") ; - class_, EditInt64NotNullSpin, boost::noncopyable>("EditInt64NotNullSpin", "Upp EditInt64NotNullSpin", no_init) + class_, boost::noncopyable>("EditInt64NotNullSpin", "Upp EditInt64NotNullSpin") ; - class_, EditDoubleNotNullSpin, boost::noncopyable>("EditDoubleNotNullSpin", "Upp EditDoubleNotNullSpin", no_init) + class_, boost::noncopyable>("EditDoubleNotNullSpin", "Upp EditDoubleNotNullSpin") ; } } diff --git a/bazaar/CtrlLibBoostPy/Progress.cpp b/bazaar/CtrlLibBoostPy/Progress.cpp index 67ff728fb..a586047ba 100644 --- a/bazaar/CtrlLibBoostPy/Progress.cpp +++ b/bazaar/CtrlLibBoostPy/Progress.cpp @@ -7,7 +7,7 @@ void export_Progress() { ONCELOCK { - class_, Progress, boost::noncopyable>("Progress", "Upp Progress", no_init) + class_, boost::noncopyable>("Progress", "Upp Progress") .add_property("pos", &Progress::GetPos, &Progress::SetPos) .add_property("total", &Progress::GetTotal, &Progress::SetTotal) .add_property("text", &Progress::GetText, (void (Progress::*)(const String&))&Progress::SetText) diff --git a/bazaar/CtrlLibBoostPy/SliderCtrl.cpp b/bazaar/CtrlLibBoostPy/SliderCtrl.cpp index 9bf401527..bdcd89bf4 100644 --- a/bazaar/CtrlLibBoostPy/SliderCtrl.cpp +++ b/bazaar/CtrlLibBoostPy/SliderCtrl.cpp @@ -7,7 +7,7 @@ void export_SliderCtrl() { ONCELOCK { - class_, SliderCtrl, boost::noncopyable>("SliderCtrl", "Upp SliderCtrl", no_init) + class_, boost::noncopyable>("SliderCtrl", "Upp SliderCtrl") .def("inc", &SliderCtrl::Inc) .def("dec", &SliderCtrl::Dec) .def("step", &SliderCtrl::GetStep) diff --git a/bazaar/CtrlLibBoostPy/ValueCtrl.cpp b/bazaar/CtrlLibBoostPy/ValueCtrl.cpp index 45c18308c..3aa12cde9 100644 --- a/bazaar/CtrlLibBoostPy/ValueCtrl.cpp +++ b/bazaar/CtrlLibBoostPy/ValueCtrl.cpp @@ -7,7 +7,7 @@ void export_ValueCtrl() { ONCELOCK { - class_, ValueCtrl, boost::noncopyable>("ValueCtrl", "Upp ValueCtrl", no_init) + class_, boost::noncopyable>("ValueCtrl", "Upp ValueCtrl") ; } }