From s_sourceforge at nedprod.com Wed Jun 1 16:32:06 2005 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Wed, 01 Jun 2005 15:32:06 +0100 Subject: [C++-sig] Pyste's AllFromHeader() Message-ID: <429DD4F6.22635.894F478@localhost> How's that function looking now in pyste? It is fully working yet? I was strongly thinking of finishing off TnFOX's python bindings and for that we'll need AllFromHeader() working, or at least 98% working. Cheers, Niall From nicodemus at esss.com.br Wed Jun 1 17:08:49 2005 From: nicodemus at esss.com.br (Nicodemus) Date: Wed, 01 Jun 2005 12:08:49 -0300 Subject: [C++-sig] Pyste's AllFromHeader() In-Reply-To: <429DD4F6.22635.894F478@localhost> References: <429DD4F6.22635.894F478@localhost> Message-ID: <429DCF81.2090408@esss.com.br> Hi Niall, It does work in most cases, but it has some problems regarding finding the correct relationship between classes and subclasses when AllFromHeader is used. The fix for this is complicated, because of the --multiple support and the ability of spreading the bindings over several source files, so I have no plans to fix this in the near future, sorry. :( Regards, Bruno. Niall Douglas wrote: >How's that function looking now in pyste? It is fully working yet? I >was strongly thinking of finishing off TnFOX's python bindings and >for that we'll need AllFromHeader() working, or at least 98% working. > >Cheers, >Niall > > > >_______________________________________________ >C++-sig mailing list >C++-sig at python.org >http://mail.python.org/mailman/listinfo/c++-sig > > > From skottmckay at gmail.com Thu Jun 2 03:04:17 2005 From: skottmckay at gmail.com (Scott McKay) Date: Wed, 1 Jun 2005 19:04:17 -0600 Subject: [C++-sig] custom smart pointer, vector_indexing_suite typeerror Message-ID: <51d01787050601180429bc001e@mail.gmail.com> Is the following possible or am I doing something wrongly? I have a custom smart pointer, and an abstract base class that is wrapped specifying smart_ptr as the HeldType, as I want to treat the object as if it's automatically wrapped with a smart_ptr. I then have a std::vector> exposed using the vector_indexing_suite with proxying turned off. Basically something along these lines... struct X_Wrapper: X { X_Wrapper(PyObject* py_self_): X(), py_self(py_self_) {} X& run() { return call_method< X& >(py_self, "run"); } } class_< X, X_Wrapper, boost::noncopyable, smart_ptr< X > >("X", init<>()) .def("run", pure_virtual(&X::run), return_self<>()) ; class_< std::vector< smart_ptr > > ( "vector_X" ) .def( vector_indexing_suite< std::vector< smart_ptr >, true >() ) ; Then in the python code I want to implement the X interface and add the python object that does so to the vector. class testX( X ): def run( self ): print "run" return self tester = testX() vector = vector_X() vector.append( tester ) Doing so leads to a type error in the append (from the base_append of the vector_indexing_suite). The object type is a 'testX', which I thought would be held as a smart_ptr under the covers and hence would be convertible, but I guess that isn't the case. As the vector takes a non-const I thought it was necessary to use the HeldType rather than register_ptr_to_python. Is there a way to make this work? I'm not sure I have everything setup correctly though, so perhaps I'm missing a piece. Thanks for any help. Scott From skottmckay at gmail.com Thu Jun 2 04:28:34 2005 From: skottmckay at gmail.com (Scott McKay) Date: Wed, 1 Jun 2005 20:28:34 -0600 Subject: [C++-sig] custom smart pointer, vector_indexing_suite typeerror In-Reply-To: <51d01787050601180429bc001e@mail.gmail.com> References: <51d01787050601180429bc001e@mail.gmail.com> Message-ID: <51d017870506011928538aecc3@mail.gmail.com> After some experimentation/review I think this > class_< X, X_Wrapper, boost::noncopyable, smart_ptr< X > >("X", init<>()) > .def("run", pure_virtual(&X::run), return_self<>()) > ; should be class_ >("X", init<>()) ... However doing so still results in a TypeError. Now if I make it a vector of boost::shared_ptr's, I can append a testX to it, so I'm thinking it may be due to the 'smart' pointer class not being able to handle the conversion between X_Wrapper and X. Could that be the case? Thanks S From aashish at iastate.edu Thu Jun 2 07:13:00 2005 From: aashish at iastate.edu (aashish at iastate.edu) Date: Thu, 2 Jun 2005 00:13:00 -0500 (CDT) Subject: [C++-sig] _POSIX_C_SOURCE redefinition warning with python 2.3and boost-1.31.0 Message-ID: <2978.68.108.219.106.1117689180.squirrel@mail.eng.iastate.edu> Hi, I am using one of the library which uses Boost. When I was trying to compile boost on my linux (fedora core 3) machine I was getting warnings about POSIX_C_SOURCE redefinition. I found this post http://lists.boost.org/MailArchives/boost/msg61875.php and I believe that I need to check out cvs version but not exactly sure which branch I have to check out (for verison 1.31.0). I have to use boost 1.31.0 to make this library work (an older version). My system is: Fedora core 3 python 2.3.5 boost 1.31.0 Thanks for your help. ~Regards, Ashish ----------------------------------------------- Aashish Chaudhary Technical Programmer, PRISM Email: ashish_cy at yahoo.com Ph: (480) 275-0755 ----------------------------------------------- From dave at boost-consulting.com Thu Jun 2 18:10:17 2005 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 02 Jun 2005 12:10:17 -0400 Subject: [C++-sig] custom smart pointer, vector_indexing_suite typeerror References: <51d01787050601180429bc001e@mail.gmail.com> Message-ID: Scott McKay writes: > Is the following possible or am I doing something wrongly? > > I have a custom smart pointer, and an abstract base class that is > wrapped specifying smart_ptr as the HeldType, as I want to treat > the object as if it's automatically wrapped with a smart_ptr. > > I then have a std::vector> exposed using the > vector_indexing_suite with proxying turned off. > > Basically something along these lines... > > struct X_Wrapper: X > { > X_Wrapper(PyObject* py_self_): > X(), py_self(py_self_) {} > > X& run() { > return call_method< X& >(py_self, "run"); > } > } You should use the new-style polymorphism support (http://www.boost.org/libs/python/doc/v2/wrapper.html) although this probably has nothing to do with your problem. > class_< X, X_Wrapper, boost::noncopyable, smart_ptr< X > >("X", init<>()) > .def("run", pure_virtual(&X::run), return_self<>()) > ; > > class_< std::vector< smart_ptr > > ( "vector_X" ) > .def( vector_indexing_suite< std::vector< smart_ptr >, true >() ) > ; > > Then in the python code I want to implement the X interface and add > the python object that does so to the vector. > > class testX( X ): > > def run( self ): > > print "run" > return self > > > tester = testX() > vector = vector_X() > vector.append( tester ) > > Doing so leads to a type error in the append (from the base_append of > the vector_indexing_suite). The object type is a 'testX', which I > thought would be held as a smart_ptr under the covers and hence > would be convertible, but I guess that isn't the case. The problem is that you're missing an __init__ function in testX. Calling the __init__ function of the base class inside it (i.e. X.__init__(self)) is what causes the held smart_ptr to be created. > As the vector takes a non-const I thought it was necessary to use the > HeldType rather than register_ptr_to_python. I'm not sure they're related. > Is there a way to make this work? I'm not sure I have everything setup > correctly though, so perhaps I'm missing a piece. I think the __init__ function will do it for you. -- Dave Abrahams Boost Consulting www.boost-consulting.com From nico_ml at mgdesign.org Thu Jun 2 18:24:09 2005 From: nico_ml at mgdesign.org (Nicolas Lelong) Date: Thu, 2 Jun 2005 18:24:09 +0200 Subject: [C++-sig] exporting __stdcall methods References: <20050308143928.36875.qmail@web31510.mail.mud.yahoo.com><422DCDCD.8090803@paniq.org> <42334D12.2020608@paniq.org><005101c52759$ee9cc030$37ce4e51@MIKESPC01> <42337D6E.2010505@paniq.org><024f01c52a4b$5caa5df0$0dc66b51@fuji> Message-ID: <110901c5678f$814a1f70$de00a8c0@nico> Hi ! as I have some time ahead, I upgraded my codebase to latest boost snapshot. I was quite surprised to see that, by default, BPL still can't export __stdcall & __fastcall functions, or, at least, I could not find anything that allows that !... I thought that it may be useful to send my patch to deal with these calling conventions... I improved somewhat the patch I used before to handle the situation a little bit like type_traits lib does, by adding two defines that should sit in BPL config.hpp : BOOST_PYTHON_ENABLE_STDCALL and BOOST_PYTHON_ENABLE_FASTCALL. I did not go on tweaking or adding a specific test, as I first wanted to have some feedback about the usefulness of such a patch and about the quality of the one I'm proposing. Any thoughts ? Regards, Nicolas. ----- Original Message ----- From: "David Abrahams" To: "John Maddock" Cc: "pysig" Sent: Thursday, March 17, 2005 4:48 PM Subject: [C++-sig] Re: exporting __stdcall methods > "John Maddock" writes: > >>> Files like boost/type_traits/detail/is_mem_fun_pointer_tester.hpp >>> which are outside the Boost.Python library would need to be enhanced >>> to deal with __stdcall, etc. >> >> Should now be fixed in cvs: provided the changes don't break anything >> else >> of course! > > Fantastic! Thanks, John! > > -- > Dave Abrahams > Boost Consulting > www.boost-consulting.com > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: stdcall_and_fastcall_patch.txt URL: From dave at boost-consulting.com Thu Jun 2 18:12:29 2005 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 02 Jun 2005 12:12:29 -0400 Subject: [C++-sig] _POSIX_C_SOURCE redefinition warning with python 2.3and boost-1.31.0 References: <2978.68.108.219.106.1117689180.squirrel@mail.eng.iastate.edu> Message-ID: aashish at iastate.edu writes: > Hi, > > I am using one of the library which uses Boost. When I was trying to compile > boost on my linux (fedora core 3) machine I was getting warnings about > POSIX_C_SOURCE redefinition. > > I found this post > > http://lists.boost.org/MailArchives/boost/msg61875.php > > and I believe that I need to check out cvs version but not exactly sure > which branch I have to check out (for verison 1.31.0). If you want version 1.31.0, get Revision_1_31_0. I don't know what relevance that has to your problem, though. -- Dave Abrahams Boost Consulting www.boost-consulting.com From skottmckay at gmail.com Thu Jun 2 18:37:22 2005 From: skottmckay at gmail.com (Scott McKay) Date: Thu, 2 Jun 2005 10:37:22 -0600 Subject: [C++-sig] custom smart pointer, vector_indexing_suite typeerror In-Reply-To: References: <51d01787050601180429bc001e@mail.gmail.com> Message-ID: <51d0178705060209375bc52494@mail.gmail.com> > You should use the new-style polymorphism support > (http://www.boost.org/libs/python/doc/v2/wrapper.html) although this > probably has nothing to do with your problem. I'll check it out. Thanks > The problem is that you're missing an __init__ function in testX. > Calling the __init__ function of the base class inside it > (i.e. X.__init__(self)) is what causes the held smart_ptr to be > created. Ahh. Didn't realize the __init__ was required to trigger that. I did have it 'working' without the init after I added an implicitly_convertible< < smart_ptr, smart_ptr >(). It would append but I hadn't verified that all the reference counting was working as expected. I will add the __init__ as well. Many thanks for your help. Scott From aashish at iastate.edu Thu Jun 2 19:16:00 2005 From: aashish at iastate.edu (aashish at iastate.edu) Date: Thu, 2 Jun 2005 12:16:00 -0500 (CDT) Subject: [C++-sig] _POSIX_C_SOURCE redefinition warning with python 2.3and boost-1.31.0 Message-ID: <57302.149.169.227.180.1117732560.squirrel@mail.eng.iastate.edu> Thanks Dave. Here is what I am getting on my console when I am trying to compile Boost. On googling I found that I am getting this warning because, of the importance of include order for Python header files. Should I ignore these warnings? or what I can do to get rid of these warnings ? Also due to unfamiliarity with CVS , I have to ask this rather stupid question. When you say Revision_1_31_0 does it mean it is a tag or branch in CVS ? I believe in Boost RC_n_n_n stands for release version and there is a separate tag Version_n_n_n. Thanks in advance. ~Ashish /usr/local/include/python2.3/pyconfig.h:856:1: warning: "_POSIX_C_SOURCE" redefined In file included from /usr/include/limits.h:26, from /usr/lib/gcc/i386-redhat-linux/3.4.3/include/limits.h:122, from /usr/lib/gcc/i386-redhat-linux/3.4.3/include/syslimits.h:7, from /usr/lib/gcc/i386-redhat-linux/3.4.3/include/limits.h:11, from /home/software/vrjuggler/cvs_version/VRJ_2_0_ALPHA_4_BRANCH/juggler_deps/source/boost/boost/python/detail/wrap_python.hpp:27, from /home/software/vrjuggler/cvs_version/VRJ_2_0_ALPHA_4_BRANCH/juggler_deps/source/boost/boost/python/detail/prefix.hpp:13, from /home/software/vrjuggler/cvs_version/VRJ_2_0_ALPHA_4_BRANCH/juggler_deps/source/boost/boost/python/type_id.hpp:9, from /home/software/vrjuggler/cvs_version/VRJ_2_0_ALPHA_4_BRANCH/juggler_deps/source/boost/boost/python/converter/registry.hpp:8, from /home/software/vrjuggler/cvs_version/VRJ_2_0_ALPHA_4_BRANCH/juggler_deps/source/boost/libs/python/build/../src/converter/registry.cpp:6: /usr/include/features.h:150:1: warning: this is the location of the previous definition From dave at boost-consulting.com Thu Jun 2 19:49:59 2005 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 02 Jun 2005 13:49:59 -0400 Subject: [C++-sig] _POSIX_C_SOURCE redefinition warning with python 2.3and boost-1.31.0 References: <57302.149.169.227.180.1117732560.squirrel@mail.eng.iastate.edu> Message-ID: aashish at iastate.edu writes: > Thanks Dave. > > Here is what I am getting on my console when I am trying to compile Boost. > > On googling I found that I am getting this warning because, of the > importance of include order for Python header files. Right. > Should I ignore these warnings? Probably not. This is a question for the Python developers really. > or what I can do to get rid of these warnings ? Boost 1.32.0 shouldn't give you the warnings. As for 1.31.0, the only thing I can suggest is that you steal boost/python/detail/prefix.hpp, boost/python/detail/wrap_python.hpp, and boost/python/detail/config.hpp from 1.32.0, and make sure you start all of your source files with #include > Also due to unfamiliarity with CVS , I have to ask this rather stupid > question. When you say Revision_1_31_0 does it mean it is a tag or branch > in CVS ? Branches are a special kind of tag; they're identified the same way. > I believe in Boost RC_n_n_n stands for release version No, it stands for release candidate. > and there is a separate tag Version_n_n_n. That's the tag for the actual release. -- Dave Abrahams Boost Consulting www.boost-consulting.com From beyer at imb-jena.de Thu Jun 2 20:11:34 2005 From: beyer at imb-jena.de (Andreas Beyer) Date: Thu, 02 Jun 2005 11:11:34 -0700 Subject: [C++-sig] _POSIX_C_SOURCE redefinition warning with python 2.3and boost-1.31.0 In-Reply-To: References: <57302.149.169.227.180.1117732560.squirrel@mail.eng.iastate.edu> Message-ID: <429F4BD6.2060209@imb-jena.de> David Abrahams wrote: >aashish at iastate.edu writes: > > > >>Thanks Dave. >> >>Here is what I am getting on my console when I am trying to compile Boost. >> >>On googling I found that I am getting this warning because, of the >>importance of include order for Python header files. >> >> > >Right. > > > >>Should I ignore these warnings? >> >> > >Probably not. This is a question for the Python developers really. > > > >>or what I can do to get rid of these warnings ? >> >> > >Boost 1.32.0 shouldn't give you the warnings. >As for 1.31.0, the only thing I can suggest is that you steal >boost/python/detail/prefix.hpp, boost/python/detail/wrap_python.hpp, >and boost/python/detail/config.hpp from 1.32.0, and make sure you >start all of your source files with > >#include > > Here is another suggested work-around. It involves changing pyconfig.h: http://mail.python.org/pipermail/c++-sig/2005-April/008776.html Maybe it is easier to apply. Are you sure you can't switch to Boost 1.32? Andreas From aashishvr2004 at yahoo.com Thu Jun 2 20:22:20 2005 From: aashishvr2004 at yahoo.com (Ashish Chaudhary) Date: Thu, 2 Jun 2005 11:22:20 -0700 (PDT) Subject: [C++-sig] _POSIX_C_SOURCE redefinition warning with python 2.3and boost-1.31.0 In-Reply-To: <429F4BD6.2060209@imb-jena.de> Message-ID: <20050602182220.20844.qmail@web30511.mail.mud.yahoo.com> Thanks again Dave and Andreas. I am giving 1.32.0 a try and yes I didn't get those warnings with this version. So now I am going to try compiling other library (VRJuVRJugglersion 2.0 alpha4 ) with new boost version. If it does not work I will try Dave's or your suggestion. Also I think I created two threads on the same subject. I am sorry about that as something went wrong with my email. ~Regards, AshiAshish --- Andreas Beyer David AbraAbrahamste: > > >aashaashishtiastate edutes: > > > > > > > >>Thanks Dave. > >> > >>Here is what I am getting on my console when I am > trying to compile Boost. > >> > >>On googgooglingound that I am getting this warning > because, of the > >>importance of include order for Python header > files. > >> > >> > > > >Right. > > > > > > > >>Should I ignore these warnings? > >> > >> > > > >Probably not. This is a question for the Python > developers really. > > > > > > > >>or what I can do to get rid of these warnings ? > >> > >> > > > >Boost 1.32.0 shouldn't give you the warnings. > >As for 1.31.0, the only thing I can suggest is that > you steal > >boost/python/detail/prefix.hpp,hpp boost/python/detail/wrap_python.hpp,hpp >and boost/python/detail/confconfig hppm 1.32.0, and > make sure you > >start all of your source files with > > > >#include hpp > > > > Here is another suggested work-around. It involves > changing pycopyconfig > httphttpail.python.org/pipepipermail-sig/sig5-April/008776.htmlhtmlMaybe it is easier to apply. > Are you sure you can't switch to Boost 1.32? > > Andreas > > _______________________________________________ > C++-sig sigling list > C++-sig at sighon.org > httphttpail.python.org/mailman/listlistinfo-sig sig __________________________________ Discover Yahoo! Use Yahoo! to plan a weekend, have fun online and more. Check it out! http://discover.yahoo.com/ From nyamatongwe at gmail.com Thu Jun 2 23:46:30 2005 From: nyamatongwe at gmail.com (Neil Hodgson) Date: Fri, 3 Jun 2005 07:46:30 +1000 Subject: [C++-sig] _POSIX_C_SOURCE redefinition warning with python 2.3and boost-1.31.0 In-Reply-To: <20050602182220.20844.qmail@web30511.mail.mud.yahoo.com> References: <429F4BD6.2060209@imb-jena.de> <20050602182220.20844.qmail@web30511.mail.mud.yahoo.com> Message-ID: <50862ebd050602144659db82c0@mail.gmail.com> These warnings went away for me when I moved #include to the top of each file rather than starting with system includes. Neil From dave at boost-consulting.com Fri Jun 3 13:56:59 2005 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 03 Jun 2005 07:56:59 -0400 Subject: [C++-sig] _POSIX_C_SOURCE redefinition warning with python 2.3and boost-1.31.0 References: <429F4BD6.2060209@imb-jena.de> <20050602182220.20844.qmail@web30511.mail.mud.yahoo.com> <50862ebd050602144659db82c0@mail.gmail.com> Message-ID: Neil Hodgson writes: > These warnings went away for me when I moved > #include > to the top of each file rather than starting with system includes. You always have to start with a Boost.Python #include if you are using Boost.Python (because Python itself imposes that rule and we have to wrap the Python.h header). I assumed the OP was doing that already. -- Dave Abrahams Boost Consulting www.boost-consulting.com From apprentice_99 at hotmail.com Sun Jun 5 10:59:19 2005 From: apprentice_99 at hotmail.com (Studious Apprentice) Date: Sun, 05 Jun 2005 08:59:19 +0000 Subject: [C++-sig] Raw member and constructor functions Message-ID: Hello ! I would like to use raw member functions and a raw constructor. However I can only manage to have raw functions to work. The following code works : #include #include using namespace boost::python; tuple raw(tuple args, dict kw) { return make_tuple(args, kw); } BOOST_PYTHON_MODULE(PythonTest) { def("raw", raw_function(raw)); } However this code does not compile with MSVC7.1 and results in "error C2064: term does not evaluate to a function taking 2 arguments" : #include #include using namespace boost::python; class X { public: object memberraw(tuple args, dict kw) { return object(); } }; BOOST_PYTHON_MODULE(PythonTest) { class_("X") .def("memberraw", raw_function(&X::memberraw)) ; } Anyone would have an idea of how to get this working ? Thanks in advance, Marc From dave at boost-consulting.com Mon Jun 6 04:30:52 2005 From: dave at boost-consulting.com (David Abrahams) Date: Sun, 05 Jun 2005 22:30:52 -0400 Subject: [C++-sig] Raw member and constructor functions References: Message-ID: "Studious Apprentice" writes: > Hello ! > > I would like to use raw member functions and a raw constructor. However I > can only manage to have raw functions to work. > > The following code works : > > #include > #include > using namespace boost::python; > > tuple raw(tuple args, dict kw) > { > return make_tuple(args, kw); > } > > BOOST_PYTHON_MODULE(PythonTest) > { > def("raw", raw_function(raw)); > } > > However this code does not compile with MSVC7.1 and results in "error C2064: > term does not evaluate to a function taking 2 arguments" : > > #include > #include > using namespace boost::python; > > class X { > public: > object memberraw(tuple args, dict kw) > { > return object(); > } > }; > > BOOST_PYTHON_MODULE(PythonTest) > { > class_("X") > .def("memberraw", raw_function(&X::memberraw)) > ; > } As http://www.boost.org/libs/python/doc/v2/raw_function.html says, f(tuple(), dict()) must be well-formed where f is the argument to raw_function. That's clearly not the case here. This might work: tuple raw(tuple raw, dict kw) { extract(raw[0])().memberraw(raw.slice(1), kw); } BOOST_PYTHON_MODULE(PythonTest) { class_("X") .def("memberraw", raw_function(raw)) ; } -- Dave Abrahams Boost Consulting www.boost-consulting.com From apprentice_99 at hotmail.com Mon Jun 6 10:32:40 2005 From: apprentice_99 at hotmail.com (Studious Apprentice) Date: Mon, 06 Jun 2005 08:32:40 +0000 Subject: [C++-sig] Raw member and constructor functions Message-ID: Thanks a lot for this fast answer ! This looks like the way to go. The following code does compile but the result under python is unexpected : #include #include using namespace boost::python; namespace { class X { public: object memberraw(const tuple& args, const dict& kw) { return make_tuple(args, kw); } }; object memberrawfwd(tuple raw, dict kw) { tuple arg = extract(raw.slice(1, _))(); return extract(raw[0])(). memberraw(arg, kw); } }; BOOST_PYTHON_MODULE(PythonTest) { class_("X") .def("memberraw", raw_function(memberrawfwd)) ; } However the following results when run with Python : >>>a = X() >>>a.memberraw() Traceback (most recent call last): File "", line 1, in ? TypeError: No registered converter was able to extract a C++ reference to type c lass boost::python::tuple from this Python object of type tuple >>> Any further help ? Thanks in advance, Marc -----Original Message----- From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] On Behalf Of David Abrahams Sent: lundi 6 juin 2005 04:31 To: c++-sig at python.org Subject: Re: [C++-sig] Raw member and constructor functions "Studious Apprentice" writes: >Hello ! > >I would like to use raw member functions and a raw constructor. However I >can only manage to have raw functions to work. > >The following code works : > >#include >#include >using namespace boost::python; > >tuple raw(tuple args, dict kw) >{ > return make_tuple(args, kw); >} > >BOOST_PYTHON_MODULE(PythonTest) >{ > def("raw", raw_function(raw)); >} > >However this code does not compile with MSVC7.1 and results in "error >C2064: term does not evaluate to a function taking 2 arguments" : > >#include >#include >using namespace boost::python; > >class X { >public: > object memberraw(tuple args, dict kw) > { > return object(); > } >}; > >BOOST_PYTHON_MODULE(PythonTest) >{ > class_("X") > .def("memberraw", raw_function(&X::memberraw)) > ; >} As http://www.boost.org/libs/python/doc/v2/raw_function.html says, f(tuple(), dict()) must be well-formed where f is the argument to raw_function. That's clearly not the case here. This might work: tuple raw(tuple raw, dict kw) { extract(raw[0])().memberraw(raw.slice(1), kw); } BOOST_PYTHON_MODULE(PythonTest) { class_("X") .def("memberraw", raw_function(raw)) ; } -- Dave Abrahams Boost Consulting www.boost-consulting.com _______________________________________________ C++-sig mailing list C++-sig at python.org http://mail.python.org/mailman/listinfo/c++-sig From dave at boost-consulting.com Mon Jun 6 12:56:04 2005 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 06 Jun 2005 06:56:04 -0400 Subject: [C++-sig] Raw member and constructor functions References: Message-ID: "Studious Apprentice" writes: > Thanks a lot for this fast answer ! This looks like the way to go. The > following code does compile but the result under python is unexpected : > > #include > #include > using namespace boost::python; > > namespace { > class X { > public: > object memberraw(const tuple& args, const dict& kw) > { > return make_tuple(args, kw); > } > }; > > object memberrawfwd(tuple raw, dict kw) > { > tuple arg = extract(raw.slice(1, _))(); Why didn't you just do it the way I told you to? Did that fail somehow? This should be tuple arg( raw.slice(1,_) ); > return extract(raw[0])(). > memberraw(arg, kw); > } > > }; > > BOOST_PYTHON_MODULE(PythonTest) > { > class_("X") > .def("memberraw", raw_function(memberrawfwd)) > ; > } -- Dave Abrahams Boost Consulting www.boost-consulting.com From apprentice_99 at hotmail.com Mon Jun 6 14:33:08 2005 From: apprentice_99 at hotmail.com (Studious Apprentice) Date: Mon, 06 Jun 2005 12:33:08 +0000 Subject: [C++-sig] Raw member and constructor functions Message-ID: Thanks again! It now works ;-) Sorry for my mistake, I modified the code because I got an conversion error at compilation from tuple to object, but the error was in the member function not in the forwarding function, so I added the extract which was indeed stupid ;-) Thanks again ! Marc "Studious Apprentice" writes: >Thanks a lot for this fast answer ! This looks like the way to go. The >following code does compile but the result under python is unexpected : > >#include >#include using namespace boost::python; > >namespace { > class X { > public: > object memberraw(const tuple& args, const dict& kw) > { > return make_tuple(args, kw); > } > }; > > object memberrawfwd(tuple raw, dict kw) > { > tuple arg = extract(raw.slice(1, _))(); Why didn't you just do it the way I told you to? Did that fail somehow? This should be tuple arg( raw.slice(1,_) ); > return extract(raw[0])(). > memberraw(arg, kw); > } > >}; > >BOOST_PYTHON_MODULE(PythonTest) >{ > class_("X") > .def("memberraw", raw_function(memberrawfwd)) > ; >} -- Dave Abrahams Boost Consulting www.boost-consulting.com _______________________________________________ C++-sig mailing list C++-sig at python.org http://mail.python.org/mailman/listinfo/c++-sig From dave at boost-consulting.com Mon Jun 6 23:04:13 2005 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 06 Jun 2005 17:04:13 -0400 Subject: [C++-sig] Raw member and constructor functions References: Message-ID: "Studious Apprentice" writes: > Thanks again! It now works ;-) Excellent! > Sorry for my mistake, I modified the code > because I got an conversion error at compilation from tuple to object, but > the error was in the member function not in the forwarding function, Probably because object's ctor is explicit. Try using direct initialization (parens) instead of implicit conversion or copy initialization (assignment syntax). -- Dave Abrahams Boost Consulting www.boost-consulting.com From dan.eloff at gmail.com Tue Jun 7 01:44:55 2005 From: dan.eloff at gmail.com (Dan Eloff) Date: Mon, 6 Jun 2005 16:44:55 -0700 Subject: [C++-sig] Boost Python - class_ As object Message-ID: <4817b6fc050606164463c1601d@mail.gmail.com> Hi all, I've not posted to this discussion list before, but I have been subscribed and following it loosely for a year now. I was looking through the boost python docs and found something interesting: class_ as objects Due to the dynamic nature of Boost.Python objects, any class_ may also be one of these types! The following code snippet wraps the class (type) object. We can use this to create wrapped instances. Example: object vec345 = ( class_("Vec2", init()) .def_readonly("length", &Point::length) .def_readonly("angle", &Point::angle) )(3.0, 4.0); assert(vec345.attr("length") == 5.0); This is nice, but I'm wondering about the inline class_<> declaration. Specifically I don't want to copy and paste the entire class_<> stuff everytime I want to create a python object of a exported c++ class and use it in c++. This violates the rule of duplication as a bad thing. How could I avoid this? Looking at it as I write, I think it may be possible to save the entire thing as a C++ variable and then use it elsewhere. class_ g_Vec2 = class_("Vec2", init()) .def_readonly("length", &Point::length) .def_readonly("angle", &Point::angle); And then I use it like so ?: object vec345 = g_Vec2(3.0,4.0); object vec_other = g_Vec2(7.0,7.0); And use it inside the module declaration as well: BOOST_PYTHON_MODULE(mymodule) ( g_Vec2; ... ) I may be totally off here, but hopefully I've given a clear picture of what I'm trying to do. I just want to put everything in one place if I can. Thanks for reading! -Dan From seefeld at sympatico.ca Tue Jun 7 01:52:20 2005 From: seefeld at sympatico.ca (Stefan Seefeld) Date: Mon, 06 Jun 2005 19:52:20 -0400 Subject: [C++-sig] Boost Python - class_ As object In-Reply-To: <4817b6fc050606164463c1601d@mail.gmail.com> References: <4817b6fc050606164463c1601d@mail.gmail.com> Message-ID: <42A4E1B4.8010104@sympatico.ca> Dan Eloff wrote: > This is nice, but I'm wondering about the inline class_<> declaration. > Specifically I don't want to copy and paste the entire class_<> stuff > everytime I want to create a python object of a exported c++ class and > use it in c++. This violates the rule of duplication as a bad thing. > How could I avoid this? Looking at it as I write, I think it may be > possible to save the entire thing as a C++ variable and then use it > elsewhere. > > class_ g_Vec2 = class_("Vec2", init()) > .def_readonly("length", &Point::length) > .def_readonly("angle", &Point::angle); > > And then I use it like so ?: > > object vec345 = g_Vec2(3.0,4.0); > object vec_other = g_Vec2(7.0,7.0); > > And use it inside the module declaration as well: > > BOOST_PYTHON_MODULE(mymodule) > ( > g_Vec2; > ... > ) > > I may be totally off here, but hopefully I've given a clear picture of > what I'm trying to do. I just want to put everything in one place if I > can. I think you got it right. 'g_Vec2' represents a (python) type, and 'g_Vec2(...)' invokes __call__ on it, which is a constructor call in this case, i.e. a factory that returns an instance of type 'g_Vec2'. Regards, Stefan From dave at boost-consulting.com Tue Jun 7 04:14:54 2005 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 06 Jun 2005 22:14:54 -0400 Subject: [C++-sig] Boost Python - class_ As object References: <4817b6fc050606164463c1601d@mail.gmail.com> Message-ID: Dan Eloff writes: > Hi all, I've not posted to this discussion list before, but I have > been subscribed and following it loosely for a year now. > > I was looking through the boost python docs and found something interesting: > > class_ as objects > > Due to the dynamic nature of Boost.Python objects, any class_ may > also be one of these types! The following code snippet wraps the class > (type) object. > > We can use this to create wrapped instances. Example: > > object vec345 = ( > class_("Vec2", init()) > .def_readonly("length", &Point::length) > .def_readonly("angle", &Point::angle) > )(3.0, 4.0); > > assert(vec345.attr("length") == 5.0); > > This is nice, but I'm wondering about the inline class_<> declaration. > Specifically I don't want to copy and paste the entire class_<> stuff > everytime I want to create a python object of a exported c++ class and > use it in c++. This violates the rule of duplication as a bad thing. > How could I avoid this? Looking at it as I write, I think it may be > possible to save the entire thing as a C++ variable and then use it > elsewhere. > > class_ g_Vec2 = class_("Vec2", init()) > .def_readonly("length", &Point::length) > .def_readonly("angle", &Point::angle); Well, I'm not sure that class_ has a copy ctor. But as you've been saying, why repeat yourself? object g_Vec2 = class_("Vec2", init()) .def_readonly("length", &Point::length) .def_readonly("angle", &Point::angle) ; object vec345 = g_Vec2(3.0,4.0); object vec_other = g_Vec2(7.0,7.0); If the tutorial doesn't make it crystal clear that you can do that, it should. -- Dave Abrahams Boost Consulting www.boost-consulting.com From apprentice_99 at hotmail.com Tue Jun 7 17:43:03 2005 From: apprentice_99 at hotmail.com (Studious Apprentice) Date: Tue, 07 Jun 2005 15:43:03 +0000 Subject: [C++-sig] And now for a raw constructor Message-ID: Thanks again Dave for the help provided ! I would like to know if there is a way to do the same for a constructor. I planned to use a .def("__init__", rawfunction(constructorfwd)) but this wont work for I do not have a constructed object to start with ;-) and on the top of that the object needs to be constructed at a specific place. Browsing through the Boost Python code, it looks like I could use the detail::make_keyword_range_constructor function or even use the objects::make_holder however I do know which parameters I should provide... Thanks in advance, Marc From skottmckay at gmail.com Tue Jun 7 18:33:04 2005 From: skottmckay at gmail.com (Scott McKay) Date: Tue, 7 Jun 2005 10:33:04 -0600 Subject: [C++-sig] pyste #include format Message-ID: <51d01787050607093312978ffa@mail.gmail.com> Could this line in pyste.py context['Include'] = lambda header: infos.CodeInfo('#include <%s>\n' % header, 'include') possibly be changed to something like this instead to honour the existing syntax but also allow you to explicitly specify the include format? context['Include'] = infos.Include with the following addition to infos.py def Include( header ): header = header.strip() if ( header[0] == '"' or header[0] == '<' ) : CodeInfo('#include %s\n' % header, 'include') else: CodeInfo('#include <%s>\n' % header, 'include') Cheers Scott From s_sourceforge at nedprod.com Tue Jun 7 18:52:28 2005 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Tue, 07 Jun 2005 17:52:28 +0100 Subject: [C++-sig] Custodian & ward Message-ID: <42A5DEDC.611.1BAEEAF@localhost> Hi, If there is: struct FXWindow { FXWindow(FXWindow *parent=0); }; ... and each FXWindow instance maintains a list of its children, and deletes its children when it gets deleted, then how do I apply custodian & ward to ensure that when the parent instance is deleted, python knows not to delete the children? Something like: class_< FXWindow >("FXWindow", init< FXWindow*>()[with_custodian_and_ward_postcall<1,2>()]) BTW the docs on the reference page for with_custodian_and_ward are confusing - the text suggests that the first arg determines the life of the second, whereas the code for return_internal_reference() is pretty clear that the second arg determines the life of the first. I am assuming that the latter is the correct orientation? Cheers, Niall From s_sourceforge at nedprod.com Tue Jun 7 18:58:56 2005 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Tue, 07 Jun 2005 17:58:56 +0100 Subject: [C++-sig] Custodian & ward Message-ID: <42A5E060.10783.1C0DA7E@localhost> Hi, If there is: struct FXWindow { FXWindow(FXWindow *parent=0); }; ... and each FXWindow instance maintains a list of its children, and deletes its children when it gets deleted, then how do I apply custodian & ward to ensure that when the parent instance is deleted, python knows not to delete the children? Something like: class_< FXWindow >("FXWindow", init< FXWindow*>()[with_custodian_and_ward_postcall<1,2>()]) BTW the docs on the reference page for with_custodian_and_ward are confusing - the text suggests that the first arg determines the life of the second, whereas the code for return_internal_reference() is pretty clear that the second arg determines the life of the first. I am assuming that the latter is the correct orientation? Cheers, Niall From s_sourceforge at nedprod.com Tue Jun 7 19:01:32 2005 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Tue, 07 Jun 2005 18:01:32 +0100 Subject: [C++-sig] Improved pyste Message-ID: <42A5E0FC.812.1C33D07@localhost> (The file is at http://www.nedprod.com/Pyste.zip as it seems you can't post attachments here) Enclosed is a further improved version of pyste over the one I sent some months ago. This is from the pyste in v1.32. Here are the changes: * Overloads were being declared multiply per code unit if they applied to each class, now they are output only once * friend functions of classes which overload weren't being distinguished between by casting (fixed by brute force casting all functions) * Outputs things missing a policy to a file for more easier browsing * Fixed a bug where it was missing "artificial" copy constructors ie; ones generated by the compiler * Got AllFromHeader() to maintain a list of things it exported so the pyste file can know what policies to apply. This is very much a hack and would conflict with anything in the header file called "exporter" * Fixed AllFromHeader() breaking application of bases<> to class definitions * Added new SplitOutput() directive which can split output into multiple files, thus avoiding MSVC's "internal structure overflow" error. Note that the implementation of this is pretty hacky This is in addition to the previous enhancements: * Support for void* by casting to void_* and treating it as an opaque pointer. This is a major new feature for wrapping most code. * Prevents the problem of throw() specifiers confusing Boost.Python by casting them off * Passing of gccxml errors out so you can see what's confusing GCC/GCCXML (handy when you develop primarily with MSVC) * Protected virtual methods are no longer wrapped as there were access problems. I've had similar problems with protected inheritance. Cheers, Niall From nicodemus at esss.com.br Tue Jun 7 19:26:15 2005 From: nicodemus at esss.com.br (Nicodemus) Date: Tue, 07 Jun 2005 14:26:15 -0300 Subject: [C++-sig] Improved pyste In-Reply-To: <42A5E0FC.812.1C33D07@localhost> References: <42A5E0FC.812.1C33D07@localhost> Message-ID: <42A5D8B7.9010301@esss.com.br> Hi Niall, Niall Douglas wrote: > > > Thanks a lot. Some of the improvements have already been applied to the HEAD from your previous patch. I will take a look at the new changes in the next few days and apply it. Regards, Bruno. From cppsig-eric at sneakemail.com Tue Jun 7 22:50:24 2005 From: cppsig-eric at sneakemail.com (Eric) Date: Tue, 7 Jun 2005 13:50:24 -0700 Subject: [C++-sig] Improved pyste In-Reply-To: <42A5E0FC.812.1C33D07@localhost> Message-ID: <28794-74921@sneakemail.com> Wow, can't wait to try this out. I had a question: > * Added new SplitOutput() directive which can split output into > multiple files, thus avoiding MSVC's "internal structure overflow" > error. Note that the implementation of this is pretty hacky Can you say a bit more about how this works? > -----Original Message----- > From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org]On > Behalf Of Niall Douglas s_sourceforge-at-nedprod.com |cppsig| > Sent: Tuesday, June 07, 2005 10:02 AM > To: ...................... > Subject: [C++-sig] Improved pyste > > > (The file is at http://www.nedprod.com/Pyste.zip as it seems you > can't post attachments here) > > Enclosed is a further improved version of pyste over the one I sent > some months ago. This is from the pyste in v1.32. Here are the > changes: > > * Overloads were being declared multiply per code unit if they > applied to each class, now they are output only once > > * friend functions of classes which overload weren't being > distinguished between by casting (fixed by brute force casting all > functions) > > * Outputs things missing a policy to a file for more easier browsing > > * Fixed a bug where it was missing "artificial" copy constructors ie; > ones generated by the compiler > > * Got AllFromHeader() to maintain a list of things it exported so the > pyste file can know what policies to apply. This is very much a hack > and would conflict with anything in the header file called "exporter" > > * Fixed AllFromHeader() breaking application of bases<> to class > definitions > > * Added new SplitOutput() directive which can split output into > multiple files, thus avoiding MSVC's "internal structure overflow" > error. Note that the implementation of this is pretty hacky > > This is in addition to the previous enhancements: > > * Support for void* by casting to void_* and treating it as an opaque > pointer. This is a major new feature for wrapping most code. > > * Prevents the problem of throw() specifiers confusing Boost.Python > by casting them off > > * Passing of gccxml errors out so you can see what's confusing > GCC/GCCXML (handy when you develop primarily with MSVC) > > * Protected virtual methods are no longer wrapped as there were > access problems. I've had similar problems with protected > inheritance. > > Cheers, > Niall > > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From rwgk at yahoo.com Tue Jun 7 23:18:52 2005 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 7 Jun 2005 14:18:52 -0700 (PDT) Subject: [C++-sig] Improved pyste In-Reply-To: <28794-74921@sneakemail.com> Message-ID: <20050607211852.66574.qmail@web31501.mail.mud.yahoo.com> --- Eric wrote: > Wow, can't wait to try this out. I had a question: > > > * Added new SplitOutput() directive which can split output into > > multiple files, thus avoiding MSVC's "internal structure overflow" > > error. Note that the implementation of this is pretty hacky > > Can you say a bit more about how this works? FWIW: I've never seen the dreaded "internal structure overflow" error with Visual C++ 7.1. Since the compiler is available free of charge I wonder why anybody is still "investing" time working around the numerous problems in VC6 and VC 7.0: http://msdn.microsoft.com/visualc/vctoolkit2003/ Cheers, Ralf __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From s_sourceforge at nedprod.com Wed Jun 8 00:43:33 2005 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Tue, 07 Jun 2005 23:43:33 +0100 Subject: [C++-sig] Improved pyste In-Reply-To: <20050607211852.66574.qmail@web31501.mail.mud.yahoo.com> References: <28794-74921@sneakemail.com> Message-ID: <42A63125.6154.2FC5ABE@localhost> On 7 Jun 2005 at 14:18, Ralf W. Grosse-Kunstleve wrote: > > > * Added new SplitOutput() directive which can split output into > > > multiple files, thus avoiding MSVC's "internal structure overflow" > > > error. Note that the implementation of this is pretty hacky > > > > Can you say a bit more about how this works? Yeah it's very easy. For example: class A { virtual void foo(); }; class B { virtual void foo(); } in file TestFile.h with TestFile.pyste containing SplitOutput("A") causes generation of _TestFile.cpp and _TestFile1.cpp. _TestFile.cpp contain everything not split ie; class B. _TestFile1.cpp contains just the class_<"A"> and the A_Wrapper class. All headers, PCH etc. are the same for both files. This good when any one of your classes alone isn't complex enough to kill MSVC, but doesn't help you if any single class is. However it's not much of an additional step to get pyste to pass the class_<> instance to the subsiduary c++ file so that more defs can be applied to it. I could have had pyste do this automatically, but the problem is that complexity has little to do with simple line counts - a short class definition can trip the compiler as much as a much longer one. Hence I went with the new directive so the user can specify manually. You can specify SplitOutput() many times, with each class going into its own .cpp file. I had to do this with FXMDIButton.h as each class alone was too big to coexist with any other, and it defined like six MDI buttons. I should warn you that the pyste I supplied outputs TnFOX-only code as I had to patch BPL to unlock the interpreter around entering C++, though it's trivial to return to the default pyste output. > FWIW: I've never seen the dreaded "internal structure overflow" error > with Visual C++ 7.1. Since the compiler is available free of charge I > wonder why anybody is still "investing" time working around the > numerous problems in VC6 and VC 7.0: Oh no, it's MSVC7.1 is the problem. Some *nine* files of 238 total output by pyste cause fatal internal structure overflows but then I can see why, the output is about 50-80Kb long with multiple polymorphic classes with multiple inheritance all kicking along. To give you some idea, the whole of the TnFOX python bindings is around 110,000 lines of code which is nearly that of the TnFOX core library itself. The DLL output was around 16Mb release build and takes about six hours to link and comdat optimise. As you might imagine, binding TnFOX to Python has pushed BPL itself, pyste and the compilers & linkers to their limit. It was after all the cause of me patching GCC with the visibility patch. I'd imagine MSVC8 is better, but I haven't tried it. GCC is just fine. Cheers, Niall From roman.yakovenko at gmail.com Wed Jun 8 08:02:39 2005 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Wed, 8 Jun 2005 09:02:39 +0300 Subject: [C++-sig] Improved pyste In-Reply-To: <42A63125.6154.2FC5ABE@localhost> References: <28794-74921@sneakemail.com> <20050607211852.66574.qmail@web31501.mail.mud.yahoo.com> <42A63125.6154.2FC5ABE@localhost> Message-ID: <7465b61705060723025e2d4dff@mail.gmail.com> Hi. Sorry for bad English! A few month ago I started to write boost python code generator from zero. It's name is pycplusplus ( py++ ). Right now I am missing 3 futures: class wrappers, call policies( will be implemented pretty soon ) and documentation. I attach small example of using my library. Small introduction: py++ is based on an other library I developed: pygccxml. About pygccxml: This library parsers GCC-XML generated file. It use only build in libraries. XML parsing done using SAX api. This gave huge speed improvement. Also pygccxml can read whole project: you can give him a list of files and it will tell you all declarations found within files. It can do it by parsing file by file and after this joining declarations. Or by creating temporal file that includes all files. That's not all. I am almost sure that you use boost::type_traites library. Well pygccxml has similar capabilities. It's implements almost all type_traites functionality. This functionality will be used in implementing call policies in py++. Although pygccxml has good documentation and more then 60 unittests. pygccxml uses boost license. If you interested here is url: http://pygccxml.sourceforge.net/. About py++: py++ is library I am developing right now. It is heavily based on pygccxml. py++ introduces next terminology: code creators - classes that implements code creation logic. file writers - classes that implements logic that will dump created code to different files. module creator - class (factory) that implements logic what should be exported and the order of to be export elements. For example in this factory implemented \ topological sort algorithm in order to find out c++ class exporting order. This gave me power, flexible and expendable design. User can introduce his own code creators. To implement his own file writer. That's not all. I found that there are 2 - 3 projects similar to boost.python library: langbinding, lua bind and tcl bind that use almost same syntax's to expose C++ classes to target language. I think it should be easy to add code generation functionality for those projects. An other difference between py++ and pyste is the way you use it. py++ is python package: you call function and it does the job. Well an other way that py++ could be extended is generating python code. Consider next situation: namespace top{ namepsace x1{...} namepsace x2{...} } In my opinion the resulting could should be package top that has to modules or sub packages x1 and x2. py++ has all data in order to implement this. Any way: I think I introduced new and powerful alternative to pyste. Right now it has more bugs than futures, less power than pyste. But don't worry I am going to fix the situation.. What I am asking is please take a look to py++ and say what do you think about it. py++ is sharing same cvs as pygccxml. Here is the link with instructions to check out the code. http://sourceforge.net/cvs/?group_id=118209 Development of both projects done in simultaneously on windows and Linux. Thanks for attention. Roman -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: example.py URL: From dave at boost-consulting.com Wed Jun 8 15:21:46 2005 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 08 Jun 2005 09:21:46 -0400 Subject: [C++-sig] Improved pyste References: <28794-74921@sneakemail.com> <20050607211852.66574.qmail@web31501.mail.mud.yahoo.com> <42A63125.6154.2FC5ABE@localhost> <7465b61705060723025e2d4dff@mail.gmail.com> Message-ID: Roman Yakovenko writes: > Any way: I think I introduced new and powerful alternative to pyste. > Right now it has more bugs than futures, less power than pyste. But > don't worry I am going to fix the situation.. What is the point? Why not pour your energy into Pyste? Or work with Nicodemus to integrate the two efforts? -- Dave Abrahams Boost Consulting www.boost-consulting.com From nico_ml at mgdesign.org Wed Jun 8 15:55:22 2005 From: nico_ml at mgdesign.org (Nicolas Lelong) Date: Wed, 8 Jun 2005 15:55:22 +0200 Subject: [C++-sig] std::wstring argument troubles ? Message-ID: <028d01c56c31$bd50beb0$de00a8c0@nico> Hi, I updated my boost libraries last week (via CVS on the 06/02) and I'm now experiencing problems when calling functions with wstring arguments, which worked seamlessly with my previous boost libs, using python 2.4. I may be missing something obvious, did anything change concerning wstring support (I was previously using a CVS snapshot around v1.31 of boost) for instance, I have a class BrushTextMenu::Entry defined roughly as follows :: class BrushTextMenu : public ... { public: struct Entry { Entry() {}; explicit Entry(std::wstring const& _text) : text(_text) {}; std::wstring text; }; which is wrapped as follows :: python::class_, Brush_Holder::type, boost::noncopyable> class_BrushTextMenu("BrushTextMenu", no_init); { python::scope class_scope = class_BrushTextMenu; python::class_("Entry") .def( init() ) ; } now, whenever I call the Entry constructor, I get error messages concerning signature mismatch :: b = BrushTextMenu.Entry(u"r") ==> Traceback (most recent call last): File "", line 1, in ? Boost.Python.ArgumentError: Python argument types in Entry.__init__(Entry, unicode) did not match C++ signature: __init__(struct _object *, class std::basic_string,class std::allocator >) __init__(struct _object *) or b = BrushTextMenu.Entry("r") ==> Traceback (most recent call last): File "", line 1, in ? Boost.Python.ArgumentError: Python argument types in Entry.__init__(Entry, str) did not match C++ signature: __init__(struct _object *, class std::basic_string,class std::allocator >) __init__(struct _object *) Thanks in advance, Nicolas. From nico_ml at mgdesign.org Wed Jun 8 16:39:21 2005 From: nico_ml at mgdesign.org (Nicolas Lelong) Date: Wed, 8 Jun 2005 16:39:21 +0200 Subject: [C++-sig] std::wstring argument troubles ? References: <028d01c56c31$bd50beb0$de00a8c0@nico> Message-ID: <02bc01c56c37$dc145bd0$de00a8c0@nico> Hm, obsiouvly I missed something obvious ... :} For the records, the problem was that I compiled boost.python lib with BJam (which I did not do before) with vc-7_1 toolset, and BJam activates the VC 'treat wchar_t as Build-in Type' (/Zc:wchar_t) whereas my extension modules were not using this option. Hence, the registered builtin type converter was refering to std::wstring as std::basic_string and my module to std::basic_string So one have to make sure that the boost.python lib and his modules are consistent in wchar_t compilation... Sorry for the time lost, Regards, Nicolas. From dave at boost-consulting.com Wed Jun 8 18:25:06 2005 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 08 Jun 2005 12:25:06 -0400 Subject: [C++-sig] Improved pyste References: <28794-74921@sneakemail.com> <20050607211852.66574.qmail@web31501.mail.mud.yahoo.com> <42A63125.6154.2FC5ABE@localhost> <7465b61705060723025e2d4dff@mail.gmail.com> Message-ID: David Abrahams writes: > Roman Yakovenko writes: > >> Any way: I think I introduced new and powerful alternative to pyste. >> Right now it has more bugs than futures, less power than pyste. But >> don't worry I am going to fix the situation.. > > What is the point? Why not pour your energy into Pyste? Or work with > Nicodemus to integrate the two efforts? Sorry, I don't mean to be discouraging. It's always great when a new project supporting Boost.Python appears. But I still prefer cooperation to competition when possible. Can you explain what your system offers, or will offer, that Pyste cannot? -- Dave Abrahams Boost Consulting www.boost-consulting.com From jake at zarloc.com Thu Jun 9 02:26:32 2005 From: jake at zarloc.com (Jake Skinner) Date: Thu, 09 Jun 2005 09:56:32 +0930 Subject: [C++-sig] trouble linking with wxWidgets In-Reply-To: References: <28794-74921@sneakemail.com> <20050607211852.66574.qmail@web31501.mail.mud.yahoo.com> <42A63125.6154.2FC5ABE@localhost> <7465b61705060723025e2d4dff@mail.gmail.com> Message-ID: <42A78CB8.10804@zarloc.com> Hello, I am trying to do an extension. I'm using python 2.4, wxWidgets 2.6, boost 1.32 and vc.net. I can't seem to get to get wxWidgets to link (I have built it as one big dll). I am building it in the libs/python/example directory this is my jamfile --------------------------- project-root ; import python ; extension pyROSS : pyROSS.cpp : c:/wxDockit/include c:/wxWidgets-src-2.6.0.0/include c:/data/RossClient c:/wxWidgets-src-2.6.0.0/lib/vc_dll/mswd boost_python_debug wxmswd26d_vc c:/boost_1_32_0/libs/python/build/bin-stage c:/wxWidgets-src-2.6.0.0/lib/vc_dll boost_python_debug wxmsw26d