From tegan at gnometank.net Sun Sep 2 01:07:47 2007 From: tegan at gnometank.net (Matt Holmes) Date: Sat, 01 Sep 2007 18:07:47 -0500 Subject: [C++-sig] Object lifetime issue Message-ID: I am trying to expose one of the classes in my engine as an abstract class that is used as the base for a series of Python classes. That class is called InputCommand and is defined as such: namespace Stasis { class InputCommand { public: virtual bool execute() = 0; }; } To expose that class, I created the following wrapper: class InputCommandWrapper : public Stasis::InputCommand, public wrapper { public: bool execute() { return this->get_override("execute")(); } }; And added it to my Boost.Python module like so: class_("InputCommand") .def("execute", pure_virtual(&InputCommand::execute)); Everything seems okay so far, but then I have another class called InputManager. This class exposes a function, registerCommand, that takes a const std::string& and an InputCommand*. That classes partial defintion is: class InputManager : public Singleton public: static InputManager& getSingleton() { return *ms_Singleton; } static InputManager* getSingletonPtr() { return ms_Singleton; } InputManager(); ~InputManager(); void executeCommand(const string& cmdName); void registerCommand(const string& cmdName, InputCommand* cmd); } It is defined in the Boost.Python module as such: class_("InputManager") .def("registerCommand", &InputManager::registerCommand, with_custodian_and_ward_postcall<1, 3>()) .def("getSingleton", &InputManager::getSingleton, return_value_policy()).staticmethod("getSingleton"); I am executing the follwing Python script, which should create an instance of the QuitCommand object, pass it to the InputManagers::registerCommand method, which will store that command object and use it to execute the given command later (which is implemented in Python). The issue is that when I call the execute() method of my store InputCommand*, my program crashes. From what I can tell it's because Python is destroying the object I created in the Python script below to pass to registerCommand. I thought with_custodian_and_ward<1, 3> (the custodian should be 'this', the InputManader, and the ward should be the InputCommand sub-class object) would stop the Python GC from destroying it, but I guess I was wrong. Here is the Python script: from engine import * class QuitCommand(InputCommand): def execute(self): Kernel.getSingleton().shutdown() if __name__ == "__main__": InputManager.getSingleton().registerCommand("Quit", QuitCommand()) What am I doing wrong here? What do I need to do to tell Python "The QuitCommand() object I just created, don't destroy it, something else is holding a reference to it"? From lloyd at fusion.net.nz Mon Sep 3 03:21:58 2007 From: lloyd at fusion.net.nz (Lloyd Weehuizen) Date: Mon, 3 Sep 2007 13:21:58 +1200 Subject: [C++-sig] Strange problem with boost::python::scope Message-ID: <7170F7DD-582F-4930-8992-04B71FC37D08@fusion.net.nz> Hi There I've run into an issue with the scope object that I don't understand. I'm trying to defined class Y under class X similar to the scoping examples as follows: // No code, just a place holder class for scoping class ElementNamespace {}; // Class with implementation class DataGrid { }; python::scope element_scope( python::class_< ElementNamespace, boost::noncopyable >( "element", python::no_init ) ); python::class_< DataGrid, ElementWrapper< DataGrid >, boost::noncopyable, python::bases< Element > >("DataGrid", python::init< const char* >()) ... ; I then try to inherit from DataGrid in python code as follows: class CustomDataGrid(testmodule.element.DataGrid): def __init__(self, tag): testmodule.element.DataGrid.__init__(self, tag) And I get the following error: Traceback (most recent call last): File "c:\projects\testmodule\datagrid.py", line 6, in __init__ testmodule.element.DataGrid.__init__(self, tag) AttributeError: 'module' object has no attribute 'DataGrid' Strangely enough the CustomDataGrid class inheritance finds the object correctly, but calling the base initializer fails. Any ideas? Thanks, Lloyd From achim-bpl at mol-net.com Mon Sep 3 11:02:04 2007 From: achim-bpl at mol-net.com (Achim H.) Date: Mon, 3 Sep 2007 11:02:04 +0200 Subject: [C++-sig] Object lifetime issue In-Reply-To: References: Message-ID: <200709031102.05246.achim-bpl@mol-net.com> Hi, I had a similar problem and all I could come up with was this memory-leaking approach using Py_INCREF(). Please note that I don't use the copy ctor but a special duplicate() function that creates a new object and does not make a copy: template boost::python::object getOwner(T* tp) { using namespace boost::python; // see http://article.gmane.org/gmane.comp.python.c++/9530 return object ( handle<> ( borrowed ( detail::wrapper_base_::get_owner(*tp)))); } /* virtual */ Base* BaseWrapper::duplicate() const { BaseWrapper* orig = const_cast(this); object self = getOwner(orig); object OBJ = self.attr("__class__"); object o = OBJ(); // ctor call BaseWrapper& obj = extract(o); BaseWrapper* dup = &obj; Py_INCREF(o.ptr()); return dup; } It is still a kludge - maybe somebody else can propose a cleaner solution. I'd be very interested. Achim. Am Sonntag 02 September 2007 schrieb Matt Holmes: > I am trying to expose one of the classes in my engine as an abstract > class that is used as the base for a series of Python classes. > > That class is called InputCommand and is defined as such: > namespace Stasis { > class InputCommand { > public: > virtual bool execute() = 0; > }; > } > > To expose that class, I created the following wrapper: > > class InputCommandWrapper : public Stasis::InputCommand, public > wrapper { > public: > bool execute() { > return this->get_override("execute")(); > } > }; > > And added it to my Boost.Python module like so: > > class_("InputCommand") > .def("execute", pure_virtual(&InputCommand::execute)); > > Everything seems okay so far, but then I have another class called > InputManager. This class exposes a function, registerCommand, that takes > a const std::string& and an InputCommand*. That classes partial > defintion is: > > class InputManager : public Singleton > public: > static InputManager& getSingleton() { return *ms_Singleton; } > static InputManager* getSingletonPtr() { return ms_Singleton; } > > InputManager(); > ~InputManager(); > > void executeCommand(const string& cmdName); > void registerCommand(const string& cmdName, InputCommand* cmd); > } > > It is defined in the Boost.Python module as such: > > class_("InputManager") > .def("registerCommand", &InputManager::registerCommand, > with_custodian_and_ward_postcall<1, 3>()) > .def("getSingleton", &InputManager::getSingleton, > return_value_policy()).staticmethod("getSingleto >n"); > > I am executing the follwing Python script, which should create an > instance of the QuitCommand object, pass it to the > InputManagers::registerCommand method, which will store that command > object and use it to execute the given command later (which is > implemented in Python). The issue is that when I call the execute() > method of my store InputCommand*, my program crashes. From what I can > tell it's because Python is destroying the object I created in the > Python script below to pass to registerCommand. I thought > with_custodian_and_ward<1, 3> (the custodian should be 'this', the > InputManader, and the ward should be the InputCommand sub-class object) > would stop the Python GC from destroying it, but I guess I was wrong. > > Here is the Python script: > > from engine import * > > class QuitCommand(InputCommand): > def execute(self): > Kernel.getSingleton().shutdown() > > if __name__ == "__main__": > InputManager.getSingleton().registerCommand("Quit", QuitCommand()) > > What am I doing wrong here? What do I need to do to tell Python "The > QuitCommand() object I just created, don't destroy it, something else is > holding a reference to it"? > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig From meine at informatik.uni-hamburg.de Mon Sep 3 11:51:00 2007 From: meine at informatik.uni-hamburg.de (Hans Meine) Date: Mon, 3 Sep 2007 11:51:00 +0200 Subject: [C++-sig] Object lifetime issue In-Reply-To: References: Message-ID: <200709031151.01513.meine@informatik.uni-hamburg.de> Am Sonntag, 02. September 2007 01:07:47 schrieb Matt Holmes: > I am trying to expose one of the classes in my engine as an abstract > class that is used as the base for a series of Python classes. > > That class is called InputCommand and is defined as such: > namespace Stasis { > class InputCommand { > public: > virtual bool execute() = 0; > }; > } My compiler warns me in such cases that you have a virtual function, but no virtual destructor (IIRC Scott Meyers' effective C++ has a section on that). Don't know if that's related, but note that no destructor of derived classes can be guaranteed to be called from C++. Ciao, / / /--/ / / ANS From Mark.English at rbccm.com Mon Sep 3 11:55:40 2007 From: Mark.English at rbccm.com (English, Mark) Date: Mon, 3 Sep 2007 10:55:40 +0100 Subject: [C++-sig] Object lifetime issue Message-ID: > -----Original Message----- > From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org]On > Behalf Of Matt Holmes > Sent: 02 September 2007 00:08 > To: c++-sig at python.org > Subject: [C++-sig] Object lifetime issue > > > I am trying to expose one of the classes in my engine as an abstract > class that is used as the base for a series of Python classes. > > > > I am executing the follwing Python script, which should create an > instance of the QuitCommand object, pass it to the > InputManagers::registerCommand method, which will store that command > object and use it to execute the given command later (which is > implemented in Python). The issue is that when I call the execute() > method of my store InputCommand*, my program crashes. From what I can > tell it's because Python is destroying the object I created in the > Python script below to pass to registerCommand. I thought > with_custodian_and_ward<1, 3> (the custodian should be 'this', the > InputManader, and the ward should be the InputCommand > sub-class object) > would stop the Python GC from destroying it, but I guess I was wrong. > Would any of the other return policies be of any use either directly or as example code ? For example "return_internal_reference" which inherits from "with_custodian_and_ward_postcall" ? Also, sys.getrefcount() may help you if you haven't seen it already, and also various debug build options for the python interpreter. MarkE ________________________________________ This E-Mail (including any attachments) may contain privileged or confidential information. It is intended only for the addressee(s) indicated above. The sender does not waive any of its rights, privileges or other protections respecting this information. Any distribution, copying or other use of this E-Mail or the information it contains, by other than an intended recipient, is not sanctioned and is prohibited. If you received this E-Mail in error, please delete it and advise the sender (by return E-Mail or otherwise) immediately. This E-Mail (including any attachments) has been scanned for viruses. It is believed to be free of any virus or other defect that might affect any computer system into which it is received and opened. However, it is the responsibility of the recipient to ensure that it is virus free. The sender accepts no responsibility for any loss or damage arising in any way from its use. E-Mail received by or sent from RBC Capital Markets is subject to review by Supervisory personnel. Such communications are retained and may be produced to regulatory authorities or others with legal rights to the information. IRS CIRCULAR 230 NOTICE: TO COMPLY WITH U.S. TREASURY REGULATIONS, WE ADVISE YOU THAT ANY U.S. FEDERAL TAX ADVISE INCLUDED IN THIS COMMUNICATION IS NOT INTENDED OR WRITTEN TO BE USED, AND CANNOT BE USED, TO AVOID ANY U.S. FEDERAL TAX PENALTIES OR TO PROMOTE, MARKET, OR RECOMMEND TO ANOTHER PARTY ANY TRANSACTION OR MATTER. From roman.yakovenko at gmail.com Tue Sep 4 09:06:06 2007 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Tue, 4 Sep 2007 10:06:06 +0300 Subject: [C++-sig] Object lifetime issue In-Reply-To: References: Message-ID: <7465b6170709040006s19609effgc0c7bceb86f770ac@mail.gmail.com> On 9/2/07, Matt Holmes wrote: > > I am trying to expose one of the classes in my engine as an abstract > class that is used as the base for a series of Python classes. > > That class is called InputCommand and is defined as such: > namespace Stasis { > class InputCommand { > public: > virtual bool execute() = 0; > }; > } > > To expose that class, I created the following wrapper: > > class InputCommandWrapper : public Stasis::InputCommand, public > wrapper { > public: > bool execute() { > return this->get_override("execute")(); > } > }; > > And added it to my Boost.Python module like so: > > class_("InputCommand") > .def("execute", pure_virtual(&InputCommand::execute)); > > Everything seems okay so far, but then I have another class called > InputManager. This class exposes a function, registerCommand, that takes > a const std::string& and an InputCommand*. That classes partial > defintion is: > > class InputManager : public Singleton > public: > static InputManager& getSingleton() { return *ms_Singleton; } > static InputManager* getSingletonPtr() { return ms_Singleton; } > > InputManager(); > ~InputManager(); > > void executeCommand(const string& cmdName); > void registerCommand(const string& cmdName, InputCommand* cmd); > } Who is responsible for cmd lifetime, InputManager or somebody else? This answer is a key for correct solution. I attached 2 files that contains solution for your problem P.S. The code is not minimal, because I extracted it from Py++ unittests -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: transfer_ownership.cpp Type: text/x-c++src Size: 4836 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: transfer_ownership_to_be_exported.hpp Type: text/x-c++hdr Size: 690 bytes Desc: not available URL: From capak at inputwish.com Tue Sep 4 12:14:48 2007 From: capak at inputwish.com (Libor Capak) Date: Tue, 4 Sep 2007 12:14:48 +0200 Subject: [C++-sig] py++ na namespace Message-ID: <20070904101448.GA21592@inputwish.com> Hi, i'm learning py++ and i have following problem: c++: namespace A { void foo(); } generated file by py++ contains something like that: bp::def("foo", &A::foo); but py++ doesn't create "sub-module" A and function foo() is at "basic level". What about handle this situation this way: ? bp::handle<> m(PyModule_New("A")); bp::scope().attr("A") = m; bp::scope s = bp::object(m); def("foo", &A::foo); or did i overpass some simple solution in documentation? thanks Libor Capak From furkankuru at gmail.com Tue Sep 4 13:44:41 2007 From: furkankuru at gmail.com (Furkan Kuru) Date: Tue, 4 Sep 2007 14:44:41 +0300 Subject: [C++-sig] exposing pointers using boost Message-ID: <3a4a8f930709040444r68b8ef1dx2c688382f866b1c7@mail.gmail.com> Hello, Is there a way to expose structs containing pointers of their types? Let's say, I have a very simple doubly-linked list. struct Node { Node* next; Node* prev; int value; }; I expose it like this: class_("Node") .def_readwrite("value", &Node::value) .def_readwrite("next", &Node::next) .def_readwrite("prev", &Node::prev); When I try to access the next and prev attributes of a Node instance in python, I get this error: TypeError: No to_python (by-value) converter found for C++ type: struct Node * Thanks in advance. -- Furkan Kuru From roman.yakovenko at gmail.com Tue Sep 4 13:54:52 2007 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Tue, 4 Sep 2007 14:54:52 +0300 Subject: [C++-sig] py++ na namespace In-Reply-To: <20070904101448.GA21592@inputwish.com> References: <20070904101448.GA21592@inputwish.com> Message-ID: <7465b6170709040454n2ad9fba6ufda015286f363313@mail.gmail.com> On 9/4/07, Libor Capak wrote: > > Hi, > > i'm learning py++ and i have following problem: > > c++: > > namespace A { void foo(); } > > generated file by py++ contains something like that: > > bp::def("foo", &A::foo); > > but py++ doesn't create "sub-module" A and function foo() is at > "basic level". What about handle this situation this way: ? > > bp::handle<> m(PyModule_New("A")); > bp::scope().attr("A") = m; > bp::scope s = bp::object(m); > def("foo", &A::foo); > > or did i overpass some simple solution in documentation? Basically Boost.Python doesn't provide this functionality, so Py++. I remember there were some problems to expose namespaces, this way. Take a look on next link: http://www.boost.org/libs/python/doc/tutorial/doc/html/python/techniques.html#python.creating_packages -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From roman.yakovenko at gmail.com Tue Sep 4 14:03:58 2007 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Tue, 4 Sep 2007 15:03:58 +0300 Subject: [C++-sig] exposing pointers using boost In-Reply-To: <3a4a8f930709040444r68b8ef1dx2c688382f866b1c7@mail.gmail.com> References: <3a4a8f930709040444r68b8ef1dx2c688382f866b1c7@mail.gmail.com> Message-ID: <7465b6170709040503s5b93b0dbsf285a5bbb096d8b5@mail.gmail.com> On 9/4/07, Furkan Kuru wrote: > > Hello, > > Is there a way to expose structs containing pointers of their types? There is another problem here Let's say, I have a very simple doubly-linked list. > > struct Node { > Node* next; > Node* prev; > int value; > }; > > I expose it like this: > > class_("Node") > .def_readwrite("value", &Node::value) > .def_readwrite("next", &Node::next) > .def_readwrite("prev", &Node::prev); > > When I try to access the next and prev attributes of a Node instance in > python, > I get this error: > > TypeError: No to_python (by-value) converter found for C++ type: struct > Node * If you would have access to Py++, it would generate the right code for you. Here is cut and paste of the relevant code from the unittests: struct tree_node_t{ ... tree_node_t *left; ... }; struct tree_node_t_wrapper : tree_node_t, bp::wrapper< tree_node_t > { ... static tree_node_t * get_right(tree_node_t const & inst ){ return inst.right; } static void set_right( tree_node_t & inst, tree_node_t * new_value ){ inst.right = new_value; } }; { //::tree_node_t typedef bp::class_< tree_node_t_wrapper > tree_node_t_exposer_t; tree_node_t_exposer_t tree_node_t_exposer = tree_node_t_exposer_t( "tree_node_t", "documentation", bp::init< bp::optional< member_variables::pointers::tree_node_t const * > >(( bp::arg("parent")=bp::object() ), "documentation") ); bp::scope tree_node_t_scope( tree_node_t_exposer ); tree_node_t_exposer.add_property( "right" , bp::make_function( (::tree_node_t * (*)( ::tree_node_t const & ))(&tree_node_t_wrapper::get_right), bp::return_internal_reference< >() ) , bp::make_function( (void (*)( ::tree_node_t &,::tree_node_t * ))(&tree_node_t_wrapper::set_right), bp::with_custodian_and_ward_postcall< 1, 2 >() )); } Pay attention to used call policies. They are very important. HTH -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From meine at informatik.uni-hamburg.de Tue Sep 4 14:12:29 2007 From: meine at informatik.uni-hamburg.de (Hans Meine) Date: Tue, 4 Sep 2007 14:12:29 +0200 Subject: [C++-sig] py++ na namespace In-Reply-To: <20070904101448.GA21592@inputwish.com> References: <20070904101448.GA21592@inputwish.com> Message-ID: <200709041412.30075.meine@informatik.uni-hamburg.de> Am Dienstag, 04. September 2007 12:14:48 schrieb Libor Capak: > but py++ doesn't create "sub-module" A and function foo() is at > "basic level". What about handle this situation this way: ? > > bp::handle<> m(PyModule_New("A")); > bp::scope().attr("A") = m; > bp::scope s = bp::object(m); > def("foo", &A::foo); What about pickling? Does that work or do you get "XY is not found as 'foo'" or similar? -- Ciao, / / /--/ / / ANS From roberto.delfiore at srlabs.it Tue Sep 4 16:01:45 2007 From: roberto.delfiore at srlabs.it (Roberto Delfiore) Date: Tue, 04 Sep 2007 16:01:45 +0200 Subject: [C++-sig] Problems building boost.python with python-debugging Message-ID: <46DD6549.90900@srlabs.it> I'm developing a C++ Windows Application using VC++ 2005, I need to have a version of boost.python that uses only debug runtime environment. Python25.dll needs msvcrt.dll release runtime environment. Being a big project, in debug build I've problems mixing debug and release dlls runtime environments. - I've rebuild python in debug (python_d) using Visual Studio. - I've created "user-config.jam" file in my home dir, the file content is: using python : 2.5 : F:\\src\\custom_python-vc80-2_5 : # includes : # libs : on ; - I've rebuild boost-python using bjam toolset=msvc --debug-configuration This generates a link error: "undefined symbol Py_InitModule4" In python 2.5 sources Include/modsupport.h - I've commented out: #define Py_InitModule4 Py_InitModule4TraceRefs Why boost.python build doesn't know that using "python debugging", Py_InitModule4 is renamed???? - I've rebuild boost-python Linking OK!! - In my Application I've used preprocessor define BOOST_DEBUG_PYTHON Always looking to run correctly but first time I call: Py_Initialize(); I've an assert error: assert((op->_ob_prev == NULL) == (op->_ob_next == NULL)); in In python 2.5 sources Objects/object.c: void _Py_AddToAllObjects(PyObject *op, int force) I guess that the op->_ob_next is not correctly initialized!! In release the application run correctly!! How can I solve this problem? Is it possible to use boost python without python_d Py_TRACE_REFS? (Now if I disable Py_TRACE_REFS I get undefined symbols, linking my application that use boost-python with python debug and BOOST_DEBUG_PYTHON) My only need is to use boost.python without release runtime environments dll in my debug application mode. Thanks Regards, Roberto Delfiore From dave at boost-consulting.com Tue Sep 4 19:02:39 2007 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 04 Sep 2007 13:02:39 -0400 Subject: [C++-sig] Strange problem with boost::python::scope References: <7170F7DD-582F-4930-8992-04B71FC37D08@fusion.net.nz> Message-ID: <87tzqaxt1s.fsf@grogan.peloton> on Sun Sep 02 2007, Lloyd Weehuizen wrote: > I then try to inherit from DataGrid in python code as follows: > > class CustomDataGrid(testmodule.element.DataGrid): > def __init__(self, tag): > testmodule.element.DataGrid.__init__(self, tag) > > And I get the following error: > Traceback (most recent call last): > File "c:\projects\testmodule\datagrid.py", line 6, in __init__ > testmodule.element.DataGrid.__init__(self, tag) > AttributeError: 'module' object has no attribute 'DataGrid' > > Strangely enough the CustomDataGrid class inheritance finds the > object correctly, but calling the base initializer fails. > > Any ideas? I'm afraid not. Your best bet is to debug python itself in Visual Studio (I'm assuming you're on VC++) and find out where the exception is being thrown. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com From dave at boost-consulting.com Tue Sep 4 19:05:57 2007 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 04 Sep 2007 13:05:57 -0400 Subject: [C++-sig] Problems building boost.python with python-debugging References: <46DD6549.90900@srlabs.it> Message-ID: <87odgixswa.fsf@grogan.peloton> on Tue Sep 04 2007, Roberto Delfiore wrote: > I'm developing a C++ Windows Application using VC++ 2005, I need to have > a version of boost.python that uses only debug runtime environment. > Python25.dll needs msvcrt.dll release runtime environment. > Being a big project, in debug build I've problems mixing debug and > release dlls runtime environments. > > - I've rebuild python in debug (python_d) using Visual Studio. > > - I've created "user-config.jam" file in my home dir, the file content is: > using python : 2.5 : F:\\src\\custom_python-vc80-2_5 > : # includes > : # libs > : on ; > > - I've rebuild boost-python using bjam toolset=msvc --debug-configuration > This generates a link error: > "undefined symbol Py_InitModule4" That's because you didn't turn python-debugging on for that build. Try bjam toolset=msvc python-debugging=on --debug-configuration > In python 2.5 sources Include/modsupport.h > - I've commented out: > #define Py_InitModule4 Py_InitModule4TraceRefs Whoa, never modify the Python sources. > Why boost.python build doesn't know that using "python debugging", > Py_InitModule4 is renamed???? > > - I've rebuild boost-python > Linking OK!! You broke modsupport.h, and you shouldn't expect anything to work from here on, even if linking succeeds. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com From ndbecker2 at gmail.com Tue Sep 4 19:11:55 2007 From: ndbecker2 at gmail.com (Neal Becker) Date: Tue, 04 Sep 2007 13:11:55 -0400 Subject: [C++-sig] signature indentation breaks epydoc Message-ID: C++ signature generation has incorrect indentation. This breaks epydoc. Here is an example: perm_corr(...) correlate a permuted input. @param in: input. @type in: vector_Complex @param perm: permutation mapping of input @type perm: vector_int @param coef: reference pattern @type coef: vector_Complex @param size: size of the output desired @type size: int @param stride: stride for input (def=1) @type stride: int C++ signature: perm_corr(boost::numeric::ublas::vector, boost::numeric::ublas::unbounded_array, std::allocator > > > in, boost::numeric::ublas::vector > > perm, boost::numeric::ublas::vector, boost::numeric::ublas::unbounded_array, std::allocator > > > coef, int size, int stride=1) -> boost::numeric::ublas::vector, boost::numeric::ublas::unbounded_array, std::allocator > > > The indentation on that last line screws up epydoc. Can we fix this? From meine at informatik.uni-hamburg.de Wed Sep 5 11:14:18 2007 From: meine at informatik.uni-hamburg.de (Hans Meine) Date: Wed, 5 Sep 2007 11:14:18 +0200 Subject: [C++-sig] signature indentation breaks epydoc In-Reply-To: References: Message-ID: <200709051114.19199.meine@informatik.uni-hamburg.de> Am Dienstag, 04. September 2007 19:11:55 schrieb Neal Becker: > C++ signature generation has incorrect indentation. This breaks epydoc. Why, what is the error? I am using epydoc with reST and it gets nicely recognized as a description this way. (After changing BPL to prepend a \n.) If you need changes for epytext support, they should not break reST / should be made optional via docstring_options. (In the end, it would be best anyhow to have a proper API for introspection from Python, e.g. http://www.python.org/dev/peps/pep-0362/ ) -- Ciao, / / /--/ / / ANS From roberto.delfiore at srlabs.it Wed Sep 5 11:20:39 2007 From: roberto.delfiore at srlabs.it (Roberto Delfiore) Date: Wed, 05 Sep 2007 11:20:39 +0200 Subject: [C++-sig] Problems building boost.python with python-debugging In-Reply-To: <87odgixswa.fsf@grogan.peloton> References: <46DD6549.90900@srlabs.it> <87odgixswa.fsf@grogan.peloton> Message-ID: <46DE74E7.9030709@srlabs.it> David Abrahams wrote: > on Tue Sep 04 2007, Roberto Delfiore wrote: > > >> I'm developing a C++ Windows Application using VC++ 2005, I need to have >> a version of boost.python that uses only debug runtime environment. >> Python25.dll needs msvcrt.dll release runtime environment. >> Being a big project, in debug build I've problems mixing debug and >> release dlls runtime environments. >> >> - I've rebuild python in debug (python_d) using Visual Studio. >> >> - I've created "user-config.jam" file in my home dir, the file content is: >> using python : 2.5 : F:\\src\\custom_python-vc80-2_5 >> : # includes >> : # libs >> : on ; >> >> - I've rebuild boost-python using bjam toolset=msvc --debug-configuration >> This generates a link error: >> "undefined symbol Py_InitModule4" >> > > That's because you didn't turn python-debugging on for that build. > Try > > bjam toolset=msvc python-debugging=on --debug-configuration > Everything run correctly now. I've thought reading documentation that specifying on in user-config.jam and watching during build: notice: [python-cfg] user-specified condition: "on" configured the build to python-debugging. Ok, bjam Boost.python build is independent by its Python configuration. Thanks a lot. From ndbecker2 at gmail.com Wed Sep 5 12:53:04 2007 From: ndbecker2 at gmail.com (Neal Becker) Date: Wed, 05 Sep 2007 06:53:04 -0400 Subject: [C++-sig] signature indentation breaks epydoc References: <200709051114.19199.meine@informatik.uni-hamburg.de> Message-ID: Hans Meine wrote: > Am Dienstag, 04. September 2007 19:11:55 schrieb Neal Becker: >> C++ signature generation has incorrect indentation. This breaks epydoc. > Why, what is the error? > > I am using epydoc with reST and it gets nicely recognized as a description > this way. (After changing BPL to prepend a \n.) > What change did you make? Can you send a patch? Do you have an example of using epydoc with reST with boost::python code? From meine at informatik.uni-hamburg.de Wed Sep 5 13:09:58 2007 From: meine at informatik.uni-hamburg.de (Hans Meine) Date: Wed, 5 Sep 2007 13:09:58 +0200 Subject: [C++-sig] signature indentation breaks epydoc In-Reply-To: References: <200709051114.19199.meine@informatik.uni-hamburg.de> Message-ID: <200709051309.58570.meine@informatik.uni-hamburg.de> Am Mittwoch, 05. September 2007 12:53:04 schrieb Neal Becker: > Hans Meine wrote: > > Am Dienstag, 04. September 2007 19:11:55 schrieb Neal Becker: > >> C++ signature generation has incorrect indentation. This breaks epydoc. > > > > Why, what is the error? > > > > I am using epydoc with reST and it gets nicely recognized as a > > description this way. (After changing BPL to prepend a \n.) > > What change did you make? Prepending \n before the "C++ signature:" > Can you send a patch? It was integrated by Ralf (see the "Better introspection/apidoc extraction support?" thread). -- Ciao, / / /--/ / / ANS From furkankuru at gmail.com Wed Sep 5 15:00:17 2007 From: furkankuru at gmail.com (Furkan Kuru) Date: Wed, 5 Sep 2007 16:00:17 +0300 Subject: [C++-sig] exposing pointers using boost In-Reply-To: <7465b6170709040503s5b93b0dbsf285a5bbb096d8b5@mail.gmail.com> References: <3a4a8f930709040444r68b8ef1dx2c688382f866b1c7@mail.gmail.com> <7465b6170709040503s5b93b0dbsf285a5bbb096d8b5@mail.gmail.com> Message-ID: <3a4a8f930709050600v1d7b7ba4s22a46943046b4c54@mail.gmail.com> My team-mate offered a shorter way adding Node* while exposing the class Node: class_("Node") .def_readwrite("value", &Node::value) .def_readwrite("next", &Node::next) .def_readwrite("prev", &Node::prev); On 9/4/07, Roman Yakovenko wrote: > On 9/4/07, Furkan Kuru wrote: > > Hello, > > > > Is there a way to expose structs containing pointers of their types? > > There is another problem here > > > Let's say, I have a very simple doubly-linked list. > > > > struct Node { > > Node* next; > > Node* prev; > > int value; > > }; > > > > I expose it like this: > > > > class_("Node") > > .def_readwrite("value", &Node::value) > > .def_readwrite("next", &Node::next) > > .def_readwrite("prev", &Node::prev); > > > > When I try to access the next and prev attributes of a Node instance in > python, > > I get this error: > > > > TypeError: No to_python (by-value) converter found for C++ type: struct > Node * > > > If you would have access to Py++, it would generate the right code for you. > > Here is cut and paste of the relevant code from the unittests: > > > struct tree_node_t{ > ... > tree_node_t *left; > ... > }; > > struct tree_node_t_wrapper : tree_node_t, bp::wrapper< tree_node_t > { > ... > > static tree_node_t * get_right(tree_node_t const & inst ){ > return inst.right; > } > > static void set_right( tree_node_t & inst, tree_node_t * new_value ){ > inst.right = new_value; > } > > }; > > > { //::tree_node_t > typedef bp::class_< tree_node_t_wrapper > tree_node_t_exposer_t; > tree_node_t_exposer_t tree_node_t_exposer = tree_node_t_exposer_t( > "tree_node_t", "documentation", bp::init< bp::optional< > member_variables::pointers::tree_node_t const * > >(( > bp::arg("parent")=bp::object() ), "documentation") ); > bp::scope tree_node_t_scope( tree_node_t_exposer ); > tree_node_t_exposer.add_property( "right" > , bp::make_function( (::tree_node_t * (*)( ::tree_node_t > const & ))(&tree_node_t_wrapper::get_right), > bp::return_internal_reference< >() ) > , bp::make_function( (void (*)( ::tree_node_t > &,::tree_node_t * ))(&tree_node_t_wrapper::set_right), > bp::with_custodian_and_ward_postcall< 1, 2 >() )); > } > > Pay attention to used call policies. They are very important. > > HTH > > -- > Roman Yakovenko > C++ Python language binding > http://www.language-binding.net/ > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > > -- Furkan Kuru From ndbecker2 at gmail.com Thu Sep 6 14:30:05 2007 From: ndbecker2 at gmail.com (Neal Becker) Date: Thu, 06 Sep 2007 08:30:05 -0400 Subject: [C++-sig] python-3k Message-ID: Anyone looking at the impact of python-3k? From rwgk at yahoo.com Thu Sep 6 23:20:44 2007 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 6 Sep 2007 14:20:44 -0700 (PDT) Subject: [C++-sig] python-3k Message-ID: <236878.80863.qm@web31104.mail.mud.yahoo.com> I didn't get very far because even print "hello world" doesn't work anymore in Python 3. Therefore I cannot use our build system and all the Boost.Python unit tests will also be broken. I decided it is best to wait for Python 2.6 and to follow the transition path as outlined here: http://www.python.org/dev/peps/pep-3000/#compatibility-and-transition Also, it may take a while before it is worth the effort. I couldn't find anything new in Python 3 that would be worth giving up backward compatibility, or maintaining two versions of everything. Python 3 mainly seems to be a big cleanup at this stage. Ralf ____________________________________________________________________________________ Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out. http://answers.yahoo.com/dir/?link=list&sid=396545469 -------------- next part -------------- An HTML attachment was scrubbed... URL: From ndbecker2 at gmail.com Fri Sep 7 12:56:50 2007 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 07 Sep 2007 06:56:50 -0400 Subject: [C++-sig] PEP-362 (function signature) Message-ID: FYI, Brett Cannon has a post on python-dev regarding moving forward on pep-362. From martin.rosekeit at freenet.de Fri Sep 7 15:16:55 2007 From: martin.rosekeit at freenet.de (Martin Rosekeit) Date: Fri, 07 Sep 2007 15:16:55 +0200 Subject: [C++-sig] Problems with compiling with 'Hello World' from Boost::python Message-ID: <46E14F47.7000104@freenet.de> Moin, moin, group, I have problems to compile the 'Hello World' from Boost::python (http://www.boost.org/libs/python/doc/tutorial/doc/html/index.html). When I start bjam I get the following error message: $ bjam error: Could not find parent for project at '.' error: Did not find Jamfile or project-root.jam in any parent directory. My test-folder: ~/temp$ ls hellp.cpp Jamfile Jamrules My Jamfile: # This is the top of our own project tree project-root ; import python ; extension hello # Declare a Python extension called hello : hello.cpp # source # requirements and dependencies for Boost.Python extensions