From RaoulGough at yahoo.co.uk Sat Nov 1 00:45:51 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Fri, 31 Oct 2003 23:45:51 +0000 Subject: [C++-sig] Re: container suite feedback & ideas References: <20031030061624.82729.qmail@web20201.mail.yahoo.com> <008001c39f01$88cff6a0$64646464@godzilla> Message-ID: "Joel de Guzman" writes: > Raoul Gough wrote: > >> If anyone does want to try it out in the mean time, I would suggest >> starting with testnonlinear.cpp - it already attempts to workaround >> the partial specialization limitation (untested, of course). I suspect >> there will be issues with this anyway (in particular, there is a >> specialized value_traits for the container_proxy value type), not to >> mention all the other VC6 limitations I don't know about. >> >> How important is MSVC6 support with respect to putting indexing_v2 >> into the next release? Time is getting a bit short, if this compiler >> is going to present as many difficulties as everybody seems to think. > > FWIW, the current indexing suite works on VC6 and 7. Why hurry? > > One thing that I don't quite understand with the new indexing suite > is why it didn't build up on what's already existing. Support for these > compilers has been there from the start. It seems rather wasteful > to throw away what has been developed. Porting to VC6/7 is something > that you'd not want to repeat. I'm beginning to see what everybody means about those compilers. Maybe I could have done more to stay within the existing indexing suite framework, but I thought we discussed these things back in September when I first started out. At the time, I didn't see an easy way to adapt it to the separation into traits and algorithms that I went for. Anyway, I would surely have broken it for MSVC6 in any case, with the number of extensions that I ended up doing, since I didn't have MSVC6 available to test with. I'm now starting to get to grips with the problems, though. -- Raoul Gough. (setq dabbrev-case-fold-search nil) From greg at abbas.org Sat Nov 1 02:06:35 2003 From: greg at abbas.org (Greg Abbas) Date: Fri, 31 Oct 2003 17:06:35 -0800 Subject: [C++-sig] Big slow compilation Message-ID: I've got a question. I just returned to a project that I had written about a year ago using boost::python version 1.28 (I think). After updating my Debian system I had trouble resolving all the old dependencies, so I decided to try 1.30, and gcc version 3.2. Now, my program (the boost::python part of it is 1500 lines long) won't even compile on the old 256MB machine, so I switched to a different Debian box that has 1GB of RAM and it compiles but takes about 10 minutes. If I turn off debugging (no "-g3") then I can get it down to about 3 minutes, but that's still pretty different from all my other source files (some of which are a lot longer) that compile in a few _seconds_. Is this the result of boost, or gcc, or what? It's kind of a bummer because it makes my development cycle really slow. Is there anything I can do? (Besides go out and buy some overclocked watercooled hotrod CPU :-D). Thanks, -greg. -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg at abbas.org Sat Nov 1 02:12:02 2003 From: greg at abbas.org (Greg Abbas) Date: Fri, 31 Oct 2003 17:12:02 -0800 Subject: [C++-sig] RE: Big slow compilation In-Reply-To: Message-ID: Oops, one correction -- removing -g3 doesn't actually speed it up. It takes about as long whether I ask for debugging info or not. -greg. From dave at boost-consulting.com Sat Nov 1 07:10:08 2003 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 31 Oct 2003 20:10:08 -1000 Subject: [C++-sig] Re: bad iterator related warning References: <3FA15B41.921185A0@sitius.com> Message-ID: Nikolay Mladenov writes: > I updated from the CVS and now I am getting scary warning > wherever I have used python::iterator<>: That's a known bug in MSVC7.1. There's no good way around it AFAIK, so your best bet is to ignore it or shut off the warning. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Sat Nov 1 07:17:56 2003 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 31 Oct 2003 20:17:56 -1000 Subject: [C++-sig] Re: bad iterator related warning - Solved References: <3FA15B41.921185A0@sitius.com> <3FA19311.C19DC158@sitius.com> Message-ID: Nikolay Mladenov writes: > I specified void as reference type of the std::iterator and it worked. > I guess this kind of iterators shouldn't really use the default template > params anyway. I have a strong suspicion that the resulting lack of a warning is a fluke. You shouldn't try to build your own iterators by hand; it's too error prone. Like every other hand-written iterator I've seen posted to a NG or mailing list, your iterator doesn't conform (it's missing operator->). Consider using the boost iterator_facade template instead. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Sat Nov 1 07:19:21 2003 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 31 Oct 2003 20:19:21 -1000 Subject: [C++-sig] Re: boost.python on OS X 10.3 (Panther) References: <20031030184521.94205.qmail@web20205.mail.yahoo.com> Message-ID: "Ralf W. Grosse-Kunstleve" writes: > The same syntax error happens under Redhat 8, gcc 3.2, Python 2.2.1. > I believe it probably never worked anywhere. How about this: > >>>> type(ref_to_noncopyable()) > Yes, you might notice it's already checked in that way ;-) -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Sat Nov 1 07:24:56 2003 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 31 Oct 2003 20:24:56 -1000 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> Message-ID: Nikolay Mladenov writes: > I had to change function::argument_error because it was throwing > exception (MSVC6.5 built) Nikolay, I'm confused. The whole point of argument_error is to throw an exception. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Sat Nov 1 07:21:22 2003 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 31 Oct 2003 20:21:22 -1000 Subject: [C++-sig] Re: Pyste suggestion: handling void * arguments References: <3F9DCA7B.21864.2957DADB@localhost> <3FA1C8BA.25020.38F0FEF0@localhost> Message-ID: "Niall Douglas" writes: >> >If however you choose the casting route (which is technically >> >undefined behaviour, but I can't see many modern systems >> >differentiating between types of pointers) I can send you my altered >> >pyste. Remember that virtual method overrides in wrapper classes will >> > have to cast anyway no matter what. >> >> I don't know, "undefined behaviour" is never good. Dave, what's your >> opinion on this? > > It's no more undefined than the is_polymorphic trick in type_traits. There is absolutely no undefined behavior in is_polymorphic -- Dave Abrahams Boost Consulting www.boost-consulting.com From nicodemus at esss.com.br Sat Nov 1 19:49:11 2003 From: nicodemus at esss.com.br (Nicodemus) Date: Sat, 01 Nov 2003 15:49:11 -0300 Subject: [C++-sig] Pyste suggestion: handling void * arguments In-Reply-To: <3FA1C8BA.25020.38F0FEF0@localhost> References: <3F9DCA7B.21864.2957DADB@localhost> <3FA1C8BA.25020.38F0FEF0@localhost> Message-ID: <3FA40027.4090100@esss.com.br> Niall Douglas wrote: >On 28 Oct 2003 at 19:05, Nicodemus wrote: > > > >>>You're nearly there. I foresee two options here - either make void * >>>a container where python can access the pointer or make it an opaque >>>type. Mixing the two creates confusion IMHO. >>> >>> >>Acess void* in Python? What for? You won't be able to do anything with >>it, except pass it to other C++ functions that accept void* too. And >>then the code above would take care of that, creating automatic >>wrappers for this functions too. >> >> > >You can alter it like an long integer - add and subtract offsets, set >to fixed locations etc. I'm not saying it's all that common, but it >would offer the ability for python to use pointers* > >(*: Many would consider adding pointers to python a real retrograde >step. I'm not saying it's a good idea, but it is useful in selected >instances) > > Hmm... I don't think that supporting pointer arithmetic in Python is a compelling reason the let the user access the void* in Python... I think the user-cases for this are very limited, and not very Pythonic at all... 8/ >>>If you're going for opaque, you don't define void_ptr at all. This >>>lets you catch when you're returning void * but have forgotten to >>>specify return_opaque_pointer. Even better if pyste does this for you >>>automagically. >>> >>> >>Sorry, I didn't understand you. You mean that when a function returns >>void*, Pyste could automatically set its default policy for >>return_opaque_pointer? That would be the optimal solution, but >>return_opaque_pointer doesn't work with void*, or am I wrong? >> >> > >Sorry, I wasn't being clear. If you declare a type (can't be void *) >to be opaque under BPL, then you don't define it. You just do: > >struct void_ptr; > >... and that's it. Best to leave it undefined because then failing to >set return_opaque_pointer policy causes a compile-time error and >until you add the array-indexed policy setting, we need errors where >at least one overload returns void *. > I still don't understand you, sorry. 8( You said (in the quote above) that if you declare a type to be opaque under BPL, it's better that you don't define it, because if you forget to set return_opaque_pointer it will cause compile-time errors. What I don't understand is how can you declare it "to be opaque under BPL" *without* setting its policy... >>>Your problem with generating wrappers is passing parameters in a >>>fashion which doesn't cause problems. Most specifically, you must >>>avoid copy construction when parameters are entering any C++ code. >>>I've found call_traits::param_type to be useful here, but I'd imagine >>>pyste would know when it can pass by reference and when not without >>>that. >>> >>> >>Hmm, I see. But what's the problem with extra copy construction? You >>mean performance, or some other problem? >> >> > >More that some classes either (a) don't implement copying and worse >(b) their copy constructor does a destructive copy. Especially in the >latter case a copy construction is *fatal* to continued program >operation as it alters the semantics of the C++ ABI. > > You're right about that... >See the multithreading patch to invoke.hpp I posted here a week or so >ago. You'll note the care I went to to avoid copy construction in the >parameters (returns may need it too, though that's rare). > Hmm, can you help then with the implementation of this wrappers then? 8) It would be greatly appreciated. Regards, Nicodemus. From nicodemus at esss.com.br Sat Nov 1 19:50:01 2003 From: nicodemus at esss.com.br (Nicodemus) Date: Sat, 01 Nov 2003 15:50:01 -0300 Subject: [C++-sig] Some pyste errors, Question... In-Reply-To: References: Message-ID: <3FA40059.3040607@esss.com.br> Sean Spicer wrote: > > ...whom is the appropriate person for me to mail a tarball containing > errors from a pyste run to (including xml files from pyste.py --debug) ? > > sean That would be me. Send it to me at nicodemus at esss.com.br, thanks. Nicodemus. From nicodemus at esss.com.br Sat Nov 1 19:53:44 2003 From: nicodemus at esss.com.br (Nicodemus) Date: Sat, 01 Nov 2003 15:53:44 -0300 Subject: [C++-sig] Re: FAQ patch for debugging with gdb under Windows In-Reply-To: References: Message-ID: <3FA40138.3050904@esss.com.br> David Abrahams wrote: >Raoul Gough writes: > > >>OK - it's now checked in on HEAD. I should probably have updated the >>"Revised" date at the bottom, but didn't see this in time. Immediately >>after committing it, I also noticed that two existing links at the >>bottom are broken (on my working copy of CVS, anyway). They reference >>nonexistent files in the tutorial section, >>reducing_compiling_time.html and creating_packages.html. >> >> > >Hmm, these appear to be Bruno's text. What's up with that, Bruno? > > I have asked Joel (has been some time now) to re-generate the documentation of the tutorial, since he has the quickdoc tool correctly configured for that... I think Joel didn't had time to do it yet, thought. Joel? From nicodemus at esss.com.br Sat Nov 1 19:56:45 2003 From: nicodemus at esss.com.br (Nicodemus) Date: Sat, 01 Nov 2003 15:56:45 -0300 Subject: [C++-sig] Email change Message-ID: <3FA401ED.5030405@esss.com.br> I'd just like to say that I've change my email to nicodemus at esss.com.br, and also apologize for my disappearance from the list in the past few days. My city suffered a 3 day blackout, and only now the power has been restored. 8) Thanks, Nicodemus. From dave at boost-consulting.com Sat Nov 1 22:53:37 2003 From: dave at boost-consulting.com (David Abrahams) Date: Sat, 01 Nov 2003 11:53:37 -1000 Subject: [C++-sig] Re: BPL on MSVC7.1 -w3 warnings References: Message-ID: "Mike Rovner" writes: > David Abrahams wrote: >> "Mike Rovner" writes: > >>> class.cpp >> I'm not surprised. I don't really have time to issue the magic >> incantations (mostly static_casts) to silence the warnings right now, >> but if you submit a patch I could probably apply it. I already squashed that one (though not as elegantly). What about the others? -- Dave Abrahams Boost Consulting www.boost-consulting.com From s_sourceforge at nedprod.com Sat Nov 1 18:09:23 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Sat, 01 Nov 2003 17:09:23 -0000 Subject: [C++-sig] Re: Pyste suggestion: handling void * arguments In-Reply-To: Message-ID: <3FA3E8C3.17797.413E2218@localhost> On 31 Oct 2003 at 20:21, David Abrahams wrote: > >> I don't know, "undefined behaviour" is never good. Dave, what's > >> your opinion on this? > > > > It's no more undefined than the is_polymorphic trick in type_traits. > > There is absolutely no undefined behavior in is_polymorphic Where in the C++ standard does it state that a class with a virtual function table shall be bigger than one without? While the chances are that the above will remain true, it can't be guaranteed and thus is strictly speaking undefined behaviour. Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From s_sourceforge at nedprod.com Sat Nov 1 18:06:44 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Sat, 01 Nov 2003 17:06:44 -0000 Subject: [C++-sig] Big slow compilation In-Reply-To: Message-ID: <3FA3E824.8432.413BB3F6@localhost> On 31 Oct 2003 at 17:06, Greg Abbas wrote: > I've got a question. I just returned to a project that I had written > about a year ago using boost::python version 1.28 (I think). After > updating my Debian system I had trouble resolving all the old > dependencies, so I decided to try 1.30, and gcc version 3.2. Now, my > program (the boost::python part of it is 1500 lines long) won't even > compile on the old 256MB machine, so I switched to a different Debian > box that has 1GB of RAM and it compiles but takes about 10 minutes. If > I turn off debugging (no "-g3") then I can get it down to about 3 > minutes, but that's still pretty different from all my other source > files (some of which are a lot longer) that compile in a few > _seconds_. Is this the result of boost, or gcc, or what? It's kind of > a bummer because it makes my development cycle really slow. Is there > anything I can do? (Besides go out and buy some overclocked > watercooled hotrod CPU :-D). That's the price of heavy template usage. Mine takes over an hour with a dual-processor 1700 machine with MSVC and more like six hours with GCC 3.2 uniprocessor. To my knowledge, your only solution is the usual - GCC v3.4 (when the precompiled headers are fixed), faster machine, distcc and also consider applying that patch removing symbol folding which takes O(N^2) on GCC. Search the list archives. Lastly, also consider a faster compiler eg; Borland, Intel C++ etc. Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From dave at boost-consulting.com Sun Nov 2 01:16:18 2003 From: dave at boost-consulting.com (David Abrahams) Date: Sat, 01 Nov 2003 14:16:18 -1000 Subject: [C++-sig] Re: Pyste suggestion: handling void * arguments References: <3FA3E8C3.17797.413E2218@localhost> Message-ID: "Niall Douglas" writes: > On 31 Oct 2003 at 20:21, David Abrahams wrote: > >> >> I don't know, "undefined behaviour" is never good. Dave, what's >> >> your opinion on this? >> > >> > It's no more undefined than the is_polymorphic trick in type_traits. >> >> There is absolutely no undefined behavior in is_polymorphic > > Where in the C++ standard does it state that a class with a virtual > function table shall be bigger than one without? > > While the chances are that the above will remain true, it can't be > guaranteed and thus is strictly speaking undefined behaviour. No, it's unspecified behavior. Big difference. Check your standard. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Sun Nov 2 01:17:43 2003 From: dave at boost-consulting.com (David Abrahams) Date: Sat, 01 Nov 2003 14:17:43 -1000 Subject: [C++-sig] Re: Big slow compilation References: <3FA3E824.8432.413BB3F6@localhost> Message-ID: "Niall Douglas" writes: > That's the price of heavy template usage. Mine takes over an hour > with a dual-processor 1700 machine with MSVC and more like six hours > with GCC 3.2 uniprocessor. > > To my knowledge, your only solution is the usual - GCC v3.4 (when the > precompiled headers are fixed), faster machine, distcc and also > consider applying that patch removing symbol folding which takes > O(N^2) on GCC. Search the list archives. Lastly, also consider a > faster compiler eg; Borland, Intel C++ etc. Borland doesn't work with Boost.Python and Intel C++ is slower than GCC last time I checked. Better suggestions for speed are Metrowerks or MSVC. -- Dave Abrahams Boost Consulting www.boost-consulting.com From s_sourceforge at nedprod.com Sun Nov 2 01:26:21 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Sun, 02 Nov 2003 00:26:21 -0000 Subject: [C++-sig] Pyste suggestion: handling void * arguments In-Reply-To: <3FA40027.4090100@esss.com.br> References: <3FA1C8BA.25020.38F0FEF0@localhost> Message-ID: <3FA44F2D.27488.42CE2FE9@localhost> On 1 Nov 2003 at 15:49, Nicodemus wrote: > >Sorry, I wasn't being clear. If you declare a type (can't be void *) > >to be opaque under BPL, then you don't define it. You just do: > > > >struct void_ptr; > > > >... and that's it. Best to leave it undefined because then failing to > > set return_opaque_pointer policy causes a compile-time error and > >until you add the array-indexed policy setting, we need errors where > >at least one overload returns void *. > > I still don't understand you, sorry. 8( > > You said (in the quote above) that if you declare a type to be opaque > under BPL, it's better that you don't define it, because if you forget > to set return_opaque_pointer it will cause compile-time errors. What I > don't understand is how can you declare it "to be opaque under BPL" > *without* setting its policy... You declare it to be opaque using BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID somewhere high up after the #include > >See the multithreading patch to invoke.hpp I posted here a week or so > > ago. You'll note the care I went to to avoid copy construction in > >the parameters (returns may need it too, though that's rare). > > Hmm, can you help then with the implementation of this wrappers then? > 8) It would be greatly appreciated. As it just happens, I've finally fixed the last of the problems with casting out the void *'s. I'll send you a copy of my altered pyste in full to your new email address - I would recommend you run a visual diff viewer between yours and mine and see the changes I've made (eg; Beyond Compare). Almost certainly you could improve them with your superior knowledge of pyste's internals. If you have any problems at all, email me. I work late so 5am for me is about midnight for you. Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From s_sourceforge at nedprod.com Sun Nov 2 02:55:22 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Sun, 02 Nov 2003 01:55:22 -0000 Subject: [C++-sig] Re: Pyste suggestion: handling void * arguments In-Reply-To: Message-ID: <3FA4640A.29674.431FAED3@localhost> On 1 Nov 2003 at 14:16, David Abrahams wrote: > >> There is absolutely no undefined behavior in is_polymorphic > > > > Where in the C++ standard does it state that a class with a virtual > > function table shall be bigger than one without? > > > > While the chances are that the above will remain true, it can't be > > guaranteed and thus is strictly speaking undefined behaviour. > > No, it's unspecified behavior. Big difference. Check your standard. Ach! My apologies to the list for misleading ye on both this and the "faster compilers" advice which were actually slower compilers. Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From s_sourceforge at nedprod.com Sun Nov 2 02:53:56 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Sun, 02 Nov 2003 01:53:56 -0000 Subject: [C++-sig] value_holder_back_reference::holds() Message-ID: <3FA463B4.16841.431E5E47@localhost> This goes as follows: template void* value_holder_back_reference::holds( type_info dst_t) { type_info src_t = python::type_id(); Value* x = &m_held; if (dst_t == src_t) return x; else if (dst_t == python::type_id()) return &m_held; else return find_static_type(x, src_t, dst_t); } Q: Why is find_static_type() used here? Shouldn't it use find_dynamic_type() when the value is polymorphic? I only ask because I am passing "self" in python to a class constructor which expects a FXComposite pointer. self is python class MainWindow which inherits off C++ class FXMainWindow which someway down the line inherits off FXComposite, so the above should work. Unfortunately find_static_type() is not finding the FXComposite and is returning zero. If however I alter the "polymorphic" parameter in convert_type() (called by find_static_type()) to true, it *does* find the FXComposite correctly. Of course FXComposite has virtual functions, therefore a virtual function table for RTTI to work with. If this is not known behaviour (it seems odd that find_static_type() is not finding base classes), I'll get to work on a repeatable example. Just say the word. Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From rwgk at yahoo.com Sun Nov 2 17:20:15 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Sun, 2 Nov 2003 08:20:15 -0800 (PST) Subject: [C++-sig] Big slow compilation In-Reply-To: Message-ID: <20031102162015.36628.qmail@web20209.mail.yahoo.com> Thanks to Bruno a.k.a Nicodemus there is a nice section on "Reducing compile times" in the CVS version of the Boost.Python tutorial: http://cvs.sourceforge.net/viewcvs.py/boost/boost/libs/python/doc/tutorial/doc/quickstart.txt?rev=1.19&view=auto Splitting up your project in suitable ways will make a big difference for your development work. I have a project that takes an hour to compile from scratch (with one CPU), but recompiling the bit that I am working on often takes less than a minute. Unless I am changing core facilities like my array bindings. In that case I am sure to use parallel builds (scons -j or bjam -j) which cuts down recompiling from scratch to a little over 15 minutes on a $3k PC (2 CPU Xeon with hyper threading turned on) with gcc 3.2. Ralf --- Greg Abbas wrote: > I've got a question. I just returned to a project that I had written about a > year ago using boost::python version 1.28 (I think). After updating my > Debian system I had trouble resolving all the old dependencies, so I decided > to try 1.30, and gcc version 3.2. Now, my program (the boost::python part of > it is 1500 lines long) won't even compile on the old 256MB machine, so I > switched to a different Debian box that has 1GB of RAM and it compiles but > takes about 10 minutes. If I turn off debugging (no "-g3") then I can get it > down to about 3 minutes, but that's still pretty different from all my other > source files (some of which are a lot longer) that compile in a few > _seconds_. Is this the result of boost, or gcc, or what? It's kind of a > bummer because it makes my development cycle really slow. Is there anything > I can do? (Besides go out and buy some overclocked watercooled hotrod CPU > :-D). __________________________________ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ From dave at boost-consulting.com Sun Nov 2 20:00:50 2003 From: dave at boost-consulting.com (David Abrahams) Date: Sun, 02 Nov 2003 09:00:50 -1000 Subject: [C++-sig] Re: Big slow compilation References: <20031102162015.36628.qmail@web20209.mail.yahoo.com> Message-ID: "Ralf W. Grosse-Kunstleve" writes: > Thanks to Bruno a.k.a Nicodemus there is a nice section on "Reducing compile > times" in the CVS version of the Boost.Python tutorial: > > http://cvs.sourceforge.net/viewcvs.py/boost/boost/libs/python/doc/tutorial/doc/quickstart.txt?rev=1.19&view=auto > > Splitting up your project in suitable ways will make a big difference for your > development work. I have a project that takes an hour to compile from scratch > (with one CPU), but recompiling the bit that I am working on often takes less > than a minute. Unless I am changing core facilities like my array bindings. In > that case I am sure to use parallel builds (scons -j or bjam -j) which cuts > down recompiling from scratch to a little over 15 minutes on a $3k PC (2 CPU > Xeon with hyper threading turned on) with gcc 3.2. > > Ralf Using -j2 actually reduces build times even for single-processor computers. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Sun Nov 2 20:37:56 2003 From: dave at boost-consulting.com (David Abrahams) Date: Sun, 02 Nov 2003 09:37:56 -1000 Subject: [C++-sig] Re: value_holder_back_reference::holds() References: <3FA463B4.16841.431E5E47@localhost> Message-ID: "Niall Douglas" writes: > This goes as follows: > > template > void* value_holder_back_reference::holds( > type_info dst_t) > { > type_info src_t = python::type_id(); > Value* x = &m_held; > > if (dst_t == src_t) > return x; > else if (dst_t == python::type_id()) > return &m_held; > else > return find_static_type(x, src_t, dst_t); > } > > Q: Why is find_static_type() used here? Shouldn't it use > find_dynamic_type() when the value is polymorphic? No, we already know the most-derived type it can be: Held. Unless you've introduced multiple levels of inheritance between Value and Held (you're not supposed to do that) there's no way you can correctly downcast to anything else from Value. > I only ask because I am passing "self" in python to a class > constructor which expects a FXComposite pointer. There's too much information missing and the little you've provied is too vague. How are you passing it? What is a "class constructor?" Metaclasses construct classes when called. Do you actually mean an __init__ function? Instead of trying to describe it in English, please just show a small code example. > self is python class Really, a class? Not an instance of the class? > MainWindow which inherits off C++ class FXMainWindow More accurately, I presume: you derived self.__class__ in Python from the Python class wrapper for the C++ class FXMainWindow. > which someway down the line inherits off FXComposite, so the above > should work. I don't understand what you mean by "the above should work". When constructing a C++ class instance in a Python object, there is no check to see that the Python object already holds an instance of the C++ class, since, after all, the C++ object has not been constructed. > Unfortunately find_static_type() is not finding the FXComposite and > is returning zero. If however I alter the "polymorphic" parameter in > convert_type() (called by find_static_type()) to true, it *does* find > the FXComposite correctly. Of course FXComposite has virtual > functions, therefore a virtual function table for RTTI to work with. That surprises me, but I guess anything is possible. > If this is not known behaviour (it seems odd that find_static_type() > is not finding base classes), I'll get to work on a repeatable > example. Just say the word. "the word" -- Dave Abrahams Boost Consulting www.boost-consulting.com From s_sourceforge at nedprod.com Mon Nov 3 01:47:59 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Mon, 03 Nov 2003 00:47:59 -0000 Subject: [C++-sig] Re: value_holder_back_reference::holds() In-Reply-To: Message-ID: <3FA5A5BF.8032.4808599D@localhost> On 2 Nov 2003 at 9:37, David Abrahams wrote: > Instead of trying to describe it in English, please just show a small > code example. Like as follows: class MainWindow(FXMainWindow): def __init__(self, app): FXMainWindow.__init__(self, app) def setup(self): self.text=FXText(self) myapp=FXApp() main=MainWindow(myapp) main.setup() The point it fails at is the self.text=FXText(self) claiming that a MainWindow does not match C++ signature FXText(self, FXComposite *) despite that FXMainWindow inherits off FXComposite. BTW I've tried making a small repeatable example. It works as expected and since I've no idea why the misbehaviour, it's proving hard to know where to go next. > > Unfortunately find_static_type() is not finding the FXComposite and > > is returning zero. If however I alter the "polymorphic" parameter in > > convert_type() (called by find_static_type()) to true, it *does* > > find the FXComposite correctly. Of course FXComposite has virtual > > functions, therefore a virtual function table for RTTI to work with. > > That surprises me, but I guess anything is possible. Stepping through it in the debugger, find_static_type() calls convert_type() (in inheritence.cpp) with src_t being a FXMainWindow, dst_t being a FXComposite and polymorphic=false. It looks up src_p and dst_p fine, no problem. It then makes a std::pair of p & src_t and searches the cache for it. It finds an entry as seek.key.head becomes FXMainWindow, seek.key.tail.head becomes FXComposite and seek.key.tail.tail becomes FXMainWindow. cache_pos is not end() and cache_pos->key equals seek.key. However, cache_pos->offset equals cache_element::not_found so it returns zero. FXMainWindow definitely inherits FXComposite. If polymorphic is true, it appears to create a dynamic_id via a RTTI lookup. The *only* difference is that dynamic_id.second now is a FXMainWindow_Wrapper rather than a FXMainWindow. Again it finds an entry identical to before except seek.key.tail.tail becomes FXMainWindow_Wrapper. Now the differences begin, cache_pos->key is not seek.key so the early exit isn't taken. It goes on instead to search the full_graph() rather than up_graph() where it finds it, and the correct result is returned. Q: What's in cache() precisely? I understand that it's used to determine the offsets of base class instance data within a derived class. But does it contain every instance of every class within it, or just one representative instance? I only say this because it looks here that because no instance of FXMainWindow is ever created by the program, it's not in the cache and thus its offset member is cache_element::not_found. If however it gets FXMainWindow_Wrapper, that has been created and thus it is found. Of course, I am confusing two different search mechanisms for static and polymorphic types here. I should add that my small repeatable example has the wrapper too, yet it oddly enough works fine. So it can't be as simple as that. Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From s_sourceforge at nedprod.com Mon Nov 3 01:52:02 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Mon, 03 Nov 2003 00:52:02 -0000 Subject: [C++-sig] ATTN: Nicodemus Message-ID: <3FA5A6B2.5760.480C1127@localhost> Your email address @esss.com.br appears to be not working (I sent you my altered pyste). Alternative? Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From rwgk at yahoo.com Mon Nov 3 02:05:50 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Sun, 2 Nov 2003 17:05:50 -0800 (PST) Subject: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <68227290-0A3F-11D8-81CD-0050E4601908@arabianranta.com> Message-ID: <20031103010550.92256.qmail@web20204.mail.yahoo.com> --- Harri Hakula wrote: > With the latest compiler from Apple everything builds even on Jaguar. > I got most of the tests I tried running, but had to compile everything > manually. After seeing Harri Hakula's posting I've upgraded our Mac to OS 10.2.8 followed by installing the August 2003 gcc update. gcc --version reports: gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1493) I've used this gcc to compile Python 2.3 from scratch as a framework build. Using the current boost CVS I've made just one modification based on Sean Spicer's posting. See attached patch. Then: bjam -sPYTHON_VERSION=2.3 -sTOOLS=darwin "-sBUILD=debug off" -sALL_LOCATE_TARGET=/net_coral/scratch1/rwgk/bjam This is a full success. Everything compiles and links without warnings or errors. Some tests run, but unfortunately most hang indefinitely until killed manually with -9. See attached log. For example, this is fine: bjam -sPYTHON_VERSION=2.3 -sTOOLS=darwin "-sBUILD=debug off" -sALL_LOCATE_TARGET=/net_coral/scratch1/rwgk/bjam -sRUN_ALL_TESTS=1 dict ...found 2015 targets... ...updating 1 target... python-test-target /net_coral/scratch1/rwgk/bjam/bin/boost/libs/python/test/dict.test/darwin/debug/warnings-off/dict.test running... Done. ...updated 1 target... But this one hangs: bjam -sPYTHON_VERSION=2.3 -sTOOLS=darwin "-sBUILD=debug off" -sALL_LOCATE_TARGET=/net_coral/scratch1/rwgk/bjam -sRUN_ALL_TESTS=1 list It hangs at this line: from list_ext import * According to the debugger the process hangs here: (gdb) where #0 0x90034728 in semaphore_wait_trap () #1 0x90009c18 in pthread_mutex_lock () #2 0x0054f1f0 in std::__default_alloc_template::allocate(unsigned long etc. Does this ring any bells? Harri, how did you get around this problem? Could you please post more details about your platform and the commands that you used to compile and link? Ralf Index: build/v1/darwin-tools.jam =================================================================== RCS file: /cvsroot/boost/boost/tools/build/v1/darwin-tools.jam,v retrieving revision 1.8 diff -r1.8 darwin-tools.jam 160c160 < -framework$(_)$(FRAMEWORKS) -bundle_loader$(_)"$(BUNDLE_LOADER)" "$(BUNDLE_LOADER)" --- > -framework Python -bundle_loader$(_)"$(BUNDLE_LOADER)" "$(BUNDLE_LOADER)" 171c171 < -framework$(_)$(FRAMEWORKS) \ --- > -framework Python \ % boost_python_run_tests.csh python $BOOST_DIST/libs/python/test/staticmethod.py running... Killed python $BOOST_DIST/libs/python/test/shared_ptr.py running... Killed python $BOOST_DIST/libs/python/test/polymorphism.py Killed python $BOOST_DIST/libs/python/test/auto_ptr.py running... Killed python $BOOST_DIST/libs/python/test/minimal.py IMPORTING minimal_ext DONE IMPORTING minimal_ext python $BOOST_DIST/libs/python/test/args.py running... Killed python $BOOST_DIST/libs/python/test/numpy.py running... Done. python $BOOST_DIST/libs/python/test/enum.py running... Killed python $BOOST_DIST/libs/python/test/exception_translator.py running... Done. python $BOOST_DIST/libs/python/test/test_pointer_adoption.py running... Killed python $BOOST_DIST/libs/python/test/operators.py running... Killed python $BOOST_DIST/libs/python/test/callbacks.py running... Killed python $BOOST_DIST/libs/python/test/defaults.py running... Killed python $BOOST_DIST/libs/python/test/object.py running... Killed python $BOOST_DIST/libs/python/test/list.py running... Killed python $BOOST_DIST/libs/python/test/long.py running... Killed python $BOOST_DIST/libs/python/test/dict.py running... Done. python $BOOST_DIST/libs/python/test/tuple.py running... Killed python $BOOST_DIST/libs/python/test/str.py running... Done. python $BOOST_DIST/libs/python/test/virtual_functions.py running... Killed python $BOOST_DIST/libs/python/test/back_reference.py running... Killed python $BOOST_DIST/libs/python/test/implicit.py running... Killed python $BOOST_DIST/libs/python/test/data_members.py running... Killed python $BOOST_DIST/libs/python/test/ben_scott1.py Killed python $BOOST_DIST/libs/python/test/bienstman1.py running... Killed python $BOOST_DIST/libs/python/test/bienstman2.py running... Killed python $BOOST_DIST/libs/python/test/bienstman3.py running... Killed python $BOOST_DIST/libs/python/test/multi_arg_constructor.py running... Killed python $BOOST_DIST/libs/python/test/extract.py running... Killed python $BOOST_DIST/libs/python/test/opaque.py running... Killed python $BOOST_DIST/libs/python/test/pickle1.py running... Killed python $BOOST_DIST/libs/python/test/pickle2.py running... Killed python $BOOST_DIST/libs/python/test/pickle3.py running... Killed python $BOOST_DIST/libs/python/test/nested.py running... Killed python $BOOST_DIST/libs/python/test/docstring.py running... Killed python $BOOST_DIST/libs/python/test/bienstman4.py running... Killed python $BOOST_DIST/libs/python/test/bienstman5.py running... Killed python $BOOST_DIST/libs/python/test/test_builtin_converters.py running... Killed python $BOOST_DIST/libs/python/test/test_cltree.py Killed python $BOOST_DIST/libs/python/test/newtest.py running... Killed python $BOOST_DIST/libs/python/test/iterator.py running... Killed python $BOOST_DIST/libs/python/test/crossmod_exception.py running... Done. python $BOOST_DIST/libs/python/test/vector_indexing_suite.py running... Killed python $BOOST_DIST/libs/python/test/return_arg.py running... Killed python $BOOST_DIST/libs/python/test/keywords_test.py running... Killed python $BOOST_DIST/libs/python/test/properties.py Killed python $BOOST_DIST/libs/python/test/map_indexing_suite.py running... Killed python $BOOST_DIST/libs/python/test/injected.py running... Killed __________________________________ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ From grafik.list at redshift-software.com Mon Nov 3 02:42:04 2003 From: grafik.list at redshift-software.com (Rene Rivera) Date: Sun, 2 Nov 2003 19:42:04 -0600 Subject: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031103010550.92256.qmail@web20204.mail.yahoo.com> Message-ID: <20031102194205-r01010800-2494bf12-0860-0108@12.100.89.43> [2003-11-02] Ralf W. Grosse-Kunstleve wrote: >But this one hangs: > >bjam -sPYTHON_VERSION=2.3 -sTOOLS=darwin "-sBUILD=debug off" >-sALL_LOCATE_TARGET=/net_coral/scratch1/rwgk/bjam -sRUN_ALL_TESTS=1 list > >It hangs at this line: > >from list_ext import * > >According to the debugger the process hangs here: > >(gdb) where >#0 0x90034728 in semaphore_wait_trap () >#1 0x90009c18 in pthread_mutex_lock () >#2 0x0054f1f0 in std::__default_alloc_template::allocate(unsigned >long >etc. > >Does this ring any bells? Yes... That is the state of my first attempts at using Apples compiler. Things compile and link, but tests would hang indefinately. At the time, and mostly now also, I didn't have direct access to a MacOSX machine so I didn't know more than that. >Harri, how did you get around this problem? Could you please post more >details about your platform and the commands that you used to compile >and link? Yes please. Ralf is there a chance you could do some test to see how one can select the version of the frameowrk one links against? I'd really like to know if it's possible as the Apple documentation only alludes to one being able to do it but doesn't tell you how. -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From bob at redivi.com Mon Nov 3 03:13:01 2003 From: bob at redivi.com (Bob Ippolito) Date: Sun, 2 Nov 2003 21:13:01 -0500 Subject: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031102194205-r01010800-2494bf12-0860-0108@12.100.89.43> References: <20031102194205-r01010800-2494bf12-0860-0108@12.100.89.43> Message-ID: <4024E27B-0DA3-11D8-8BB0-000A95686CD8@redivi.com> On Nov 2, 2003, at 8:42 PM, Rene Rivera wrote: > Ralf is there a chance you could do some test to see how one can > select the > version of the frameowrk one links against? I'd really like to know if > it's > possible as the Apple documentation only alludes to one being able to > do it > but doesn't tell you how. -F will alter the search path for frameworks, just like -L for libraries The normal search path is something like: ~/Library/Frameworks /Library/Frameworks /Network/Library/Frameworks /System/Library/Frameworks On Panther, you want it to find Python.framework in /System/Library/Frameworks, so don't install another Python anywhere else if you're on Panther. -bob From rwgk at yahoo.com Mon Nov 3 03:18:55 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Sun, 2 Nov 2003 18:18:55 -0800 (PST) Subject: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031102194205-r01010800-2494bf12-0860-0108@12.100.89.43> Message-ID: <20031103021855.79112.qmail@web20202.mail.yahoo.com> --- Rene Rivera wrote: > Yes... That is the state of my first attempts at using Apples compiler. > Things compile and link, but tests would hang indefinately. At the time, and > mostly now also, I didn't have direct access to a MacOSX machine so I didn't > know more than that. It's not "direct", but you still have the account on our machine. Email me for details if necessary/interesting. > Ralf is there a chance you could do some test to see how one can select the > version of the frameowrk one links against? I'd really like to know if it's > possible as the Apple documentation only alludes to one being able to do it > but doesn't tell you how. I've only one framework installed (I've wiped out the 2.2 version). Learning how to select between framework versions will only be really interesting once we know it works at least with the one that I have currently installed. BTW: On the same machine with the same Python gcc 3.3.1 from gcc.gnu.org works without a problem incl. full optimization. Ralf __________________________________ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ From rwgk at yahoo.com Mon Nov 3 03:23:56 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Sun, 2 Nov 2003 18:23:56 -0800 (PST) Subject: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <4024E27B-0DA3-11D8-8BB0-000A95686CD8@redivi.com> Message-ID: <20031103022356.39783.qmail@web20210.mail.yahoo.com> --- Bob Ippolito wrote: > -F will alter the search path for frameworks, just like -L for libraries > The normal search path is something like: > ~/Library/Frameworks > /Library/Frameworks > /Network/Library/Frameworks > /System/Library/Frameworks > > On Panther, you want it to find Python.framework in > /System/Library/Frameworks, so don't install another Python anywhere > else if you're on Panther. Oh, if it's that then maybe this is useful: I noticed that the Python installation involves commands like: gcc -Wl,-F. -bundle -framework Python build/temp.darwin-6.8-Power_Macintosh-2.3/_TEmodule.o -L/usr/local/lib -o build/lib.darwin-6.8-Power_Macintosh-2.3/_TE.so -framework Carbon Note the "-Wl,-F" Ralf __________________________________ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ From s_sourceforge at nedprod.com Mon Nov 3 04:16:55 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Mon, 03 Nov 2003 03:16:55 -0000 Subject: [C++-sig] Re: value_holder_back_reference::holds() In-Reply-To: <3FA5A5BF.8032.4808599D@localhost> References: Message-ID: <3FA5C8A7.15562.4890B68C@localhost> On 3 Nov 2003 at 0:47, Niall Douglas wrote: > I should add that my small repeatable example has the wrapper too, yet > it oddly enough works fine. So it can't be as simple as that. I became increasingly sceptic as to what the problem might be, and so rebuilt everything from scratch. Interestingly now convert_type() /doesn't/ find the entry in the cache (which is correct) and goes on to search for it. This smells to me like a bug in the compiler or DLL load order. In search(), it receives a src and dst type index (I'm guessing?) calculated using tuples::get() which works by some mysterious fashion. However it would appear that dst is calculated incorrectly as search() correctly steps up the src hierarchy through the correct types, as evidenced by the ->offset member remaining correct. This therefore leaves two conclusions: (i) there is a bug in the compiler whereby separate compilation modules are calculating different indices (I have the optimiser turned on with /Os) or (ii) something is up with the STL. Q: Are MSVC7.1's CRT libraries fine with debug and release coexisting in the same process space? You would really have thought so, but older MSVC's I remember had issues with it. I'll just go recompile everything again with the optimiser off. It may then want to spend four hours linking, if so I'll get back to you tomorrow night. Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From bob at redivi.com Mon Nov 3 04:34:34 2003 From: bob at redivi.com (Bob Ippolito) Date: Sun, 2 Nov 2003 22:34:34 -0500 Subject: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031103022356.39783.qmail@web20210.mail.yahoo.com> References: <20031103022356.39783.qmail@web20210.mail.yahoo.com> Message-ID: On Nov 2, 2003, at 9:23 PM, Ralf W. Grosse-Kunstleve wrote: > --- Bob Ippolito wrote: >> -F will alter the search path for frameworks, just like -L for >> libraries >> The normal search path is something like: >> ~/Library/Frameworks >> /Library/Frameworks >> /Network/Library/Frameworks >> /System/Library/Frameworks >> >> On Panther, you want it to find Python.framework in >> /System/Library/Frameworks, so don't install another Python anywhere >> else if you're on Panther. > > Oh, if it's that then maybe this is useful: > > I noticed that the Python installation involves commands like: > > gcc -Wl,-F. -bundle -framework Python > build/temp.darwin-6.8-Power_Macintosh-2.3/_TEmodule.o -L/usr/local/lib > -o > build/lib.darwin-6.8-Power_Macintosh-2.3/_TE.so -framework Carbon > > Note the "-Wl,-F" -Wl,-F. means "tell the linker to look for frameworks in the current directory first" .. that's because the Python.framework isn't installed yet, so it's not on the normal search path. By the way, the 2.2 version is neither framework nor dylib. The Python symbols are in the interpreter executable, so it's pretty worthless, especially considering that 2.2.0 had a broken bundle loader on OS X (can only load one somemodule.so.. i.e. if site-packages/somemodule.so loads first, then site-packages/somepackage/somemodule.so will not raise an exception but will be just a copy of site-packages/somemodule.so .. or vice versa, depends on which comes first), among other bugs. -bob From hhakula at math.hut.fi Mon Nov 3 07:10:35 2003 From: hhakula at math.hut.fi (Harri Hakula) Date: Mon, 3 Nov 2003 08:10:35 +0200 Subject: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031103010550.92256.qmail@web20204.mail.yahoo.com> References: <20031103010550.92256.qmail@web20204.mail.yahoo.com> Message-ID: <703F52CD-0DC4-11D8-AE8A-000393C34364@math.hut.fi> On Nov 3, 2003, at 3:05 AM, Ralf W. Grosse-Kunstleve wrote: > --- Harri Hakula wrote: >> With the latest compiler from Apple everything builds even on Jaguar. >> I got most of the tests I tried running, but had to compile everything >> manually. > > After seeing Harri Hakula's posting I've upgraded our Mac to > OS 10.2.8 followed by installing the August 2003 gcc update. > gcc --version reports: > > gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1493) > > I've used this gcc to compile Python 2.3 from scratch as a framework > build. Using the current boost CVS I've made just one modification > based on Sean Spicer's posting. See attached patch. Then: > > bjam -sPYTHON_VERSION=2.3 -sTOOLS=darwin "-sBUILD=debug off" > -sALL_LOCATE_TARGET=/net_coral/scratch1/rwgk/bjam > > This is a full success. Everything compiles and links without > warnings or errors. Some tests run, but unfortunately most hang > indefinitely until killed manually with -9. See attached log. > For example, this is fine: > > bjam -sPYTHON_VERSION=2.3 -sTOOLS=darwin "-sBUILD=debug off" > -sALL_LOCATE_TARGET=/net_coral/scratch1/rwgk/bjam -sRUN_ALL_TESTS=1 > dict > ...found 2015 targets... > ...updating 1 target... > python-test-target > /net_coral/scratch1/rwgk/bjam/bin/boost/libs/python/test/dict.test/ > darwin/debug/warnings-off/dict.test > running... > Done. > ...updated 1 target... > > But this one hangs: > > bjam -sPYTHON_VERSION=2.3 -sTOOLS=darwin "-sBUILD=debug off" > -sALL_LOCATE_TARGET=/net_coral/scratch1/rwgk/bjam -sRUN_ALL_TESTS=1 > list > > It hangs at this line: > > from list_ext import * > > According to the debugger the process hangs here: > > (gdb) where > #0 0x90034728 in semaphore_wait_trap () > #1 0x90009c18 in pthread_mutex_lock () > #2 0x0054f1f0 in std::__default_alloc_template 0>::allocate(unsigned > long > etc. > > Does this ring any bells? > > Harri, how did you get around this problem? Could you please post more > details about your platform and the commands that you used to compile > and link? > Unfortunately I've already upgraded to Panther on my system so I cannot replicate everything. (And I accidentally wiped my /usr/local/src ... :-() Luckily, I did save some notes. Mac: Dual 1GHz, 10.2.8 Apple compilers: August 2003 gcc update MacPython 2.3 compiled from source with ./configure --enable-framework --with-cxx=g++ boost: I am not sure about this, but I believe it was 1.30.2 and not a snapshot from CVS. I compiled with the standard actions except I added the -fabi-version=0 since the ublas tests require this -- I had this on MacPython also. I followed Jonathan Brandmeyer's advice on an earlier thread and linked everything manually along the lines of this makefile snippet (this is from his posting): libboost_python.dylib: $(BOOST_OBJS) ld -w -d -u -o libboost_python.lo $^ g++ -w -dynamic -undefined suppress -o $@ libboost_python.lo rm -f libboost_python.lo I never got the dynamic loading working properly (unfortunately I did not save the error messages) but this led to success: g++ -undefined suppress -flat_namespace -bundle getting_started1.o /usr/local/src/boost/bin/boost/libs/python/build/libboost_python.dylib/ darwin/debug/shared-linkable-true/warnings-off/libboost_python.lo -o getting_started1.so I am afraid I was not employing any scientific method while trying to get this to work. Having reread Jonathan Brandmeyer's message I don't understand why I never tried this idea # python points to the python2.3 executable # libboost_python.dylib is assumed to be on the standard library search # path. myextension.so: $(MYEXTENSION_OBJS) g++ -w -bundle -bundle_loader $(python) -o $@ $^ -lboost_python Sorry for this stream-of-consciousness, too much teaching, not enough sleep... Cheers, Harri Hakula From grafik.list at redshift-software.com Mon Nov 3 07:17:06 2003 From: grafik.list at redshift-software.com (Rene Rivera) Date: Mon, 3 Nov 2003 00:17:06 -0600 Subject: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: Message-ID: <20031103001707-r01010800-118abd14-0860-0108@12.100.89.43> [2003-11-02] Bob Ippolito wrote: > >On Nov 2, 2003, at 9:23 PM, Ralf W. Grosse-Kunstleve wrote: > >> --- Bob Ippolito wrote: >>> -F will alter the search path for frameworks, just like -L for >>> libraries >>> The normal search path is something like: >>> ~/Library/Frameworks >>> /Library/Frameworks >>> /Network/Library/Frameworks >>> /System/Library/Frameworks >>> >>> On Panther, you want it to find Python.framework in >>> /System/Library/Frameworks, so don't install another Python anywhere >>> else if you're on Panther. >> >> Oh, if it's that then maybe this is useful: >> >> I noticed that the Python installation involves commands like: >> >> gcc -Wl,-F. -bundle -framework Python >> build/temp.darwin-6.8-Power_Macintosh-2.3/_TEmodule.o -L/usr/local/lib >> -o >> build/lib.darwin-6.8-Power_Macintosh-2.3/_TE.so -framework Carbon >> >> Note the "-Wl,-F" > >-Wl,-F. means "tell the linker to look for frameworks in the current >directory first" .. that's because the Python.framework isn't installed >yet, so it's not on the normal search path. The -F flag when specified straight, gcc -F ..., also makes it to the linker. Installing only one Python framework is _not_ an acceptable answer. When Python 2.4 comes out people will install it, and you'll end up with two of them. And then you have the problem of wanting to use/test with 2 different versions and are unable to do it. >By the way, the 2.2 version is neither framework nor dylib. The Python Like I said just above ;-) It's not the past I'm worried about but the future. After all 2.2 doesn't work for Boost.Python on MacOSX regardless of how it's built. -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From s_sourceforge at nedprod.com Mon Nov 3 07:19:10 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Mon, 03 Nov 2003 06:19:10 -0000 Subject: [C++-sig] value_holder_back_reference::holds() solved In-Reply-To: <3FA5C8A7.15562.4890B68C@localhost> References: <3FA5A5BF.8032.4808599D@localhost> Message-ID: <3FA5F35E.6745.493791D2@localhost> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body Turned out that a very small mistake in my policy files had set the bases<> for the class_<> of FXTopWindow (inherited by FXMainWindow) to be FXWindow when in fact it was FXShell, thus skipping the relevent FXComposite. One of those tiny, tiny errors you never think of checking and it's eaten three full days of development now :( Anyway, if anyone ever has the problem I did, go check your inheritence tree as told to BPL matches reality!!! (Also, sorry for wasting bandwidth!) Cheers, Niall -----BEGIN PGP SIGNATURE----- Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 iQA/AwUBP6XzYMEcvDLFGKbPEQK+SACgla4Adev9pzIwsK3DmHDoVLT4ftYAn09Q pDoW3xQFKi0UhNJ9A+OnFkXj =qLsJ -----END PGP SIGNATURE----- From dave at boost-consulting.com Mon Nov 3 07:19:49 2003 From: dave at boost-consulting.com (David Abrahams) Date: Sun, 02 Nov 2003 20:19:49 -1000 Subject: [C++-sig] Re: value_holder_back_reference::holds() References: <3FA5A5BF.8032.4808599D@localhost> Message-ID: "Niall Douglas" writes: > On 2 Nov 2003 at 9:37, David Abrahams wrote: > >> Instead of trying to describe it in English, please just show a small >> code example. > > Like as follows: > > class MainWindow(FXMainWindow): > def __init__(self, app): > FXMainWindow.__init__(self, app) > > def setup(self): > self.text=FXText(self) > > myapp=FXApp() > main=MainWindow(myapp) > main.setup() > > The point it fails at is the self.text=FXText(self) Which has seemingly nothing at all to do with most of what you described before (the "class constructor" business), leaving me at a loss. Is self.text a property of FXMainWindow (e.g. exposed with def_readwrite)? > claiming that a MainWindow does not match C++ signature FXText(self, > FXComposite *) despite that FXMainWindow inherits off FXComposite. "does not match C++ signature FXText(self, FXComposite *)" ?? I don't believe you copied the first part of the message correctly. In particular, "self" would probably not show up in the first slot unless you had a class self defined in the global namespace. Can't you bring yourself to post the exact error message instead of making me guess? I'm sorry to lose my patience again, but this is typical of your requests for help. By now you should know that casual description is more frustrating than helpful. Posting the exact error message and sample code works better. Regardless of what goes in place of "self", the error message clearly indicates that the signature requires two arguments, and you're only passing one. > Q: What's in cache() precisely? If there was a chance it would solve your problem, I might try to describe it for you, but there is no such chance AFAICT. You're barking up the wrong tree. > I understand that it's used to determine the offsets of base class > instance data within a derived class. But does it contain every > instance of every class within it, or just one representative > instance? It contains no instances. > I should add that my small repeatable example has the wrapper too, > yet it oddly enough works fine. Thus, it doesn't repeatably show the bug. > So it can't be as simple as that. My advice: a. Stop hunting for bugs in Boost.Python and assume you've made an error until you prove otherwise b. Reduce your failing example to a small case until it stops failing. Then you'll know what you're doing wrong. -- Dave Abrahams Boost Consulting www.boost-consulting.com From bob at redivi.com Mon Nov 3 07:31:20 2003 From: bob at redivi.com (Bob Ippolito) Date: Mon, 3 Nov 2003 01:31:20 -0500 Subject: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031103001707-r01010800-118abd14-0860-0108@12.100.89.43> References: <20031103001707-r01010800-118abd14-0860-0108@12.100.89.43> Message-ID: <5685A066-0DC7-11D8-8BB0-000A95686CD8@redivi.com> On Nov 3, 2003, at 1:17 AM, Rene Rivera wrote: > [2003-11-02] Bob Ippolito wrote: > >> >> On Nov 2, 2003, at 9:23 PM, Ralf W. Grosse-Kunstleve wrote: >> >>> --- Bob Ippolito wrote: >>>> -F will alter the search path for frameworks, just like -L for >>>> libraries >>>> The normal search path is something like: >>>> ~/Library/Frameworks >>>> /Library/Frameworks >>>> /Network/Library/Frameworks >>>> /System/Library/Frameworks >>>> >>>> On Panther, you want it to find Python.framework in >>>> /System/Library/Frameworks, so don't install another Python anywhere >>>> else if you're on Panther. >>> >>> Oh, if it's that then maybe this is useful: >>> >>> I noticed that the Python installation involves commands like: >>> >>> gcc -Wl,-F. -bundle -framework Python >>> build/temp.darwin-6.8-Power_Macintosh-2.3/_TEmodule.o >>> -L/usr/local/lib >>> -o >>> build/lib.darwin-6.8-Power_Macintosh-2.3/_TE.so -framework Carbon >>> >>> Note the "-Wl,-F" >> >> -Wl,-F. means "tell the linker to look for frameworks in the current >> directory first" .. that's because the Python.framework isn't >> installed >> yet, so it's not on the normal search path. > > The -F flag when specified straight, gcc -F ..., also makes it to the > linker. > > Installing only one Python framework is _not_ an acceptable answer. > When > Python 2.4 comes out people will install it, and you'll end up with > two of > them. And then you have the problem of wanting to use/test with 2 > different > versions and are unable to do it. Yeah, and in a year, year and a half, there will be a saner way to approach that problem. The way distutils interacts with OS X is relatively broken as-is, especially for a vendor installed Python. It's sane to pick one and only one Python framework at this point. -bob From joel at boost-consulting.com Mon Nov 3 12:14:22 2003 From: joel at boost-consulting.com (Joel de Guzman) Date: Mon, 3 Nov 2003 19:14:22 +0800 Subject: [C++-sig] Re: container suite feedback & ideas References: <20031030061624.82729.qmail@web20201.mail.yahoo.com> <008001c39f01$88cff6a0$64646464@godzilla> Message-ID: <030b01c3a1fc$660fd510$64646464@godzilla> Raoul Gough wrote: > "Joel de Guzman" writes: >> One thing that I don't quite understand with the new indexing suite >> is why it didn't build up on what's already existing. Support for these >> compilers has been there from the start. It seems rather wasteful >> to throw away what has been developed. Porting to VC6/7 is something >> that you'd not want to repeat. > > I'm beginning to see what everybody means about those compilers. Maybe > I could have done more to stay within the existing indexing suite > framework, but I thought we discussed these things back in September > when I first started out. At the time, I didn't see an easy way to > adapt it to the separation into traits and algorithms that I went > for. Anyway, I would surely have broken it for MSVC6 in any case, with > the number of extensions that I ended up doing, since I didn't have > MSVC6 available to test with. I'm now starting to get to grips with > the problems, though. Well, I assumed that you were going to break apart the interface, but I didn't realize, until later, that you were also going to depart from the implementation. Anyway, I thought you knew what you were doing and assumed that you knew the VC6/7 issues from the start. Pardon me; I should have warned you more loudly. Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net From Basavaraj.Goudar at infineon.com Mon Nov 3 12:41:05 2003 From: Basavaraj.Goudar at infineon.com (Goudar Basavaraj (IFIN DC SMS)) Date: Mon, 3 Nov 2003 17:11:05 +0530 Subject: [C++-sig] Passing default argument Message-ID: <0C674B14EAEBD61196D900B0D03DB49FF90F16@blrw502w.blr.infineon.com> Hi, I am facing a problem in passing default parameters to this program. class A { public: A(){} void f(int a=2,int b=4,int c=10,int d=4) { printf("HI am here\n"); } }; BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(F1,A::f,0,4) BOOST_PYTHON_MODULE(overload) { class_("A") .def("F",&A::f,F1(args("a","b","c","d"))) ; } I call the overloaded method from python by passing >>>name=overload.A() >>>name.F(a=0) //This works fine >>>name.F(a=0,b=1) //This works fine >>>name.F(b=1) //Fails. bad argument type for built in operation I am not able to figure out whether this is the property of boost or I have to do something else. Please let me know................ Thanks & Regards, Basavaraj From RaoulGough at yahoo.co.uk Mon Nov 3 13:06:48 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Mon, 03 Nov 2003 12:06:48 +0000 Subject: [C++-sig] Re: boost::python::range and duplicate comdat under MSVC 6 References: Message-ID: Raoul Gough writes: [snip] > a bug that seems to crop up whenever a module defines two or more > instances of boost::python::range with the same call policies. It > results in a link-time error like the following: > > iterator.obj : fatal error LNK1179: invalid or corrupt file: duplicate comdat > "?registration@?$shared_ptr_from_python at U?$iterator_range at U?$return_value_policy at Ureturn_by_value@python at boost@@$D" I have some more information about this problem (which, if I didn't make it clear before, does *not* depend on the indexing_v2 code). It seems to be a genuine MSVC6 bug to do with static member variables of templates, and AFAICT is casued by an _atexit handler that the compiler generates whether or not the static object has a non-trivial destructor. I'm pretty sure it is the same problem reported in a few 2000/2001-vintage usenet postings to microsoft.public.vc.*: http://groups.google.com/groups?th=8a05c82c4ffee280 (look for P78) http://groups.google.com/groups?th=b462a38bc2c132f7 http://groups.google.com/groups?th=2f0b2d7ab9a2485f In our case it's being triggered by the static member variable in shared_ptr_from_python (see coverter/shared_ptr_from_python.hpp). Seems pretty fatal to me, since (AFAIK) a static object is necessary for the type registration scheme to work. I'm not going to bother trying to fix this. -- Raoul Gough. (setq dabbrev-case-fold-search nil) From dimour at mail.ru Mon Nov 3 13:07:08 2003 From: dimour at mail.ru (Dmitri Mouromtsev) Date: Mon, 3 Nov 2003 15:07:08 +0300 Subject: [C++-sig] working under msvc 7.1 Message-ID: <17916785781.20031103150708@mail.ru> Hello all, I am using msvc 7.1 standard edition. I installed Python 2.3 and its source code. Then I downloaded cvs snapshot of boost.python and rebuild all. When I tried to run simplest program in debug mode: #include "stdafx.h" #include "Python.h" #include "boost\python.hpp" using namespace boost::python; int _tmain(int argc, _TCHAR* argv[]) { Py_Initialize(); object b_object = object(handle<>(PyFloat_FromDouble(3.1415))); std::cout << extract(b_object) << '\n'; return 0; } I have the message: "This application has failed to start because MSVC70D.dll was not found.". So, if I use native python API instead BOOST objects: PyObject *p_object = PyFloat_FromDouble(3.1415); std::cout << PyFloat_AsDouble(p_object) << '\n'; it's ok. Please help, what I did wrong or what is the problem? thanks -- Best regards, Dmitri mailto:dimour at mail.ru From testa at allos.sytes.net Mon Nov 3 15:16:49 2003 From: testa at allos.sytes.net (F.G.Testa) Date: Mon, 3 Nov 2003 12:16:49 -0200 Subject: [C++-sig] PyArg_ParseTuple Message-ID: Consider the following snippet, do I have to free "device" before exiting? Thank you! PyObject* sdk_MonitorDevice(PyObject *self, PyObject * args) { char * device; int size; InvokeID_t invoke; if (PyArg_ParseTuple(args, "s#",&device, &size)) { invoke = OAcs.sdk.MonitorDevice(device); return PyLong_FromUnsignedLong(invoke); } else return NULL; } From nickm at sitius.com Mon Nov 3 15:46:30 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Mon, 03 Nov 2003 09:46:30 -0500 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> Message-ID: <3FA66A46.1A4D05EF@sitius.com> David Abrahams wrote: > > Nikolay Mladenov writes: > > > I had to change function::argument_error because it was throwing > > exception (MSVC6.5 built) > > Nikolay, I'm confused. The whole point of argument_error is to throw > an exception. Yes, but the current cvs code causes an exception to be thrown from line 266 of function.cpp and this exception is completely unrelated to the argument error, it was something like "no converter to_python found for C++ type char", instead of "no match found for C++ signatures ...". I suspect this only happens on MSVC. The first patch in my post fixes that. The second patch I posted beautifies the signatures so they include the arg names and the default values. May be the names aren't so important in this case I think that it is good to have the default values. Than another thing I thought is that list of those pretty signatures can be used to generate nicer docstrings when there are overloaded functions. As it is now one cannot provide separate docstrings for the different overloads and on top of that the signatures of the functions are not shown when documentation is generated. so I thought that static PyObject* function_get_doc(PyObject* op, void*) can be modified to return something like (loosely speaking): f->pretty_signature() + f->doc() + "\n"+ get_doc(f->m_overload) Nikolay From nickm at sitius.com Mon Nov 3 16:02:52 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Mon, 03 Nov 2003 10:02:52 -0500 Subject: [C++-sig] Re: Passing default argument References: <0C674B14EAEBD61196D900B0D03DB49FF90F16@blrw502w.blr.infineon.com> Message-ID: <3FA66E1C.F19D9F83@sitius.com> You can do something else instead: BOOST_PYTHON_MODULE(overload) { class_("A") .def("F",&A::f, (arg("a")=2,arg("b")=4,arg("c")=10,arg("d")=4) )) ; } "Goudar Basavaraj (IFIN DC SMS)" wrote: > > Hi, > > I am facing a problem in passing default parameters to this program. > > class A > { > public: > A(){} > void f(int a=2,int b=4,int c=10,int d=4) > { > printf("HI am here\n"); > } > }; > BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(F1,A::f,0,4) > > BOOST_PYTHON_MODULE(overload) > { > class_("A") > .def("F",&A::f,F1(args("a","b","c","d"))) > ; > } > > I call the overloaded method from python by passing > >>>name=overload.A() > >>>name.F(a=0) //This works fine > >>>name.F(a=0,b=1) //This works fine > >>>name.F(b=1) //Fails. > bad argument type for built in operation > > I am not able to figure out whether this is the property of boost or > I have to do something else. > > Please let me know................ > > Thanks & Regards, > Basavaraj From nickm at sitius.com Mon Nov 3 17:36:22 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Mon, 03 Nov 2003 11:36:22 -0500 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> Message-ID: <3FA68406.755D7131@sitius.com> And if signature_element is modified to hold type_info * as well than the python types can be printed instead of the C++ types. Nikolay Mladenov wrote: > > David Abrahams wrote: > > > > Nikolay Mladenov writes: > > > > > I had to change function::argument_error because it was throwing > > > exception (MSVC6.5 built) > > > > Nikolay, I'm confused. The whole point of argument_error is to throw > > an exception. > > Yes, but the current cvs code causes an exception to be thrown from line > 266 of function.cpp and > this exception is completely unrelated to the argument error, it was > something like > "no converter to_python found for C++ type char", instead of "no match > found for C++ signatures ...". > I suspect this only happens on MSVC. > The first patch in my post fixes that. > > The second patch I posted beautifies the signatures so they include the > arg names and the default values. > May be the names aren't so important in this case I think that it is > good to have the default values. > > Than another thing I thought is that list of those pretty signatures > can be used to generate nicer docstrings > when there are overloaded functions. As it is now one cannot provide > separate docstrings for the different overloads > and on top of that the signatures of the functions are not shown when > documentation is generated. > so I thought that > static PyObject* function_get_doc(PyObject* op, void*) > can be modified to return something like (loosely speaking): > f->pretty_signature() + f->doc() + "\n"+ get_doc(f->m_overload) > > Nikolay From mike at nospam.com Mon Nov 3 18:30:39 2003 From: mike at nospam.com (Mike Rovner) Date: Mon, 3 Nov 2003 09:30:39 -0800 Subject: [C++-sig] Re: working under msvc 7.1 References: <17916785781.20031103150708@mail.ru> Message-ID: Dmitri Mouromtsev wrote: > I am using msvc 7.1 standard edition. I installed Python 2.3 and > its source code. Then I downloaded cvs snapshot of boost.python and > rebuild all. When I tried to run simplest program in debug mode: > > #include "stdafx.h" > #include "Python.h" > #include "boost\python.hpp" Try reverse order: #include "boost\python.hpp" // you don't need "Python.h" as it's already included in a proper (wrapped) manner. /// You don't want to debug python itself, do you? #include "stdafx.h" Mike From mike at nospam.com Mon Nov 3 18:49:01 2003 From: mike at nospam.com (Mike Rovner) Date: Mon, 3 Nov 2003 09:49:01 -0800 Subject: [C++-sig] Re: BPL on MSVC7.1 -w3 warnings References: Message-ID: David Abrahams wrote: > I already squashed that one (though not as elegantly). What about > the others? I placed both diffs in one file, is it ok? Mike begin 666 bpl.patch M26YD97 at Z(&QI8G,O<'ET:&]N+W-R8R]C;VYV97)T97(O8G5I;'1I;E]C;VYV M97)T97)S+F-P< H]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T] M/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]"E)#4R!F:6QE.B O M8W9S71H;VXO71E M3HZ97AT M3HZ97AT5-TF4H*2DI"BM"3T]35%]0 M651(3TY?5$]?4%E42$].7T)97U9!3%5%*'-T9#HZ"YS:7IE*"DI*2D*(",@:69N9&5F($)/3U-47TY/7U-41%]74U1224Y' M"BU"3T]35%]0651(3TY?5$]?4%E42$].7T)97U9!3%5%*'-T9#HZ=W-T55N:6-O9&5?1G)O;5=I9&5#:&%R*'@N9&%T82 at I+'@N"YD871A*"DLF4H*2DI*0H@(R!E;F1I9B *($)/3U-47U!95$A/ M3E]43U]0651(3TY?0EE?5D%,544H9FQO870L(#HZ4'E&;&]A=%]& Message-ID: <20031103135732-r01010800-0716b939-0860-0108@12.100.89.43> Well I've made some changes to the CVS build (python.jam and darwin-tools.jam) which incorporates the changes posted so far. Feedback on how this works, or doesn't, are most appreciated :-) -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From dave at boost-consulting.com Mon Nov 3 21:33:47 2003 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 03 Nov 2003 10:33:47 -1000 Subject: [C++-sig] Re: boost::python::range and duplicate comdat under MSVC 6 References: Message-ID: Raoul Gough writes: > Raoul Gough writes: > > [snip] >> a bug that seems to crop up whenever a module defines two or more >> instances of boost::python::range with the same call policies. It >> results in a link-time error like the following: >> >> iterator.obj : fatal error LNK1179: invalid or corrupt file: duplicate comdat >> "?registration@?$shared_ptr_from_python at U?$iterator_range at U?$return_value_policy at Ureturn_by_value@python at boost@@$D" > > I have some more information about this problem (which, if I didn't > make it clear before, does *not* depend on the indexing_v2 code). It > seems to be a genuine MSVC6 bug to do with static member variables of > templates, and AFAICT is casued by an _atexit handler that the > compiler generates whether or not the static object has a non-trivial > destructor. I'm pretty sure it is the same problem reported in a few > 2000/2001-vintage usenet postings to microsoft.public.vc.*: > > http://groups.google.com/groups?th=8a05c82c4ffee280 (look for P78) > http://groups.google.com/groups?th=b462a38bc2c132f7 > http://groups.google.com/groups?th=2f0b2d7ab9a2485f > > In our case it's being triggered by the static member variable in > shared_ptr_from_python (see coverter/shared_ptr_from_python.hpp). > Seems pretty fatal to me, since (AFAIK) a static object is necessary > for the type registration scheme to work. I'm not going to bother > trying to fix this. We use lots of static data members, though; this isn't the only place we ought to be seeing a problem if that's the issue. However, a simple transformation ought to be enough to eliminate the static data member, AFAICT. Do you need help working it out? -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Mon Nov 3 21:36:45 2003 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 03 Nov 2003 10:36:45 -1000 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> Message-ID: Nikolay Mladenov writes: > And if signature_element is modified to hold type_info * as well > than the python types can be printed instead of the C++ types. I like the general direction you're headed in, here, but am a little bit swamped. In order for me to better evaluate the results could you show a few use cases with "what it does now" and "what your patches would make it do"? Thanks, -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Mon Nov 3 21:45:05 2003 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 03 Nov 2003 10:45:05 -1000 Subject: [C++-sig] Re: BPL on MSVC7.1 -w3 warnings References: Message-ID: "Mike Rovner" writes: > David Abrahams wrote: >> I already squashed that one (though not as elegantly). What about >> the others? > > I placed both diffs in one file, is it ok? Beautiful. Committed. -- Dave Abrahams Boost Consulting www.boost-consulting.com From mikeowen at llnl.gov Tue Nov 4 00:25:23 2003 From: mikeowen at llnl.gov (J. Michael Owen) Date: Mon, 3 Nov 2003 15:25:23 -0800 Subject: [C++-sig] Boost.Python, AIX, and gcc Message-ID: I've been trying to use the latest Boost.Python with gcc on AIX, which is always fun with AIX's strange dynamic library system. I now have it working after modifying the some of the jam build files, and one source file. The files I've altered are: tools/build/v1/boost-base.jam tools/build/v1/gcc-tools.jam tools/build/v1/python.jam boost/type_traits/type_with_alignment.hpp I'm attaching copies of my versions of these files to this message (current against the latest CVS), in the hopes that Dave (or someone) will look at incoroporating these changes. The jam changes all seem innocuous enough, but the change to type_with_alignment.hpp is something of a hack. The problem lines are in the definition of the class type_with_alignment: the following static assertion (on line 136) fails on AIX with gcc: BOOST_STATIC_ASSERT(found >= Align); with error messages like ... /g/g12/owen/Spheral++/aix/boost/boost/type_traits/type_with_alignment.hpp: In instantiation of `boost::type_with_alignment<8>': /g/g12/owen/Spheral++/aix/boost/boost/python/object/instance.hpp:31: instantiated from `boost::python::objects::instance >' /g/g12/owen/Spheral++/aix/boost/boost/python/object/instance.hpp:47: instantiated from `boost::python::objects::additional_instance_size >' /g/g12/owen/Spheral++/aix/boost/boost/python/class.hpp:607: instantiated from `void boost::python::class_::register_holder() [with T = Derived, X1 = boost::python::bases, X2 = boost::python::detail::not_specified, X3 = boost::python::detail::not_specified]' /g/g12/owen/Spheral++/aix/boost/boost/python/class.hpp:268: instantiated from `boost::python::class_::class_(const char*, const boost::python::init_base&) [with DerivedT = boost::python::init, T = Derived, X1 = boost::python::bases, X2 = boost::python::detail::not_specified, X3 = boost::python::detail::not_specified]' Test.cc:30: instantiated from here /g/g12/owen/Spheral++/aix/boost/boost/type_traits/type_with_alignment.hpp:136: `sizeof' applied to incomplete type `boost::STATIC_ASSERTION_FAILURE' ... I don't know enough about the internals here to fix this problem correctly, but since I noticed that these static assertions are already skipped for some architectures I just added AIX to the list of architectures that skip them. This doesn't seem like a very satisfactory solution though -- any suggestions? Anyway, with these changes I've been able to successfully build and use small test python extensions using Boost.Python on AIX. I'll be pushing this much harder with large complex extension modules shortly. Mike. -- "Hey...where are the sunflower seeds?" | J. Michael Owen o_o / | (") | Email: mikeowen at llnl.gov \/'\/ | ____(__(,_,)_______________________________________________________________ -------------- next part -------------- # (C) Copyright David Abrahams and Carlos Pinto Coelho 2001. Permission to # copy, use, modify, sell and distribute this software is granted provided this # copyright notice appears in all copies. This software is provided "as is" # without express or implied warranty, and with no claim as to its suitability # for any purpose. # # Jamrules file by David Abrahams (abrahams at mediaone.net) and Carlos Pinto # Coelho (cfspc at altrabroadband.com). # Notes on the design of the system: # # This system is designed to support building the "same" targets with multiple # build tool suites (e.g. msvc, gcc,...) and build variants (e.g. debug, # release...). Although it currently varies across two dimensions, it should # trivially support extension to three or more, e.g. in case of cross-platform # builds. The word "same" is written in quotes above because internally, # separate targets are generated for each unique toolset/build-variant # combination. # # Specifics of build tool suites are specified in files with names of the form # "-tools.jam", where is the name used to identify the tool suite. # Workarounds for Jam limitations: # # 1. Jam supports something like the setting of attributes on targets using the # syntax: # on = # # This facility is used to control build actions for individual targets # (target-specific variables take precedence over global ones when build # actions # are executed). An obvious approach would be to use target # attributes to hold # properties of build tools (e.g. where to find the # standard includes). # Unfortunately, although you can write target # attributes, there is no way to # read them. Instead, we take advantage of # two properties of Jam: # # a. A variable name can be formed by evaluating an expression. For example, # the following rule, appends FOOBAR to its first argument to form the # name of a new variable, which is given the value "baz" # # rule X { $(1)FOOBAR = baz ; } # # b. Any character is allowed in a variable name. So, although they are # actually global variables, we can form names like .c++-flags thus: # # C++FLAGS = $($(1).c++-flags) # Get the c++-flags "attribute" from $(1) # # 2. There is no way to call a rule based on the value of a variable # other than by using a switch statement. Because that approach requires # intrusive changes to rules when the system is extended, we have avoided # it. Instead, we have taken advantage of two "features" of Jam: # # a. The name of a file to be included can be computed from an # expression. For example, the following includes a file whose name is # formed by concatenating $(1) and "-tools.jam": # # include $(1)-tools.jam # # b. A rule can be redefined any number of times. Its latest definition is # the one invoked. For example, the following prints "#2". # # rule X { ECHO #1 ; } # rule X { ECHO #2 ; } # X ; # # Together, these facts allow us to select tool-suite-specific actions for # building specific target types by repeatedly redefining the generalized # build actions in the various -tools.jam files if $(NT) { TOOLS ?= borland gcc metrowerks msvc ; } else { TOOLS ?= gcc ; } SHARED_TYPES = DLL ; STATIC_TYPES = LIB ; # detect-build-tools : # # Declares a pseudotarget for the specified build tools which is built by # the given . # # Although not currently implemented, the plan is to make compilation of # tool-specific targets dependent on this pseudotarget. That way, we will never # even attempt to build targets for tools that don't exist. rule detect-build-tools { detection-command on $(<) = $($(<).bin-directory)$(>) ; } # lib: generator function # rule library-file { LibraryFromObjects $(<) : [ Objects $(>) ] ; } # exe: generator function # rule executable-file { type-DEPENDS exe : $(<) ; main-from-objects $(<) : [ Objects $(>) ] : EXE ; } # dll: generator function # rule dll-files ( module implib ? : sources * : target-type ? ) { type-DEPENDS dll : $(<) ; # Set up the import library dependency on Windows if $(<[2]) { INCLUDES $(<[1]) : $(<[2-]) ; INCLUDES $(<[2-]) : $(<[1]) ; } target-type ?= DLL ; if [ MATCH ^(CRAY).* : $(JAMUNAME[-1]) ] # no shared libs on cray { NOTFILE $(<) ; } else { main-from-objects $(<) : [ Objects $(>) ] : $(target-type) ; } } # template: modifier function # # The target specs are modified by adding those previously specified in a template source. # Any specs containing paths are rerooted to correctly reference the dependee locations. # rule template-modifier ( target : source ) { local source-dir = [ directory-of $(source:G=) ] ; local source-id = [ target-id-of $(source) ] ; # Make sure it's defined. # if ! $(gTARGET_TYPE($(source-id))) { dependent-include $(source:G=) ; } # Copy the base specs into the target specs, adjust any paths # gTARGET_SOURCES($(target)) += [ root-paths $(gTARGET_SOURCES($(source-id))) : $(source-dir) ] ; gTARGET_DEPS($(target)) += [ root-paths $(gTARGET_DEPS($(source-id))) : $(source-dir) ] ; gTARGET_REQUIREMENTS($(target)) += [ fixup-path-properties $(gTARGET_REQUIREMENTS($(source-id))) : $(source-dir) ] ; gTARGET_DEFAULT_BUILD($(target)) += $(gTARGET_DEFAULT_BUILD($(source-id))) ; } # main-from-objects exe-target : obj-target... : ("EXE"|"DLL") # # generate instructions to build the given "main" target from the given object # files given in the 2nd parameter. The 3rd parameter should be EXE for an # executable, or DLL for a shared library. rule main-from-objects ( targets * : objects * : type ) { # make compiled sources a dependency of target MakeLocate $(targets) : $(LOCATE_TARGET) ; Clean clean : $(targets) ; MODE on $(targets) = $($(type)MODE) ; local link-function = Link-$(type) ; local extra-files = [ $(link-function) $(targets) : $(objects) : $(type) ] ; Chmod $(targets[1]) ; DEPENDS $(targets) : $(objects) ; # locate and attach the extra files generated if $(extra-files) { MakeLocate $(extra-files) : $(LOCATE_TARGET) ; DEPENDS $(targets) : $(extra-files) ; } gFILES($(targets[1])) = $(targets) $(extra-files) ; } rule Link-EXE { # N.B. By the time this rule is invoked, we had better have gRUN_PATH completely set. local extra-files = [ Link-action $(<) : $(>) : EXE ] ; RUN_PATH on $(<) = [ join [ unique $(gRUN_PATH($(<))) $(gTOOLSET_LIB_PATH) ] : $(SPLITPATH) ] ; if $(UNIX) { RUN_LD_LIBRARY_PATH on $(<) = [ join $(gRUN_LD_LIBRARY_PATH($(<))) : $(SPLITPATH) ] ; } return $(extra-files) ; } rule Link-DLL { gRUN_PATH($(<)) += $(gLOCATE($(<[1]))) $(gTOOLSET_LIB_PATH) ; if $(UNIX) { RUN_LD_LIBRARY_PATH on $(<) = [ join $(gRUN_LD_LIBRARY_PATH($(<))) : $(SPLITPATH) ] ; gRUN_LD_LIBRARY_PATH($(<)) += $(gLOCATE($(<[1]))) ; if $(OS) = AIX { Aix-Implib-Action $(<) : $(>) ; } } return [ Link-action $(<) : $(>) : DLL ] ; } rule Aix-Implib-Action { SPACE on $(<) = " " ; } actions Aix-Implib-Action bind import-generator-script { "$(BOOST_ROOT)/tools/build/v1/gen_aix_import_file.py" $(<[1]:BD=) $(>:D=) "-directory=$(<[1]:D)" -verbose=1 } # store the shell's PATH again, just in case someone uses PATH. # This also allows the user to customize the base path for running built # products from the command-line RUN_PATH ?= $(PATH) ; if $(UNIX) { RUN_LD_LIBRARY_PATH ?= $($(gSHELL_LIBPATH)) ; gAPPEND_LD_LIBRARY_PATH = ":$"$(gSHELL_LIBPATH) ; gAPPEND_PATH = ":$"PATH ; } if $(NT) { # Try some other likely spellings RUN_PATH ?= $(Path) ; RUN_PATH ?= $(path) ; gAPPEND_LD_LIBRARY_PATH = ";%LD_LIBRARY_PATH%" ; gAPPEND_PATH = ";%PATH%" ; } # Now set this, just in case someone tries to use it. PATH = $(RUN_PATH) ; if $(UNIX) { $(gSHELL_LIBPATH) = $(RUN_LD_LIBRARY_PATH) ; } DOLLAR = "$" ; # A simple action to run an executable target if $(UNIX) { actions Run { $(SHELL_SET)PATH=$(RUN_PATH):$PATH $(SHELL_EXPORT)PATH $(SHELL_SET)$(gSHELL_LIBPATH)=$(RUN_LD_LIBRARY_PATH):$$(gSHELL_LIBPATH) $(SHELL_EXPORT)$(gSHELL_LIBPATH) $(<) $(COMMAND-LINE) } } else { actions Run { $(SHELL_SET)PATH=$(RUN_PATH);%PATH% $(SHELL_EXPORT)PATH $(<) $(COMMAND-LINE) } } # bubble variable-name # # Helper function for sort, below # Removes the greatest element from $(variable-name) and returns it. rule bubble # { local result = ; local last = $($(<)[1]) ; for x in $($(<)[2-]) { if $(last) <= $(x) { result += $(last) ; last = $(x) ; } else { result += $(x) ; } } $(<) = $(result) ; return $(last) ; } # sort args # # return args sorted in lexicographic order. rule sort { local _all = $(<) ; local _result = ; local _count ; for _count in $(<) { _result = [ bubble _all ] $(_result) ; } return $(_result) ; } # min args # # return the lexicographic minimum element of args rule min { local result = ; local x ; for x in $(<) { if ! $(result) || ( $(x) < $(result) ) { result = $(x) ; } } return $(result) ; } # difference listB : listA # returns the elements of B that are not in A rule difference { local result = ; local element ; for element in $(<) { if ! ( $(element) in $(>) ) { result += $(element) ; } } return $(result) ; } # replace list : old-value new-value # # returns list with occurrences of old-value replaced by new-value rule replace { local result = ; local x ; for x in $(<) { if $(x) = $(>[1]) { result += $(>[2]) ; } else { result += $(x) ; } } return $(result) ; } # select-ungristed list... # # Returns the elements of list that have no grist rule select-ungristed { local result x ; for x in $(<) { if ! $(x:G) { result += $(x) ; } } return $(result) ; } rule select-gristed ( list * ) { local result ; for local x in $(list) { if $(x:G) { result += $(x) ; } } return $(result) ; } # Returns grist without "<"/">" for elements matching "<.*>", # and ignores other elements. rule ungrist ( names * ) { local result ; for local name in $(names) { local stripped = [ MATCH ^<(.*)>$ : $(name) ] ; result += $(stripped) ; } return $(result) ; } # Split a qualified property into 3 elements. # # Grammar description of qualified-property : # [[]]property # # returns property # missing or are treated as <*> rule split-qualified-property { local grist1 = $(<:G) ; local ungrist1 = $(<:G=) ; local grist2 = $(ungrist1:G) ; local ungrist2 = $(ungrist1:G=) ; local grist3 = $(ungrist2:G) ; local ungrist3 = $(ungrist2:G=) ; if $(grist3) { return $(grist1) $(grist2) $(grist3)$(ungrist3) ; } else if $(grist2) { return <*> $(grist1) $(grist2)$(ungrist2) ; } else { return <*> <*> $(<) ; } } rule unique # list { local result = ; local f ; for f in $(<) { if ! $(f) in $(result) { result += $(f) ; } } return $(result) ; } # get-properties features : properties # # Given a list of gristed features and a list of properties, returns the # properties matching the given features. rule get-properties { local result = ; local property ; for property in $(>) { if $(property:G) in $(<) { result += $(property) ; } } return $(result) ; } # get-values features : properties # # Given a list of gristed feature names and a list of properties, returns the # value(s) of the given features. rule get-values { local _properties = [ get-properties $(<) : $(>) ] ; return $(_properties:G=) ; } # normalize-properties properties # # Normalizes a set of (possibly qualified) properties by prepending <*> as many # times as neccessary to ensure that each property has at least 3 gristed elements. rule normalize-properties { local property ; local result ; for property in $(<) { switch $(property) { case <*><*><*><*@*>* : result += $(property) ; case <*><*><*@*>* : result += <*>$(property) ; case <*><*@*>* : result += <*><*>$(property) ; case <*@*>* : result += <*><*><*>$(property) ; case <*><*><*>* : result += $(property) ; case <*><*>* : result += <*>$(property) ; case <*>* : result += <*><*>$(property) ; case * : result += <*><*><*>$(property) ; } } return $(result) ; } # intersection set1 : set2 # # Removes from set1 any items which don't appear in set2 and returns the result. rule intersection { local result v ; for v in $(<) { if $(v) in $(>) { result += $(v) ; } } return $(result) ; } # subset sub : super # # Returns true iff sub is a subset of super, empty otherwise rule is-subset { if [ intersection $(<) : $(>) ] = $(<) { return true ; } } # distribute-feature value1[/value2...] # # Distribute the given feature across the slash-separated set of values, i.e. # returns value1[ /value2...] rule distribute-feature { local g = $(<:G) ; local result = [ split-path $(<:G=) ] ; return $(g)$(result) ; } # set-insert variable-name : value... ; # # Appends the given values to the list designated by variable-name if they are # not already present. rule set-insert { local v ; for v in $(>) { if ! ( $(v) in $($(<)) ) { $(<) += $(v) ; } } } # equal-sets set1 : set2 # # Returns true iff set1 contains the same elements as set2. # Not sensitive to the same element appearing multiple times rule equal-sets { if ( ! [ difference $(<) : $(>) ] ) && ( ! [ difference $(>) : $(<) ] ) { return true ; } } # feature name : [values...] # # Declares a feature with the given name, and the given allowed values. rule feature { if $(<) in $(gFEATURES) { EXIT feature $(<) : $(gFEATURE_VALUES(<$(<)>) redeclared as $(<) : $(>) ; } gFEATURES += <$(<)> ; gUNGRISTED(<$(<)>) = $(<) ; gFEATURE_VALUES(<$(<)>) = $(>) ; } rule free-feature { feature $(<) : $(>) ; gFREE_FEATURES += <$(<)> ; if $(>) { gSINGLE_VALUED_FREE_FEATURES += <$(<)> ; } } rule path-feature { free-feature $(<) : $(>) ; gPATH_FEATURES += <$(<)> ; } rule dependency-feature { path-feature $(<) : $(>) ; gDEPENDENCY_FEATURES += <$(<)> ; } # feature-default ... # # return the default properties corresponding to the given feature(s) rule feature-default { local result f ; for f in $(<) { result += $(f)$(gFEATURE_VALUES($(f))[1]) ; } return $(result) ; } # flags tools-name variable-name condition [: value(s)] # # Declare command-line settings for a given toolset. # toolset: the name of the toolset # variable-name: the name of a global variable which can be used to carry # information to a command-line # condition: One of the following: # 1. zero or more property-sets of the form: # value[/value...] # 2. one or more [/...] # # This rule appends to the specified variable, depending on a target's build # configuration and the form of condition. # # 1. if any specified property-set is a subset of the target's build properties or if # condition is empty, the values specified in $(3) will be appended once to # /variable-name/. # # 2. The value of each specified feature that participates in the target's # build properaties is appended to /variable-name/. # # The variable will be set "on" the target so it may be used in its build actions. rule flags { local toolset = $(gCURRENT_TOOLSET) ; local variable = $(<[2]) ; local condition = $(<[3-]) ; # record the names of all variables used so they can be set on targets if ! ( $(variable) in $(gTARGET_VARIABLES) ) { gTARGET_VARIABLES += $(variable) ; $(variable) = ; } local found = ; local x ; for x in $(condition) { x = [ split-path $(x) ] ; # Add each feature to the set of features relevant to the toolset gRELEVANT_FEATURES($(toolset)) += $(x:G) ; # is it a property set? if $(x:G=) { # if this property_set is a subset of the current build-properties if ( ! $(found) ) && [ is-subset $(x) : $(gBUILD_PROPERTIES) ] { found = true ; $(variable) += $(>) ; } } else { $(variable) += [ get-values $(x) : $(gBUILD_PROPERTIES) ] ; if $(x:G) in $(gDEPENDENCY_FEATURES) { gDEPENDENCY_VARIABLES($(toolset)) += $(variable) ; } } } if ! $(condition) { $(variable) += $(>) ; } } # include-tools toolset # # Unconditionally process the specification file for the given toolset. It is # neccessary to do this for each target built with that toolset, since the # toolset will invoke the flags rule to set global variables based on the build # properties of the target. rule include-tools { if ! $(gIN_INCLUDE_TOOLS) { gCURRENT_TOOLSET = $(<) ; gRELEVANT_FEATURES($(<)) = ; # clear relevant feature set gDEPENDENCY_VARIABLES($(<)) = ; # clear any lingering target variables that may have been declared $(gTARGET_VARIABLES) = ; gTARGET_VARIABLES = NEEDLIBS NEEDIMPS ; # start over from the beginning gTOOLSET_LIB_PATH = ; } { local gIN_INCLUDE_TOOLS = true ; SEARCH on $(<)-tools.jam = $(BOOST_BUILD_PATH) ; include $(<)-tools.jam ; } # Always maintain the list of relevant features as unique if ! $(gIN_INCLUDE_TOOLS) { gRELEVANT_FEATURES($(<)) = [ unique $(gRELEVANT_FEATURES($(<))) $(gALWAYS_RELEVANT) ] ; } gINCLUDED($(<)-tools.jam) = TRUE ; } # extends-toolset toolset # # Used in a toolset definition file; Declares that the toolset currently being # defined is an extension of the given toolset. rule extends-toolset { include-tools $(<) ; } # relevant-features toolset # # Returns the set of unique features relevant to the given toolset; includes the # toolset description file as a side-effect if neccessary. rule relevant-features # name { if ! $(gRELEVANT_FEATURES($(<))) { include-tools $(<) ; } return $(gRELEVANT_FEATURES($(<))) ; } # variant name [ : parents... ] : []value... # # Declare a build variant, whose configuration is given by the given (optionally # toolset-qualified) properties. rule variant ( name : parents-or-properties * : tool-properties * ) { gALL_VARIANTS += $(name) ; local parents ; if ! $(tool-properties) { if $(parents-or-properties[1]:G) { tool-properties = $(parents-or-properties) ; } else { parents = $(parents-or-properties) ; } } else { parents = $(parents-or-properties) ; } local toolset ; for toolset in $(TOOLS) { # We hijack select-properties to do our dirty work here. # Because properties in a variant declaration are only qualified with # toolset and not variant, we specify the toolset where # select-properties expects a variant name. The first toolset parameter # is neccessary to get the relevant-features correctly set. We supply # the variant name as the target name, so that error messages will look # coherent. local name-properties = [ select-properties $(toolset) $(toolset) $(name) : $(tool-properties) ] ; if $(parents) { local parent ; for parent in $(parents) { local parent-properties = $(gBASE_PROPERTIES($(toolset),$(parent))) ; local inherited-features = [ unique [ difference $(parent-properties:G) : $(name-properties:G) ] $(gFREE_FEATURES) $(gPATH_FEATURES) $(gDEPENDENCY_FEATURES ] ; local inherited-properties = [ get-properties $(inherited-features) : $(parent-properties) ] ; name-properties += $(inherited-properties) ; } } gBASE_PROPERTIES($(toolset),$(name)) = [ sort $(name-properties) ] ; } } # select-properties toolset variant target : qualified-properties... # # Returns rule select-properties ( toolset variant target ? : qualified-properties * ) { local relevant_features = [ relevant-features $(toolset) ] ; local normalized = [ normalize-properties $(>) ] ; # Classify properties by the specificity of their qualification. # First, grab those that apply to this toolset, or all toolsets local this_toolset = [ get-values <$(toolset)> : $(normalized) ] ; local all_toolsets = [ get-values <*> : $(normalized) ] ; local 0-stars = [ get-values <$(variant)> : $(this_toolset) ] ; local 1-stars = [ get-values <*> : $(this_toolset) ] [ get-values <$(variant)> : $(all_toolsets) ] ; local 2-stars = [ get-values <*> : $(all_toolsets) ] ; # Select feature names from the features relevant to the toolset. local features = [ intersection $(relevant_features) : $(0-stars:G) $(1-stars:G) $(2-stars:G) ] ; local result f ; for f in $(features) { local is_free = [ intersection $(f) : $(gFREE_FEATURES) ] ; # Go through the $(n-stars) lists from most- to least- specific; # collect the best set of values of a simple feature, and /all/ # values of a free feature. local r n ; for n in 0 1 2 { if ! $(r) || $(is_free) { r += [ get-values $(f) : $($(n)-stars) ] ; } } r = [ unique $(r) ] ; if $(r[2]) && ! $(is_free) # Check for conflicting simple-feature requests { EXIT "Error: Ambiguous properties requested for" $(target) <$(toolset)><$(variant)> ":" $(f)$(r) ; } result += $(f)$(r) ; } return $(result) ; } # get toolset features SEARCH on features.jam = $(BOOST_BUILD_PATH) ; include features.jam ; # ungrist-properties properties... # # Transforms a list of properties of the form: # value1 [value2... ] # into a list of the form: # feature1-value1 feature2-value2 # suitable for use as directory path elements # rule ungrist-properties { local property ; local result = ; for property in $(<) { result += $(gUNGRISTED($(property:G)))-$(property:G=) ; } return $(result) ; } # set-target-variables target # # attach global build tool settings to the given file-target, so that they can be # used in build actions. rule set-target-variables ( targets * ) { local s ; for s in $(gTARGET_VARIABLES) { $(s) on $(targets) = $($(s)) ; # set up dependencies if the target is a "top-level" target if ( $(s) in $(gDEPENDENCY_VARIABLES($(gCURRENT_TOOLSET))) ) && $(gTARGET_TYPE($(<))) { DEPENDS $(targets) : $($(s)) ; } } local libpath = [ get-properties : $(gBUILD_PROPERTIES) ] ; gRUN_PATH($(targets)) += $(libpath:G=) ; gRUN_LD_LIBRARY_PATH($(targets)) += $(libpath:G=) ; } # For path properties, add a relative path prefix to the value as # neccessary to locate the path relative to the given subproject # directory. rule fixup-path-properties ( properties * : subproject-directory ? ) { if $(subproject-directory) { local result ; for local p in $(properties) { if $(p:G) in $(gPATH_FEATURES) { result += [ root-paths $(p) : $(subproject-directory) ] ; } else { result += $(p) ; } } properties = $(result) ; } return $(properties) ; } # remove-incompatible-builds requirements... : build-request... : target-name # # If any element of requirements has the same grist but a different ungristed # part as any element of build-request, exits with an error report about target-name rule remove-incompatible-builds ( requirements * : build-request * : target-name + ) { local all-properties = [ unique $(<) $(>) ] ; local all-features = $(all-properties:G) ; local unique-features = [ unique $(all-features) ] ; if $(all-features) != $(unique-features) { local result ; local skip ; for local p in $(build-request) { # if a feature of the build request is also in the # requirements, but with differing value(s) if ( $(p:G) in $(requirements:G) ) && ! ( $(p) in $(requirements) ) { # decide what to do. local value = [ get-values $(p:G) : $(requirements) ] ; if $(value[2]) { EXIT Unexpectedly found multiple build requests for feature $(p:G) with values $(values) ; } local requested = [ split-path $(p:G=) ] ; if $(requested[2]) { local skipped = [ difference $(requested) : $(value) ] ; if ! $(gNOWARN_INCOMPATIBLE_BUILDS) { ECHO $(target-name) requires $(p:G)$(value), skipping requested build configuration(s) $(p:G)$(skipped). ; } result += $(p:G)$(value) ; } else { if ! $(gNOWARN_INCOMPATIBLE_BUILDS) { ECHO skipping $(target-name) due to incompatible build requirements $(p:G)$(value). ; } skip = true ; } } else { result += $(p) ; } } if $(skip) { build-request = SKIP ; } else { build-request = $(result) ; } } return $(build-request) ; } # multiply-property-sets [value1[/value2...] ]... # # Expands a set of (possibly multi-valued) properties into all the combinations # that include every feature in the set. Each combination is given as a path, # with the slash separating the properties, sorted in feature order. rule multiply-property-sets { local result p ; for p in [ sort $(<) ] { # expand any multi-valued simple features from the default build local multiple = [ distribute-feature $(p) ] ; # concatenation produces a product, so the tree branches for each # multi-valued simple feature. result = $(result)/$(multiple) ; result ?= $(multiple) ; # this trick allows us to get started } return $(result) ; } # Return a list consisting of all the elements of properties which # aren't the defaults for their features. rule remove-default-properties ( properties * ) { return [ difference $(properties) : [ feature-default $(properties:G) ] ] ; } # make-path-property-sets base-path : common-properties : property-sets # # Returns a list of paths where the initial ungristed part of each element is a # relative path to a subvariant directory from a target's build root and the # rest of the element is a slash-separated property set describing the # properties of the target to be built. # # Each path returned is base-path extended by one of the ungristed property-sets # (or just the base-path if no property-sets are supplied). Each property set # returned is formed by extending common-properties with one of the property-sets. # # For example, # # make-path-property-sets gcc/release : v1 : v2/v3 # # returns this single-element list: # # gcc/release/p2-v2/p3-v3/v1/v2/v3 # |<-- subvariant path -->|<-- property-set -->| rule make-path-property-sets ( base-path : common-properties * : property-sets * ) { local result ; local s ; for s in $(property-sets) { local x = # directory components $(base-path) [ ungrist-properties [ remove-default-properties [ split-path $(s) ] ] ] # properties $(common-properties) $(s) ; result += $(x:J=$(SLASH)) ; } # if there were no overrides, just add the base variant and properties if ! $(result) { result = [ join $(base-path) $(common-properties) : $(SLASH) ] ; } return $(result) ; } # segregate-overrides override-var base-var # # removes elements of $(base-var) from $(override-var), and removes elements # whose grist is in $(override-var:G) from $(base-var). rule segregate-overrides { $(<) = [ difference $($(<)) : $($(>)) ] ; # Which features, and thus properties, of the base variant are we keeping? local kept-features = [ difference $($(>):G) : $($(<):G) ] ; $(>) = [ get-properties $(kept-features) : $($(>)) ] ; } # report-free-property-conflicts free-property... : target # # If any single-valued free-feature appears more than once in free-property..., # exit with an appropriate error message. rule report-free-property-conflicts { local p = [ get-properties $(gSINGLE_VALUED_FREE_FEATURES) $(<) ] ; local f = [ unique $(p:G) ] ; if $(p:G) != $(f) { EXIT $(>): multiple values for single-valued free feature(s) [ difference $(p:G) $(f) ] requested ; } } # expand-build-request # toolset variant target-name : requirements : build-request # # Returns a list of path-property-sets (see make-path-property-sets above) for # all build configurations based on the given toolset, requirements, and # build-request. Target-name is just used for error reporting. rule expand-build-request { local toolset = $(<[1]) ; local variant = $(<[2]) ; # grab the requirements and BUILD-request relevant to this toolset and variant local requirements = [ select-properties $(toolset) $(variant) : $(>) ] ; local build-request = [ select-properties $(toolset) $(variant) : $(3) ] ; # Separate the free features (e.g. , , ) from the others local free-properties = [ segregate-free-properties requirements build-request ] ; # Check for conflicts report-free-property-conflicts $(free-properties) : $(<[3]) ; build-request = [ remove-incompatible-builds $(requirements) : $(build-request) : $(<[3]) ] ; if $(build-request) != SKIP { # Get the base variant for the toolset. Includes free features local base-properties = $(gBASE_PROPERTIES($(toolset),$(variant))) ; # Which properties will override settings in the base variant? local override-properties = [ unique $(requirements) $(build-request) ] ; segregate-overrides override-properties : base-properties ; # Which features will pick up a default value because they are not in # the base variant or in the overrides? local relevant-features = [ relevant-features $(toolset) ] ; local override-free-features = [ intersection $(gSINGLE_VALUED_FREE_FEATURES) : $(free-properties:G) ] ; local defaulted-features = [ difference $(relevant-features) : $(override-properties:G) $(base-properties:G) $(override-free-features) ] ; local defaulted-properties = [ feature-default $(defaulted-features) ] ; # VP: defaulted-properties have the form value and there's 1 value. # Hence, each element of defaulted-properties will be part of each # component of override-sets and will be a part of each property-set # returned. By segregating them, the result is changed in only one # way: free properties does not show up in target path. local defaulted-free-properties = [ segregate-free-properties defaulted-properties ] ; # form override property sets of the form (property1[/property2...] )+, # sorted in feature order. These represent the properties of subvariants # that differ from the base variant local override-sets = [ multiply-property-sets $(override-properties) $(defaulted-properties) ] ; # return path-property-sets corresponding to each (sub)variant build # described. return [ make-path-property-sets $(toolset)$(SLASH)$(variant) : [ fixup-path-properties $(base-properties) $(free-properties) $(defaulted-free-properties) : $(RELATIVE_SUBDIR) ] : $(override-sets) ] ; } } # split-path-at-grist path # # Breaks path at each $(SLASH) that is followed by grist. This can be used to # break apart property sets, particularly where the feature is used, # since its value is typically a path. rule split-path-at-grist { local full-split = [ split-path $(<) ] ; local last ; local result x ; for x in $(full-split) { if $(x:G) { result += $(last) ; last = $(x) ; } else { last = $(last)$(SLASH)$(x) ; last ?= $(x) ; } } return $(result) $(last) ; } # # GIVEN: # # A set of dependency sources with grist to indicate the types # (*, *, etc) # # RESULT: # # Will use the type, basename, and SUF*/PRE* to expand the name # of the sources to their fully specific target name. # # EXAMPLE: # # [ expand-source-names test test test README.txt test ] # # RETURNS: # # libtest.a libtest.so test.app README.TXT test.so # rule expand-source-names ( sources * ) { local x-sources = ; for local source in $(sources) { local grist = [ ungrist $(source:G) ] ; local type = $(gTARGET_TYPE_ID($(grist))) ; if $(type) { local p = "" ; if $(source:B=:S=:G=) { p = "/" ; } local prefix = "" ; local suffix = "" ; if $(PRE$(type)[1]) { prefix = $(PRE$(type)[1]) ; } if $(SUF$(type)[1]) { suffix = $(SUF$(type)[1]) ; } x-sources += $(source:B=:S=)$(p)$(prefix)$(source:B:S=)$(suffix) ; } else { x-sources += $(source) ; } } return $(x-sources) ; } # # GIVEN: # # A set of targets and a single target type for all the targets # (DLL, LIB, etc.) # # RESULT: # # Will use the type, basename, and SUF*/PRE* to expand the name # of the targets to their fully specific target name. # # EXAMPLE: # # [ expand-targets-names foo bar : DLL ] # # RETURNS: # # libfoo.a libbar.so # rule expand-target-names ( targets + : target-type ) { local x-targets = ; for local target in $(targets) { local prefix = "" ; local suffix = "" ; if $(PRE$(target-type)[1]) { prefix = $(PRE$(target-type)[1]) ; } if $(SUF$(target-type)[1]) { suffix = $(SUF$(target-type)[1]) ; } x-targets += $(prefix)$(target)$(suffix) ; } return $(x-targets) ; } # declare-local-target name : sources : requirements : local-BUILD : target-type # # declares a subproject-local target of the given name and target-type. This is # all top-level rules which declare targets should eventually go through here. # # RETURNS: the a list of target names for the files built by the target. rule declare-local-target ( target : sources * : requirements * : default-build * : target-type ) { # We expand out the name of the target and sources local x-target = [ expand-target-names $(target) : $(target-type) ] ; local x-sources = [ expand-source-names $(sources) ] ; # We add SOURCE_GRIST the base target name here because we're referring the # abstract target which generates all of the actual builds. We need a way to # distinguish targets of the same name from different subprojects. local target-id = [ FGristFiles $(x-target) ] ; if ! $(target-type) { EXIT No target type given for "$(x-target)" ; } # Define the specifications of the target, but only if we haven't already. # if ! $(gTARGET_TYPE($(target-id))) { # Save basic information about the target. # gTARGET_TYPE($(target-id)) = $(target-type) ; gTARGET_NAME($(target-id)) = $(target) ; # Add the specified requirements to any requirements given by the target # type, and the corresponding property. # gTARGET_REQUIREMENTS($(target-id)) = $(requirements) $(gTARGET_TYPE_REQUIREMENTS($(target-type))) ; if ! $(gNO_TARGET_TYPE_REQUIREMENT($(target-type))) { gTARGET_REQUIREMENTS($(target-id)) += $(target-type) ; } # Collect the recognized dependencies to other targets. # local dependencies ; for local source in [ select-gristed $(x-sources) ] { local dependency-type = [ ungrist $(source:G:L) ] ; local dependency-type-id = $(gTARGET_TYPE_ID($(dependency-type))) ; if $(gIS_DEPENDENCY($(dependency-type-id))) { gTARGET_DEPS($(target-id)) += $(source:G=$(dependency-type-id)) ; } } # Sources that aren't recognized as targets, are considered raw sources. # gTARGET_SOURCES($(target-id)) = [ FGristFiles [ difference $(x-sources:G=) : $(gTARGET_DEPS($(target-id)):G=) ] ] ; # Save the default builds. # gTARGET_DEFAULT_BUILD($(target-id)) = $(default-build) ; # Apply any modifiers to the target specs. # for local mod in $(gTARGET_DEPS($(target-id))) { local dependency-type-id = [ ungrist $(mod:G) ] ; local modifier-function = $(gMODIFIER_FUNCTION($(dependency-type-id))) ; if $(modifier-function) { # Remove and apply the modifier. gTARGET_DEPS($(target-id)) = [ difference $(gTARGET_DEPS($(target-id))) : $(mod) ] ; local ignored = [ $(modifier-function) $(target-id) : $(mod) ] ; } } } # Trying to define the same specific target with a different type. # else if $(gTARGET_TYPE($(target-id))) != $(target-type) { EXIT conflicting target types for "$(x-target)": "$(gTARGET_TYPE($(target-id)))" "$(target-type)" ; } # Generate build instructions, but only if the target has a generator. # if $(gGENERATOR_FUNCTION($(gTARGET_TYPE($(target-id))))) { # Supress the regular build of this target local suppress = [ get-values : $(default-build) ] ; local gSUPPRESS_FAKE_TARGETS = $(suppress[1]) ; declare-fake-targets $(target) : $(target-id) ; # Just gather information if we are including a library's Jamfile for a # dependent target. Don't generate build instructions here. if ! $(gIN_LIB_INCLUDE) { main-target $(target-id) : $(gTARGET_DEFAULT_BUILD($(target-id))) ; } } return $(gTARGET_FILES($(target-id))) ; } # directory-of files... # # Returns a list of the directories containing each element of files rule directory-of { local result d ; for d in $(<:D) { if $(d) = "" { result += $(DOT) ; } else { result += $(d) ; } } return $(result) ; } # top-relative-tokens path # # Returns a list of path elements which form the relative path from TOP to path, # which is expected to be given relative to the current subproject. rule top-relative-tokens { return [ simplify-path-tokens $(SUBDIR_TOKENS) [ split-path $(<) ] ] ; } .project-root-tokens = [ split-path $(.boost-build-file:D) ] ; # try to make a potentially absolute path relative to the project # root. Only works for paths below the project root right now; others # will remain absolute. rule relative-path ( path ) { local path-tokens = [ split-path $(path) ] ; # try to strip the project root local r = $(.project-root-tokens) ; local p = $(path-tokens) ; while $(r) && ( $(r[1]) = $(p[1]) ) { p = $(p[2-]) ; r = $(r[2-]) ; } # if successful, use the stripped project root if ! $(r) { path-tokens = $(p) ; } return [ tokens-to-simple-path $(path-tokens) ] ; } # dependent-include target-path... # # For each target-path, ensure that the appropriate Jamfile has been # included. Used when a target declares its dependency on another target. rule dependent-include { local target ; for target in $(<) { { local .project-path = [ target-path-of $(target) ] ; .project-path = $(.project-path:D) ; # load the file as a dependent. local gIN_LIB_INCLUDE = TRUE ; # local [ protect-subproject ] ; local .project-name-and-subdir = [ enter-subproject $(.project-path) ] ; local .project-name = $(.project-name-and-subdir[1]) ; local .project-subdir = $(.project-name-and-subdir[2]) ; local .jamfile-path = [ root-paths $(JAMFILE) : [ root-paths $(.project-subdir) : $(TOP) ] ] ; load-jamfiles $(.jamfile-path) ; } } } # segregate-free-properties variable1 variable2... # # returns the and removes the unique list of free properties from # $(variable1) $(variable2)... rule segregate-free-properties { local free-properties = [ unique [ get-properties $(gFREE_FEATURES) : $($(<)) ] ] ; local v ; for v in $(<) { $(v) = [ difference $($(v)) : $(free-properties) ] ; } return $(free-properties) ; } # is-link-compatible feature : value1 : value2 # # return non-empty iff a library built with value1 can be linked into a # target with value2, empty otherwise rule is-link-compatible ( feature : value1 : value2 ) { return [ intersection $(feature) $(value1:G=$(feature)) $(value1:G=$(feature))$(SLASH)$(value12:G=$(feature)) $(value2:G=$(feature)) : $(gLINK_COMPATIBLE) ] ; } # find-compatible-subvariant main-target : toolset variant : dependent-simple-properties rule find-compatible-subvariant ( main-target : toolset variant : dependent-simple-properties * ) { # calculate the subvariant only of what is requested # the subvariant requested... local sv-request = [ multiply-property-sets [ get-properties $(BUILD:G) : $(dependent-simple-properties) ] ] ; # the available build requests... local build-requests = [ multiply-property-sets [ select-gristed $(BUILD) ] ] ; # the build requst we want to build... local sv-build = [ intersection $(sv-request) : $(build-requests) ] ; sv-build ?= "" ; local BUILD = $(variant) [ split-path $(sv-build) ] ; # the full subvariant to build... local subvariant = [ expand-target-subvariants $(main-target) : $(variant) : $(toolset) ] ; local sv-target = ; local sv-properties = ; local sv-toolset = ; local sv-variant = ; split-target-subvariant sv-target sv-properties sv-toolset sv-variant : $(subvariant) ; local sv-overrides = [ difference $(dependent-simple-properties) : [ select-gristed $(sv-properties) ] ] ; if ! $(gTARGET_TYPE($(main-target))) { EXIT unknown dependent target $(main-target) ; } # check to make sure we can link against the subvariant local target-requirements = [ select-gristed $(gTARGET_REQUIREMENTS($(main-target))) ] ; local override-conflicts = [ get-properties $(target-requirements:G) $(gALWAYS_RELEVANT) : $(sv-overrides) ] ; for local sv-override in $(override-conflicts) { local sv-required = [ get-values $(sv-override:G) : $(sv-properties) ] ; if ! [ is-link-compatible $(sv-override:G) : $(sv-override:G=) : $(sv-required) ] { EXIT $(main-target): required property $(sv-override:G)$(sv-required) incompatible with $(sv-override) ; } } # now that we have a mostly (or completely) compatible subvariant do the overrides local gTARGET_REQUIREMENTS($(main-target)) = # property rules... [ select-ungristed $(gTARGET_REQUIREMENTS($(main-target))) ] # always relevant properties to target... [ difference $(target-requirements) : [ get-properties [ difference $(sv-overrides:G) : $(gALWAYS_RELEVANT) ] : $(target-requirements) ] ] # link compatible properties, on the target... [ get-properties [ difference $(sv-overrides:G) : $(gALWAYS_RELEVANT) ] : $(target-requirements) ] # overrides from dependent... [ get-properties [ difference $(sv-overrides:G) : $(override-conflicts:G) ] : $(dependent-simple-properties) ] ; subvariant = [ expand-target-subvariants $(sv-target) : $(sv-variant) : $(sv-toolset) ] ; split-target-subvariant sv-target sv-properties sv-toolset sv-variant : $(subvariant) ; return $(sv-properties) ; } # For each target specified in libs, generate build instructions # for a subvariant that can be linked with a dependent target with # dependent-properties, returning a list of all generated targets. rule link-libraries ( libs * : toolset variant : dependent-simple-properties * ) { local lib-path result ; for lib-path in $(libs) { local lib-path = [ target-path-of $(lib-path) ] ; local lib-target = [ target-id-of $(lib-path) ] ; # Enter the dependee subproject local [ protect-subproject ] ; enter-subproject [ directory-of $(lib-path) ] ; local lib-subvariant = [ find-compatible-subvariant $(lib-target) : $(toolset) $(variant) : $(dependent-simple-properties) ] ; # Generate build instructions for the library target result += [ subvariant-target $(lib-target) : $(lib-subvariant) : $(toolset) $(variant) ] ; } return $(result) ; } # Which configuration(s) to build if nothing is explicitly specified DEFAULT_BUILD ?= debug ; # get-BUILD [target-default-build] # # pick the first of ($(BUILD), $(>), $(DEFAULT_BUILD)) which is set. If it # contains no variants, add variants from $(DEFAULT_BUILD). rule get-BUILD { local build = $(BUILD) ; build ?= $(<) ; build ?= $(DEFAULT_BUILD) ; local variants = [ select-ungristed $(build) ] ; if ! $(variants) { build += [ select-ungristed $(DEFAULT_BUILD) ] ; } return $(build) ; } # declare-fake-targets abstract-target : target-file # # rule declare-fake-targets { # make a fake target so that it can be built without knowing the suffix # Since executables under *NIX have no suffix, we'd better check if $(>) != $(<) { DEPENDS $(<) : $(>) ; NOTFILE $(<) ; } # The following checks that we're in the subdirectory of Jam's invocation # so that we can arrange for ungristed target names to be built from the # command-line. if $(<:G) && [ in-invocation-subdir ] { DEPENDS $(<:G=) : $(<) ; # allows $(<:G=) to be used to build all variants NOTFILE $(<:G=) ; } } # declare-target-type TYPE : [[]]value... rule declare-target-type { gTARGET_TYPE_REQUIREMENTS($(<)) = $(>) ; } declare-target-type DLL : true ; if $(NT) { gIMPORT_SUFFIX(DLL) = .lib ; gIMPORT_SUFFIX(LIB) = .lib ; gEXPORT_SUFFIX(DLL) = .lib ; } else { gIMPORT_SUFFIX(DLL) = .so ; gIMPORT_SUFFIX(LIB) = .a ; } # depend-on-libraries target-files : library-targets rule depend-on-libraries { NEEDLIBS = [ unique $(NEEDLIBS) $(>) ] ; NEEDLIBS on $(<) = [ on $(<) return [ unique $(NEEDLIBS) $(>) ] ] ; DEPENDS $(<) : $(>) ; # To run these targets, we need everything needed to run the libraries gRUN_PATH($(<)) = [ unique $(gRUN_PATH($(<))) $(gRUN_PATH($(>))) ] ; gRUN_LD_LIBRARY_PATH($(<)) = [ unique $(gRUN_LD_LIBRARY_PATH($(<))) $(gRUN_LD_LIBRARY_PATH($(>))) ] ; } rule depend-on-dlls ( targets + : dlls-and-import-libs * ) { local linkable ; # collect the linkable elements of the source libs into the appropriate variables for local f in $(dlls-and-import-libs) { local v = $(gLINK_VARIABLE($(f:S))) ; $(v) += $(f) ; $(v) on $(targets) += $(f) ; if $(v) { linkable += $(f) ; } } LIBPATH on $(<) += [ unique $(gLOCATE($(>))) ] ; FINDLIBS on $(<) += [ unique $(gTARGET_BASENAME($(gTARGET_SUBVARIANT($(>))))) ] ; DEPENDS $(<) : $(>) ; # To run these targets, we need everything needed to run the libraries gRUN_PATH($(<)) = [ unique $(gRUN_PATH($(<))) $(gRUN_PATH($(>))) ] ; gRUN_LD_LIBRARY_PATH($(<)) = [ unique $(gRUN_LD_LIBRARY_PATH($(<))) $(gRUN_LD_LIBRARY_PATH($(>))) ] ; } # Given build properties, returns the normalised version of the features for # use by rename-targets. rule get-tag-features ( variant : build-properties * ) { local result = ; local tags = [ get-properties : $(build-properties) ] ; for local tag in $(tags) { tag = $(tag:G=) ; if $(tag:G) { result += $(tag) ; } else { result += <$(variant)>$(tag) ; } } return $(result) ; } # Given target, a main target name gristed with $(SOURCE_GRIST), generate build # instructions for a subvariant target using the given toolset, variant, etc. # # RETURNS: the a list of target names for the files built by the subvariant. If # the target is a library, the first filename is the one that should be linked # into a dependent target. rule subvariant-target ( target : subvariant-id build-properties * : toolset variant ) { # SOURCE_GRIST identifies the subproject directory; TARGET_GRIST will identify # the target and subvariant, since unique versions of files will be built for # that combination. local property-tags = [ get-tag-features $(variant) : $(build-properties) ] ; local tags = [ get-properties : $(gIMPOSED_REQUIREMENTS($(target))) ] $(property-tags) ; local TARGET_GRIST = [ join-path $(SOURCE_GRIST) $(target:G=) $(subvariant-id) ] ; local subvariant = $(target:G=$(TARGET_GRIST)) ; # Keep track of the generated targets. if ! $(TARGET_GRIST) in $(gDECLARED_TARGETS) { gDECLARED_TARGETS += $(TARGET_GRIST) ; } # Make sure we know how to generate these types of targets. local target-type = $(gTARGET_TYPE($(target))) ; if ! $(target-type) { EXIT unknown target type for $(target) ; } gTARGET_TYPE($(subvariant)) = $(target-type) ; # LOCATE_TARGET affects where built targets are generated. We move it # relative to the default location based on the subvariant local LOCATE_TARGET = [ join-path $(LOCATE_TARGET) $(target:G=) $(subvariant-id) ] ; # The renamed base name of the target. Only considers the tags defined directly # on the target. gTARGET_BASENAME($(target)) = [ rename-target $(gTARGET_NAME($(target))) : [ split-path [ ungrist $(subvariant:G) ] ] : $(property-tags) ] ; # First order names have the suffix, if any according to the platform. local target-files = [ FAppendSuffix $(subvariant) : $(SUF$(target-type)) ] ; # Second order names have any tags as imposed from stage target contexts. target-files = [ rename-target $(target-files) : [ split-path [ ungrist $(subvariant:G) ] ] : $(tags) ] ; # Third order names are customized as determined by a rename rule on the target type. if $(gNAME_ADJUST($(target-type))) { target-files = [ $(gNAME_ADJUST($(target-type))) $(target-files) : $(subvariant-id) $(build-properties) : $(toolset) $(variant) ] ; } # Do nothing if we already have the build instructions for the specific # target files of this subvariant target. if ! $(target-files) in $(gTARGET_FILES($(target))) { gTARGET_SUBVARIANT($(target-files)) = $(target) ; ###gTARGET_FILES($(subvariant)) = $(target-files) ; gTARGET_FILES($(target)) += $(target-files) ; # Remember the path from the build root to the subvariant directory gSUBVARIANT_PATH($(subvariant)) = $(subvariant-id) ; # Add target suppression if was in the requirements local gSUPPRESS_FAKE_TARGETS = [ get-values : $(gTARGET_REQUIREMENTS($(target))) ] $(gSUPPRESS_FAKE_TARGETS) ; declare-fake-targets $(target) : $(target-files) ; # set up gBUILD_PROPERTIES for include-tools (below) local gBUILD_PROPERTIES = $(build-properties) ; # Include the toolset specification. This will set up the global flags # variables in a way appropriate to this build. include-tools $(toolset) ; # headers should be identified specific to the target, since search paths # may differ for different subvariants. The same header name or relative # path may refer to different files. local HDRGRIST = [ join $(SOURCE_GRIST) $(HDRS) $(STDHDRS) : "#" ] ; # transfer target variables to the target file. set-target-variables $(target-files) ; if [ get-values <$(STATIC_TYPES)> <$(SHARED_TYPES)> : $(gTARGET_DEPS($(target))) ] { # include each jamfile describing a dependee target. dependent-include [ get-values <$(STATIC_TYPES)> <$(SHARED_TYPES)> : $(gTARGET_DEPS($(target))) ] ; local libs dlls ; { # Protect target variables against modification while lib dependencies # are built. They will be made empty here, and restored when this scope exits local $(gTARGET_VARIABLES) ; # extract the simple properties from dependent-properties local simple-properties = $(gBUILD_PROPERTIES) ; segregate-free-properties simple-properties ; # generate library build instructions local BUILD = $(BUILD) ; BUILD ?= $(gTARGET_DEFAULT_BUILD($(target))) ; libs = [ link-libraries [ get-values <$(STATIC_TYPES)> : $(gTARGET_DEPS($(target))) ] : $(toolset) $(variant) : $(simple-properties) ] ; dlls = [ link-libraries [ get-values <$(SHARED_TYPES)> : $(gTARGET_DEPS($(target))) ] : $(toolset) $(variant) : $(simple-properties) ] ; } depend-on-libraries $(target-files) : $(libs) ; depend-on-dlls $(target-files) : $(dlls) ; } # dispatch to the appropriate declaration function. Here we are using an # FTJam-only feature (thanks, David Turner!) local ignored = [ $(gGENERATOR_FUNCTION($(target-type))) $(target-files) : $(gTARGET_SOURCES($(target))) ] ; $(gTARGET_VARIABLES) = ; # Be sure that we don't mask bugs with lingering target variables } return $(target-files) ; } # Generate the expanded subvariants of a target. # rule expand-target-subvariants ( target : local-build * : tools + : ) { local BUILD = [ get-BUILD $(local-build) ] ; local variants = [ select-ungristed $(BUILD) ] ; local build-request = [ difference $(BUILD) : $(variants) ] ; local subvariants = ; for local toolset in $(tools) { for local variant in $(variants) { local rules = [ select-ungristed $(gTARGET_REQUIREMENTS($(target))) $(gIMPOSED_REQUIREMENTS($(target))) ] ; local requirements = [ select-gristed $(gTARGET_REQUIREMENTS($(target))) $(gIMPOSED_REQUIREMENTS($(target))) ] ; local expanded = [ expand-build-request $(toolset) $(variant) $(target) : $(requirements) : $(build-request) ] ; local gNOWARN_INCOMPATIBLE_BUILDS = TRUE ; for local instance in $(expanded) { local properties = [ split-path-at-grist $(instance) ] ; for local r in $(rules) { properties = [ $(r) $(toolset) $(variant) : $(properties) ] ; } # the rules may have modified the build request, reconstruct it properties = [ expand-build-request $(toolset) $(variant) $(target) : $(properties[2-]) : $(build-request) ] ; subvariants += $(target)|$(properties)|$(toolset)|$(variant) ; } } } return [ unique $(subvariants) ] ; } # Given an expanded subvariant of a terget, sets the various variables accordingly. # rule split-target-subvariant ( target-var properties-var toolset-var variant-var : subvariant ) { local subvariant-items = [ MATCH (.*)[|](.*)[|](.*)[|](.*) : $(subvariant) ] ; $(target-var) = $(subvariant-items[1]) ; $(properties-var) = [ split-path-at-grist $(subvariant-items[2]) ] ; $(toolset-var) = $(subvariant-items[3]) ; $(variant-var) = $(subvariant-items[4]) ; return $((target-var)) ; } # main-target target : local-build # # Generates requested subvariant build instructions for the given main target rule main-target { local subvariants = [ expand-target-subvariants $(<) : $(>) : $(TOOLS) ] ; # include each jamfile describing a dependee target. dependent-include [ get-values <$(STATIC_TYPES)> <$(SHARED_TYPES)> : $(gTARGET_DEPS($(<))) ] ; for local subvariant in $(subvariants) { local target = ; local properties = ; local toolset = ; local variant = ; split-target-subvariant target properties toolset variant : $(subvariant) ; subvariant-target $(target) : $(properties) : $(toolset) $(variant) ; } } # Declare an executable target. # gTARGET_TYPE_ID(exe) = EXE ; gGENERATOR_FUNCTION(EXE) = executable-file ; rule exe ( target : sources + : requirements * : default-build * ) { declare-local-target $(target) : $(sources) : $(requirements) : $(default-build) : EXE ; } # Declare a shared library target. # gTARGET_TYPE_ID(dll) = DLL ; gGENERATOR_FUNCTION(DLL) = dll-files ; gIS_DEPENDENCY(DLL) = TRUE ; rule dll ( target : sources + : requirements * : default-build * ) { if $(JAMUNAME[1]) = OpenBSD { if ! [ get-values : $(requirements) ] { requirements += 0.0 ; } } declare-local-target $(target) : $(sources) : $(requirements) : $(default-build) : DLL ; } # Declare a statically-linked library target. # gTARGET_TYPE_ID(lib) = LIB ; gGENERATOR_FUNCTION(LIB) = library-file ; gIS_DEPENDENCY(LIB) = TRUE ; rule lib ( target : sources + : requirements * : default-build * ) { declare-local-target $(target) : $(sources) : $(requirements) : $(default-build) : LIB ; } # Declare a template target for other targets. This is a modifier only. It # Adds the specs specified here to any other target it's a dependee of. # gTARGET_TYPE_ID(template) = TEMPLATE ; gMODIFIER_FUNCTION(TEMPLATE) = template-modifier ; gIS_DEPENDENCY(TEMPLATE) = TRUE ; gNO_TARGET_TYPE_REQUIREMENT(TEMPLATE) = TRUE ; rule template ( target : sources * : requirements * : default-build * ) { declare-local-target $(target) : $(sources) : $(requirements) : $(default-build) : TEMPLATE ; } # Declare an executable target, to be run by tests. rule unit-test ( target + : sources + : requirements * : default-build * : cmd-line * ) { if ! $(.testing.jam-included) { SEARCH on testing.jam = $(BOOST_BUILD_PATH) ; include testing.jam ; } DEPENDS all : [ run $(sources) : $(cmd-line) : # input-files : $(requirements) : $(target) : $(default-build) ] ; } # Used to build command files from a list of sources. rule build-command-file ( command : sources * ) { # Clean up after ourselves Clean clean : $(command) ; DEPENDS $(command) : $(sources) ; # Check whether there's anything to dump, so that we don't end up # executing a line of the form: # # echo > file.CMD # # on Windows this writes "echo is on." into the command-file, # which then breaks the link. if $(sources[1]) { # Handle the first target specially, so that the first source file # will clear the command file command-file-dump-1st $(command) : $(sources[1]) ; } if $(sources[2]) { # Then fill the rest up piecemeal command-file-dump-rest $(command) : $(sources[2-]) ; } } # command-file-dump-1st: dump the first source path into the target if $(NT) { # the windows command shell has the anyoing effect of appending whitespace # when redirecting with > and >> actions quietly command-file-dump-1st { echo "$(>)">"$(<)" } } else { actions quietly command-file-dump-1st { echo "$(>)" > "$(<)" } } # command-file-dump: dump the remaining source paths into the target if $(NT) { # the windows command shell has the anyoing effect of appending whitespace # when redirecting with > and >> actions quietly piecemeal command-file-dump-rest { echo "$(>)">>"$(<)" } } else { actions quietly piecemeal command-file-dump-rest { echo "$(>)" >> "$(<)" } } # Clean up the temporary COMMAND-FILE used to build TARGETS. rule remove-command-file ( targets + : command-file ) { TEMPORARY $(command-file) ; Clean clean : $(command-file) ; # Mark the file for removal via clean } actions ignore quietly piecemeal together remove-command-file { $(RM) $(>) } # build TARGETS from SOURCES using a command-file, where RULE-NAME is # used to generate the build instructions from the command-file to # TARGETS rule with-command-file ( rule-name targets * : sources * ) { # create a command-file target and place it where the first target # will be built local command-file = $(targets[1]:S=.CMD) ; LOCATE on $(command-file) = $(gLOCATE($(targets[1]))) ; build-command-file $(command-file) : $(sources) ; # Build the targets from the command-file instead of the sources DEPENDS $(targets) : $(command-file) ; local result = [ $(rule-name) $(targets) : $(command-file) ] ; # clean up afterwards # Can't really do this until arguments are accounted for. # remove-command-file $(targets) : $(command-file) ; return $(result) ; } TAG(prefix) = "" ; TAG(postfix) = "" ; # GIVEN: # # A target subvariant, the subvariant info, and a set of rename tags. # # RESULT: # # Uses the rename tags, and the global TAG map, to append a tag to the # target basename. The new subvariant target is returned. The tag for # the target is composed from the subvariant info and the corresponding # entry in the tags. This creates the tag in the order as given by the # subvariant info. # # EXAMPLE: # # [ rename-target libtest.so : gcc debug : _gcc _debug ] # # RETURNS: # # libtest_gcc_debug.so # rule rename-target ( target + : subvariant * : tags * ) { local tag-values = ; for local tag in $(tags) { local tag-tokens = [ MATCH (<)(.*)(>)(.*) : $(tag:G=) ] ; tag-tokens = $(tag-tokens[2]) $(tag-tokens[4]) ; tag-values += $(tag-tokens[2]:G=$(tag-tokens[1])) ; } local tag-text = "" ; # the prefix of the tag... # local prefix-tag = [ get-values : $(tag-values) $(TAG(prefix):G=prefix) ] ; tag-text = $(prefix-tag[1]) ; # the subvariant tags... # for local sv in $(subvariant) { local sv-tag = [ get-values <$(sv)> : $(tag-values) $(TAG($(sv)):G=$(sv)) ] ; if $(sv-tag) { tag-text = $(tag-text)$(sv-tag[1]) ; } } # the postfix of the tag... # local postfix-tag = [ get-values : $(tag-values) $(TAG(postfix):G=postfix) ] ; tag-text = $(tag-text)$(postfix-tag[1]) ; local renamed-target = ; for t in $(target) { local B-S = [ MATCH ([^\\.]*)(.*) : $(t:G=) ] ; local B = $(B-S[1]) ; B ?= "" ; local S = $(B-S[2]) ; S ?= "" ; local new-name = $(B)$(tag-text)$(S) ; new-name = $(new-name:G=$(t:G)) ; renamed-target += $(new-name) ; } return $(renamed-target) ; } rule grist-targets ( targets + : subdir-tokens * ) { local subdir-grist = "" ; if $(subdir-tokens) { subdir-grist = [ FGrist $(subdir-tokens) ] ; if $(SOURCE_GRIST) { subdir-grist = "!$(subdir-grist)" ; } } if ! $(SOURCE_GRIST) { return $(targets:G=$(subdir-grist)) ; } else { return $(targets:G=$(SOURCE_GRIST)$(subdir-grist)) ; } } # EXAMPLE: # # stage test-stage # : foo/bar/test1 qwerty/keys docs/README # : "_" "D" "P" "GCC" # : debug profile true # ; # # PRODUCES: # # test-stage/libkeys_GCCD.so # test-stage/libkeys_GCCP.so # test-stage/test1_GCCD # test-stage/test1_GCCP # test-stage/README # # IFF: # # $shell> jam test-stage # rule stage ( name : sources + : requirements * : local-build * ) { if ! $(gIN_LIB_INCLUDE) { local stage-id = [ grist-targets $(name) ] ; local arch-subdirs = [ get-values : $(requirements) ] ; local tree-root = [ get-values : $(requirements) ] ; if $(tree-root) { tree-root = [ split-path $(tree-root[1]) ] ; } local locate = [ get-values : $(requirements) ] ; if $(locate) { locate = [ split-path $(locate) ] ; } local fake-target = [ get-values : $(requirements) ] ; # Supress the regular build of this target local gSUPPRESS_FAKE_TARGETS = [ get-values : $(local-build) ] ; local stage-dir = $(name:G=) ; local files = [ select-ungristed $(sources) ] ; local file-mode ; local file-tagged ; local file-subdir ; # Prevent built object from getting deleted so that when targets are linked # multiple times they are available. local KEEPOBJS = true ; # For each source, collect its information, and possibly generate it. # for local source in $(sources) { source = [ split-qualified-property $(source) ] ; local source-build = [ MATCH "^<([^>]*)>" : $(source[1-2]) ] ; source = [ expand-source-names $(source[3]) ] ; if $(source:G) { local gIN_LIB_INCLUDE = TRUE ; local target = $(source:D=:G=) ; local target-id = [ target-id-of $(source) ] ; local target-subdir = [ directory-of [ target-path-of $(source) ] ] ; dependent-include $(source:G=) ; local gIMPOSED_REQUIREMENTS($(target-id)) = $(requirements) ; local subvariants = [ expand-target-subvariants $(target-id) : $(local-build) : $(TOOLS) ] ; for local subvariant in $(subvariants) { local s-target = ; local s-properties = ; local s-toolset = ; local s-variant = ; split-target-subvariant s-target s-properties s-toolset s-variant : $(subvariant) ; local s-subdir ; if $(arch-subdirs) { local arch = [ get-values : $(s-properties) ] ; arch ?= [ get-values : $(s-properties) ] ; arch ?= $(OSPLAT:L) ; if $(arch) = "default" { arch = $(OSPLAT:L) ; } arch += [ get-values : $(s-properties) ] ; arch += $(OS:L) ; s-subdir = $(arch:J=-) ; } if ( $(s-toolset) = $(source-build[1]) || $(source-build[1]) = * ) && ( $(s-variant) = $(source-build[2]) || $(source-build[2]) = * ) { local target-subvariant = ; { local [ protect-subproject ] ; enter-subproject $(target-subdir) ; target-subvariant = [ subvariant-target $(s-target) : $(s-properties) : $(s-toolset) $(s-variant) ] ; } local sv-files = ; for local sv in $(target-subvariant) { local sv-file = $(gFILES($(sv))) ; sv-file ?= $(sv) ; sv-files += $(sv-file) ; } sv-files = [ unique $(sv-files) ] ; for local sv in $(sv-files) { local renamed-target = [ rename-target $(sv) : [ split-path $(s-properties[1]) ] : ] ; files += $(sv) ; file-mode($(sv)) = $($(gTARGET_TYPE($(s-target)))MODE) ; file-tagged($(sv)) = $(renamed-target) ; file-subdir($(sv)) = $(s-subdir) ; } } } } } # Generate and collect the file copy build instructions. If we # are getting defined in the dependent phase skip the actual instructions. # local destination-files = ; local locate-target = $(locate) ; if $(ALL_LOCATE_TARGET) { locate-target ?= [ join-path [ split-path $(ALL_LOCATE_TARGET) ] $(SUBDIR_TOKENS) ] ; } locate-target ?= [ split-path $(SUBDIR) ] ; for local file in $(files) { local destination-file ; local destination-subdir ; if $(file:G) { destination-file = $(file-tagged($(file)):G=:D=) ; destination-subdir = $(file-subdir($(file))) ; } else { destination-file = $(file:D=) ; if $(tree-root) { destination-subdir = [ strip-initial $(tree-root) : [ split-path $(file:D) ] ] ; } } destination-file = [ grist-targets $(destination-file) : [ split-path $(stage-dir) ] $(destination-subdir) ] ; destination-files += $(destination-file) ; { local FILEMODE = $(FILEMODE) ; if $(file-mode($(file))) { FILEMODE = $(file-mode($(file))) ; } MakeLocate $(destination-file) : [ FDirName $(locate-target) [ split-path $(stage-dir) ] $(destination-subdir) ] ; FileClone $(destination-file) : $(file) ; local target = $(stage-id) $(destination-subdir) $(destination-file:G=) ; declare-fake-targets $(target:J=/) : $(destination-file) ; } } # Don't expose fake targets when suppressing default builds. # But honor requirement to expose sources through given . # if ! $(fake-target) { declare-fake-targets $(stage-id:G=) : $(destination-files) ; } else { if $(gSUPPRESS_FAKE_TARGETS) { declare-fake-targets $(fake-target) : $(files) ; } else { declare-fake-targets $(fake-target) : $(destination-files) ; } } Clean clean : $(destination-files) ; } } # GIVEN: # # A bare target, either with or without grist. # # RETURNS: # # The fully qualified and gristed target ID. # # EXAMPLE: # # [ target-id-of ../../sub1/sub2/test.dll ] # # RETURNS: # # test.dll # rule target-id-of ( target-ref ) { local path = [ directory-of $(target-ref:G=) ] ; if ! [ MATCH "^(@)" : $(path) ] { path = [ join @$(PROJECT) [ simplify-path-tokens [ top-relative-tokens $(path) ] ] : / ] ; } local tokens = [ split-path $(path) ] ; local project-name = [ MATCH "^@([^/\\]+)" : $(tokens[1]) ] ; if $(project-name) { tokens = $(tokens[2-]) ; } project-name ?= $(PROJECT) ; local SOURCE_GRIST = [ FGrist @$(project-name) [ simplify-path-tokens $(tokens) ] ] ; local target-id = [ FGristFiles $(target-ref:D=:G=) ] ; return $(target-id) ; } # # rule target-path-of ( target-ref ) { local path = [ directory-of $(target-ref:G=) ] ; if ! [ MATCH "^(@)" : $(path) ] { path = [ join @$(PROJECT) [ simplify-path-tokens [ top-relative-tokens $(path) ] ] : / ] ; } local grist = $(target-ref:G) ; path = $(path)/$(target-ref:D=:G=) ; return $(path:G=$(grist)) ; } # Common rules for generating a single stage tag based on the # variant, build properties, and the toolset used to build. # To use place this rule name in the requirementes section of # a stage target. # # The tag is constructed as such: # # [-][-][-] # # maps to an abbreviated name of the toolset # and when possible and applicable the version of the toolset. # # "mt" when multi-threading is enabled. # # adds these single letter tags: # "s" when static linking to runtime # "g" when linking to debug runtime # "y" when building debug-python variants # "d" when building debug variants # "p" when building with stlport libraries # "n" when building with stlport and using native iostreams # # The tag added is a to allow for additional tags # in the stage. For example the version tag. # rule common-stage-tag ( toolset variant : properties * ) { local tags = ; local thread-tag = ; if multi in $(properties) { thread-tag = mt ; } local runtime-tag = ; if static in $(properties) { runtime-tag += s ; } if debug in $(properties) { runtime-tag += g ; } if [ MATCH .*(debug-python).* : $(variant) ] { runtime-tag += y ; } else { if [ MATCH .*(debug).* : $(variant) ] { runtime-tag += d ; } } if [ MATCH .*(stlport).* : $(toolset) ] || [ MATCH .*(stlport).* : $(properties:G) ] { runtime-tag += p ; } if off in $(properties) { runtime-tag += n ; } local toolset-tag = ; switch $(toolset) { case *borland* : toolset-tag += bcb ; case *como* : toolset-tag += como ; case *cwpro8* : toolset-tag += cw8 ; case *darwin* : toolset-tag += ; case *edg* : toolset-tag += edg ; case *gcc* : toolset-tag += gcc ; case *intel-linux* : toolset-tag += il ; case *intel-win32* : toolset-tag += iw ; case *kcc* : toolset-tag += kcc ; case *kylix* : toolset-tag += bck ; case *metrowerks* : toolset-tag += cw ; case *mingw* : toolset-tag += mgw ; case *mipspro* : toolset-tag += mp ; case *msvc* : { toolset-tag += vc6 ; if dynamic in $(properties) { thread-tag = mt ; } } case *sunpro* : toolset-tag += sw ; case *tru64cxx* : toolset-tag += tru ; case *vacpp* : toolset-tag += xlc ; case *vc7* : { toolset-tag += vc7 ; toolset-tag += [ MATCH "vc7[.]([0123456789]*)" : $(toolset) ] ; if dynamic in $(properties) { thread-tag = mt ; } } case * : toolset-tag += [ MATCH "^([^-]*)" : $(toolset) ] ; } toolset-tag += [ MATCH "[-]([0123456789]+).([0123456789]*)" : $(toolset) ] ; tags += $(toolset-tag:J=) ; tags += $(thread-tag:J=) ; tags += $(runtime-tag:J=) ; if $(tags) { return $(properties) <*><*>-$(tags:J=-) ; } else { return $(properties) ; } } # Recursive version of GLOB. Builds the glob of files while # also searching in the subdirectories of the given root. # rule glob-tree ( root : patterns * ) { local e ; local f = [ GLOB $(root) : $(patterns) ] ; local files ; for e in $(f) { if $(e:D=) != CVS { files += $(e) ; } } local d = [ difference [ GLOB $(root) : * ] : $(files) ] ; for e in $(d) { if ! ( $(e:D=) in . .. ) { files += [ glob-tree $(e) : $(patterns) ] ; } } return $(files) ; } rule unless ( test * : no-value * : yes-value * ) { if ! $(test) { return $(no-value) ; } else { return $(yes-value) ; } } rule cond ( test * : yes-value * : no-value * ) { if $(test) { return $(yes-value) ; } else { return $(no-value) ; } } # If the toolset matches the given regex pattern, modify the # subvariant-path and properties for static linking rule force-NT-static-link ( pattern : toolset : subvariant-path properties * ) { if $(NT) && [ MATCH $(pattern) : $(toolset) ] { properties = [ difference $(properties) : dynamic ] static ; } return $(subvariant-path) $(properties) ; } # Stick this rule name in your requirements if you are building code # which requires locale support. It handles the metrowerks-specific # case that locale support demands the static version of the runtime # library. rule std::locale-support ( toolset variant : subvariant-path properties * ) { return [ force-NT-static-link .*(metrowerks|cwpro).* : $(toolset) : $(subvariant-path) $(properties) ] ; } # Stick this rule name in your requirements if you are building code # which requires facet support. It handles the intel-win32-specific # case that facet support seems to demand the static version of the # runtime library. rule std::facet-support ( toolset variant : subvariant-path properties * ) { return [ force-NT-static-link .*(intel).* : $(toolset) : $(subvariant-path) $(properties) ] ; } # load the specified modules if they haven't been loaded already. If # the module has no suffix, ".jam" is appended. If the module name is # prepended with a path, it is sought in that location relative to the # current Jamfile, otherwise it is sought in BOOST_BUILD_PATH. rule import ( modules + ) { for local name in $(modules) { local search = $(BOOST_BUILD_PATH) ; # search here local n = $(name:D=) ; # for this basename if ! $(n:S) { n = $(n).jam ; } # if a directory was specified local d = $(name:D) ; if $(d) { # Normalize the path relative to the invocation directory. n = [ root-paths $(n) : $(d:R=$(SUBDIR)) ] ; n = [ root-paths $(n) : [ PWD ] ] ; search = ; # no searching; the path was specified. } SEARCH on $(n) = $(search) ; if ! $($(n).included) { include $(n) ; $(n).included = true ; } } } # declare a project's installable sources (raw sources or built targets) rule install ( name type : sources + : options * ) { if $(gINSTALL_SOURCES) && ! $(name) in $(gINSTALL_EXCLUSIONS) { local result ; for local source in $(sources) { result += [ target-path-of $(source) ] ; } if ! $(result) in $(gINSTALL_SOURCES($(type))) { gINSTALL_SOURCES($(type)) += $(result) ; } return $(result) ; } } # rule install-subinclude ( jamfiles + : options * ) { local gINSTALL_SOURCES = TRUE ; local gIN_LIB_INCLUDE = TRUE ; local gINSTALL_EXCLUSIONS = [ get-values : $(options) ] ; for local jamfile in $(jamfiles) { local sub-jamfile = [ relative-path $(jamfile) ] ; dependent-include $(sub-jamfile) ; } } # get project installation sources of a given type rule install-sources ( type ) { return $(gINSTALL_SOURCES($(type))) ; } -------------- next part -------------- #~ Copyright (c) 2001 David Abrahams. #~ Copyright (c) 2002-2003 Rene Rivera. #~ Use, modification and distribution is subject to the Boost Software #~ License Version 1.0. (See accompanying file LICENSE_1_0.txt or #~ http://www.boost.org/LICENSE_1_0.txt) # The following #// line will be used by the regression test table generation # program as the column heading for HTML tables. Must not include version number. #//GNU
GCC
# compute directories for invoking GCC # # The gcc toolset can be user-configured using the following # variables: # # GCC_ROOT_DIRECTORY # The directory in which GCC was installed. Defaults to # unset. Usually, there is no need to set this variable at # all. However, if G++ is not in the path it is usually # sufficient to configure this one variable. More fine-grained # configuration is available by setting the following: # # GCC_BIN_DIRECTORY # the directory prefix used to find the gcc executables. Defaults to # $(GCC_ROOT_DIRECTORY)/bin/, or "" if GCC_ROOT_DIRECTORY is # not set. # # GCC_INCLUDE_DIRECTORY # the directory in which to find system includes. Defaults to # empty. # # GCC_STDLIB_DIRECTORY # the directory in which to find the standard library # objects associated with this build of gcc. Defaults to # $(GCC_ROOT_DIRECTORY)/lib. # # GXX # The name by which g++ is invoked. You can also use this in # lieu of setting the property to force options such # as "-V3.0.4" into the g++ command line: "-sGXX=g++ -V3.0.4". # # GCC # Similar to GXX, the name by which gcc is invoked for "C" # language targets. # singleton variables... set-as-singleton GCC_ROOT_DIRECTORY GCC_BIN_DIRECTORY GCC_INCLUDE_DIRECTORY GCC_STDLIB_DIRECTORY ; flags gcc GCC_BIN_DIRECTORY : $(GCC_BIN_DIRECTORY) ; flags gcc GCC_INCLUDE_DIRECTORY : $(GCC_INCLUDE_DIRECTORY) ; flags gcc GCC_STDLIB_DIRECTORY : $(GCC_STDLIB_DIRECTORY) ; GCC_BIN_DIRECTORY ?= $(GCC_ROOT_DIRECTORY)/bin/ ; GCC_BIN_DIRECTORY ?= "" ; # Don't clobber tool names if GCC_ROOT_DIRECTORY not set GCC_STDLIB_DIRECTORY ?= $(GCC_ROOT_DIRECTORY)/lib ; # Make sure this gets set "on" the target flags gcc GCC_BIN_DIR : $(GCC_BIN_DIRECTORY) ; flags gcc LINKFLAGS static : -static ; flags gcc CFLAGS on : -g ; flags gcc LINKFLAGS on : -g ; flags gcc CFLAGS off : -O0 ; flags gcc CFLAGS speed : -O3 ; # Other optimizations we might want for GCC # -fforce-mem -fomit-frame-pointer # -foptimize-sibling-calls -finline-functions -ffast-math -finline-limit=10000 flags gcc CFLAGS space : -Os ; flags gcc CFLAGS off : -fno-inline ; flags gcc CFLAGS on : -Wno-inline ; flags gcc CFLAGS full : -finline-functions -Wno-inline ; flags gcc .GXX : $(GXX) ; flags gcc .GCC : $(GCC) ; # # set threading options for various platforms: # local on-windows ; if $(NT) { on-windows = 1 ; } else if $(UNIX) { switch $(JAMUNAME) { case CYGWIN* : { on-windows = 1 ; } } } if $(on-windows) { flags gcc CFLAGS multi : -mthreads ; } else if $(UNIX) { switch $(JAMUNAME) { case SunOS* : { flags gcc CFLAGS multi : -pthreads ; flags gcc LINKFLAGS multi : -pthreads ; flags gcc FINDLIBS multi : rt ; } case BeOS : { # BeOS has no threading options, don't set anything here. } case Darwin : { # MacOS X, doesn't need any threading options set # -lpthread is linked to by default. # There is no gcc/g++, we need to use cc/c++ instead: .GCC ?= cc ; .GXX ?= c++ ; } case *BSD : { flags gcc CFLAGS multi : -pthread ; flags gcc LINKFLAGS multi : -pthread ; # there is no -lrt on BSD } case IRIX : { # gcc on IRIX does not support multi-threading, don't set anything here. } case HP_UX : { # gcc on HP-UX does not support multi-threading, don't set anything here } case * : { flags gcc CFLAGS multi : -pthread ; flags gcc LINKFLAGS multi : -pthread ; flags gcc FINDLIBS multi : rt ; } } } # Some possibly supported, or not, linker flags. The support depends on the OS linker. # flags gcc RPATH_LINK ; flags gcc SONAME ; # Set/reset options for the linker of the platform. # if $(UNIX) { switch $(JAMUNAME) { case SunOS* : { NO_GNU_LN = true ; # sun seems not to use the GNU linker with gcc } case Linux : { RPATH_LINK = -Wl,-rpath-link, ; SONAME = -Wl,-soname, ; } case OpenBSD : { SONAME = -Wl,-soname, ; } case AIX* : { NO_GNU_LN = true ; IMPLIB_FLAGS = "-Wl,-bI:" ; } } } # Set architecture/instruction-set options. # # x86 and compatible .ARCH = x86 native ; flags gcc CFLAGS x86/default : -mcpu=i386 ; flags gcc CFLAGS $(.ARCH)/i386 : -mcpu=i386 ; flags gcc CFLAGS $(.ARCH)/i486 : -mcpu=i486 ; flags gcc CFLAGS $(.ARCH)/i586 : -mcpu=i586 ; flags gcc CFLAGS $(.ARCH)/i686 : -mcpu=i686 ; flags gcc CFLAGS $(.ARCH)/pentium : -mcpu=pentium ; flags gcc CFLAGS $(.ARCH)/pentium-mmx : -mcpu=pentium-mmx ; flags gcc CFLAGS $(.ARCH)/pentiumpro : -mcpu=pentiumpro ; flags gcc CFLAGS $(.ARCH)/pentium2 : -mcpu=pentium2 ; flags gcc CFLAGS $(.ARCH)/pentium3 : -mcpu=pentium3 ; flags gcc CFLAGS $(.ARCH)/pentium4 : -mcpu=pentium4 ; flags gcc CFLAGS $(.ARCH)/k6 : -mcpu=k6 ; flags gcc CFLAGS $(.ARCH)/k6-2 : -mcpu=k6-2 ; flags gcc CFLAGS $(.ARCH)/k6-3 : -mcpu=k6-3 ; flags gcc CFLAGS $(.ARCH)/athlon : -mcpu=athlon ; flags gcc CFLAGS $(.ARCH)/athlon-tbird : -mcpu=athlon-tbird ; flags gcc CFLAGS $(.ARCH)/athlon-4 : -mcpu=athlon-4 ; flags gcc CFLAGS $(.ARCH)/athlon-xp : -mcpu=athlon-xp ; flags gcc CFLAGS $(.ARCH)/athlon-mp : -mcpu=athlon-mp ; # Sparc .ARCH = sparc native ; flags gcc CFLAGS sparc/default : -mcpu=v7 ; flags gcc CFLAGS $(.ARCH)/v7 : -mcpu=v7 ; flags gcc CFLAGS $(.ARCH)/cypress : -mcpu=cypress ; flags gcc CFLAGS $(.ARCH)/v8 : -mcpu=v8 ; flags gcc CFLAGS $(.ARCH)/supersparc : -mcpu=supersparc ; flags gcc CFLAGS $(.ARCH)/sparclite : -mcpu=sparclite ; flags gcc CFLAGS $(.ARCH)/hypersparc : -mcpu=hypersparc ; flags gcc CFLAGS $(.ARCH)/sparclite86x : -mcpu=sparclite86x ; flags gcc CFLAGS $(.ARCH)/f930 : -mcpu=f930 ; flags gcc CFLAGS $(.ARCH)/f934 : -mcpu=f934 ; flags gcc CFLAGS $(.ARCH)/sparclet : -mcpu=sparclet ; flags gcc CFLAGS $(.ARCH)/tsc701 : -mcpu=tsc701 ; flags gcc CFLAGS $(.ARCH)/v9 : -mcpu=v9 ; flags gcc CFLAGS $(.ARCH)/ultrasparc : -mcpu=ultrasparc ; # RS/6000 & PowerPC .ARCH = power native ; flags gcc CFLAGS power/default : -mcpu=power ; flags gcc CFLAGS $(.ARCH)/rios : -mcpu=rios ; flags gcc CFLAGS $(.ARCH)/rios1 : -mcpu=rios1 ; flags gcc CFLAGS $(.ARCH)/rsc : -mcpu=rsc ; flags gcc CFLAGS $(.ARCH)/rios2 : -mcpu=rios2 ; flags gcc CFLAGS $(.ARCH)/rs64a : -mcpu=rs64a ; flags gcc CFLAGS $(.ARCH)/601 : -mcpu=601 ; flags gcc CFLAGS $(.ARCH)/602 : -mcpu=602 ; flags gcc CFLAGS $(.ARCH)/603 : -mcpu=603 ; flags gcc CFLAGS $(.ARCH)/603e : -mcpu=603e ; flags gcc CFLAGS $(.ARCH)/604 : -mcpu=604 ; flags gcc CFLAGS $(.ARCH)/604e : -mcpu=604e ; flags gcc CFLAGS $(.ARCH)/620 : -mcpu=620 ; flags gcc CFLAGS $(.ARCH)/630 : -mcpu=630 ; flags gcc CFLAGS $(.ARCH)/740 : -mcpu=740 ; flags gcc CFLAGS $(.ARCH)/750 : -mcpu=750 ; flags gcc CFLAGS $(.ARCH)/power : -mcpu=power ; flags gcc CFLAGS $(.ARCH)/power2 : -mcpu=power2 ; flags gcc CFLAGS $(.ARCH)/powerpc : -mcpu=powerpc ; flags gcc CFLAGS $(.ARCH)/power64 : -mcpu=power64 ; flags gcc CFLAGS $(.ARCH)/403 : -mcpu=403 ; flags gcc CFLAGS $(.ARCH)/505 : -mcpu=505 ; flags gcc CFLAGS $(.ARCH)/801 : -mcpu=801 ; flags gcc CFLAGS $(.ARCH)/821 : -mcpu=821 ; flags gcc CFLAGS $(.ARCH)/823 : -mcpu=823 ; flags gcc CFLAGS $(.ARCH)/860 : -mcpu=860 ; flags gcc CFLAGS $(.ARCH)/power-common : -mcpu=common ; # MIPS-1-2-3-4 flags gcc MIPS mips1 mips2 mips3 mips4 : TRUE ; flags gcc MIPS r2000 r3000 r3900 r4000 r4100 r4300 r4400 r4600 r4650 r5000 r6000 r8000 orion : TRUE ; if $(MIPS) { flags gcc CFLAGS mips1 : -mips1 ; flags gcc CFLAGS mips2 : -mips2 ; flags gcc CFLAGS mips3 : -mips3 ; flags gcc CFLAGS mips4 : -mips4 ; flags gcc CFLAGS r2000 : -mcpu=r2000 ; flags gcc CFLAGS r3000 : -mcpu=r3000 ; flags gcc CFLAGS r3900 : -mcpu=r3900 ; flags gcc CFLAGS r4000 : -mcpu=r4000 ; flags gcc CFLAGS r4100 : -mcpu=r4100 ; flags gcc CFLAGS r4300 : -mcpu=r4300 ; flags gcc CFLAGS r4400 : -mcpu=r4400 ; flags gcc CFLAGS r4600 : -mcpu=r4600 ; flags gcc CFLAGS r4650 : -mcpu=r4650 ; flags gcc CFLAGS r5000 : -mcpu=r5000 ; flags gcc CFLAGS r6000 : -mcpu=r6000 ; flags gcc CFLAGS r8000 : -mcpu=r8000 ; flags gcc CFLAGS orion : -mcpu=orion ; # ...addressing model options flags gcc ADDRESS_MODEL_INVALID 16 : TRUE ; if $(ADDRESS_MODEL_INVALID) { EXIT "Error: Invalid addressing model for MIPS architecture (16)." ; } flags gcc CFLAGS default : -mgp32 ; flags gcc CFLAGS 32 : -mgp32 ; flags gcc CFLAGS 64 : -mgp64 -mlong64 ; } # # define compiler names if not set: .GCC ?= gcc ; .GXX ?= g++ ; flags gcc CFLAGS on : -pg ; flags gcc LINKFLAGS on : -pg ; flags gcc C++FLAGS off : -fno-rtti ; flags gcc C++FLAGS on : -fvtable-thunks ; flags gcc C++FLAGS off : -fvtable-thunks=0 ; flags gcc CFLAGS ; flags gcc C++FLAGS ; flags gcc DEFINES ; flags gcc UNDEFS ; flags gcc HDRS ; flags gcc STDHDRS ; flags gcc LINKFLAGS ; flags gcc LINKFLAGS off : -s ; flags gcc ARFLAGS ; flags gcc STDHDRS : $(GCC_INCLUDE_DIRECTORY) ; flags gcc STDLIBPATH : $(GCC_STDLIB_DIRECTORY) ; if ! $(ARFLAGS) { flags gcc ARFLAGS : "" ; } if ! $(on-windows) # The compiler complains about -fPIC on NT { flags gcc CFLAGS true : -fPIC ; flags gcc LINKFLAGS true : -fPIC ; } if $(BETOOLS) { flags gcc LINKFLAGS $(SHARED_TYPES) : -nostart ; } else { flags gcc LINKFLAGS $(SHARED_TYPES) : -shared ; } flags gcc LIBPATH ; flags gcc NEEDLIBS ; flags gcc FINDLIBS ; flags gcc DLLVERSION ; DLLVERSION = $(DLLVERSION[1]) ; DLLVERSION ?= $(BOOST_VERSION) ; flags gcc TARGET_TYPE ; # allow for "ar" to be part of the compiler distribution, for # example in mingw and cygwin flags gcc .AR : [ GLOB $(GCC_BIN_DIRECTORY) $(PATH) : ar ar.exe ] ; .AR ?= ar ; # used to manipulate the object files produced by GCC to # prevent the merging of debug symbols (which happens to be n^2 slow) flags gcc .OBJCOPY : [ GLOB $(GCC_BIN_DIRECTORY) $(PATH) : objcopy ] ; flags gcc OBJCOPY_FLAGS on : "--set-section-flags .debug_str=contents,debug" ; if ! $(on-windows) { flags gcc .SET_EXIT : "set -e" ; } #### Link #### rule Link-action { _ on $(<) = " " ; # if we don't have a GNU linker then we can't pass any GNU-ld specific flags: if $(NO_GNU_LN) { LNOPT on $(<) = ; } else { LNOPT on $(<) = "" ; } # do we use sonames or not? if $(DLLVERSION) && $(TARGET_TYPE) in $(SHARED_TYPES) && ( $(OS) = LINUX || $(OS) = OPENBSD ) && ! $(NO_GNU_LN) { OUTTAG on $(<) = ".$(DLLVERSION)" ; SOTAG on $(<) = ".$(DLLVERSION)" ; ACTION_1 on $(<) = "" ; } else { OUTTAG on $(<) = "" ; SOTAG on $(<) = ; ACTION_1 on $(<) = ; } # On Win32, choose different image bases for load-time efficiency if $(on-windows) { DLL_LINK_FLAGS = "-Wl,--enable-auto-image-base " ; } else { DLL_LINK_FLAGS = "" ; } # Allow gcc-nocygwin to avoid this flag if ! $(GCC_NO_EXPORT_ALL) { DLL_LINK_FLAGS = "$(DLL_LINK_FLAGS)-Wl,--export-all-symbols " ; } # This will appear before the import library name when building a DLL, but # will be "multiplied away" otherwise. The --exclude-symbols directive # proved to be neccessary with some versions of Cygwin. if ! $(NO_GNU_LN) { IMPLIB_COMMAND on $(<) = "$(DLL_LINK_FLAGS)-Wl,--exclude-symbols,_bss_end__:_bss_start__:_data_end__:_data_start__ -Wl,--out-implib," ; } DEPENDS $(<) : $(NEEDLIBS) $(NEEDIMPS) ; gRUN_LD_LIBRARY_PATH($(<)) += $(STDLIBPATH:T) ; # Workaround GCC's lack of command-files and NT's line-length limitation. if $(NT) { JAMSHELL on $(<) = % ; } gcc-Link-action $(<) : $(>) ; if $(DLLVERSION) && $(TARGET_TYPE) in $(SHARED_TYPES) && ( $(OS) = LINUX || $(OS) = OPENBSD ) && ! $(NO_GNU_LN) { return "$(<[1]).$(DLLVERSION)" ; } } # for gcc, we repeat all libraries so that dependencies are always resolved actions gcc-Link-action bind NEEDLIBS NEEDIMPS { $(SHELL_SET)$(gSHELL_LIBPATH)=$(RUN_LD_LIBRARY_PATH)$(gAPPEND_LD_LIBRARY_PATH) $(SHELL_EXPORT)$(gSHELL_LIBPATH) $(.GXX[1]:R=$(GCC_BIN_DIR)) $(.GXX[2-]) $(IMPLIB_COMMAND)$(<[2]) $(LINKFLAGS) -o "$(<[1])$(OUTTAG)" -L"$(LIBPATH:T)" -L"$(STDLIBPATH:T)" "$(>)" "$(NEEDLIBS)" "$(NEEDLIBS)" "$(IMPLIB_FLAGS)$(NEEDIMPS)" -l$(FINDLIBS) $(LNOPT)$(RPATH_LINK). $(LNOPT)$(SONAME)$(<[1]:D=)$(SOTAG) $(ACTION_1)$(LN)$(_)-fs$(_)"$(<[1]:D=)$(OUTTAG)"$(_)"$(<[1])" } #### Cc ##### rule Cc-action { _ on $(<) = " " ; gcc-Cc-action $(<) : $(>) ; } actions gcc-Cc-action { $(.SET_EXIT) $(.GCC[1]:R=$(GCC_BIN_DIR)) $(.GCC[2-]) -c -Wall -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) -I"$(HDRS)" -I$(_)"$(STDHDRS)" -o "$(<)" "$(>)" $(.OBJCOPY[1])$(_)$(OBJCOPY_FLAGS)$(_)"$(<)" } #### C++ #### rule C++-action { _ on $(<) = " " ; gcc-C++-action $(<) : $(>) ; } actions gcc-C++-action { $(.SET_EXIT) $(.GXX[1]:R=$(GCC_BIN_DIR)) $(.GXX[2-]) -c -Wall -ftemplate-depth-100 -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) $(C++FLAGS) -I"$(HDRS)" -I$(_)"$(STDHDRS)" -o "$(<)" "$(>)" $(.OBJCOPY[1])$(_)$(OBJCOPY_FLAGS)$(_)"$(<)" } #### Archive #### rule Archive-action { gcc-Archive-action $(<) : $(>) ; } actions updated together piecemeal gcc-Archive-action { $(.AR[1]) ru$(ARFLAGS:J=) "$(<:T)" "$(>:T)" } -------------- next part -------------- A non-text attachment was scrubbed... Name: python.jam Type: text/x-java Size: 17103 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: type_with_alignment.hpp Type: text/x-c++ Size: 6235 bytes Desc: not available URL: From grafik.list at redshift-software.com Tue Nov 4 00:42:10 2003 From: grafik.list at redshift-software.com (Rene Rivera) Date: Mon, 3 Nov 2003 17:42:10 -0600 Subject: [C++-sig] Boost.Python, AIX, and gcc In-Reply-To: Message-ID: <20031103174212-r01010800-8c74f924-0860-0108@12.100.89.43> [2003-11-03] J. Michael Owen wrote: >I've been trying to use the latest Boost.Python with gcc on AIX, which is always >fun with AIX's strange dynamic library system. I now have it working after >modifying the some of the jam build files, and one source file. The files I've >altered are: > >tools/build/v1/boost-base.jam >tools/build/v1/gcc-tools.jam >tools/build/v1/python.jam >boost/type_traits/type_with_alignment.hpp OK, but a diff of the changes would be way more usefull ;-) As we could look at them without having to figure what changes you made are. -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From mikeowen at llnl.gov Tue Nov 4 01:41:49 2003 From: mikeowen at llnl.gov (J. Michael Owen) Date: Mon, 3 Nov 2003 16:41:49 -0800 Subject: [C++-sig] Boost.Python, AIX, and gcc In-Reply-To: <20031103174212-r01010800-8c74f924-0860-0108@12.100.89.43> References: <20031103174212-r01010800-8c74f924-0860-0108@12.100.89.43> Message-ID: Sorry! Here are the diffs for the file's I've changed. On Monday 03 November 2003 03:42 pm, Rene Rivera wrote: > [2003-11-03] J. Michael Owen wrote: > >I've been trying to use the latest Boost.Python with gcc on AIX, which is > > always > > >fun with AIX's strange dynamic library system. I now have it working > > after modifying the some of the jam build files, and one source file. > > The files > > I've > > >altered are: > > > >tools/build/v1/boost-base.jam > >tools/build/v1/gcc-tools.jam > >tools/build/v1/python.jam > >boost/type_traits/type_with_alignment.hpp > > OK, but a diff of the changes would be way more usefull ;-) As we could > look at them without having to figure what changes you made are. > > > -- grafik - Don't Assume Anything > -- rrivera (at) acm.org - grafik (at) redshift-software.com > -- 102708583 (at) icq -- "Hey...where are the sunflower seeds?" | J. Michael Owen o_o / | Phone: 925-423-7160 (") | Email: mikeowen at llnl.gov \/'\/ | ____(__(,_,)_______________________________________________________________ -------------- next part -------------- A non-text attachment was scrubbed... Name: boost-base.jam.diff Type: text/x-diff Size: 764 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: gcc-tools.jam.diff Type: text/x-diff Size: 1196 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: python.jam.diff Type: text/x-diff Size: 607 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: type_with_alignment.hpp.diff Type: text/x-diff Size: 763 bytes Desc: not available URL: From nickm at sitius.com Tue Nov 4 02:34:31 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Mon, 03 Nov 2003 20:34:31 -0500 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> Message-ID: <3FA70227.546F2E0@sitius.com> If you have the following module: #include #include struct Foo { Foo( int a = 0 , double b = 0 , const std::string &n = std::string() ) : a_(a) , b_(b) , n_(n) {} void set(int a=0, double b=0, const std::string &n=std::string()) { a_ = a; b_ = b; n_ = n; } void set(double b) { b_ = b; } void set(int a=0) { a_ = a; } void set(const std::string &n=std::string()) { n_ = n; } private: int a_; double b_; std::string n_; }; using namespace boost::python; BOOST_PYTHON_MODULE(keywords) { class_("Foo" , init( ( arg("a") = 0 , arg("b") = 0.0 , arg("n") = std::string() )) ) .def("set" , (void (Foo::*)(int , double , const std::string &) )&Foo::set , (arg("self"),arg("a") = 0, arg("b") = 0.0, arg("n") = std::string()) , "Sets all the fields of self") .def("set" , (void (Foo::*)(int ) )&Foo::set , (arg("self"),arg("a")) , " Sets the integer field of self") .def("set" , (void (Foo::*)(double ) )&Foo::set , (arg("self"),arg("b")) , " Sets the float field of self") .def("set" , (void (Foo::*)(const std::string &) )&Foo::set , (arg("self"), arg("n") ) , "Sets the string field of self" ) ; } #include "module_tail.cpp" //////////////////////////////////////// with what I currently have (cvs patched by me) I get: >>> import keywords >>> keywords.Foo(.1) Traceback (most recent call last): File "", line 1, in ? Boost.Python.ArgumentError: Python argument types in Foo.__init__(Foo, float) did not match C++ signature: __init__(struct _object *, int a=0, double b=0.0, class _STL::basic_string,class _STL::allocator > n="") >>> help(keywords.Foo.set) Help on method set: set(...) unbound keywords.Foo method set(struct Foo self, class _STL::basic_string,class _STL::allocator > n) Sets the string field of self set(struct Foo self, double b) Sets the float field of self set(struct Foo self, int a) Sets the integer field of self set(struct Foo self, int a=0, double b=0.0, class _STL::basic_string,class _STL::allocator > n="") Sets all the fields of self (END) >>> with the (almost)current cvs : >>> import keywords >>> keywords.Foo(.1) Traceback (most recent call last): File "", line 1, in ? TypeError: No to_python (by-value) converter found for C++ type: char >>> help(keywords.Foo.set) Help on method set: set(...) unbound keywords.Foo method Sets the string field of self I was also thinking of modifying the signature element to include type_info *(instead of just type_info->name()) Then instead of outputing C++ signatures some kind of Python signatures can be generated. I think this would be better since the python programmer generally would not know about the underlying CPP code. My problem is that I am not exactly sure how should the python signature look (since types are not specified for python function parameters): something like: set( [keywords.Foo] self, [int] a=0, [float] b=0.0, [str] n="") may be? Thoughts? Nikolay From jbrandmeyer at earthlink.net Tue Nov 4 03:31:31 2003 From: jbrandmeyer at earthlink.net (Jonathan Brandmeyer) Date: Mon, 03 Nov 2003 21:31:31 -0500 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings In-Reply-To: <3FA70227.546F2E0@sitius.com> References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> Message-ID: <1067913091.1005.102.camel@illuvatar> On Mon, 2003-11-03 at 20:34, Nikolay Mladenov wrote: > I was also thinking of modifying the signature element to include > type_info *(instead of just type_info->name()) > Then instead of outputing C++ signatures some kind of Python signatures > can be generated. > I think this would be better since the python programmer generally would > not know about the underlying CPP code. Since client coders for a C++ -based python extension are either a) only familiar with the Python interface, or b) also know the C++ interface (and can therefore presumably deduce the underlying C++ types), this sounds FANTASTIC to me. In my case 'client coders' are undergraduate physics students who generally have no idea what :: means in an error message. > My problem is that I am not exactly sure how should the python signature > look > (since types are not specified for python function parameters): > > something like: > set( [keywords.Foo] self, [int] a=0, [float] b=0.0, [str] n="") > may be? > > Thoughts? > > Nikolay >>> help(str) produces messages like: count(...) | S.count(sub[, start[, end]]) -> int So, square brackets have a well defined meaning in the Python "standard library's" help system. Functions returning void are documented as returning None (as dict.clear()). C-syntax type conversions are supported in Python, so what about using parenthesis to identify type information? What about: set(...) Foo.set( (Keywords.Foo)self, (str)n) -> None sets the string field of self Foo.set( (Keywords.Foo)self, (int)a) -> None sets the integer field of self Foo.set( (Keywords.Foo)self, (float)b) -> None sets the float field of self Foo.set( (Keywords.Foo)self, (int)a=0 [, (float)b=0.0 [, (str)n=""]]) -> None sets (up to) all the fields of self (e-mail spacing is going to make a hash of that, but I hope you see what I mean). -Jonathan Brandmeyer From grafik.list at redshift-software.com Tue Nov 4 04:03:03 2003 From: grafik.list at redshift-software.com (Rene Rivera) Date: Mon, 3 Nov 2003 21:03:03 -0600 Subject: [C++-sig] Boost.Python, AIX, and gcc In-Reply-To: Message-ID: <20031103210305-r01010800-02d0335d-0860-0108@12.100.89.43> [2003-11-03] J. Michael Owen wrote: >Sorry! Here are the diffs for the file's I've changed. Thanks, the build changes are applied to CVS. -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From rwgk at yahoo.com Tue Nov 4 05:04:24 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Mon, 3 Nov 2003 20:04:24 -0800 (PST) Subject: [C++-sig] Boost.Python, AIX, and gcc In-Reply-To: Message-ID: <20031104040424.43113.qmail@web20201.mail.yahoo.com> --- "J. Michael Owen" wrote: > > Index: boost/type_traits/type_with_alignment.hpp > =================================================================== > RCS file: /cvsroot/boost/boost/boost/type_traits/type_with_alignment.hpp,v > retrieving revision 1.14 > diff -u -r1.14 type_with_alignment.hpp > --- boost/type_traits/type_with_alignment.hpp 3 Sep 2003 15:19:12 -0000 1.14 > +++ boost/type_traits/type_with_alignment.hpp 4 Nov 2003 00:31:00 -0000 > @@ -132,7 +132,7 @@ > > BOOST_STATIC_CONSTANT(std::size_t, found = > alignment_of::value); > > -#if !(defined(__APPLE__) && defined(__MACH__) && defined(__GNUC__)) > +#if !(((defined(__APPLE__) && defined(__MACH__)) || defined(_AIX)) && > defined(__GNUC__)) > BOOST_STATIC_ASSERT(found >= Align); > BOOST_STATIC_ASSERT(found % Align == 0); > #endif I am afraid I am responsible for the __APPLE__ hack. It would be good if we could get rid of this. Could you please try this: --- Douglas Gregor wrote: > My apologies for the very late reply. I was away for a while and am still > sorting through my inbox... > > > Platform: > > Mac OS 10.2 > > gcc 3.3 compiled from sources > > boost cvs from last Friday > > > > When porting the Boost.Python bindings for some custom libraries I ran > > into a problem with static asserts in type_with_alignment.hpp: > [snip patch] > > This patch allows me to compile and link, and our regression test > > runs fine. > > > > Reducing my code to a minimal test is most likely a time-consuming > > project that I'd like to avoid if possible (compilation is quite slow > > to make things worse). Do the authors of the code above have any ideas > > what could be going wrong? Are there things that I could try first > > before chopping my code into pieces? > > If you could figure out what alignment value you're trying to get a type for > it would help greatly. One way you could do it would be to replace the > static assertion lines with something that will halt the compile and give > back the Align value in an error message, e.g., > > // somewhere > template struct maybe_print_align { > typedef void type; } > template struct maybe_print_align {}; > > // instead of the static asserts: > typedef typename maybe_print_align<(found >= Align), Align>::type foobar; > > Note that when those static asserts fail, it means that you aren't getting > back a type with the right alignment. > > Doug Here is the result for the Mac: From: "Ralf W. Grosse-Kunstleve" To: "Boost mailing list" Sent: Saturday, June 07, 2003 5:50 AM Subject: Re: [boost] Mac OS 10 & type_traits/type_with_alignment.hpp > --- Douglas Gregor wrote: > /var/tmp/mac/boost/boost/type_traits/type_with_alignment.hpp:120: > error: no type named `type' in `boost::maybe_print_align' So you have a type that is 8-byte aligned, but we don't have any types in the list of possible types that have an alignment of 8 on that architecture, so it fails. We'll just have to find a type that has 8-byte alignment and add it to the list. I'll see if I can dig one up tomorrow. Doug As of today we are still waiting. Maybe if we can give Doug a little more incentive he'll be able to help. Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From hhakula at math.hut.fi Tue Nov 4 06:52:38 2003 From: hhakula at math.hut.fi (Harri Hakula) Date: Tue, 4 Nov 2003 07:52:38 +0200 Subject: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031103135732-r01010800-0716b939-0860-0108@12.100.89.43> References: <20031103135732-r01010800-0716b939-0860-0108@12.100.89.43> Message-ID: <188A1DD3-0E8B-11D8-A099-000393C34364@math.hut.fi> On Nov 3, 2003, at 9:57 PM, Rene Rivera wrote: > Well I've made some changes to the CVS build (python.jam and > darwin-tools.jam) which incorporates the changes posted so far. > > Feedback on how this works, or doesn't, are most appreciated :-) > I get lots of messages like darwin-C++-action bin/boost/libs/python/build/libboost_python.dylib/darwin/debug/shared- linkable-true/list.o c++: -framework: linker input file unused because linking not done c++: Python: linker input file unused because linking not done Perhaps we shouldn't have -framework in Cc- and C++-actions? However, what is most worrying is that on all machines that I have access to, I see the infamous semaphore_wait_trap raising its head. Having consulted with Sean Spicer who never sees it, I'm completely baffled. Tests stall at injected.test. Here is what gdb says: (gdb) attach 22070 Attaching to process 22070. Reading symbols for shared libraries . done Reading symbols for shared libraries warning: Pre-compiled symbol file "/usr/libexec/gdb/symfiles/python.syms" is out of date (Fri Sep 26 09:40:51 2003 vs. Fri Sep 26 09:40:47 2003); ignoring .......................... done 0x90014628 in semaphore_wait_trap () (gdb) where #0 0x90014628 in semaphore_wait_trap () #1 0x90002310 in pthread_mutex_lock () #2 0x0202ad5c in std::__default_alloc_template::allocate(unsigned long) () at /usr/local/src/boost/boost/python/object/py_function.hpp:125 #3 0x02078d18 in std::__simple_alloc, std::__default_alloc_template >::allocate(unsigned long) (__n=Cannot access memory at address 0x88 ) at /usr/include/gcc/darwin/3.3/c++/bits/stl_alloc.h:232 #4 0x02078b40 in std::_Rb_tree_alloc_base, true>::_M_get_node() (this=0x20e9f58) at /usr/include/gcc/darwin/3.3/c++/bits/stl_tree.h:564 #5 0x02078340 in std::_Rb_tree_base >::_Rb_tree_base(std::allocator const&) (this=0x20e9f58, __a=@0xbfffbb40) at /usr/include/gcc/darwin/3.3/c++/bits/stl_tree.h:579 #6 0x020782f8 in std::_Rb_tree_base >::_Rb_tree_base(std::allocator const&) (this=0x20e9f58, __a=@0xbfffbb40) at /usr/include/gcc/darwin/3.3/c++/bits/stl_tree.h:579 #7 0x02077a30 in std::_Rb_tree, std::less, std::allocator >::_Rb_tree(std::less const&, std::allocator const&) (this=0x20e9f58, __comp=@0xbfffbb50, __a=@0xbfffbb40) at /usr/include/gcc/darwin/3.3/c++/bits/stl_tree.h:730 #8 0x020779f0 in std::_Rb_tree, std::less, std::allocator >::_Rb_tree(std::less const&, std::allocator const&) (this=0x20e9f58, __comp=@0xbfffbb50, __a=@0xbfffbb40) at /usr/include/gcc/darwin/3.3/c++/bits/stl_tree.h:730 #9 0x020774ac in std::set, std::allocator >::set() (this=0x20e9f58) at /usr/include/gcc/darwin/3.3/c++/bits/stl_set.h:123 #10 0x02077464 in std::set, std::allocator >::set() (this=0x20e9f58) at /usr/include/gcc/darwin/3.3/c++/bits/stl_set.h:123 #11 0x02011050 in boost::python::converter::(anonymous namespace)::entries() () at /usr/local/src/boost/libs/python/src/converter/registry.cpp:71 #12 0x020110d0 in boost::python::converter::(anonymous namespace)::get(boost::python::type_info) (type={> = {> = { >> = {> = { = {}, }, }, }, }, m_base_type = 0x206fc78 "b"}) at /usr/local/src/boost/libs/python/src/converter/registry.cpp:142 #13 0x020114ac in boost::python::converter::registry::lookup(boost::python::type_info) (key={> = {> = { >> = {> = { = {}, }, }, }, }, m_base_type = 0x206fc78 "b"}) at /usr/local/src/boost/libs/python/src/converter/registry.cpp:231 #14 0x020ab190 in __static_initialization_and_destruction_0(int, int) (__initialize_p=1, __priority=65535) at /usr/local/src/boost/boost/python/converter/registered.hpp:56 #15 0x020ab3c8 in _GLOBAL__I__ZN5boost6python7numeric65_GLOBAL__N__usr_local_src_boost_lib s_python_src_numeric.cppebPZ6a5stateE () at /usr/local/src/boost/boost/python/object_core.hpp:280 #16 0x8fe178d0 in __dyld_call_module_initializers_for_library () #17 0x8fe17648 in __dyld_call_module_initializers () #18 0x8fe118ac in __dyld_link_in_need_modules () #19 0x8fe11290 in __dyld_bind_lazy_symbol_reference () #20 0x8fe01620 in __dyld_stub_binding_helper_interface () #21 0x0202b274 in std::__default_alloc_template::_S_chunk_alloc(unsigned long, int&) () at /usr/local/src/boost/boost/python/object/py_function.hpp:125 #22 0x0202b114 in std::__default_alloc_template::_S_refill(unsigned long) () at /usr/local/src/boost/boost/python/object/py_function.hpp:125 #23 0x0202ad70 in std::__default_alloc_template::allocate(unsigned long) () at /usr/local/src/boost/boost/python/object/py_function.hpp:125 #24 0x02078d18 in std::__simple_alloc, std::__default_alloc_template >::allocate(unsigned long) (__n=Cannot access memory at address 0x88 ) at /usr/include/gcc/darwin/3.3/c++/bits/stl_alloc.h:232 #25 0x02078b40 in std::_Rb_tree_alloc_base, true>::_M_get_node() (this=0x20e9f58) at /usr/include/gcc/darwin/3.3/c++/bits/stl_tree.h:564 #26 0x02078340 in std::_Rb_tree_base >::_Rb_tree_base(std::allocator const&) (this=0x20e9f58, __a=@0xbfffc510) at /usr/include/gcc/darwin/3.3/c++/bits/stl_tree.h:579 #27 0x020782f8 in std::_Rb_tree_base >::_Rb_tree_base(std::allocator const&) (this=0x20e9f58, __a=@0xbfffc510) at /usr/include/gcc/darwin/3.3/c++/bits/stl_tree.h:579 #28 0x02077a30 in std::_Rb_tree, std::less, std::allocator >::_Rb_tree(std::less const&, std::allocator const&) (this=0x20e9f58, __comp=@0xbfffc520, __a=@0xbfffc510) at /usr/include/gcc/darwin/3.3/c++/bits/stl_tree.h:730 #29 0x020779f0 in std::_Rb_tree, std::less, std::allocator >::_Rb_tree(std::less const&, std::allocator const&) (this=0x20e9f58, __comp=@0xbfffc520, __a=@0xbfffc510) at /usr/include/gcc/darwin/3.3/c++/bits/stl_tree.h:730 #30 0x020774ac in std::set, std::allocator >::set() (this=0x20e9f58) at /usr/include/gcc/darwin/3.3/c++/bits/stl_set.h:123 #31 0x02077464 in std::set, std::allocator >::set() (this=0x20e9f58) at /usr/include/gcc/darwin/3.3/c++/bits/stl_set.h:123 #32 0x02011050 in boost::python::converter::(anonymous namespace)::entries() () at /usr/local/src/boost/libs/python/src/converter/registry.cpp:71 #33 0x020110d0 in boost::python::converter::(anonymous namespace)::get(boost::python::type_info) (type={> = {> = { >> = {> = { = {}, }, }, }, }, m_base_type = 0x423a58 "N5boost10shared_ptrI10test_classILi0EEEE"}) at /usr/local/src/boost/libs/python/src/converter/registry.cpp:142 #34 0x0201137c in boost::python::converter::registry::insert(void* (*)(_object*), void (*)(_object*, boost::python::converter::rvalue_from_python_stage1_data*), boost::python::type_info) (convertible=0x415b48 >::convertible(_object*)>, construct=0x415bbc >::construct(_object*, boost::python::converter::rvalue_from_python_stage1_data*)>, key={> = {> = { >> = {> = { = {}, }, }, }, }, m_base_type = 0x423a58 "N5boost10shared_ptrI10test_classILi0EEEE"}) at /usr/local/src/boost/libs/python/src/converter/registry.cpp:202 #35 0x00415a10 in boost::python::converter::shared_ptr_from_python >::shared_ptr_from_python() (this=0x423438) at /usr/local/src/boost/boost/python/converter/shared_ptr_from_python.hpp: 19 #36 0x00415988 in boost::python::converter::shared_ptr_from_python >::shared_ptr_from_python() (this=0x423438) at /usr/local/src/boost/boost/python/converter/shared_ptr_from_python.hpp: 19 #37 0x0041b938 in __static_initialization_and_destruction_0(int, int) (__initialize_p=1, __priority=65535) at /usr/local/src/boost/boost/python/converter/shared_ptr_from_python.hpp: 49 #38 0x0041bac0 in _GLOBAL__I__Z5emptyv () at /usr/local/src/boost/boost/python/object/instance.hpp:31 #39 0x8fe17b38 in __dyld_call_module_initializers_for_objects () #40 0x8fe17600 in __dyld_call_module_initializers () #41 0x8fe118ac in __dyld_link_in_need_modules () #42 0x8fe134e4 in __dyld__dyld_link_module () #43 0x9003f5a8 in NSLinkModule () #44 0x95fcc4e4 in _PyImport_GetDynLoadFunc () #45 0x95fc1b6c in _PyImport_LoadDynamicModule () #46 0x95fbf7a4 in PyImport_ExecCodeModuleEx () #47 0x95fc08c4 in PyImport_ImportModuleEx () #48 0x95fc02e0 in PyImport_ImportModuleEx () #49 0x95fbfe00 in PyImport_ImportModule () #50 0x95fbffd4 in PyImport_ImportModuleEx () #51 0x95f9cbf0 in _PyUnicodeUCS2_IsAlpha () #52 0x95f4a8d0 in PyObject_Call () #53 0x95fa91ec in PyEval_CallObjectWithKeywords () #54 0x95fa6984 in PyEval_EvalCode () #55 0x95fa7e30 in PyEval_EvalCodeEx () #56 0x95fa4734 in PyEval_EvalCode () #57 0x95faab78 in _PyEval_SliceIndex () #58 0x95fa5e08 in PyEval_EvalCode () #59 0x95fa7e30 in PyEval_EvalCodeEx () #60 0x95fa97dc in PyEval_GetFuncDesc () #61 0x95fa9580 in PyEval_GetFuncDesc () #62 0x95fa6c64 in PyEval_EvalCode () #63 0x95fa9728 in PyEval_GetFuncDesc () #64 0x95fa9580 in PyEval_GetFuncDesc () #65 0x95fa6c64 in PyEval_EvalCode () #66 0x95fa7e30 in PyEval_EvalCodeEx () #67 0x95fa97dc in PyEval_GetFuncDesc () #68 0x95fa9580 in PyEval_GetFuncDesc () #69 0x95fa6c64 in PyEval_EvalCode () #70 0x95fa7e30 in PyEval_EvalCodeEx () #71 0x95fa97dc in PyEval_GetFuncDesc () #72 0x95fa9580 in PyEval_GetFuncDesc () #73 0x95fa6c64 in PyEval_EvalCode () #74 0x95fa7e30 in PyEval_EvalCodeEx () #75 0x95fa97dc in PyEval_GetFuncDesc () #76 0x95fa9580 in PyEval_GetFuncDesc () #77 0x95fa6c64 in PyEval_EvalCode () #78 0x95fa7e30 in PyEval_EvalCodeEx () #79 0x95fa97dc in PyEval_GetFuncDesc () #80 0x95fa9580 in PyEval_GetFuncDesc () #81 0x95fa6c64 in PyEval_EvalCode () #82 0x95fa7e30 in PyEval_EvalCodeEx () #83 0x95fa4734 in PyEval_EvalCode () #84 0x95fc85f0 in PyRun_FileExFlags () #85 0x95fc7668 in PyRun_SimpleFileExFlags () #86 0x95fd1ec0 in Py_Main () #87 0x00003c78 in start () #88 0x00003aec in start () (gdb) > > -- grafik - Don't Assume Anything > -- rrivera (at) acm.org - grafik (at) redshift-software.com > -- 102708583 (at) icq > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig Cheers, Harri Hakula From rwgk at yahoo.com Tue Nov 4 08:27:39 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Mon, 3 Nov 2003 23:27:39 -0800 (PST) Subject: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <188A1DD3-0E8B-11D8-A099-000393C34364@math.hut.fi> Message-ID: <20031104072739.90761.qmail@web20202.mail.yahoo.com> --- Harri Hakula wrote: > However, what is most worrying is that on all machines that I have > access to, I see the > infamous semaphore_wait_trap raising its head. Having consulted with > Sean Spicer who > never sees it, I'm completely baffled. Ouch. Is this under 10.3? Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From mikeowen at comcast.net Tue Nov 4 09:02:29 2003 From: mikeowen at comcast.net (Mike Owen) Date: Tue, 4 Nov 2003 00:02:29 -0800 Subject: [C++-sig] Boost.Python, AIX, and gcc In-Reply-To: <20031104040424.43113.qmail@web20201.mail.yahoo.com> References: <20031104040424.43113.qmail@web20201.mail.yahoo.com> Message-ID: OK, I've tried out your debug print with the example I have, and here's the output I get from the compiler: ... type_traits/type_with_alignment.hpp: In instantiation of` boost::type_with_alignment<8>': ... type_traits/type_with_alignment.hpp:142: no type named `type' in `struct boost::maybe_print_align' So this is telling me that the type is 8 bit aligned (just like your example on Mac below), but how should I follow up on this? Also, how bad is it that this assert is failing? I've been able to make my small test cases work by just excluding these asserts on AIX, but I assume this is eventually going to cause trouble. By the way, the test case I'm using to generate this error is really small, so I could provide it if that would be helpful. I'm not sure if that's useful, though, since you have to have an AIX machine handy to reproduce the problem. On Monday 03 November 2003 20:04, Ralf W. Grosse-Kunstleve wrote: > --- "J. Michael Owen" wrote: > > > Index: boost/type_traits/type_with_alignment.hpp > > > > =================================================================== > > RCS file: > > /cvsroot/boost/boost/boost/type_traits/type_with_alignment.hpp,v > > retrieving revision 1.14 > > diff -u -r1.14 type_with_alignment.hpp > > --- boost/type_traits/type_with_alignment.hpp 3 Sep 2003 15:19:12 > > -0000 1.14 +++ boost/type_traits/type_with_alignment.hpp 4 Nov 2003 > > 00:31:00 -0000 @@ -132,7 +132,7 @@ > > > > BOOST_STATIC_CONSTANT(std::size_t, found = > > alignment_of::value); > > > > -#if !(defined(__APPLE__) && defined(__MACH__) && defined(__GNUC__)) > > +#if !(((defined(__APPLE__) && defined(__MACH__)) || defined(_AIX)) && > > defined(__GNUC__)) > > BOOST_STATIC_ASSERT(found >= Align); > > BOOST_STATIC_ASSERT(found % Align == 0); > > #endif > > I am afraid I am responsible for the __APPLE__ hack. It would be good if we > could get rid of this. Could you please try this: > > --- Douglas Gregor wrote: > > My apologies for the very late reply. I was away for a while and am still > > sorting through my inbox... > > > > > Platform: > > > Mac OS 10.2 > > > gcc 3.3 compiled from sources > > > boost cvs from last Friday > > > > > > When porting the Boost.Python bindings for some custom libraries I ran > > > into a problem with static asserts in type_with_alignment.hpp: > > > > [snip patch] > > > > > This patch allows me to compile and link, and our regression test > > > runs fine. > > > > > > Reducing my code to a minimal test is most likely a time-consuming > > > project that I'd like to avoid if possible (compilation is quite slow > > > to make things worse). Do the authors of the code above have any ideas > > > what could be going wrong? Are there things that I could try first > > > before chopping my code into pieces? > > > > If you could figure out what alignment value you're trying to get a type > > for it would help greatly. One way you could do it would be to replace > > the static assertion lines with something that will halt the compile and > > give back the Align value in an error message, e.g., > > > > // somewhere > > template struct maybe_print_align { > > typedef void type; } > > template struct maybe_print_align {}; > > > > // instead of the static asserts: > > typedef typename maybe_print_align<(found >= Align), Align>::type foobar; > > > > Note that when those static asserts fail, it means that you aren't > > getting back a type with the right alignment. > > > > Doug > > Here is the result for the Mac: > > From: "Ralf W. Grosse-Kunstleve" > To: "Boost mailing list" > Sent: Saturday, June 07, 2003 5:50 AM > Subject: Re: [boost] Mac OS 10 & type_traits/type_with_alignment.hpp > > > --- Douglas Gregor wrote: > > /var/tmp/mac/boost/boost/type_traits/type_with_alignment.hpp:120: > > error: no type named `type' in `boost::maybe_print_align' > > So you have a type that is 8-byte aligned, but we don't have any types in > the list of possible types that have an alignment of 8 on that > architecture, so it fails. We'll just have to find a type that has 8-byte > alignment and add it to the list. I'll see if I can dig one up tomorrow. > > Doug > > > As of today we are still waiting. Maybe if we can give Doug a little more > incentive he'll be able to help. > > Ralf > > > __________________________________ > Do you Yahoo!? > Protect your identity with Yahoo! Mail AddressGuard > http://antispam.yahoo.com/whatsnewfree -- "Hey...where are the sunflower seeds?" | J. Michael Owen o_o / | Phone: 925-423-7160 (") | Email: mikeowen at comcast.net \/'\/ | ____(__(,_,)_______________________________________________________________ From grafik.list at redshift-software.com Tue Nov 4 09:22:52 2003 From: grafik.list at redshift-software.com (Rene Rivera) Date: Tue, 4 Nov 2003 02:22:52 -0600 Subject: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031103022356.39783.qmail@web20210.mail.yahoo.com> Message-ID: <20031104022253-r01010800-695bef12-0860-0108@12.100.89.43> [2003-11-02] Ralf W. Grosse-Kunstleve wrote: >--- Bob Ippolito wrote: >> -F will alter the search path for frameworks, just like -L for libraries >> The normal search path is something like: >> ~/Library/Frameworks >> /Library/Frameworks >> /Network/Library/Frameworks >> /System/Library/Frameworks >> >> On Panther, you want it to find Python.framework in >> /System/Library/Frameworks, so don't install another Python anywhere >> else if you're on Panther. > >Oh, if it's that then maybe this is useful: > >I noticed that the Python installation involves commands like: > >gcc -Wl,-F. -bundle -framework Python >build/temp.darwin-6.8-Power_Macintosh-2.3/_TEmodule.o -L/usr/local/lib -o >build/lib.darwin-6.8-Power_Macintosh-2.3/_TE.so -framework Carbon > >Note the "-Wl,-F" OK, I looked at this email again and at some of the info for the built in extensions that the Python framework build generates (thanks for the machine access Ralf.. I still had the info written down). And I made some changes to how the extensions are built by python.jam to be as close as possible to the above gcc invocation. This is with the idea that if Python itself is building that way it would seem that doing that way would be the most compatible way to do things ;-) -- Basically it boils down to not using bundle_loader when building the extensions, as that is only usefull if you don't have a framework. So please try the new darwin-tools.jam and python.jam. -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From RaoulGough at yahoo.co.uk Tue Nov 4 10:37:07 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Tue, 04 Nov 2003 09:37:07 +0000 Subject: [C++-sig] Re: boost::python::range and duplicate comdat under MSVC 6 References: Message-ID: David Abrahams writes: > Raoul Gough writes: [snip] >> In our case it's being triggered by the static member variable in >> shared_ptr_from_python (see coverter/shared_ptr_from_python.hpp). >> Seems pretty fatal to me, since (AFAIK) a static object is necessary >> for the type registration scheme to work. I'm not going to bother >> trying to fix this. > > We use lots of static data members, though; this isn't the only place > we ought to be seeing a problem if that's the issue. It seems to be dependant in some complicated way on the template arguments. For example, the following is sufficient to demonstrate the problem: #include #include #include #include int main () { namespace python = boost::python; namespace objects = boost::python::objects; namespace detail = boost::python::detail; namespace converter = boost::python::converter; typedef python::return_value_policy policy_t; typedef python::return_value_policy policy_t; typedef objects::iterator_range iterator_t1; typedef objects::iterator_range iterator_t2; detail::force_instantiate ( converter::shared_ptr_from_python::registration); detail::force_instantiate ( converter::shared_ptr_from_python::registration); return 0; } >From the assembly listing, this has the following symbol duplicated for two slightly different procedures that are passed to _atexit. They both do some setup before calling one of the (correctly distinguished) static object destructors. ?registration@?$shared_ptr_from_python at U?$iterator_range at U?$ return_value_policy at Ureturn_by_value@python at boost@@$E Only the first part of the iterator type seems to be embedded in the mangled name (the return value policy) which obviously causes a clash whenever two different iterators use the same policies. I guess that reordering the template parameters to iterator_range might reduce the likelihood of the problem occurring in practice. > > However, a simple transformation ought to be enough to eliminate the > static data member, AFAICT. Do you need help working it out? It looks to me like the static member is only useful for the side-effects of its constructor. Is there an alternative way to achieve this? -- Raoul Gough. (setq dabbrev-case-fold-search nil) From hhakula at math.hut.fi Tue Nov 4 13:08:09 2003 From: hhakula at math.hut.fi (Harri Hakula) Date: Tue, 4 Nov 2003 14:08:09 +0200 Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031103135732-r01010800-0716b939-0860-0108@12.100.89.43> References: <20031103135732-r01010800-0716b939-0860-0108@12.100.89.43> Message-ID: <8E5D34B1-0EBF-11D8-A099-000393C34364@math.hut.fi> Adding -bind_at_load to darwin-Link-DyLib-action did the trick to me. All tests run -- one failure, ie exactly what Sean Spicer reported earlier. This is what I have now: actions darwin-Link-DyLib-action bind NEEDLIBS NEEDIMPS { $(SHELL_SET)$(gSHELL_LIBPATH)=$(RUN_LD_LIBRARY_PATH) $(SHELL_EXPORT)$(gSHELL_LIBPATH) ld -dynamic -m -r -d -bind_at_load -o "$(<[1]:S=.lo)" "$(>)" \ && \ $(.GCC_BIN_DIR)$(.GXX) $(LINKFLAGS) $(DLLFLAGS) -o "$(<[1])" "$(<[1]:S=.lo)" \ -L"$(LIBPATH:T)" -L"$(STDLIBPATH:T)" "$(NEEDLIBS)" "$(NEEDLIBS)" -l$(FINDLIBS) \ -F$(FRAMEWORKS:D) -framework$(_)$(FRAMEWORKS:D=) \ && \ rm -f "$(<[1]:S=.lo)" } For some applications this may not be acceptable, however. Well, I'm a happy bunny now! Cheers, Harri Hakula From hhakula at math.hut.fi Tue Nov 4 14:17:53 2003 From: hhakula at math.hut.fi (Harri Hakula) Date: Tue, 4 Nov 2003 15:17:53 +0200 Subject: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031104072739.90761.qmail@web20202.mail.yahoo.com> References: <20031104072739.90761.qmail@web20202.mail.yahoo.com> Message-ID: <4BE359C4-0EC9-11D8-A099-000393C34364@math.hut.fi> On Nov 4, 2003, at 9:27 AM, Ralf W. Grosse-Kunstleve wrote: > --- Harri Hakula wrote: >> However, what is most worrying is that on all machines that I have >> access to, I see the >> infamous semaphore_wait_trap raising its head. Having consulted with >> Sean Spicer who >> never sees it, I'm completely baffled. > > Ouch. Is this under 10.3? > Yes. Sorry, I forgot to mention it. I am running 10.3 on all machines. -bind_at_load seems to resolve whatever causes this problem. Perhaps it works on 10.2.8 also? Of course, if your solution loads loads of dynamic libraries this may affect the user experience... I've tried on two Powerbooks (Lombard G3 & Titanium G4) and a Dual 1GHz PowerMac. Powerbooks had a clean install of Panther, PowerMac archive&install. I got exactly same behaviour on all of them. Cheers, Harri Hakula From mike at nospam.com Tue Nov 4 18:11:31 2003 From: mike at nospam.com (Mike Rovner) Date: Tue, 4 Nov 2003 09:11:31 -0800 Subject: [C++-sig] Re: BPL on MSVC7.1 -w3 warnings References: Message-ID: David Abrahams wrote: > Beautiful. Committed. In the light of 2.4 we may have to patch it back ;) Here is MvL responce on the subject: "Mike Rovner" writes: >> That may even be a source of bugs. I'm in the process of putting >> size_t in every place Python currently uses "int" or "long" to store a >> number of bytes. In some cases, exceeding 4GB (sometimes 2GB) will >> cause crashes in Python 2.3 (in other cases, this is somewhat overkill >> - eg. when the compiler complains that strlen(some_file_name) may not >> fit into 4 bytes). > > Does that mean forthcoming API interface change? Yes. I haven't changed any structure (yet), but, after approval on python-dev, this is likely to happen as well. > There are mostly ints for sizes (ex. PyString_AsStringAndSize > (PyObject *obj, char **buffer, int *length)). Indeed. I don't think it matters, though: processors typically return results in registers. On a 64-bit processor, a single register will take the result, and most likely, a 32-bit return value will be widened appropriately. So you might actually get away with not recompiling the extensions in 2.4 (atleast until ob_size changes, which does cause incompatibilities on big-endian machines). Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list From rwgk at yahoo.com Tue Nov 4 18:51:58 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 4 Nov 2003 09:51:58 -0800 (PST) Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <8E5D34B1-0EBF-11D8-A099-000393C34364@math.hut.fi> Message-ID: <20031104175158.88827.qmail@web20204.mail.yahoo.com> --- Harri Hakula wrote: > Adding -bind_at_load to darwin-Link-DyLib-action did the trick to me. > All tests run -- one failure, ie exactly what Sean Spicer reported > earlier. YES! That's it! It also works under 10.2.8. Congratulations to everybody who contributed to this *full* success! The "one failure" is due to a generic bug in the regression test. I've just checked in the trivial fix. Finally the FAQ regarding OS 10 will be very simple (phew): Q: Does Boost.Python work under OS 10? A: It is known to work under 10.2.8 and 10.3 using Apple's gcc 3.3 compiler: gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1493) Under 10.2.8 get the August 2003 gcc update (free at http://connect.apple.com/). Under 10.3 get the Xcode Tools v1.0 (also free). Any corrections or suggestions? Rene, do you want to add the -bind_at_load to the darwin toolset? Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From grafik.list at redshift-software.com Tue Nov 4 18:59:20 2003 From: grafik.list at redshift-software.com (Rene Rivera) Date: Tue, 4 Nov 2003 11:59:20 -0600 Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031104175158.88827.qmail@web20204.mail.yahoo.com> Message-ID: <20031104115922-r01010800-5d72e0dd-0860-0108@12.100.89.43> [2003-11-04] Ralf W. Grosse-Kunstleve wrote: >--- Harri Hakula wrote: >> Adding -bind_at_load to darwin-Link-DyLib-action did the trick to me. >> All tests run -- one failure, ie exactly what Sean Spicer reported >> earlier. > >YES! That's it! It also works under 10.2.8. Congratulations to everybody who >contributed to this *full* success! Hooray :-) >The "one failure" is due to a generic bug in the regression test. I've just >checked in the trivial fix. > >Finally the FAQ regarding OS 10 will be very simple (phew): > >Q: Does Boost.Python work under OS 10? > >A: It is known to work under 10.2.8 and 10.3 using Apple's gcc 3.3 compiler: >gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1493) >Under 10.2.8 get the August 2003 gcc update (free at >http://connect.apple.com/). Under 10.3 get the Xcode Tools v1.0 (also free). > >Any corrections or suggestions? > >Rene, do you want to add the -bind_at_load to the darwin toolset? Yes, and no. I don't think it's a generic toolset problem. Instead I would add it to python.jam when it builds boost_python dylib. Does that make sense? And one question, is this success with the latest changes I did to the build? -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From rwgk at yahoo.com Tue Nov 4 19:10:43 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 4 Nov 2003 10:10:43 -0800 (PST) Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031104115922-r01010800-5d72e0dd-0860-0108@12.100.89.43> Message-ID: <20031104181043.63332.qmail@web20208.mail.yahoo.com> --- Rene Rivera wrote: > >Rene, do you want to add the -bind_at_load to the darwin toolset? > > Yes, and no. I don't think it's a generic toolset problem. Instead I would > add it to python.jam when it builds boost_python dylib. Does that make > sense? Sounds good to me. > And one question, is this success with the latest changes I did to the > build? For the home run I used my scons-based build system. ;-) But I checked your bjam tools last night and everything compiled and linked. I'll check again incl. actually running everything when I see your modification to python.jam (could you please send a quick notification as soon as you are done?). Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From paul.magwene at yale.edu Tue Nov 4 19:32:33 2003 From: paul.magwene at yale.edu (Paul Magwene) Date: Tue, 04 Nov 2003 13:32:33 -0500 Subject: [C++-sig] latest checkin breaks builtin_converters.cpp on GCC cygwin Message-ID: <3FA7F0C1.6030109@yale.edu> The latest CVS checkin for builtin_converters (see below), seems to break the boost.python build on cygwin (gcc version 3.3.1 (cygming special)). A CVS version checked out early yesterday before this latest checkin built fine. --Paul M. boost/boost/libs/python/src/converter/builtin_converters.cpp Revision 1.27 - (download), view (text) (markup) (annotate) - [select for diffs] Mon Nov 3 20:45:21 2003 UTC (21 hours, 33 minutes ago) by david_abrahams CVS Tags: HEAD Changes since 1.26: +1 -1 lines Diff to previous 1.26 Warning suppression thanks to Mike Rovner Error message: /usr/local/boost/libs/python/src/converter/builtin_converters.cpp: In static member function `static void boost::python::converter::::slot_rvalue_from_python::construct(PyObject*, boost::python::converter::rvalue_from_python_stage1_data*) [with T = std::complex, SlotPolicy = boost::python::converter::::complex_rvalue_from_python]': /usr/local/boost/libs/python/src/converter/builtin_converters.cpp:56: instantiated from `boost::python::converter::::slot_rvalue_from_python::slot_rvalue_from_python() [with T = std::complex, SlotPolicy = boost::python::converter::::complex_rvalue_from_python]' /usr/local/boost/libs/python/src/converter/builtin_converters.cpp:401: instantiated from here /usr/local/boost/libs/python/src/converter/builtin_converters.cpp:78: error: invalid static_cast from type `std::complex' to type `std::complex' -- Paul M. Magwene, Ph.D. Postdoctoral Fellow Department of Biology University of Pennsylvania Goddard Labs, Rm 203 (215)898-8395 From grafik.list at redshift-software.com Tue Nov 4 19:33:19 2003 From: grafik.list at redshift-software.com (Rene Rivera) Date: Tue, 4 Nov 2003 12:33:19 -0600 Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031104181043.63332.qmail@web20208.mail.yahoo.com> Message-ID: <20031104123320-r01010800-86150dd2-0860-0108@12.100.89.43> [2003-11-04] Ralf W. Grosse-Kunstleve wrote: >--- Rene Rivera wrote: >> >Rene, do you want to add the -bind_at_load to the darwin toolset? >> >> Yes, and no. I don't think it's a generic toolset problem. Instead I would >> add it to python.jam when it builds boost_python dylib. Does that make >> sense? > >Sounds good to me. It turned out to be much easier to just add: <*>-bind_at_load ..to the dll build in libs/python/build/Jamfile -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From rwgk at yahoo.com Tue Nov 4 19:48:06 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 4 Nov 2003 10:48:06 -0800 (PST) Subject: [C++-sig] latest checkin breaks builtin_converters.cpp on GCC cygwin In-Reply-To: <3FA7F0C1.6030109@yale.edu> Message-ID: <20031104184806.14245.qmail@web20210.mail.yahoo.com> FWIW: I had the exact same problem with gcc 3.3.1 under Mac OS 10.2.8. I.e. the workaround should probably be gcc-specific (as opposed to platform-specific). Ralf --- Paul Magwene wrote: > The latest CVS checkin for builtin_converters (see below), seems to > break the boost.python build on cygwin (gcc version 3.3.1 (cygming > special)). > > A CVS version checked out early yesterday before this latest checkin > built fine. > > --Paul M. > > > > boost/boost/libs/python/src/converter/builtin_converters.cpp > > Revision 1.27 - (download), view (text) (markup) (annotate) - [select > for diffs] > Mon Nov 3 20:45:21 2003 UTC (21 hours, 33 minutes ago) by david_abrahams > CVS Tags: HEAD > Changes since 1.26: +1 -1 lines > Diff to previous 1.26 > > Warning suppression thanks to Mike Rovner > > > Error message: > > /usr/local/boost/libs/python/src/converter/builtin_converters.cpp: In static > member function `static void > boost::python::converter::::slot_rvalue_from_python SlotPolicy>::construct(PyObject*, > boost::python::converter::rvalue_from_python_stage1_data*) [with T = > std::complex, SlotPolicy = > boost::python::converter::::complex_rvalue_from_python]': > /usr/local/boost/libs/python/src/converter/builtin_converters.cpp:56: > instantiated from > `boost::python::converter::::slot_rvalue_from_python SlotPolicy>::slot_rvalue_from_python() [with T = std::complex, > SlotPolicy = > boost::python::converter::::complex_rvalue_from_python]' > /usr/local/boost/libs/python/src/converter/builtin_converters.cpp:401: > instantiated from here > /usr/local/boost/libs/python/src/converter/builtin_converters.cpp:78: > error: invalid static_cast from type `std::complex' to type > `std::complex' > > -- > Paul M. Magwene, Ph.D. > Postdoctoral Fellow > Department of Biology > University of Pennsylvania > > Goddard Labs, Rm 203 > (215)898-8395 __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From mike at nospam.com Tue Nov 4 20:08:17 2003 From: mike at nospam.com (Mike Rovner) Date: Tue, 4 Nov 2003 11:08:17 -0800 Subject: [C++-sig] Re: latest checkin breaks builtin_converters.cpp on GCCcygwin References: <3FA7F0C1.6030109@yale.edu> <20031104184806.14245.qmail@web20210.mail.yahoo.com> Message-ID: Ralf W. Grosse-Kunstleve wrote: > FWIW: I had the exact same problem with gcc 3.3.1 under Mac OS > 10.2.8. I.e. the workaround should probably be gcc-specific (as > opposed to platform-specific). Ralf > > --- Paul Magwene wrote: >> The latest CVS checkin for builtin_converters (see below), seems to >> break the boost.python build on cygwin (gcc version 3.3.1 (cygming >> special)). Unfortunately I don't have all set of compilers available, so my testing was not rigorous. I'll try to test this of several available ASAP. Mike From rwgk at yahoo.com Tue Nov 4 20:59:45 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 4 Nov 2003 11:59:45 -0800 (PST) Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031104123320-r01010800-86150dd2-0860-0108@12.100.89.43> Message-ID: <20031104195945.82353.qmail@web20206.mail.yahoo.com> --- Rene Rivera wrote: > It turned out to be much easier to just add: > > <*>-bind_at_load > > ..to the dll build in libs/python/build/Jamfile Now I am seeing the errors reported earlier by Harri; see below. Odd, I am pretty sure I didn't get these last night. Ralf bjam -sPYTHON_VERSION=2.3 -sTOOLS=darwin -sBUILD=debug -sALL_LOCATE_TARGET=/net_coral/scratch1/rwgk/bjam -d2 ...found 3336 targets... ...updating 53 targets... darwin-Link-action /net_coral/scratch1/rwgk/bjam/bin/boost/libs/python/test/crossmod_exception_a.so/darwin/debug/link-format-bundle/shared-linkable-true/crossmod_exception_a.so DYLD_LIBRARY_PATH=/net_coral/scratch1/rwgk/bjam/bin/boost/libs/python/build/libboost_python.dylib/darwin/debug/link-format-bundle/shared-linkable-true export DYLD_LIBRARY_PATH c++ -g -bundle -o "/net_coral/scratch1/rwgk/bjam/bin/boost/libs/python/test/crossmod_exception_a.so/darwin/debug/link-format-bundle/shared-linkable-true/crossmod_exception_a.so" "/net_coral/scratch1/rwgk/bjam/bin/boost/libs/python/test/crossmod_exception_a.so/darwin/debug/link-format-bundle/shared-linkable-true/crossmod_exception_a.o" \ -L"/net_coral/scratch1/rwgk/bjam/bin/boost/libs/python/build/libboost_python.dylib/darwin/debug/link-format-bundle/shared-linkable-true" -lboost_python \ -F/Library/Frameworks -framework Python ld: /net_coral/scratch1/rwgk/bjam/bin/boost/libs/python/build/libboost_python.dylib/darwin/debug/link-format-bundle/shared-linkable-true/libboost_python.dylib is input for the dynamic link editor, is not relocatable by the static link editor again ...failed darwin-Link-action /net_coral/scratch1/rwgk/bjam/bin/boost/libs/python/test/crossmod_exception_a.so/darwin/debug/link-format-bundle/shared-linkable-true/crossmod_exception_a.so... __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From grafik.list at redshift-software.com Tue Nov 4 21:12:07 2003 From: grafik.list at redshift-software.com (Rene Rivera) Date: Tue, 4 Nov 2003 14:12:07 -0600 Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031104195945.82353.qmail@web20206.mail.yahoo.com> Message-ID: <20031104141208-r01010800-72880686-0860-0108@12.100.89.43> [2003-11-04] Ralf W. Grosse-Kunstleve wrote: >--- Rene Rivera wrote: >> It turned out to be much easier to just add: >> >> <*>-bind_at_load >> >> ..to the dll build in libs/python/build/Jamfile > >Now I am seeing the errors reported earlier by Harri; see below. >Odd, I am pretty sure I didn't get these last night. >Ralf >ld: >/net_coral/scratch1/rwgk/bjam/bin/boost/libs/python/build/libboost_python.dylib/darwin/debug/link-format-bundle/shared-linkable-true/libboost_python.dylib >is input for the dynamic link editor, is not relocatable by the static link >editor again >....failed darwin-Link-action >/net_coral/scratch1/rwgk/bjam/bin/boost/libs/python/test/crossmod_exception_a.so/darwin/debug/link-format-bundle/shared-linkable-true/crossmod_exception_a.so... Curious... All I did was take out the -bundle_loader option. Could you compare that link commands to your working SCons based build? (bjam -d+2 option) -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From paul.magwene at yale.edu Tue Nov 4 21:46:58 2003 From: paul.magwene at yale.edu (Paul Magwene) Date: Tue, 04 Nov 2003 15:46:58 -0500 Subject: [C++-sig] Confused about placement of libboost_python.dll Message-ID: <3FA81042.7040603@yale.edu> Howdy folks, I'm confused about where libboost_python.dll should be placed on either a MSVC or cygwin build under windows. From messages like this: http://mail.python.org/pipermail/c++-sig/2002-September/002016.html I understand that lib_boostpython is NOT a python module. OK - so under cygwin I put it in "/usr/local/lib" and change my shell profile to include: LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH After resourcing my profile a quick check with "env" confirms this is set. After doing this I'm still unable to properly import a boost built python module. I get the following message: Python 2.3.2 (#1, Oct 9 2003, 12:03:29) [GCC 3.3.1 (cygming special)] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> import hello Traceback (most recent call last): File "", line 1, in ? ImportError: dlopen: Win32 error 126 >>> However, if I copy libboost_python.dll into the same directory that "hello.dll" lives in then I'm able to import the extension just fine. I'm obviously missing something here. Can anybody point me in the right direction? Also, what's the equivalent of LD_LIBRARY_PATH for Windows? Thanks, Paul From mike at nospam.com Tue Nov 4 22:35:56 2003 From: mike at nospam.com (Mike Rovner) Date: Tue, 4 Nov 2003 13:35:56 -0800 Subject: [C++-sig] Re: latest checkin breaks builtin_converters.cpp onGCCcygwin References: <3FA7F0C1.6030109@yale.edu><20031104184806.14245.qmail@web20210.mail.yahoo.com> Message-ID: Mike Rovner wrote: > Ralf W. Grosse-Kunstleve wrote: >> FWIW: I had the exact same problem with gcc 3.3.1 under Mac OS >> 10.2.8. I.e. the workaround should probably be gcc-specific (as >> opposed to platform-specific). Ralf >> >> --- Paul Magwene wrote: >>> The latest CVS checkin for builtin_converters (see below), seems to >>> break the boost.python build on cygwin (gcc version 3.3.1 (cygming >>> special)). > > Unfortunately I don't have all set of compilers available, so my > testing was not rigorous. > I'll try to test this of several available ASAP. > > Mike It seems to be gcc bug 12163 (http://gcc.gnu.org/PR12163) only in version 3.3.1. From rwgk at yahoo.com Tue Nov 4 22:47:13 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 4 Nov 2003 13:47:13 -0800 (PST) Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031104141208-r01010800-72880686-0860-0108@12.100.89.43> Message-ID: <20031104214713.44355.qmail@web20204.mail.yahoo.com> --- Rene Rivera wrote: > Curious... All I did was take out the -bundle_loader option. > > Could you compare that link commands to your working SCons based build? > (bjam -d+2 option) To convince myself everything is still OK I've re-run my scons-based build from scratch against the latest CVS. Everything turns out to work just fine. Here are a few example commands: c++ -fPIC -no-cpp-precomp -ftemplate-depth-120 -fcoalesce-templates -Wno-long-double -w -DNDEBUG -O3 -DBOOST_PYTHON_MAX_BASES=2 -DBOOST_PYTHON_SOURCE -I/net/worm/scratch1/rwgk/hot/boost -I/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3 -c -o boost/libs/python/src/object/function.os /net/worm/scratch1/rwgk/hot/boost/libs/python/src/object/function.cpp ld -dynamic -m -r -d -bind_at_load -o libboost_python.lo boost/libs/python/src/numeric.os boost/libs/python/src/list.os ... boost/libs/python/src/object_operators.os c++ -nostartfiles -Wl,-dylib -ldylib1.o -framework Python -o libtbx/libboost_python.dylib libboost_python.lo rm -f libboost_python.lo c++ -fPIC -no-cpp-precomp -ftemplate-depth-120 -fcoalesce-templates -Wno-long-double -w -DNDEBUG -O3 -DBOOST_PYTHON_MAX_BASES=2 -I/net/worm/scratch1/rwgk/hot/boost -I/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3 -c -o boost/libs/python/test/str.os /net/worm/scratch1/rwgk/hot/boost/libs/python/test/str.cpp c++ -bundle -bundle_loader /Library/Frameworks/Python.framework/Versions/2.3/Python /Library/Frameworks/Python.framework/Versions/2.3/Python -o libtbx/str_ext.so boost/libs/python/test/str.os -Llibtbx -L/net/worm/scratch1/rwgk/hot/libtbx -lboost_python -lm This is pretty much what I had a few days ago except for the addition of -bind_at_load. I am still using -bundle_loader as you can see. Was your idea to make this obsolete by using -F while compiling extension modules? Why do you want to eliminate the -bundle_loader switch? Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From rwgk at yahoo.com Tue Nov 4 22:50:51 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 4 Nov 2003 13:50:51 -0800 (PST) Subject: [C++-sig] Re: latest checkin breaks builtin_converters.cpp onGCCcygwin In-Reply-To: Message-ID: <20031104215051.59901.qmail@web20209.mail.yahoo.com> --- Mike Rovner wrote: > It seems to be gcc bug 12163 (http://gcc.gnu.org/PR12163) only in version > 3.3.1. We should probably hurry up adding a workaround because the boost 1.31 release is coming up soon. Does it look complicated? Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From mike at nospam.com Tue Nov 4 22:57:46 2003 From: mike at nospam.com (Mike Rovner) Date: Tue, 4 Nov 2003 13:57:46 -0800 Subject: [C++-sig] Re: Re: latest checkin breaks builtin_converters.cpponGCCcygwin References: <20031104215051.59901.qmail@web20209.mail.yahoo.com> Message-ID: Ralf W. Grosse-Kunstleve wrote: > --- Mike Rovner wrote: >> It seems to be gcc bug 12163 (http://gcc.gnu.org/PR12163) only in >> version >> 3.3.1. > > We should probably hurry up adding a workaround because the boost > 1.31 release is coming up soon. Does it look complicated? > Ralf Simple solution is just roll back to have a warning. However it doesn't feel right, so some hairy #ifdef GCC might be added to avoid that particular version of GCC (which I'm on right now). Mike From grafik.list at redshift-software.com Tue Nov 4 23:19:03 2003 From: grafik.list at redshift-software.com (Rene Rivera) Date: Tue, 4 Nov 2003 16:19:03 -0600 Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031104214713.44355.qmail@web20204.mail.yahoo.com> Message-ID: <20031104161904-r01010800-ffc04930-0860-0108@12.100.89.43> [2003-11-04] Ralf W. Grosse-Kunstleve wrote: >--- Rene Rivera wrote: >> Curious... All I did was take out the -bundle_loader option. >> >> Could you compare that link commands to your working SCons based build? >> (bjam -d+2 option) > >To convince myself everything is still OK I've re-run my scons-based build from >scratch against the latest CVS. Everything turns out to work just fine. Here >are a few example commands: >c++ -bundle -bundle_loader >/Library/Frameworks/Python.framework/Versions/2.3/Python >/Library/Frameworks/Python.framework/Versions/2.3/Python -o libtbx/str_ext.so >boost/libs/python/test/str.os -Llibtbx -L/net/worm/scratch1/rwgk/hot/libtbx >-lboost_python -lm Well.. I'll put the bundle loader option back in if it can only work with it. >This is pretty much what I had a few days ago except for the addition of >-bind_at_load. I am still using -bundle_loader as you can see. Was your idea to >make this obsolete by using -F while compiling extension modules? Why do you >want to eliminate the -bundle_loader switch? The idea came from... Your quote about what the Python build itself does for building the built in extensions. And yes the idea was to use the -framework option instead. Unfortunately the Apple documentation is very unclear in many places about such things :-( What I'm thinking now is that using the "-lboost_python" only works if you supply the loader for it explicitly. Which makes sense if one notices that when linking the extension is prebinding the bpl, with the errors we saw about not having the binding of a function (which the -bind_at_load solves)... Sorry about the rambling, trying to convince myself about this ;-) ...OK the bundle_loader option is back. Changes are to python.jam and darwin-tools.jam. -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From mike at nospam.com Tue Nov 4 23:21:20 2003 From: mike at nospam.com (Mike Rovner) Date: Tue, 4 Nov 2003 14:21:20 -0800 Subject: [C++-sig] Re: Re: latest checkin breaksbuiltin_converters.cpponGCCcygwin References: <20031104215051.59901.qmail@web20209.mail.yahoo.com> Message-ID: Mike Rovner wrote: > added to avoid that particular version of GCC (which I'm on right > now). Here it is (also attached): Index: libs/python/src/converter/builtin_converters.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/python/src/converter/builtin_converters.cpp,v retrieving revision 1.26 diff -u -r1.26 builtin_converters.cpp --- libs/python/src/converter/builtin_converters.cpp 23 Sep 2003 23:57:23 -0000 1.26 +++ libs/python/src/converter/builtin_converters.cpp 4 Nov 2003 22:20:02 -0000 @@ -75,7 +75,12 @@ // Get the location in which to construct void* storage = ((rvalue_from_python_storage*)data)->storage.bytes; +#if defined(__GNUC__) && \ + (__GNUC__ == 3 && __GNUC_MINOR__ == 3 && __GNUC_PATCHLEVEL__ == 1) new (storage) T(SlotPolicy::extract(intermediate.get())); +#else + new (storage) T(static_cast(SlotPolicy::extract(intermediate.get()))); +#endif // record successful construction data->convertible = storage; begin 666 bpl.patch M26YD97 at Z(&QI8G,O<'ET:&]N+W-R8R]C;VYV97)T97(O8G5I;'1I;E]C;VYV M97)T97)S+F-P< H]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T] M/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]"E)#4R!F:6QE.B O M8W9S71H;VXO'1R86-T*&EN=&5R;65D:6%T92YG970H*2DI.PHK(V5L M3HZ97AT References: <20031104214713.44355.qmail@web20204.mail.yahoo.com> Message-ID: <423E10D3-0F15-11D8-B158-000A95686CD8@redivi.com> On Nov 4, 2003, at 4:47 PM, Ralf W. Grosse-Kunstleve wrote: > --- Rene Rivera wrote: >> Curious... All I did was take out the -bundle_loader option. >> >> Could you compare that link commands to your working SCons based >> build? >> (bjam -d+2 option) > > To convince myself everything is still OK I've re-run my scons-based > build from > scratch against the latest CVS. Everything turns out to work just > fine. Here > are a few example commands: --snip-- > This is pretty much what I had a few days ago except for the addition > of > -bind_at_load. I am still using -bundle_loader as you can see. Was > your idea to > make this obsolete by using -F while compiling extension modules? Why > do you > want to eliminate the -bundle_loader switch? -bundle_loader is pretty worthless with a framework Python.. -bundle_loader is useful only when you want to reference symbols that are defined in a host executable. In the case of a framework Python, all the Python C API is in the framework and the host executable merely just links to it. If you use -bundle_loader, your modules may be incompatible with certain ways of embedding the Python framework. If you link directly to the framework, you will not have these problems (so long as your module and the host executable links to the same Python framework, of course, but that's another story...). -F is only useful to change the search path for frameworks, you shouldn't really have to worry about this until Python 2.4 becomes an issue. I expect various things to change in Python 2.4's framework build with respect to extension modules so please don't bother throwing these kind of "future proof" things in, because you will probably make incorrect guesses anyway. -f is what you want to use to link to a framework, and you want it to follow the normal search order. If you really feel the need to override this, you should be able to do so with environment variables (man dyld), as I believe the linker should respect them. With regard to -bind_at_load, this is only necessary for some C++ scenarios. There's some kind of static initialization happening, and typically dyld likes to defer this until you try and resolve something. Apparently whatever you're doing is not compatible with that, so Bad Things Happen. Using -bind_at_load isn't the worst thing in the world, it just makes loading your module slower because you're telling dyld to stop being lazy. -bob From rwgk at yahoo.com Tue Nov 4 23:37:54 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 4 Nov 2003 14:37:54 -0800 (PST) Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <423E10D3-0F15-11D8-B158-000A95686CD8@redivi.com> Message-ID: <20031104223754.56656.qmail@web20204.mail.yahoo.com> --- Bob Ippolito wrote: > -bundle_loader is pretty worthless with a framework Python.. But as it stands right now I don't know how to get a working build without the -bundle_loader switch. Did you see my other posting with the example compile & link commands? http://mail.python.org/pipermail/c++-sig/2003-November/006188.html How would you modify these command lines? Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From bob at redivi.com Tue Nov 4 23:55:39 2003 From: bob at redivi.com (Bob Ippolito) Date: Tue, 4 Nov 2003 17:55:39 -0500 Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031104223754.56656.qmail@web20204.mail.yahoo.com> References: <20031104223754.56656.qmail@web20204.mail.yahoo.com> Message-ID: <02D137B2-0F1A-11D8-B158-000A95686CD8@redivi.com> On Nov 4, 2003, at 5:37 PM, Ralf W. Grosse-Kunstleve wrote: > --- Bob Ippolito wrote: >> -bundle_loader is pretty worthless with a framework Python.. > > But as it stands right now I don't know how to get a working build > without the > -bundle_loader switch. Did you see my other posting with the example > compile & > link commands? > > http://mail.python.org/pipermail/c++-sig/2003-November/006188.html > > How would you modify these command lines? the last one: c++ -bundle -bundle_loader /Library/Frameworks/Python.framework/Versions/2.3/Python /Library/Frameworks/Python.framework/Versions/2.3/Python -o libtbx/str_ext.so boost/libs/python/test/str.os -Llibtbx -L/net/worm/scratch1/rwgk/hot/libtbx -lboost_python -lm should be: c++ -bundle -o libtbx/str_ext.so boost/libs/python/test/str.os -Llibtbx -L/net/worm/scratch1/rwgk/hot/libtbx -framework Python -lboost_python -lm see: LDSHARED= $(CC) $(LDFLAGS) -bundle -framework $(PYTHONFRAMEWORK) from: /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/ config/Makefile Basically the deal is that dyld does two level namespaces.. so except in the case of umbrella frameworks or libraries (don't try and do this for Python), if you don't have the symbol defined in your object file it does not get exported. Therefore, anything that uses symbols from Python have to get them from the Python framework directly (I'm assuming that both libboost_python and str_ext use symbols from Python). -bob From grafik.list at redshift-software.com Wed Nov 5 00:20:20 2003 From: grafik.list at redshift-software.com (Rene Rivera) Date: Tue, 4 Nov 2003 17:20:20 -0600 Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <02D137B2-0F1A-11D8-B158-000A95686CD8@redivi.com> Message-ID: <20031104172021-r01010800-5b6a2e17-0860-0108@12.100.89.43> [2003-11-04] Bob Ippolito wrote: > >On Nov 4, 2003, at 5:37 PM, Ralf W. Grosse-Kunstleve wrote: > >> --- Bob Ippolito wrote: >>> -bundle_loader is pretty worthless with a framework Python.. >> >> But as it stands right now I don't know how to get a working build >> without the >> -bundle_loader switch. Did you see my other posting with the example >> compile & >> link commands? >> >> http://mail.python.org/pipermail/c++-sig/2003-November/006188.html >> >> How would you modify these command lines? > >the last one: > >c++ -bundle -bundle_loader >/Library/Frameworks/Python.framework/Versions/2.3/Python >/Library/Frameworks/Python.framework/Versions/2.3/Python -o >libtbx/str_ext.so boost/libs/python/test/str.os -Llibtbx >-L/net/worm/scratch1/rwgk/hot/libtbx -lboost_python -lm > >should be: > >c++ -bundle -o libtbx/str_ext.so boost/libs/python/test/str.os -Llibtbx >-L/net/worm/scratch1/rwgk/hot/libtbx -framework Python -lboost_python >-lm I wish... That is what I implemented, and what Ralf tried earlier today, and it doesn't work. >see: >LDSHARED= $(CC) $(LDFLAGS) -bundle -framework $(PYTHONFRAMEWORK) > >from: >/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/ >config/Makefile > >Basically the deal is that dyld does two level namespaces.. so except >in the case of umbrella frameworks or libraries (don't try and do this >for Python), if you don't have the symbol defined in your object file >it does not get exported. Therefore, anything that uses symbols from >Python have to get them from the Python framework directly (I'm >assuming that both libboost_python and str_ext use symbols from >Python). The problem isn't in the use of the Python framework but in the use of the boost_python dylib. As soon as you give the -lboost_python when building a bundle, which seems to be statically linked, it wants to bind the symbols in boost_python but because it's a dynamic object it complains that it can't. This would of course change if Boost.Python itself was built as a framework, but that's not going to happen any time soon. -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From dave at boost-consulting.com Wed Nov 5 01:34:30 2003 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 04 Nov 2003 14:34:30 -1000 Subject: [C++-sig] Re: latest checkin breaksbuiltin_converters.cpponGCCcygwin References: <20031104215051.59901.qmail@web20209.mail.yahoo.com> Message-ID: "Mike Rovner" writes: > Mike Rovner wrote: >> added to avoid that particular version of GCC (which I'm on right >> now). > > Here it is (also attached): I don't believe that static_cast is legal. Can you prove that it is supposed to work? I checked in a preferred fix. -- Dave Abrahams Boost Consulting www.boost-consulting.com From rwgk at yahoo.com Wed Nov 5 01:35:14 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 4 Nov 2003 16:35:14 -0800 (PST) Subject: [C++-sig] Re: Re: latest checkin breaksbuiltin_converters.cpponGCCcygwin In-Reply-To: Message-ID: <20031105003514.78608.qmail@web20205.mail.yahoo.com> Thanks Mike! I've just checked this in. I've verified that it fixes my old gcc 3.3.1 build on the Mac. Ralf --- Mike Rovner wrote: > Mike Rovner wrote: > > added to avoid that particular version of GCC (which I'm on right > > now). > > Here it is (also attached): > > Index: libs/python/src/converter/builtin_converters.cpp > =================================================================== __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From rwgk at yahoo.com Wed Nov 5 01:38:57 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 4 Nov 2003 16:38:57 -0800 (PST) Subject: [C++-sig] Re: latest checkin breaksbuiltin_converters.cpponGCCcygwin In-Reply-To: Message-ID: <20031105003857.82535.qmail@web20201.mail.yahoo.com> --- David Abrahams wrote: > "Mike Rovner" writes: > > > Mike Rovner wrote: > >> added to avoid that particular version of GCC (which I'm on right > >> now). > > > > Here it is (also attached): > > I don't believe that static_cast is legal. Can you prove that it is > supposed to work? > > I checked in a preferred fix. I hope what I just checked in doesn't cause too much confusion... FWIW: The static cast works with EDG 238, EDG 245, gcc 3.2 and Apple's gcc 3.3. Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From dave at boost-consulting.com Wed Nov 5 01:39:27 2003 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 04 Nov 2003 14:39:27 -1000 Subject: [C++-sig] Re: boost::python::range and duplicate comdat under MSVC 6 References: Message-ID: Raoul Gough writes: >> However, a simple transformation ought to be enough to eliminate the >> static data member, AFAICT. Do you need help working it out? > > It looks to me like the static member is only useful for the > side-effects of its constructor. Is there an alternative way to > achieve this? Sure; use a function-static variable in the constructor to make sure that the side-effects only happen once, and then change class_converters.hpp so that it constructs a shared_ptr_from_python on the stack instead of calling force_instantiate. -- Dave Abrahams Boost Consulting www.boost-consulting.com From rwgk at yahoo.com Wed Nov 5 01:47:14 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 4 Nov 2003 16:47:14 -0800 (PST) Subject: [C++-sig] Boost.Python, AIX, and gcc In-Reply-To: Message-ID: <20031105004714.54281.qmail@web20203.mail.yahoo.com> --- Mike Owen wrote: > By the way, the test case I'm using to generate this error is really small, > so I could provide it if > that would be helpful. I'm not sure if that's useful, though, since you have > to have an AIX > machine handy to reproduce the problem. Having your test could be very useful anyway: - Maybe I can reproduce it on the Macintosh. - Maybe it gives Doug the right idea. He was looking for a type with 8-byte alignment and you seem to have one. Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From paul.magwene at yale.edu Wed Nov 5 01:52:48 2003 From: paul.magwene at yale.edu (Paul Magwene) Date: Tue, 04 Nov 2003 19:52:48 -0500 Subject: [C++-sig] Re: Confused about placement of libboost_python.dll In-Reply-To: <3FA81042.7040603@yale.edu> References: <3FA81042.7040603@yale.edu> Message-ID: <3FA849E0.9040207@yale.edu> Paul Magwene wrote: > Howdy folks, > > I'm confused about where libboost_python.dll should be placed on either > a MSVC or cygwin build under windows. > ...SNIP... > > I understand that lib_boostpython is NOT a python module. OK - so under > cygwin I put it in "/usr/local/lib" and change my shell profile to include: > > LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH > export LD_LIBRARY_PATH > ...SNIP... > After doing this I'm still unable to properly import a boost built > python module. I get the following message: > ...SNIP... > However, if I copy libboost_python.dll into the same directory that > "hello.dll" lives in then I'm able to import the extension just fine. To answer my own qustion, and hopefully save somebody else some headaches in the future, cygwin does not use LD_LIBRARY_PATH to look for libraries, but rather just the PATH environment variable. The solution then is to put libboost_python.dll anywhere in your path... --Paul From mike at nospam.com Wed Nov 5 02:05:19 2003 From: mike at nospam.com (Mike Rovner) Date: Tue, 4 Nov 2003 17:05:19 -0800 Subject: [C++-sig] Re: latest checkin breaksbuiltin_converters.cpponGCCcygwin References: <20031104215051.59901.qmail@web20209.mail.yahoo.com> Message-ID: David Abrahams wrote: > > I don't believe that static_cast is legal. Can you prove that it is > supposed to work? IMHO it stated in ISO C++ 5.2.9 para 2 (for this case). Mike From mike at nospam.com Wed Nov 5 02:08:20 2003 From: mike at nospam.com (Mike Rovner) Date: Tue, 4 Nov 2003 17:08:20 -0800 Subject: [C++-sig] Re: latest checkin breaksbuiltin_converters.cpponGCCcygwin References: <20031104215051.59901.qmail@web20209.mail.yahoo.com> Message-ID: > "Mike Rovner" writes: Ooh, I better quote it here: """ An expression e can be explicitly converted to a type T using a static_cast of the form static_cast(e) if the declaration "T t(e);" is wellformed, for some invented temporary variable t (8.5). The effect of such an explicit conversion is the same as performing the declaration and initialization and then using the temporary variable as the result of the conversion. The result is an lvalue if T is a reference type (8.3.2), and an rvalue otherwise. The expression e is used as an lvalue if and only if the initialization uses it as an lvalue. """ As complex(complex) is defined, it's seems ok. Mike From mikeowen at llnl.gov Wed Nov 5 02:13:12 2003 From: mikeowen at llnl.gov (J. Michael Owen) Date: Tue, 4 Nov 2003 17:13:12 -0800 Subject: [C++-sig] Boost.Python, AIX, and gcc In-Reply-To: <20031105004714.54281.qmail@web20203.mail.yahoo.com> References: <20031105004714.54281.qmail@web20203.mail.yahoo.com> Message-ID: OK -- here's the test. It's about as simple as it can be. :) #include #include "boost/python.hpp" using namespace std; using namespace boost::python; struct Base { Base() { cerr << "Base()" << endl; } virtual ~Base() { cerr << "~Base()" << endl; } double get_x() const { return x; } void set_x(const double val) { x = val; } double x; }; struct Derived: public Base { Derived(): Base() { cerr << "Derived" << endl; } virtual ~Derived() { cerr << "~Derived" << endl; } double y; }; BOOST_PYTHON_MODULE(Test) { class_("Base", init<>()) .def("get_x", &Base::get_x) .def("set_x", &Base::set_x) .def_readwrite("x", &Base::x); class_ >("Derived", init<>()) .def_readwrite("y", &Derived::y); } On Tuesday 04 November 2003 04:47 pm, Ralf W. Grosse-Kunstleve wrote: > --- Mike Owen wrote: > > By the way, the test case I'm using to generate this error is really > > small, so I could provide it if > > that would be helpful. I'm not sure if that's useful, though, since you > > have to have an AIX > > machine handy to reproduce the problem. > > Having your test could be very useful anyway: > > - Maybe I can reproduce it on the Macintosh. > > - Maybe it gives Doug the right idea. He was looking for a type with 8-byte > alignment and you seem to have one. > > Ralf > > > __________________________________ > Do you Yahoo!? > Protect your identity with Yahoo! Mail AddressGuard > http://antispam.yahoo.com/whatsnewfree -- "Hey...where are the sunflower seeds?" | J. Michael Owen o_o / | Phone: 925-423-7160 (") | Email: mikeowen at llnl.gov \/'\/ | ____(__(,_,)_______________________________________________________________ From rwgk at yahoo.com Wed Nov 5 02:25:41 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 4 Nov 2003 17:25:41 -0800 (PST) Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <02D137B2-0F1A-11D8-B158-000A95686CD8@redivi.com> Message-ID: <20031105012541.10101.qmail@web20202.mail.yahoo.com> --- Bob Ippolito wrote: > > How would you modify these command lines? > > the last one: > > c++ -bundle -bundle_loader > /Library/Frameworks/Python.framework/Versions/2.3/Python > /Library/Frameworks/Python.framework/Versions/2.3/Python -o > libtbx/str_ext.so boost/libs/python/test/str.os -Llibtbx > -L/net/worm/scratch1/rwgk/hot/libtbx -lboost_python -lm > > should be: > > c++ -bundle -o libtbx/str_ext.so boost/libs/python/test/str.os -Llibtbx > -L/net/worm/scratch1/rwgk/hot/libtbx -framework Python -lboost_python > -lm Just to confirm this observation, unfortunately it doesn't work: c++ -bundle -o libtbx/list_ext.so boost/libs/python/test/list.os -Llibtbx -L/net/worm/scratch1/rwgk/hot/libtbx -lboost_python -lm ld: boost/libs/python/test/list.os illegal reference to symbol: _PyEval_CallFunction defined in indirectly referenced dynamic library /Library/Frameworks/Python.framework/Versions/2.3/Python If I put the -bundle_loader back and keep everything else the same there is no problem. Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From bob at redivi.com Wed Nov 5 02:32:38 2003 From: bob at redivi.com (Bob Ippolito) Date: Tue, 4 Nov 2003 20:32:38 -0500 Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031105012541.10101.qmail@web20202.mail.yahoo.com> References: <20031105012541.10101.qmail@web20202.mail.yahoo.com> Message-ID: On Nov 4, 2003, at 8:25 PM, Ralf W. Grosse-Kunstleve wrote: > --- Bob Ippolito wrote: >>> How would you modify these command lines? >> >> the last one: >> >> c++ -bundle -bundle_loader >> /Library/Frameworks/Python.framework/Versions/2.3/Python >> /Library/Frameworks/Python.framework/Versions/2.3/Python -o >> libtbx/str_ext.so boost/libs/python/test/str.os -Llibtbx >> -L/net/worm/scratch1/rwgk/hot/libtbx -lboost_python -lm >> >> should be: >> >> c++ -bundle -o libtbx/str_ext.so boost/libs/python/test/str.os >> -Llibtbx >> -L/net/worm/scratch1/rwgk/hot/libtbx -framework Python -lboost_python >> -lm > > Just to confirm this observation, unfortunately it doesn't work: > > c++ -bundle -o libtbx/list_ext.so boost/libs/python/test/list.os > -Llibtbx > -L/net/worm/scratch1/rwgk/hot/libtbx -lboost_python -lm > ld: boost/libs/python/test/list.os illegal reference to symbol: > _PyEval_CallFunction defined in indirectly referenced dynamic library > /Library/Frameworks/Python.framework/Versions/2.3/Python > > If I put the -bundle_loader back and keep everything else the same > there is no > problem. That's because it's wrong, this is right: c++ -bundle -framework Python -o libtbx/list_ext.so boost/libs/python/test/list.os -Llibtbx -L/net/worm/scratch1/rwgk/hot/libtbx -lboost_python -lm -bob From grafik.list at redshift-software.com Wed Nov 5 02:48:30 2003 From: grafik.list at redshift-software.com (Rene Rivera) Date: Tue, 4 Nov 2003 19:48:30 -0600 Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: Message-ID: <20031104194831-r01010800-9d16edc2-0860-0108@12.100.89.43> [2003-11-04] Bob Ippolito wrote: >That's because it's wrong, this is right: >c++ -bundle -framework Python -o libtbx/list_ext.so >boost/libs/python/test/list.os -Llibtbx >-L/net/worm/scratch1/rwgk/hot/libtbx -lboost_python -lm It would help if you exmplain why it's right. Is it because the "-framework Python" has to come before the "list.os"; Or because it has to come before the "-lboost_python"; Or is the order relevant at all? Looking for understanding here ;-) -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From rwgk at yahoo.com Wed Nov 5 03:08:32 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 4 Nov 2003 18:08:32 -0800 (PST) Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031104161904-r01010800-ffc04930-0860-0108@12.100.89.43> Message-ID: <20031105020832.56654.qmail@web20206.mail.yahoo.com> --- Rene Rivera wrote: > ...OK the bundle_loader option is back. Changes are to python.jam and > darwin-tools.jam. I believe the -bind_at_load slipped in the wrong place. It should be here: ld -dynamic -m -r -d -bind_at_load -o ... But it appears in the next command: c++ -bind_at_load ... Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From bob at redivi.com Wed Nov 5 03:15:56 2003 From: bob at redivi.com (Bob Ippolito) Date: Tue, 4 Nov 2003 21:15:56 -0500 Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031104194831-r01010800-9d16edc2-0860-0108@12.100.89.43> References: <20031104194831-r01010800-9d16edc2-0860-0108@12.100.89.43> Message-ID: On Nov 4, 2003, at 8:48 PM, Rene Rivera wrote: > [2003-11-04] Bob Ippolito wrote: > > >> That's because it's wrong, this is right: >> c++ -bundle -framework Python -o libtbx/list_ext.so >> boost/libs/python/test/list.os -Llibtbx >> -L/net/worm/scratch1/rwgk/hot/libtbx -lboost_python -lm > > It would help if you exmplain why it's right. > > Is it because the "-framework Python" has to come before the > "list.os"; Or > because it has to come before the "-lboost_python"; Or is the order > relevant > at all? > > Looking for understanding here ;-) It's wrong because there was *no* "-framework Python", it doesn't matter so much where it is. He didn't follow my "should be" example exactly, so I repeated it, sorry for the reordering confusion. "_PyEval_CallFunction defined in indirectly referenced dynamic library" means that he tried to steal a reference to Python.framework via libboost_python, you can't do that with two level namespaces (unless libboost_python was an umbrella for Python.framework, which it is not and should not be). You have to have direct references to the symbols that you use, as I said before when I spoke briefly about two level namespaces. -bob From dave at boost-consulting.com Wed Nov 5 03:18:31 2003 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 04 Nov 2003 16:18:31 -1000 Subject: [C++-sig] Re: Confused about placement of libboost_python.dll References: <3FA81042.7040603@yale.edu> <3FA849E0.9040207@yale.edu> Message-ID: Paul Magwene writes: > Paul Magwene wrote: > >> Howdy folks, >> I'm confused about where libboost_python.dll should be placed on >> either a MSVC or cygwin build under windows. >> > ...SNIP... > >> I understand that lib_boostpython is NOT a python module. OK - so >> under cygwin I put it in "/usr/local/lib" and change my shell >> profile to include: >> LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH >> export LD_LIBRARY_PATH >> > ...SNIP... >> After doing this I'm still unable to properly import a boost built >> python module. I get the following message: >> > ...SNIP... > >> However, if I copy libboost_python.dll into the same directory that >> "hello.dll" lives in then I'm able to import the extension just >> fine. > > To answer my own qustion, and hopefully save somebody else some > headaches in the future, cygwin does not use LD_LIBRARY_PATH to look > for libraries, but rather just the PATH environment variable. http://www.redhat.com/docs/manuals/gnupro/GNUPro-Toolkit-03r1/gnupro_8.html#IDX205 contradicts you. -- Dave Abrahams Boost Consulting www.boost-consulting.com From rwgk at yahoo.com Wed Nov 5 03:21:51 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 4 Nov 2003 18:21:51 -0800 (PST) Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: Message-ID: <20031105022151.97663.qmail@web20205.mail.yahoo.com> --- Bob Ippolito wrote: > That's because it's wrong, this is right: > c++ -bundle -framework Python -o libtbx/list_ext.so > boost/libs/python/test/list.os -Llibtbx > -L/net/worm/scratch1/rwgk/hot/libtbx -lboost_python -lm Yes, indeed, it works! This also works: c++ -bundle -o libtbx/dict_ext.so boost/libs/python/test/dict.os -Llibtbx -L/net/worm/scratch1/rwgk/hot/libtbx -framework Python -lboost_python -lm So the order does not seem to be important. I was just missing the -framework Python bit. Sorry for the oversight. Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From grafik.list at redshift-software.com Wed Nov 5 03:26:41 2003 From: grafik.list at redshift-software.com (Rene Rivera) Date: Tue, 4 Nov 2003 20:26:41 -0600 Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031105022151.97663.qmail@web20205.mail.yahoo.com> Message-ID: <20031104202641-r01010800-f6482cb9-0860-0108@12.100.89.43> [2003-11-04] Ralf W. Grosse-Kunstleve wrote: >--- Bob Ippolito wrote: >> That's because it's wrong, this is right: >> c++ -bundle -framework Python -o libtbx/list_ext.so >> boost/libs/python/test/list.os -Llibtbx >> -L/net/worm/scratch1/rwgk/hot/libtbx -lboost_python -lm > >Yes, indeed, it works! This also works: > >c++ -bundle -o libtbx/dict_ext.so boost/libs/python/test/dict.os -Llibtbx >-L/net/worm/scratch1/rwgk/hot/libtbx -framework Python -lboost_python -lm > >So the order does not seem to be important. I was just missing the -framework >Python bit. Sorry for the oversight. No problem... I'll fix Boost.Build, including the other problem you mentioned, after dinner ;-) -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From bob at redivi.com Wed Nov 5 03:36:56 2003 From: bob at redivi.com (Bob Ippolito) Date: Tue, 4 Nov 2003 21:36:56 -0500 Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031104202641-r01010800-f6482cb9-0860-0108@12.100.89.43> References: <20031104202641-r01010800-f6482cb9-0860-0108@12.100.89.43> Message-ID: On Nov 4, 2003, at 9:26 PM, Rene Rivera wrote: > [2003-11-04] Ralf W. Grosse-Kunstleve wrote: > >> --- Bob Ippolito wrote: >>> That's because it's wrong, this is right: >>> c++ -bundle -framework Python -o libtbx/list_ext.so >>> boost/libs/python/test/list.os -Llibtbx >>> -L/net/worm/scratch1/rwgk/hot/libtbx -lboost_python -lm >> >> Yes, indeed, it works! This also works: >> >> c++ -bundle -o libtbx/dict_ext.so boost/libs/python/test/dict.os >> -Llibtbx >> -L/net/worm/scratch1/rwgk/hot/libtbx -framework Python -lboost_python >> -lm >> >> So the order does not seem to be important. I was just missing the > -framework >> Python bit. Sorry for the oversight. > > No problem... I'll fix Boost.Build, including the other problem you > mentioned, after dinner ;-) Awesome, I'm really looking forward to Boost.Python working on OS X (platform of choice).. I've never really had the opportunity to play with it, as much as I'd like to (which is almost to the point where I'd play with it from linux or win32 machines). Feel free to email me directly if you'd like to about any other OS X-ism, would like help packaging Boost.Python for OS X, etc. -bob From paul.magwene at yale.edu Wed Nov 5 03:44:16 2003 From: paul.magwene at yale.edu (Paul Magwene) Date: Tue, 04 Nov 2003 21:44:16 -0500 Subject: [C++-sig] Re: Confused about placement of libboost_python.dll In-Reply-To: References: <3FA81042.7040603@yale.edu> <3FA849E0.9040207@yale.edu> Message-ID: <3FA86400.5060702@yale.edu> David Abrahams wrote: > Paul Magwene writes: > >> >>To answer my own qustion, and hopefully save somebody else some >>headaches in the future, cygwin does not use LD_LIBRARY_PATH to look >>for libraries, but rather just the PATH environment variable. > > > http://www.redhat.com/docs/manuals/gnupro/GNUPro-Toolkit-03r1/gnupro_8.html#IDX205 > contradicts you. > > The gnupro toolkit manual may say one thing, but the reality appears to be different on my recent (stock) install of cygwin. Adding the directory with libboost_python.dll to my PATH made it work, while adding the directory to LD_LIBRARY_PATH did nothing. I was tipped off after doing a google search and running across this page (see about halfway down the page): http://xml.apache.org/xerces-c/build-winunix.html --Paul From rwgk at yahoo.com Wed Nov 5 04:54:52 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 4 Nov 2003 19:54:52 -0800 (PST) Subject: [C++-sig] Boost.Python, AIX, and gcc Message-ID: <20031105035452.78301.qmail@web20208.mail.yahoo.com> --- "J. Michael Owen" wrote: > OK -- here's the test. It's about as simple as it can be. :) Thanks for the test! Unfortunately it does not fail to compile on the Macintosh. I am able to reproduce the old failure that prompted me to add the #ifdef in type_with_alignment.hpp, but in the exact same environment compiling your code succeeds. So my idea that we can use your test to give Doug a clue did not work out :( Before I added the #ifdef I found out that the PowerPC does not have strict alignment requirements. So the worst consequence of the failure to find a proper alignment is (maybe?) a performance hit. What is the situation on our AIX machine? Does unaligned access cause a crash? Does the following run? #include int main(void) { char buf[2*sizeof(double)]; for(int i=0;i Message-ID: <20031104225039-r01010800-7341526f-0860-0108@12.100.89.43> [2003-11-04] Rene Rivera wrote: >[2003-11-04] Ralf W. Grosse-Kunstleve wrote: > >>--- Bob Ippolito wrote: >>> That's because it's wrong, this is right: >>> c++ -bundle -framework Python -o libtbx/list_ext.so >>> boost/libs/python/test/list.os -Llibtbx >>> -L/net/worm/scratch1/rwgk/hot/libtbx -lboost_python -lm >> >>Yes, indeed, it works! This also works: >> >>c++ -bundle -o libtbx/dict_ext.so boost/libs/python/test/dict.os -Llibtbx >>-L/net/worm/scratch1/rwgk/hot/libtbx -framework Python -lboost_python -lm >> >>So the order does not seem to be important. I was just missing the >-framework >>Python bit. Sorry for the oversight. > >No problem... I'll fix Boost.Build, including the other problem you >mentioned, after dinner ;-) OK, changes are in CVS: python.jam and darwin-tools.jam. -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From nickm at sitius.com Wed Nov 5 06:23:21 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Wed, 05 Nov 2003 00:23:21 -0500 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> Message-ID: <3FA88949.E97E1AE2@sitius.com> Nikolay Mladenov wrote: > > If you have the following module: > struct Foo > { > void set(int a=0, double b=0, const std::string &n=std::string()) > { > a_ = a; > b_ = b; > n_ = n; > } > > private: > ..................... > }; > > using namespace boost::python; > BOOST_PYTHON_MODULE(keywords) > { > class_("Foo" > , init , double > , const std::string & > >( > ( arg("a") = 0 > , arg("b") = 0.0 > , arg("n") = std::string() > )) > ) > .def("set" > , (void (Foo::*)(int , double , const std::string &) > )&Foo::set > , (arg("self"),arg("a") = 0, arg("b") = 0.0, arg("n") = > std::string()) > , "Sets all the fields of self") > ........................... > ; > > } > #include "module_tail.cpp" > //////////////////////////////////////// > > with what I currently have (cvs patched by me) I get: > > >>> import keywords > >>> help(keywords.Foo.set) > > Help on method set: > > set(...) unbound keywords.Foo method > set(struct Foo self, int a=0, double b=0.0, class > _STL::basic_string,class > _STL::allocator > n="") > Sets all the fields of self > (END) > >>> > I now think that this is too intrusive and there should be a way to specify whether or not the signature will be attached to the docstring. May be like that: def ("f", &f, "f's docstring") def ("g", &g, "%s\n\t g's docstring") ..... >>> print f.__doc__ f's docstring >>> print g.__doc__ g() -> None g's docstring Nikolay From rwgk at yahoo.com Wed Nov 5 07:58:03 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 4 Nov 2003 22:58:03 -0800 (PST) Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031104225039-r01010800-7341526f-0860-0108@12.100.89.43> Message-ID: <20031105065803.68512.qmail@web20202.mail.yahoo.com> --- Rene Rivera wrote: > OK, changes are in CVS: python.jam and darwin-tools.jam. Almost :) This it what is issued: ld -dynamic -m -r -d -o -bind_at_load ... It should be: ld -dynamic -m -r -d -bind_at_load -o ... I looked at darwin-tools.jam but could not figure out what to do... Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From grafik.list at redshift-software.com Wed Nov 5 08:03:02 2003 From: grafik.list at redshift-software.com (Rene Rivera) Date: Wed, 5 Nov 2003 01:03:02 -0600 Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031105065803.68512.qmail@web20202.mail.yahoo.com> Message-ID: <20031105010303-r01010800-31e5093c-0860-0108@12.100.89.43> [2003-11-04] Ralf W. Grosse-Kunstleve wrote: >--- Rene Rivera wrote: >> OK, changes are in CVS: python.jam and darwin-tools.jam. > >Almost :) > >This it what is issued: > >ld -dynamic -m -r -d -o -bind_at_load ... > >It should be: > >ld -dynamic -m -r -d -bind_at_load -o ... > >I looked at darwin-tools.jam but could not figure out what to do... Arrgg.. I hate it when I make stupid mistakes like that :-\ It's fixed now.. Changed "-o $(DLLFLAGS)" to "$(DLLFLAGS) -o" ;-) -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From dave at boost-consulting.com Wed Nov 5 08:22:18 2003 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 04 Nov 2003 21:22:18 -1000 Subject: [C++-sig] Re: Need your help urgently. Please help In-Reply-To: <0C674B14EAEBD61196D900B0D03DB49F01036189@blrw502w.blr.infineon.com> (Varshney Navneet's message of "Wed, 5 Nov 2003 11:17:57 +0530") References: <0C674B14EAEBD61196D900B0D03DB49F01036189@blrw502w.blr.infineon.com> Message-ID: "Varshney Navneet (IFIN DC SMS)" writes: > Hi, > > I am facing a problem in passing default parameters to this program. > > class A > { > public: > A(){} > void f(int a=2,int b=4,int c=10,int d=4) > { > printf("HI am here\n"); > } > }; > BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(F1,A::f,0,4) > > BOOST_PYTHON_MODULE(overload) > { > class_("A") > .def("F",&A::f,F1(args("a","b","c","d"))) > ; > } > > I call the overloaded method from python by passing > >>>name=overload.A() > >>>name.F(a=0) //This works fine > >>>name.F(a=0,b=1) //This works fine > >>>name.F(b=1) //Fails. > bad argument type for built in operation Varsheney, Please post your Boost.Python questions to the C++-sig, and not to me directly (unless you want to hire me, of course ;->). I didn't answer you on the C++-sig (where you posted as Basavaraj.Goudar at infineon.com) because Nikolay Mladenov supplied a solution for you. > I am not able to figure out whether this is the property of boost or > I have to do something else. Nikolay already told you what you have to do. BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS doesn't allow any set of arguments that isn't also allowed by the underlying C++ function. In particular, if you supply argument b you must also supply argument a. -- Dave Abrahams Boost Consulting www.boost-consulting.com From Basavaraj.Goudar at infineon.com Wed Nov 5 10:08:45 2003 From: Basavaraj.Goudar at infineon.com (Goudar Basavaraj (IFIN DC SMS)) Date: Wed, 5 Nov 2003 14:38:45 +0530 Subject: [C++-sig] RE: Passing default argument Message-ID: <0C674B14EAEBD61196D900B0D03DB49FF90F31@blrw502w.blr.infineon.com> Hi Nikolay, Thanks for the info. I tried this but am getting error saying "arg undeclared". I tried including few headers but could not resolve the problem. What could be the solution. Thanks & Regards, Basavaraj BOOST_PYTHON_MODULE(overload) { class_("A") .def("F",&A::f, (arg("a")=2,arg("b")=4,arg("c")=10,arg("d")=4) )) ; } > -----Original Message----- > From: Goudar Basavaraj (IFIN DC SMS) > Sent: Monday, November 03, 2003 5:11 PM > To: 'c++-sig at python.org' > Subject: Passing default argument > > Hi, > > I am facing a problem in passing default parameters to this program. > > class A > { > public: > A(){} > void f(int a=2,int b=4,int c=10,int d=4) > { > printf("HI am here\n"); > } > }; > BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(F1,A::f,0,4) > > BOOST_PYTHON_MODULE(overload) > { > class_("A") > .def("F",&A::f,F1(args("a","b","c","d"))) > ; > } > > I call the overloaded method from python by passing > >>>name=overload.A() > >>>name.F(a=0) //This works fine > >>>name.F(a=0,b=1) //This works fine > >>>name.F(b=1) //Fails. > bad argument type for built in operation > > > I am not able to figure out whether this is the property of boost or > I have to do something else. > > Please let me know................ > > Thanks & Regards, > Basavaraj From nickm at sitius.com Wed Nov 5 15:14:40 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Wed, 05 Nov 2003 09:14:40 -0500 Subject: [C++-sig] Re: Passing default argument References: <0C674B14EAEBD61196D900B0D03DB49FF90F31@blrw502w.blr.infineon.com> Message-ID: <3FA905D0.680325BD@sitius.com> Basavaraj, arg and args are declared in one header file (in namespace boost::python). So if you have args declared you should have arg declared as well, provided that your BPL version is recent(CVS). Nikolay "Goudar Basavaraj (IFIN DC SMS)" wrote: > > Hi Nikolay, > > Thanks for the info. I tried this but am getting error saying > "arg undeclared". I tried including few headers but could not > resolve the problem. > What could be the solution. > > Thanks & Regards, > Basavaraj > > BOOST_PYTHON_MODULE(overload) > { > class_("A") > .def("F",&A::f, (arg("a")=2,arg("b")=4,arg("c")=10,arg("d")=4) )) > ; > } > > > -----Original Message----- > > From: Goudar Basavaraj (IFIN DC SMS) > > Sent: Monday, November 03, 2003 5:11 PM > > To: 'c++-sig at python.org' > > Subject: Passing default argument > > > > Hi, > > > > I am facing a problem in passing default parameters to this program. > > > > class A > > { > > public: > > A(){} > > void f(int a=2,int b=4,int c=10,int d=4) > > { > > printf("HI am here\n"); > > } > > }; > > BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(F1,A::f,0,4) > > > > BOOST_PYTHON_MODULE(overload) > > { > > class_("A") > > .def("F",&A::f,F1(args("a","b","c","d"))) > > ; > > } > > > > I call the overloaded method from python by passing > > >>>name=overload.A() > > >>>name.F(a=0) //This works fine > > >>>name.F(a=0,b=1) //This works fine > > >>>name.F(b=1) //Fails. > > bad argument type for built in operation > > > > > > I am not able to figure out whether this is the property of boost or > > I have to do something else. > > > > Please let me know................ > > > > Thanks & Regards, > > Basavaraj From oliver.walczak at momatec.de Wed Nov 5 16:37:32 2003 From: oliver.walczak at momatec.de (Oliver Walczak) Date: Wed, 5 Nov 2003 16:37:32 +0100 Subject: [C++-sig] Stdout from c++ Message-ID: <000501c3a3b2$ba89b900$7b64a8c0@momatec11> Dear list, I'm quite new to programming c++ extensions for python (not to the c++ Language itself) and i'm wondering what might be the simplest way to make simple string output to sys.stdout from the c++ api. Can anybody give me a hint? I used iostream and cout until now and this works well in the command shell, but not running the idle console under windows. Regards Oliver From seefeld at sympatico.ca Wed Nov 5 16:42:19 2003 From: seefeld at sympatico.ca (Stefan Seefeld) Date: Wed, 05 Nov 2003 10:42:19 -0500 Subject: [C++-sig] Stdout from c++ References: <000501c3a3b2$ba89b900$7b64a8c0@momatec11> Message-ID: <2f85925c6c71c99550a382b4de6904013fa917cb@Orthosoft.ca> Oliver Walczak wrote: > Dear list, > I'm quite new to programming c++ extensions for python (not to the c++ > Language itself) and i'm wondering what might be the simplest way to make > simple string output to sys.stdout from the c++ api. Can anybody give me a > hint? I used iostream and cout until now and this works well in the command > shell, but not running the idle console under windows. short answer: get a better OS. long answer: if the OS has the concept of an output stream, and its (buggy) std::cout implementation doesn't connect to it, write your own streambuf that writes to this output stream, then redirect std::cout to use your streambuf. But that has nothing to do with python programming in C++... Hope this helps, Stefan From oliver.walczak at momatec.de Wed Nov 5 16:54:12 2003 From: oliver.walczak at momatec.de (Oliver Walczak) Date: Wed, 5 Nov 2003 16:54:12 +0100 Subject: AW: [C++-sig] Stdout from c++ In-Reply-To: <2f85925c6c71c99550a382b4de6904013fa917cb@Orthosoft.ca> Message-ID: <000601c3a3b5$28af48d0$7b64a8c0@momatec11> Dear Stefan, Writing to the idle console from a dll certainly IS a task of python programming under c++. And i can't really believe that anyone writing .pyd's needs to reconnect std.cout with it's own streambuf class by hand when python provides modules to create a webserver in three rows of code, do you? Are you really shure that there is no python api functionality for this? Thanx for your advice anyway! Oliver -----Urspr?ngliche Nachricht----- Von: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] Im Auftrag von Stefan Seefeld Gesendet: Mittwoch, 5. November 2003 16:42 An: Development of Python/C++ integration Betreff: Re: [C++-sig] Stdout from c++ Oliver Walczak wrote: > Dear list, > I'm quite new to programming c++ extensions for python (not to the c++ > Language itself) and i'm wondering what might be the simplest way to > make simple string output to sys.stdout from the c++ api. Can anybody > give me a hint? I used iostream and cout until now and this works well > in the command shell, but not running the idle console under windows. short answer: get a better OS. long answer: if the OS has the concept of an output stream, and its (buggy) std::cout implementation doesn't connect to it, write your own streambuf that writes to this output stream, then redirect std::cout to use your streambuf. But that has nothing to do with python programming in C++... Hope this helps, Stefan _______________________________________________ C++-sig mailing list C++-sig at python.org http://mail.python.org/mailman/listinfo/c++-sig From seefeld at sympatico.ca Wed Nov 5 17:11:17 2003 From: seefeld at sympatico.ca (Stefan Seefeld) Date: Wed, 05 Nov 2003 11:11:17 -0500 Subject: AW: [C++-sig] Stdout from c++ References: <000601c3a3b5$28af48d0$7b64a8c0@momatec11> Message-ID: <46abfa2fc9ec5ddd879bf3b06bcbf36a3fa91e95@Orthosoft.ca> Oliver Walczak wrote: > Dear Stefan, > Writing to the idle console from a dll certainly IS a task of python > programming under c++. And i can't really believe that anyone writing .pyd's > needs to reconnect std.cout with it's own streambuf class by hand when > python provides modules to create a webserver in three rows of code, do you? > Are you really shure that there is no python api functionality for this? ok, may be I replied a bit to quickly. Sorry. Python's C API has a couple of functions to write to stdout. What I said earlier is still true: std::cout is a global object that is not automagically reconnected to any 'console' you may provide. You have to do that yourself. So the solution I suggested still seems valid: Write a streambuf class that uses the python C API in its 'overflow' call, and then reset std::cout.rdbuf() to use that. Regards, Stefan From dave at boost-consulting.com Wed Nov 5 18:08:42 2003 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 05 Nov 2003 07:08:42 -1000 Subject: [C++-sig] Re: Stdout from c++ References: <000501c3a3b2$ba89b900$7b64a8c0@momatec11> <2f85925c6c71c99550a382b4de6904013fa917cb@Orthosoft.ca> Message-ID: Stefan Seefeld writes: > Oliver Walczak wrote: >> Dear list, >> I'm quite new to programming c++ extensions for python (not to the c++ >> Language itself) and i'm wondering what might be the simplest way to make >> simple string output to sys.stdout from the c++ api. Can anybody give me a >> hint? I used iostream and cout until now and this works well in the command >> shell, but not running the idle console under windows. > > short answer: get a better OS. > > long answer: if the OS has the concept of an output stream, and its > (buggy) std::cout implementation doesn't connect to it, > write your own streambuf that writes to this output > stream, then redirect std::cout to use your streambuf. > This is pure platform bigotry. The OS doesn't have a std::cout implementation, buggy or otherwise. That is a function of your compiler and its standard library implementation. -- Dave Abrahams Boost Consulting www.boost-consulting.com From rwgk at yahoo.com Wed Nov 5 19:51:23 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Wed, 5 Nov 2003 10:51:23 -0800 (PST) Subject: [C++-sig] Boost.Python, AIX, and gcc In-Reply-To: Message-ID: <20031105185123.80418.qmail@web20205.mail.yahoo.com> I think we should tell Doug. What gcc exactly are you using (g++ --version)? Ralf --- "J. Michael Owen" wrote: > Hi Ralf, > > I tried out your test and it works just fine with g++ and xlC on AIX, so I > think I'm OK with extending that #ifdef. Whew! Thanks for the follow-up, I > feel a bit better about skipping those assert's now. > > Mike. > > On Tuesday 04 November 2003 07:52 pm, you wrote: > > --- "J. Michael Owen" wrote: > > Before I added the #ifdef I found out that the PowerPC does not have strict > > alignment requirements. So the worst consequence of the failure to find a > > proper alignment is (maybe?) a performance hit. What is the situation on > > our AIX machine? Does unaligned access cause a crash? Does the following > > run? > > > > #include > > > > int main(void) > > { > > char buf[2*sizeof(double)]; > > for(int i=0;i > double* d = (double*) &buf[i]; > > *d = 120.+i; > > std::cout << *d << std::endl; > > } > > } > > > > If this runs extending the #ifdef for your platform would seem acceptable > > to me. > > > > Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From rwgk at yahoo.com Wed Nov 5 19:54:08 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Wed, 5 Nov 2003 10:54:08 -0800 (PST) Subject: Partial success Re: [C++-sig] boost.python on OS X 10.3 (Panther) In-Reply-To: <20031105010303-r01010800-31e5093c-0860-0108@12.100.89.43> Message-ID: <20031105185408.44484.qmail@web20206.mail.yahoo.com> --- Rene Rivera wrote: > Arrgg.. I hate it when I make stupid mistakes like that :-\ I suffer from the same problem. > It's fixed now.. Changed "-o $(DLLFLAGS)" to "$(DLLFLAGS) -o" ;-) But no problem here anymore. Job done! Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From mikeowen at llnl.gov Wed Nov 5 20:11:46 2003 From: mikeowen at llnl.gov (J. Michael Owen) Date: Wed, 5 Nov 2003 11:11:46 -0800 Subject: [C++-sig] Boost.Python, AIX, and gcc In-Reply-To: <20031105185123.80418.qmail@web20205.mail.yahoo.com> References: <20031105185123.80418.qmail@web20205.mail.yahoo.com> Message-ID: I have tried it with g++ 3.2.1 and 3.2.3, both of which behave the same for these tests. On Wednesday 05 November 2003 10:51 am, Ralf W. Grosse-Kunstleve wrote: > I think we should tell Doug. What gcc exactly are you using (g++ > --version)? Ralf > > --- "J. Michael Owen" wrote: > > Hi Ralf, > > > > I tried out your test and it works just fine with g++ and xlC on AIX, so > > I think I'm OK with extending that #ifdef. Whew! Thanks for the > > follow-up, I feel a bit better about skipping those assert's now. > > > > Mike. > > > > On Tuesday 04 November 2003 07:52 pm, you wrote: > > > --- "J. Michael Owen" wrote: > > > Before I added the #ifdef I found out that the PowerPC does not have > > > strict alignment requirements. So the worst consequence of the failure > > > to find a proper alignment is (maybe?) a performance hit. What is the > > > situation on our AIX machine? Does unaligned access cause a crash? Does > > > the following run? > > > > > > #include > > > > > > int main(void) > > > { > > > char buf[2*sizeof(double)]; > > > for(int i=0;i > > double* d = (double*) &buf[i]; > > > *d = 120.+i; > > > std::cout << *d << std::endl; > > > } > > > } > > > > > > If this runs extending the #ifdef for your platform would seem > > > acceptable to me. > > > > > > Ralf > > __________________________________ > Do you Yahoo!? > Protect your identity with Yahoo! Mail AddressGuard > http://antispam.yahoo.com/whatsnewfree -- "Hey...where are the sunflower seeds?" | J. Michael Owen o_o / | Phone: 925-423-7160 (") | Email: mikeowen at llnl.gov \/'\/ | ____(__(,_,)_______________________________________________________________ From mikeowen at llnl.gov Wed Nov 5 20:29:26 2003 From: mikeowen at llnl.gov (J. Michael Owen) Date: Wed, 5 Nov 2003 11:29:26 -0800 Subject: [C++-sig] Boost.Python, AIX, and gcc In-Reply-To: <20031103174212-r01010800-8c74f924-0860-0108@12.100.89.43> References: <20031103174212-r01010800-8c74f924-0860-0108@12.100.89.43> Message-ID: I just updated to the lastest boost CVS, and there's one slight typo that crept into the AIX gcc build. It's in file tools/build/v1/python.jam, and here's the diff with the appropriate fix. Index: tools/build/v1/python.jam =================================================================== RCS file: /cvsroot/boost/boost/tools/build/v1/python.jam,v retrieving revision 1.65 diff -u -r1.65 python.jam --- tools/build/v1/python.jam 5 Nov 2003 04:49:10 -0000 1.65 +++ tools/build/v1/python.jam 5 Nov 2003 19:25:32 -0000 @@ -124,7 +124,7 @@ else if $(OS) = AIX { PYTHON_PROPERTIES - += <*><*>"-Wl,bI:$(PYTHON_LIB_PATH)/python.exp" + += <*><*>"-Wl,-bI:$(PYTHON_LIB_PATH)/python.exp" <*><*>pthreads ; } } On Monday 03 November 2003 03:42 pm, Rene Rivera wrote: > [2003-11-03] J. Michael Owen wrote: > >I've been trying to use the latest Boost.Python with gcc on AIX, which is > > always > > >fun with AIX's strange dynamic library system. I now have it working > > after modifying the some of the jam build files, and one source file. > > The files > > I've > > >altered are: > > > >tools/build/v1/boost-base.jam > >tools/build/v1/gcc-tools.jam > >tools/build/v1/python.jam > >boost/type_traits/type_with_alignment.hpp > > OK, but a diff of the changes would be way more usefull ;-) As we could > look at them without having to figure what changes you made are. > > > -- grafik - Don't Assume Anything > -- rrivera (at) acm.org - grafik (at) redshift-software.com > -- 102708583 (at) icq -- "Hey...where are the sunflower seeds?" | J. Michael Owen o_o / | Phone: 925-423-7160 (") | Email: mikeowen at llnl.gov \/'\/ | ____(__(,_,)_______________________________________________________________ From rwgk at yahoo.com Wed Nov 5 20:31:56 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Wed, 5 Nov 2003 11:31:56 -0800 (PST) Subject: [C++-sig] tutorial html files out of date? Message-ID: <20031105193157.165.qmail@web20201.mail.yahoo.com> Hi Joel and Bruno, The quickstart.txt file (in boost/libs/python/doc/tutorial/doc) seems to contain much more material than is reflected in the html files in the same directory. Is this something that we could fix before the 1.31 release? Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From grafik.list at redshift-software.com Wed Nov 5 20:34:57 2003 From: grafik.list at redshift-software.com (Rene Rivera) Date: Wed, 5 Nov 2003 13:34:57 -0600 Subject: [C++-sig] Boost.Python, AIX, and gcc In-Reply-To: Message-ID: <20031105133458-r01010800-93c8d017-0860-0108@12.100.89.43> [2003-11-05] J. Michael Owen wrote: >I just updated to the lastest boost CVS, and there's one slight typo that crept >into the AIX gcc build. It's in file tools/build/v1/python.jam, and here's the >diff with the appropriate fix. > >Index: tools/build/v1/python.jam >=================================================================== >RCS file: /cvsroot/boost/boost/tools/build/v1/python.jam,v >retrieving revision 1.65 >diff -u -r1.65 python.jam >--- tools/build/v1/python.jam 5 Nov 2003 04:49:10 -0000 1.65 >+++ tools/build/v1/python.jam 5 Nov 2003 19:25:32 -0000 >@@ -124,7 +124,7 @@ > else if $(OS) = AIX > { > PYTHON_PROPERTIES >- += <*><*>"-Wl,bI:$(PYTHON_LIB_PATH)/python.exp" >+ += <*><*>"-Wl,-bI:$(PYTHON_LIB_PATH)/python.exp" > <*><*>pthreads ; > } > } Oops... another stupid mistake on my part :-) Will fix ASAP. And thanks for noticing ;-) -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From grafik.list at redshift-software.com Wed Nov 5 20:49:38 2003 From: grafik.list at redshift-software.com (Rene Rivera) Date: Wed, 5 Nov 2003 13:49:38 -0600 Subject: [C++-sig] Boost.Python, AIX, and gcc In-Reply-To: <20031105133458-r01010800-93c8d017-0860-0108@12.100.89.43> Message-ID: <20031105134938-r01010800-778b8ac6-0860-0108@12.100.89.43> [2003-11-05] Rene Rivera wrote: >[2003-11-05] J. Michael Owen wrote: >>- += <*><*>"-Wl,bI:$(PYTHON_LIB_PATH)/python.exp" >>+ += <*><*>"-Wl,-bI:$(PYTHON_LIB_PATH)/python.exp" >> <*><*>pthreads ; >> } >> } > >Oops... another stupid mistake on my part :-) Will fix ASAP. And thanks for >noticing ;-) Fixed now. -- grafik - Don't Assume Anything -- rrivera (at) acm.org - grafik (at) redshift-software.com -- 102708583 (at) icq From mike at nospam.com Wed Nov 5 21:11:12 2003 From: mike at nospam.com (Mike Rovner) Date: Wed, 5 Nov 2003 12:11:12 -0800 Subject: [C++-sig] Re: tutorial html files out of date? References: <20031105193157.165.qmail@web20201.mail.yahoo.com> Message-ID: Ralf W. Grosse-Kunstleve wrote: > The quickstart.txt file (in boost/libs/python/doc/tutorial/doc) seems What format it uses and where I can get the parsing tool for it? Regards, Mike From s_sourceforge at nedprod.com Wed Nov 5 07:03:02 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Wed, 05 Nov 2003 06:03:02 -0000 Subject: [C++-sig] Custom by value type to python type conversion Message-ID: <3FA89296.21730.53758221@localhost> This is hopefully the last problem before the v0.4 release, yippee! :) BPL is complaining when I try to access a FXString which I have registered a conversion for using to_python_converter: No Python class registered for C++ class FX::FXString. The code triggering this is: txt+=" %s\n" % mapping.path ... where mapping.path is a FXString. My converter is: struct FXString_to_python_str : public to_python_converter { static PyObject *convert(const FX::FXString &str) { return PyString_FromStringAndSize(str.text(), str.length()); //return incref(boost::python::object(str).ptr()); } }; ... and yes, a breakpoint shows it's getting installed. BPL is also right that I have not registered FXString as I feel it's superfluous, however if I do I get: ..\TestSuite\TestPython\main.py:24: RuntimeWarning: to-Python converter for class FX::FXString already registered; second conversion method ignored. ... and then it goes to NOT call the FXString_to_python_str::convert() anyway (again, according to breakpoint). What am I missing? From the examples and list archives, I would have appeared to have done everything! Looking at the internal builtin_converters.hpp, it would seem that there's more that needs to be done, but since that's internal there must be another way? Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From mike at nospam.com Wed Nov 5 21:18:49 2003 From: mike at nospam.com (Mike Rovner) Date: Wed, 5 Nov 2003 12:18:49 -0800 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FA88949.E97E1AE2@sitius.com> Message-ID: Nikolay Mladenov wrote: >> Help on method set: >> >> set(...) unbound keywords.Foo method >> set(struct Foo self, int a=0, double b=0.0, class >> _STL::basic_string,class >> _STL::allocator > n="") >> Sets all the fields of self > > I now think that this is too intrusive and there should be a way > to specify whether or not the signature will be attached to the That's great! However I'd like to note 1. it's better to show "pythonic" signatures (several, as single name may has a few definitions) 2. let's user put his own docstring OR bpl'll generate signatures as docstring by default My 0.02 Mike From nicodemus at esss.com.br Wed Nov 5 22:31:45 2003 From: nicodemus at esss.com.br (Nicodemus) Date: Wed, 05 Nov 2003 18:31:45 -0300 Subject: [C++-sig] Stdout from c++ In-Reply-To: <000501c3a3b2$ba89b900$7b64a8c0@momatec11> References: <000501c3a3b2$ba89b900$7b64a8c0@momatec11> Message-ID: <3FA96C41.6030908@esss.com.br> Oliver Walczak wrote: >Dear list, >I'm quite new to programming c++ extensions for python (not to the c++ >Language itself) and i'm wondering what might be the simplest way to make >simple string output to sys.stdout from the c++ api. Can anybody give me a >hint? I used iostream and cout until now and this works well in the command >shell, but not running the idle console under windows. > The correct way seems to be to use PySys_WriteStdout and PySys_WriteStderr. From nicodemus at esss.com.br Wed Nov 5 22:33:11 2003 From: nicodemus at esss.com.br (Nicodemus) Date: Wed, 05 Nov 2003 18:33:11 -0300 Subject: [C++-sig] tutorial html files out of date? In-Reply-To: <20031105193157.165.qmail@web20201.mail.yahoo.com> References: <20031105193157.165.qmail@web20201.mail.yahoo.com> Message-ID: <3FA96C97.9010001@esss.com.br> Ralf W. Grosse-Kunstleve wrote: >Hi Joel and Bruno, > >The quickstart.txt file (in boost/libs/python/doc/tutorial/doc) seems to >contain much more material than is reflected in the html files in the same >directory. Is this something that we could fix before the 1.31 release? > Joel has the correctly configured quickdoc to generate the tutorial documentation... if Joel can't do it, I guess I can configure mine to handle the tutorial too (I think only the copyright needs to be changed). From nicodemus at esss.com.br Wed Nov 5 22:33:59 2003 From: nicodemus at esss.com.br (Nicodemus) Date: Wed, 05 Nov 2003 18:33:59 -0300 Subject: [C++-sig] Re: tutorial html files out of date? In-Reply-To: References: <20031105193157.165.qmail@web20201.mail.yahoo.com> Message-ID: <3FA96CC7.60802@esss.com.br> Mike Rovner wrote: >Ralf W. Grosse-Kunstleve wrote: > > >>The quickstart.txt file (in boost/libs/python/doc/tutorial/doc) seems >> >> > >What format it uses and where I can get the parsing tool for it? > > It uses quickdoc, which is avaiable in the examples folder of the spirit folder in the boost tree. From mike at nospam.com Wed Nov 5 21:40:00 2003 From: mike at nospam.com (Mike Rovner) Date: Wed, 5 Nov 2003 12:40:00 -0800 Subject: [C++-sig] Re: Re: tutorial html files out of date? References: <20031105193157.165.qmail@web20201.mail.yahoo.com> <3FA96CC7.60802@esss.com.br> Message-ID: Nicodemus wrote: >> Ralf W. Grosse-Kunstleve wrote: >>> The quickstart.txt file (in boost/libs/python/doc/tutorial/doc) > It uses quickdoc, which is avaiable in the examples folder of the > spirit folder in the boost tree. Thanks, Mike From mike at nospam.com Wed Nov 5 23:56:11 2003 From: mike at nospam.com (Mike Rovner) Date: Wed, 5 Nov 2003 14:56:11 -0800 Subject: [C++-sig] Re: tutorial html files out of date? References: <20031105193157.165.qmail@web20201.mail.yahoo.com> Message-ID: Ralf W. Grosse-Kunstleve wrote: > The quickstart.txt file (in boost/libs/python/doc/tutorial/doc) seems Here is a small syntax typo patch: Index: libs/python/doc/tutorial/doc/quickstart.txt =================================================================== RCS file: /cvsroot/boost/boost/libs/python/doc/tutorial/doc/quickstart.txt,v retrieving revision 1.19 diff -u -r1.19 quickstart.txt --- libs/python/doc/tutorial/doc/quickstart.txt 1 Sep 2003 03:12:34 -0000 1.19 +++ libs/python/doc/tutorial/doc/quickstart.txt 5 Nov 2003 22:31:20 -0000 @@ -1658,8 +1658,8 @@ Now, our C++ Wrapper: class_("Field") - .property("pions", range(&F::p_begin, &F::p_end)) - .property("bogons", range(&F::b_begin, &F::b_end)); + .add_property("pions", range(&F::p_begin, &F::p_end)) + .add_property("bogons", range(&F::b_begin, &F::b_end)); [page Exception Translation] =================================================================== Also I noticed that arg() construction is not covered. :( Mike From joel at boost-consulting.com Wed Nov 5 23:27:12 2003 From: joel at boost-consulting.com (Joel de Guzman) Date: Thu, 6 Nov 2003 06:27:12 +0800 Subject: [C++-sig] tutorial html files out of date? References: <20031105193157.165.qmail@web20201.mail.yahoo.com> <3FA96C97.9010001@esss.com.br> Message-ID: <00da01c3a3f3$469d24f0$64646464@godzilla> Nicodemus wrote: > Ralf W. Grosse-Kunstleve wrote: > >> Hi Joel and Bruno, >> >> The quickstart.txt file (in boost/libs/python/doc/tutorial/doc) seems to >> contain much more material than is reflected in the html files in the same >> directory. Is this something that we could fix before the 1.31 release? >> > > Joel has the correctly configured quickdoc to generate the tutorial > documentation... if Joel can't do it, I guess I can configure mine to > handle the tutorial too (I think only the copyright needs to be changed). Thanks, I'd appreciate that a lot. Perhaps it's more Python savvy to switch to ReST? I'm not sure. Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net From rwgk at yahoo.com Thu Nov 6 00:27:19 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Wed, 5 Nov 2003 15:27:19 -0800 (PST) Subject: [C++-sig] tutorial html files out of date? In-Reply-To: <00da01c3a3f3$469d24f0$64646464@godzilla> Message-ID: <20031105232719.15180.qmail@web20207.mail.yahoo.com> --- Joel de Guzman wrote: > > Joel has the correctly configured quickdoc to generate the tutorial > > documentation... if Joel can't do it, I guess I can configure mine to > > handle the tutorial too (I think only the copyright needs to be changed). > > Thanks, I'd appreciate that a lot. Perhaps it's more Python savvy to > switch to ReST? I'm not sure. I am worried that 1.31 is released (or even just branched) before the tutorial is updated. Could we please first do something now-ish and be more ambitious only after 1.31 is out? Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From dave at boost-consulting.com Thu Nov 6 01:57:55 2003 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 05 Nov 2003 14:57:55 -1000 Subject: [C++-sig] Re: tutorial html files out of date? References: <00da01c3a3f3$469d24f0$64646464@godzilla> <20031105232719.15180.qmail@web20207.mail.yahoo.com> Message-ID: "Ralf W. Grosse-Kunstleve" writes: > --- Joel de Guzman wrote: >> > Joel has the correctly configured quickdoc to generate the tutorial >> > documentation... if Joel can't do it, I guess I can configure mine to >> > handle the tutorial too (I think only the copyright needs to be changed). >> >> Thanks, I'd appreciate that a lot. Perhaps it's more Python savvy to >> switch to ReST? I'm not sure. All due respect to quickdoc, ReST rocks. > I am worried that 1.31 is released (or even just branched) before the tutorial > is updated. Could we please first do something now-ish and be more ambitious > only after 1.31 is out? 1. There's going to be some substantial time before 1.31 is branched; we have plenty of iterator library issues to sort out before then. 2. Beman's rule is: major doc changes after branching are OK; major code changes aren't. There's no problem moving the tutorial update to the branch. That said, I agree we should update the tutorial first and change formats second. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Thu Nov 6 02:03:09 2003 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 05 Nov 2003 15:03:09 -1000 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> Message-ID: Nikolay Mladenov writes: > with what I currently have (cvs patched by me) I get: > > >>>> import keywords >>>> keywords.Foo(.1) > Traceback (most recent call last): > File "", line 1, in ? > Boost.Python.ArgumentError: Python argument types in > Foo.__init__(Foo, float) > did not match C++ signature: > __init__(struct _object *, int a=0, double b=0.0, class > _STL::basic_string,class > _STL::allocator > n="") >>>> help(keywords.Foo.set) > > Help on method set: > > set(...) unbound keywords.Foo method > set(struct Foo self, class _STL::basic_string std::char_traits,class _STL::allocator > n) > Sets the string field of self > set(struct Foo self, double b) > Sets the float field of self > set(struct Foo self, int a) > Sets the integer field of self > set(struct Foo self, int a=0, double b=0.0, class > _STL::basic_string,class > _STL::allocator > n="") > Sets all the fields of self > (END) >>>> > > > > with the (almost)current cvs : > > >>>> import keywords >>>> keywords.Foo(.1) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: No to_python (by-value) converter found for C++ type: char Sorry, that MSVC bug obscures our current functionality. Could you show the current result with the workaround in place (or use a different compiler)? -- Dave Abrahams Boost Consulting www.boost-consulting.com From s_sourceforge at nedprod.com Thu Nov 6 01:28:15 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Thu, 06 Nov 2003 00:28:15 -0000 Subject: [C++-sig] Stdout from c++ In-Reply-To: <2f85925c6c71c99550a382b4de6904013fa917cb@Orthosoft.ca> Message-ID: <3FA9959F.3223.57695E81@localhost> On 5 Nov 2003 at 10:42, Stefan Seefeld wrote: > short answer: get a better OS. Actually the NT core, assuming he's running that, is as good as any Unix in this department. In fact, I'd go so far as to say NT core is Unix++ design-wise - it certainly smells of Unix and it's superior to POSIX in many areas. > long answer: if the OS has the concept of an output stream, and its > (buggy) std::cout implementation doesn't connect to it, > write your own streambuf that writes to this output > stream, then redirect std::cout to use your streambuf. NT uses the concept of multiple consoles attached to a process. If you link using /SUBSYSTEM:CONSOLE, linked in CRT code creates a console for you, attachs stdin/stdout/stderr of the CRT library to it and opens it. IDLE should redirect stdin/stdout/stderr to its own window. Therefore printf() should work fine. My code uses printf and it all appears in the IDLE window perfectly. Hence I really don't see why cout isn't working as intended I'm afraid. I'm running Win2k and Win9x may vary significantly in this area. However, if you're developing on Win9x, then you're mad plain and simple ;) Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From dave at boost-consulting.com Thu Nov 6 02:00:39 2003 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 05 Nov 2003 15:00:39 -1000 Subject: [C++-sig] Re: Custom by value type to python type conversion References: <3FA89296.21730.53758221@localhost> Message-ID: "Niall Douglas" writes: > ... and then it goes to NOT call the > FXString_to_python_str::convert() anyway (again, according to > breakpoint). What am I missing? From the examples and list archives, > I would have appeared to have done everything! > > Looking at the internal builtin_converters.hpp, it would seem that > there's more that needs to be done, but since that's internal there > must be another way? I'm guessing this may be a BPL bug, but without a small reproducible example it's hard to tell. You know the drill by now... -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Thu Nov 6 05:21:40 2003 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 05 Nov 2003 18:21:40 -1000 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <1067913091.1005.102.camel@illuvatar> Message-ID: Jonathan Brandmeyer writes: > On Mon, 2003-11-03 at 20:34, Nikolay Mladenov wrote: > >> I was also thinking of modifying the signature element to include >> type_info *(instead of just type_info->name()) >> Then instead of outputing C++ signatures some kind of Python signatures >> can be generated. >> I think this would be better since the python programmer generally would >> not know about the underlying CPP code. > > Since client coders for a C++ -based python extension are either a) only > familiar with the Python interface, or b) also know the C++ interface > (and can therefore presumably deduce the underlying C++ types), this > sounds FANTASTIC to me. I don't think it's such a hot idea. Some C++ types have directly corresponding Python types; some don't. The rules for converting a Python type to a C++ type are not all that straightforward, and may depend on which converters have been registered. Turning things like 'std::auto_ptr' into 'PyFoo' can obscure important information needed to diagnose a problem. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Thu Nov 6 05:24:46 2003 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 05 Nov 2003 18:24:46 -1000 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FA88949.E97E1AE2@sitius.com> Message-ID: Nikolay Mladenov writes: >> Help on method set: >> >> set(...) unbound keywords.Foo method >> set(struct Foo self, int a=0, double b=0.0, class >> _STL::basic_string,class >> _STL::allocator > n="") >> Sets all the fields of self >> (END) >> >>> >> > > I now think that this is too intrusive and there should be a way > to specify whether or not the signature will be attached to the > docstring. > May be like that: > > def ("f", &f, "f's docstring") > def ("g", &g, "%s\n\t g's docstring") > ..... >>>> print f.__doc__ > f's docstring >>>> print g.__doc__ > g() -> None > g's docstring Help has other means to generate signature information, which doesn't intrude on the docstring. At least, there is a means to tell help about the names of function parameters. You could stick their names in if supplied, and use their C++ types otherwise. I'd look more closely at the attributes used by help to produce its output. -- Dave Abrahams Boost Consulting www.boost-consulting.com From john_slater33 at yahoo.com Thu Nov 6 06:23:02 2003 From: john_slater33 at yahoo.com (John Slater) Date: Wed, 5 Nov 2003 21:23:02 -0800 (PST) Subject: [C++-sig] Unit test script problem with boost Message-ID: <20031106052302.72164.qmail@web21506.mail.yahoo.com> Hi, I have a problem using unittest script with Boost. I have a class as Command which is exposed to python through Boost. If I run a failUnlessRaises() from python as below def testFunctionBounds(self): command = Command() self.failUnlessRaises(ValueError, command.Command, -1) This gives error saying apply(callableObj, args, kwargs) TypeError: Bad argument type for built-in operation. This works fine if the Class is in python. Looking for a suggetion from ur end. Thanks & Regards, John Slater --------------------------------- Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard -------------- next part -------------- An HTML attachment was scrubbed... URL: From john_slater33 at yahoo.com Thu Nov 6 06:37:21 2003 From: john_slater33 at yahoo.com (John Slater) Date: Wed, 5 Nov 2003 21:37:21 -0800 (PST) Subject: [C++-sig] Default Argument passing to Constructor Message-ID: <20031106053721.6120.qmail@web21504.mail.yahoo.com> Hi, I am stuck badly with this problem. In class base I have an overloaded constructor with default arguments. class base { public: base(int k,int i=0,int x=0) { } }; Which is exposed to pyhton by boost as follows. .def(init >(args("k","i","x"),"_init_docstring")) >From python I import this. call the constructor >>>obj.base(1) //Success >>>obj.base(k=1, i=2) //Success >>>obj.base(k=1, i=2, x=2) //Success >>>obj.base(k=1, x=2) //Failure... Is it I have to pass all preceding arguments, or am I missing something.. Please help me out Thanks & Regards, John Slater --------------------------------- Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard -------------- next part -------------- An HTML attachment was scrubbed... URL: From oliver.walczak at momatec.de Thu Nov 6 09:28:00 2003 From: oliver.walczak at momatec.de (Oliver Walczak) Date: Thu, 6 Nov 2003 09:28:00 +0100 Subject: AW: [C++-sig] Stdout from c++ In-Reply-To: <3FA9959F.3223.57695E81@localhost> Message-ID: <001801c3a43f$e43131b0$7b64a8c0@momatec11> Dear Niall, If it helps out finding the bug: i use WinXP Professional and Python 2.3.2. I tried to change my print commands from cout to printf as you said, but in the idle environment nothing gets on screen. But using the hint of Nicodemus, PySys_WriteStdout, is exactly what i was looking for and works fine now. Thanx for your advice, folks! Oliver -----Urspr?ngliche Nachricht----- Von: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] Im Auftrag von Niall Douglas Gesendet: Donnerstag, 6. November 2003 01:28 An: c++-sig at python.org Betreff: Re: [C++-sig] Stdout from c++ On 5 Nov 2003 at 10:42, Stefan Seefeld wrote: > short answer: get a better OS. Actually the NT core, assuming he's running that, is as good as any Unix in this department. In fact, I'd go so far as to say NT core is Unix++ design-wise - it certainly smells of Unix and it's superior to POSIX in many areas. > long answer: if the OS has the concept of an output stream, and its > (buggy) std::cout implementation doesn't connect to it, > write your own streambuf that writes to this output > stream, then redirect std::cout to use your streambuf. NT uses the concept of multiple consoles attached to a process. If you link using /SUBSYSTEM:CONSOLE, linked in CRT code creates a console for you, attachs stdin/stdout/stderr of the CRT library to it and opens it. IDLE should redirect stdin/stdout/stderr to its own window. Therefore printf() should work fine. My code uses printf and it all appears in the IDLE window perfectly. Hence I really don't see why cout isn't working as intended I'm afraid. I'm running Win2k and Win9x may vary significantly in this area. However, if you're developing on Win9x, then you're mad plain and simple ;) Cheers, Niall From nickm at sitius.com Thu Nov 6 15:23:26 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Thu, 06 Nov 2003 09:23:26 -0500 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> Message-ID: <3FAA595E.1D5032CE@sitius.com> I is right here: Nikolay Mladenov wrote: > > If you have the following module: > #include > #include > > struct Foo > { > Foo( > int a = 0 > , double b = 0 > , const std::string &n = std::string() > ) : > a_(a) > , b_(b) > , n_(n) > {} > ..................................... > }; > > using namespace boost::python; > BOOST_PYTHON_MODULE(keywords) > { > class_("Foo" > , init , double > , const std::string & > >( > ( arg("a") = 0 > , arg("b") = 0.0 > , arg("n") = std::string() > )) > ) > ..................................... > } > #include "module_tail.cpp" > //////////////////////////////////////// > > with what I currently have (cvs patched by me) I get: > > >>> import keywords > >>> keywords.Foo(.1) > Traceback (most recent call last): > File "", line 1, in ? > Boost.Python.ArgumentError: Python argument types in > Foo.__init__(Foo, float) > did not match C++ signature: > __init__(struct _object *, int a=0, double b=0.0, class > _STL::basic_string,class > _STL::allocator > n="") > And the patch is: $ cvs diff function.cpp Index: function.cpp =================================================================== RCS file: /boost/boost/libs/python/src/object/function.cpp,v retrieving revision 1.36 diff -r1.36 function.cpp 256c256,257 < --- > > bool f_has_keywords = f->m_arg_names.ptr()!= Py_None && PyTuple_Size(f->m_arg_names.ptr()) != 0; 263,267c264,281 < } < < formal.append( < str(s[n].basename) + (s[n].lvalue ? " {lvalue}" : "") < ); --- > } > > object arg(s[n].lvalue ? str(" {lvalue}") : str("")); > if( f_has_keywords ){ > PyObject* kv = PyTuple_GET_ITEM(f->m_arg_names.ptr(), n-1); > if(kv != Py_None) > if(PyTuple_Size(kv) == 1) > arg = " %s"% object(handle<>(incref(kv))); > else{ > if(PyString_CheckExact(PyTuple_GET_ITEM(kv, 1))) > arg = " %s=\"%s\""% object(handle<>(incref(kv))); > else > arg = " %s=%s"% object(handle<>(incref(kv))); > } > } > formal.append( > str(s[n].basename) + arg > ); From nickm at sitius.com Thu Nov 6 15:26:14 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Thu, 06 Nov 2003 09:26:14 -0500 Subject: [C++-sig] Re: Default Argument passing to Constructor References: <20031106053721.6120.qmail@web21504.mail.yahoo.com> Message-ID: <3FAA5A06.5D9FC262@sitius.com> See the thread from monday: "Passing default argument" Nikolay John Slater wrote: > > Hi, > > I am stuck badly with this problem. > > In class base I have an overloaded constructor with default arguments. > class base > { > public: > base(int k,int i=0,int x=0) > { > } > }; > > > Which is exposed to pyhton by boost as follows. > > .def(init > >(args("k","i","x"),"_init_docstring")) > > From python I import this. > > call the constructor > > >>>obj.base(1) //Success > >>>obj.base(k=1, i=2) //Success > >>>obj.base(k=1, i=2, x=2) //Success > >>>obj.base(k=1, x=2) //Failure... > > Is it I have to pass all preceding arguments, or am I missing > something.. > > Please help me out > > > Thanks & Regards, > John Slater > > > > > > ---------------------------------------------------------------------- > Do you Yahoo!? > Protect your identity with Yahoo! Mail AddressGuard > > --------------------------------------------------------------- > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig From nidoizo at yahoo.com Thu Nov 6 17:16:59 2003 From: nidoizo at yahoo.com (Nicolas Fleury) Date: Thu, 06 Nov 2003 11:16:59 -0500 Subject: [C++-sig] Read pickled object in C++ Message-ID: Hi, There's examples in Boost.Python documentation of how to make extension classes pickleable. My case is simpler: I just want to load a dumped python object in C++. I guess the C API is enough, I was just wondering what was the simpler way to do it (C/C++ is the entry through a DLL). Thx and Regards, Nicolas From pierre.barbier at cirad.fr Thu Nov 6 18:46:18 2003 From: pierre.barbier at cirad.fr (Pierre Barbier de Reuille) Date: Thu, 06 Nov 2003 18:46:18 +0100 Subject: [C++-sig] Dereferenceable concept proposal Message-ID: <1068140778.13378.43.camel@pbarbier> In the project I'm working on, we are using intrusive smart pointers. When trying to export classes used with such smart pointers, I had a problem with the dereferenceable concept. This concept require the existence of a 'get' method, but the smart pointer we use does not have this method (ie. the method exists but with another name). We cannot rename the method for it will break to many code, and not only code from us. So, would it be possible to replace this requirement by something like having an expression : get_pointer_from_smart_pointer()( smart_pointer ) get_pointer_from_smart_pointer being a template with this default definition : template struct get_pointer_from_smart_pointer { typename pointee::type* operator()(const T& ptr) const { return ptr.get(); } } This way, it should not break the existing code and we should be able to use uour smart pointer by just redefining this class. The main problem is, I'm not really able to evaluate the changes needed in the Boost.Python code. And perhaps this solution has tons of defaults I don't see :-/ Thanks, -- Pierre Barbier de Reuille INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP Botanique et Bio-informatique de l'Architecture des Plantes TA40/PSII, Boulevard de la Lironde 34398 MONTPELLIER CEDEX 5, France tel : (33) 4 67 61 65 77 fax : (33) 4 67 61 56 68 From nickm at sitius.com Thu Nov 6 20:33:19 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Thu, 06 Nov 2003 14:33:19 -0500 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FA88949.E97E1AE2@sitius.com> Message-ID: <3FAAA1FF.24A66BB9@sitius.com> David Abrahams wrote: > Help has other means to generate signature information, which doesn't > intrude on the docstring. At least, there is a means to tell help > about the names of function parameters. You could stick their names > in if supplied, and use their C++ types otherwise. I'd look more > closely at the attributes used by help to produce its output. I see. But the problem is - help only generates one signature per method and only if the method's implementing function is of type FunctionType. So without changing the pydoc.py I don't see how can this be done for overloads. So why having the option to stick signature in the docstring is bad? It is only an option. One can do it manually anyway. Combining the overloads docstrings shouldn't be a problem as well since one can supply a single docstring per name. > > -- > Dave Abrahams > Boost Consulting > www.boost-consulting.com -- Nikolay Mladenov Sitius Automation www.sitius.com From s_sourceforge at nedprod.com Thu Nov 6 20:59:10 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Thu, 06 Nov 2003 19:59:10 -0000 Subject: AW: [C++-sig] Stdout from c++ In-Reply-To: <001801c3a43f$e43131b0$7b64a8c0@momatec11> References: <3FA9959F.3223.57695E81@localhost> Message-ID: <3FAAA80E.21831.5B995FCB@localhost> On 6 Nov 2003 at 9:28, Oliver Walczak wrote: > Dear Niall, > If it helps out finding the bug: i use WinXP Professional and Python > 2.3.2. I tried to change my print commands from cout to printf as you > said, but in the idle environment nothing gets on screen. But using > the hint of Nicodemus, PySys_WriteStdout, is exactly what i was > looking for and works fine now. Thanx for your advice, folks! Oliver Just threw together a test, and it would seem that I have misadvised the list (again). It turns out I had forgotten that my python code was using os.popen to invoke a python which then calls the C++ code, so of course printf()'d stuff appears in IDLE. Sorry about that :( Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From dave at boost-consulting.com Thu Nov 6 21:33:14 2003 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 06 Nov 2003 10:33:14 -1000 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FAA595E.1D5032CE@sitius.com> Message-ID: Nikolay Mladenov writes: > I is right here: Nikolay, if this is a response to: >> Sorry, that MSVC bug obscures our current functionality. Could you >> show the current result with the workaround in place (or use a >> different compiler)? then I was actually asking you to contrast the result of your patch which includes argument names with what's obtained with the current CVS but without the results of the MSVC bug (IOW, for you, just a simple workaround patch). However, from looking at your code I can see what difference it must be making, and of course I support it 100%! Great idea. However, the code is more complicated than it should be, and has a few other problems > And the patch is: > > > > $ cvs diff function.cpp > Index: function.cpp > =================================================================== > RCS file: /boost/boost/libs/python/src/object/function.cpp,v > retrieving revision 1.36 > diff -r1.36 function.cpp > 256c256,257 > < > --- >> >> bool f_has_keywords = f->m_arg_names.ptr()!= Py_None && PyTuple_Size(f->m_arg_names.ptr()) != 0; Why not just test f->m_arg_names as though it were a bool? Both None and and empty tuple will test as false. > 263,267c264,281 > < } > < > < formal.append( > < str(s[n].basename) + (s[n].lvalue ? " {lvalue}" : "") > < ); > --- >> } >> >> object arg(s[n].lvalue ? str(" {lvalue}") : str("")); >> if( f_has_keywords ){ >> PyObject* kv = PyTuple_GET_ITEM(f->m_arg_names.ptr(), n-1); >> if(kv != Py_None) Once you get here, you seem to drop any {lvalue} indication on the floor >> if(PyTuple_Size(kv) == 1) >> arg = " %s"% object(handle<>(incref(kv))); >> else{ >> if(PyString_CheckExact(PyTuple_GET_ITEM(kv, 1))) >> arg = " %s=\"%s\""% object(handle<>(incref(kv))); Wouldn't these two cases be handled better with one use of %r instead of %s? >> else >> arg = " %s=%s"% object(handle<>(incref(kv))); >> } >> } >> formal.append( >> str(s[n].basename) + arg >> ); What do you think of the enclosed? -------------- next part -------------- A non-text attachment was scrubbed... Name: function.cpp.diff Type: text/x-patch Size: 2378 bytes Desc: not available URL: -------------- next part -------------- -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Thu Nov 6 22:11:11 2003 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 06 Nov 2003 11:11:11 -1000 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FA88949.E97E1AE2@sitius.com> <3FAAA1FF.24A66BB9@sitius.com> Message-ID: Nikolay Mladenov writes: > David Abrahams wrote: >> Help has other means to generate signature information, which doesn't >> intrude on the docstring. At least, there is a means to tell help >> about the names of function parameters. You could stick their names >> in if supplied, and use their C++ types otherwise. I'd look more >> closely at the attributes used by help to produce its output. > > I see. But the problem is - help only generates one signature per method > and > only if the method's implementing function is of type FunctionType. So > without > changing the pydoc.py I don't see how can this be done for overloads. > > So why having the option to stick signature in the docstring is bad? It > is only an option. I didn't say it was; you were looking for something less intrusive. > One can do it manually anyway. > > Combining the overloads docstrings shouldn't be a problem as well > since one can supply a single docstring per name. Fine with me. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Thu Nov 6 22:22:49 2003 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 06 Nov 2003 11:22:49 -1000 Subject: [C++-sig] Re: Dereferenceable concept proposal References: <1068140778.13378.43.camel@pbarbier> Message-ID: Pierre Barbier de Reuille writes: > In the project I'm working on, we are using intrusive smart pointers. > When trying to export classes used with such smart pointers, I had a > problem with the dereferenceable concept. This concept require the > existence of a 'get' method, but the smart pointer we use does not have > this method (ie. the method exists but with another name). We cannot > rename the method for it will break to many code, and not only code from > us. So, would it be possible to replace this requirement by something > like having an expression : > > get_pointer_from_smart_pointer()( smart_pointer ) > > get_pointer_from_smart_pointer being a template with this default > definition : > > template > struct get_pointer_from_smart_pointer > { > typename pointee::type* operator()(const T& ptr) const > { > return ptr.get(); > } > } > > This way, it should not break the existing code and we should be able to > use uour smart pointer by just redefining this class. Doh! How could I have been so stupid? I know better than to design a generic interface that depends on member functions, really I do! The right thing to do would've been to rely on htpp://www.boost.org/libs/bind/mem_fn.html#get_pointer http://www.boost.org/libs/smart_ptr/shared_ptr.htm#get_pointer [Peter, I note that there's no specification of get_pointer for scoped_ptr, and it doesn't appear in http://www.boost.org/libs/smart_ptr/smart_ptr.htm#common_requirements either. Oversight?] > The main problem is, I'm not really able to evaluate the changes needed > in the Boost.Python code. Just do a grep for "[>\.]get()" and you should find all the instances that should be changed to get_pointer. There's a function called is_null that could be completely eliminated. I'd appreciate a patch! > And perhaps this solution has tons of defaults I don't see :-/ Do you mean "implications", perhaps? -- Dave Abrahams Boost Consulting www.boost-consulting.com From nickm at sitius.com Thu Nov 6 23:30:31 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Thu, 06 Nov 2003 17:30:31 -0500 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FAA595E.1D5032CE@sitius.com> Message-ID: <3FAACB87.A97B992@sitius.com> David Abrahams wrote: > > Nikolay Mladenov writes: > > > I is right here: > > Nikolay, > > if this is a response to: > > >> Sorry, that MSVC bug obscures our current functionality. Could you > >> show the current result with the workaround in place (or use a > >> different compiler)? > > then I was actually asking you to contrast the result of your patch > which includes argument names with what's obtained with the current > CVS but without the results of the MSVC bug (IOW, for you, just a > simple workaround patch). Aah! Well you know already, sorry I didn't understand the question. > > What do you think of the enclosed? > > function.cpp.diffName: function.cpp.diff I like it better. But with MSVC 6.5 it raises: TypeError: No to_python (by-value) converter found for C++ type: char again. the problematic line is param += (len(kv) > 1 ? " %s=%r" : " %s") % kv; the MSVC stack: KERNEL32! 77f1d479() MSVCRT! 78008fa5() boost::python::throw_error_already_set() line 59 boost::python::converter::registration::to_python(const void * 0x05fd0200) line 55 boost::python::converter::detail::arg_to_python_base::arg_to_python_base(const void * 0x05fd0200, const boost::python::converter::registration & {...}) line 25 + 19 bytes boost::python::converter::detail::pointer_deep_arg_to_python::pointer_deep_arg_to_python(char * 0x05fd0200) line 217 + 46 bytes boost::python::converter::arg_to_python::arg_to_python(char * const & 0x05fd0200) line 258 + 21 bytes boost::python::api::object_initializer_impl<0,0>::get(char * const & 0x05fd0200, boost::mpl::bool_<0> {...}) line 356 + 12 bytes boost::python::api::object_base_initializer(char * const & 0x05fd0200) line 285 + 22 bytes boost::python::api::object::object() line 298 + 16 bytes boost::python::api::operator%(char * const & 0x05fd0200, const boost::python::api::object & {...}) line 102 + 78 bytes on the other hand this works fine: if ( len(kv) > 1 ) param += " %s=%r" % kv; else param += " %s" % kv; here the call is : boost::python::api::operator%(const char [7]& 0x05fc1474, const boost::python::api::object & {...}) line 102 + 78 bytes Now, if I can get you to like my docstrings idea ...;-) -- Nikolay Mladenov Sitius Automaion Inc. www.sitius.com From nickm at sitius.com Thu Nov 6 23:34:13 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Thu, 06 Nov 2003 17:34:13 -0500 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FA88949.E97E1AE2@sitius.com> <3FAAA1FF.24A66BB9@sitius.com> Message-ID: <3FAACC65.1EF1529C@sitius.com> David Abrahams wrote: > > > So why having the option to stick signature in the docstring is bad? It > > is only an option. > > I didn't say it was; you were looking for something less intrusive. I see, but until we find it I like that one. > > > Combining the overloads docstrings shouldn't be a problem as well > > since one can supply a single docstring per name. > > Fine with me. Can I implement this? -- Nikolay Mladenov Sitius Automaion Inc. www.sitius.com From dave at boost-consulting.com Thu Nov 6 23:58:44 2003 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 06 Nov 2003 12:58:44 -1000 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FA88949.E97E1AE2@sitius.com> <3FAAA1FF.24A66BB9@sitius.com> <3FAACC65.1EF1529C@sitius.com> Message-ID: Nikolay Mladenov writes: > David Abrahams wrote: >> > >> > So why having the option to stick signature in the docstring is bad? It >> > is only an option. >> >> I didn't say it was; you were looking for something less intrusive. > > I see, but until we find it I like that one. > >> >> > Combining the overloads docstrings shouldn't be a problem as well >> > since one can supply a single docstring per name. >> >> Fine with me. > > Can I implement this? Do you mean, "will I accept your patch?" Probably, though I'm not sure I like the syntax for doing it optionally. An existing docstring might already contain a %, for example. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Fri Nov 7 00:02:39 2003 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 06 Nov 2003 13:02:39 -1000 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FAA595E.1D5032CE@sitius.com> <3FAACB87.A97B992@sitius.com> Message-ID: Nikolay Mladenov writes: > the problematic line is > param += (len(kv) > 1 ? " %s=%r" : " %s") % kv; what about: param += const_cast(len(kv) > 1 ? " %s=%r" : " %s") % kv; ?? -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Thu Nov 6 23:59:55 2003 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 06 Nov 2003 12:59:55 -1000 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FAA595E.1D5032CE@sitius.com> <3FAACB87.A97B992@sitius.com> Message-ID: Nikolay Mladenov writes: > param += (len(kv) > 1 ? " %s=%r" : " %s") % kv; Will param += str(len(kv) > 1 ? " %s=%r" : " %s") % kv; work? -- Dave Abrahams Boost Consulting www.boost-consulting.com From s_sourceforge at nedprod.com Fri Nov 7 01:04:31 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Fri, 07 Nov 2003 00:04:31 -0000 Subject: [C++-sig] Re: Custom by value type to python type conversion In-Reply-To: Message-ID: <3FAAE18F.19787.5C7A0001@localhost> On 5 Nov 2003 at 15:00, David Abrahams wrote: > > ... and then it goes to NOT call the > > FXString_to_python_str::convert() anyway (again, according to > > breakpoint). What am I missing? From the examples and list archives, > > I would have appeared to have done everything! > > > > Looking at the internal builtin_converters.hpp, it would seem that > > there's more that needs to be done, but since that's internal there > > must be another way? > > I'm guessing this may be a BPL bug, but without a small reproducible > example it's hard to tell. You know the drill by now... I've attached it below. I can tell you that it only occurs when the type to be converted is a data member of some class, so obviously it's failing to invoke the converter in this situation. I should mention that my BPL has its invoke.hpp heavily altered which while it shouldn't be incompatible, might be. Put it this way: everything compiles and works fine here, possibly excepting this. Cheers, Niall python bit: from TnFOX2 import * a=GetData() print a.name C++ bit: #include namespace FX { // Very simple FXString implementation class FXString2 { char data[256]; public: FXString2(const char *str=0) { if(str) strcpy(data, str); else data[0]=0; } FXString2(const char *str, int length) { memcpy(data, str, length); data[length]=0; } const char *text() const { return data; } int length() const { return strlen(data); } }; struct MappedData { FXString2 name; }; MappedData GetData() { MappedData ret; ret.name=FXString2("Niall is a teapot"); return ret; } } #include using namespace boost::python; struct FXString_to_python_str : public to_python_converter { static PyObject *convert(const FX::FXString2 &str) { return PyString_FromStringAndSize(str.text(), str.length()); //return incref(boost::python::object(str).ptr()); } }; BOOST_PYTHON_MODULE(TnFOX2) { FXString_to_python_str(); class_< FX::MappedData >("FXMappedData") .def_readwrite("name", &FX::MappedData::name); def("GetData", &FX::GetData); } From rwgk at yahoo.com Fri Nov 7 01:15:30 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 6 Nov 2003 16:15:30 -0800 (PST) Subject: [C++-sig] Re: Custom by value type to python type conversion In-Reply-To: <3FAAE18F.19787.5C7A0001@localhost> Message-ID: <20031107001530.92228.qmail@web20206.mail.yahoo.com> --- Niall Douglas wrote: > class_< FX::MappedData >("FXMappedData") > .def_readwrite("name", &FX::MappedData::name); Oh, this looks like a very well known problem. You have to use .add_property instead. E.g. (untested): typedef return_value_policy rbv; typedef default_call_policies dcp; .add_property("name", make_getter(&FX::MappedData::name, rbv()), make_setter(&FX::MappedData::name, dcp())) Adjust the policies as necessary. Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From s_sourceforge at nedprod.com Fri Nov 7 04:05:59 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Fri, 07 Nov 2003 03:05:59 -0000 Subject: [C++-sig] Re: Custom by value type to python type conversion In-Reply-To: <20031107001530.92228.qmail@web20206.mail.yahoo.com> References: <3FAAE18F.19787.5C7A0001@localhost> Message-ID: <3FAB0C17.21974.5D2023AF@localhost> On 6 Nov 2003 at 16:15, Ralf W. Grosse-Kunstleve wrote: > > class_< FX::MappedData >("FXMappedData") > > .def_readwrite("name", &FX::MappedData::name); > > Oh, this looks like a very well known problem. You have to use > .add_property instead. E.g. (untested): > typedef return_value_policy rbv; > typedef default_call_policies dcp; > > .add_property("name", make_getter(&FX::MappedData::name, > rbv()), > make_setter(&FX::MappedData::name, > dcp())) > > Adjust the policies as necessary. If it's so well known, then why the hell isn't it in the FAQ so everyone who uses BPL doesn't keep making the same mistake again & again??? (I am grateful for the info - thanks - it just annoys me when this happens, and it's not been the first time either). Bruno - looks like another change to pyste will be needed! Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From dave at boost-consulting.com Fri Nov 7 04:39:38 2003 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 06 Nov 2003 17:39:38 -1000 Subject: [C++-sig] Re: Custom by value type to python type conversion References: <3FAAE18F.19787.5C7A0001@localhost> <3FAB0C17.21974.5D2023AF@localhost> Message-ID: "Niall Douglas" writes: > On 6 Nov 2003 at 16:15, Ralf W. Grosse-Kunstleve wrote: > >> > class_< FX::MappedData >("FXMappedData") >> > .def_readwrite("name", &FX::MappedData::name); >> >> Oh, this looks like a very well known problem. You have to use >> .add_property instead. E.g. (untested): >> typedef return_value_policy rbv; >> typedef default_call_policies dcp; >> >> .add_property("name", make_getter(&FX::MappedData::name, >> rbv()), >> make_setter(&FX::MappedData::name, >> dcp())) >> >> Adjust the policies as necessary. > > If it's so well known, then why the hell isn't it in the FAQ so > everyone who uses BPL doesn't keep making the same mistake again & > again??? Because nobody has composed a reasonably informative FAQ entry that will be intelligible to the general public. Patches are always welcome, if you can manage to write one which other people can understand. > (I am grateful for the info - thanks - it just annoys me when this > happens, and it's not been the first time either). Get over it; this is free software. We do the best we can with the resources we have and the contributions of others. -- Dave Abrahams Boost Consulting www.boost-consulting.com From s_sourceforge at nedprod.com Fri Nov 7 05:39:04 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Fri, 07 Nov 2003 04:39:04 -0000 Subject: [C++-sig] Re: Custom by value type to python type conversion In-Reply-To: Message-ID: <3FAB21E8.15129.5D755BD8@localhost> On 6 Nov 2003 at 17:39, David Abrahams wrote: > > If it's so well known, then why the hell isn't it in the FAQ so > > everyone who uses BPL doesn't keep making the same mistake again & > > again??? > > Because nobody has composed a reasonably informative FAQ entry that > will be intelligible to the general public. Patches are always > welcome, if you can manage to write one which other people can > understand. Surely it's as easy as "def_readonly() and def_readwrite() do not perform custom to-python type conversions, therefore use add_property() as a workaround". BTW, why don't def_readonly() and def_readwrite() perform custom to- pyton type conversions? > > (I am grateful for the info - thanks - it just annoys me when this > > happens, and it's not been the first time either). > > Get over it; this is free software. We do the best we can with the > resources we have and the contributions of others. I have never and will never believe any reasoning that just because software is free that its quality should be inherently less than any commercial software. As books on good software design have noted since the 1970's, software can be as technically brilliant as it likes but without solid documentation, it can never be better than an average solution. Quality requires good documentation. I'll put together a doc patch and send it in. Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From bob at redivi.com Fri Nov 7 05:53:32 2003 From: bob at redivi.com (Bob Ippolito) Date: Thu, 6 Nov 2003 23:53:32 -0500 Subject: [C++-sig] Re: Custom by value type to python type conversion In-Reply-To: <3FAB21E8.15129.5D755BD8@localhost> References: <3FAB21E8.15129.5D755BD8@localhost> Message-ID: <563E6408-10DE-11D8-AF05-000A95686CD8@redivi.com> On Nov 6, 2003, at 11:39 PM, Niall Douglas wrote: > On 6 Nov 2003 at 17:39, David Abrahams wrote: > >>> (I am grateful for the info - thanks - it just annoys me when this >>> happens, and it's not been the first time either). >> >> Get over it; this is free software. We do the best we can with the >> resources we have and the contributions of others. > > I have never and will never believe any reasoning that just because > software is free that its quality should be inherently less than any > commercial software. As books on good software design have noted > since the 1970's, software can be as technically brilliant as it > likes but without solid documentation, it can never be better than an > average solution. Quality requires good documentation. > > I'll put together a doc patch and send it in. If you have better ideas, send patches (as you're doing, which is great). As Dave said, it's free software, they're giving it to you. Not only are they giving it to you, but they don't force you to comply with a restrictive license like the GPL. You're lucky that they offer free support. It's a bit much to ask a free software project to live up to every definition of good software in the books you've been reading the past 30 some years. If you want quality documentation (or anything else that they don't want to do for free), do it yourself, or pay someone to do it. I hear a place called "Boost Consulting" has some top notch people that know quite a bit about Boost and would probably be more than happy to trade services for money :) -bob From pierre.barbier at cirad.fr Fri Nov 7 10:07:47 2003 From: pierre.barbier at cirad.fr (Pierre Barbier de Reuille) Date: Fri, 07 Nov 2003 10:07:47 +0100 Subject: [C++-sig] Re: Dereferenceable concept proposal In-Reply-To: References: <1068140778.13378.43.camel@pbarbier> Message-ID: <1068196067.6088.48.camel@pbarbier> Ok, I made a patch that work for me. I hope I did not modify to many files (there were a lot of .get not for pointers) The patch was simply made with a cvs diff > no_get.patch on the boost/python directory. Le jeu 06/11/2003 ? 22:22, David Abrahams a ?crit : > Pierre Barbier de Reuille writes: > > > And perhaps this solution has tons of defaults I don't see :-/ > > Do you mean "implications", perhaps? Not really, I meant "problems" ... defaults was a frenchism :o) -- Pierre Barbier de Reuille INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP Botanique et Bio-informatique de l'Architecture des Plantes TA40/PSII, Boulevard de la Lironde 34398 MONTPELLIER CEDEX 5, France tel : (33) 4 67 61 65 77 fax : (33) 4 67 61 56 68 -------------- next part -------------- A non-text attachment was scrubbed... Name: no_get.patch Type: text/x-patch Size: 1443 bytes Desc: not available URL: From testa at allos.sytes.net Fri Nov 7 13:35:24 2003 From: testa at allos.sytes.net (F.G.Testa) Date: Fri, 7 Nov 2003 10:35:24 -0200 Subject: [C++-sig] redirect to file Message-ID: Hi all! I'm new to python and I'm embedding into a Win32 service application. So far I couldn't redirect the output from Python's 'print' command to a file. The CRT freopen seems not work. Also, when I call PyErr_Print() has the same behavior. Any suggestions? Thanks From rwgk at yahoo.com Fri Nov 7 13:57:11 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Fri, 7 Nov 2003 04:57:11 -0800 (PST) Subject: [C++-sig] Re: Custom by value type to python type conversion In-Reply-To: <3FAB0C17.21974.5D2023AF@localhost> Message-ID: <20031107125711.59724.qmail@web20201.mail.yahoo.com> --- Niall Douglas wrote: > If it's so well known, then why the hell isn't it in the FAQ so > everyone who uses BPL doesn't keep making the same mistake again & > again??? As you know, everybody here volunteers his/her time for maintaining Boost.Python. We are waiting for an addition to the FAQ from you now. I am happy to check it in for you. Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From nicodemus at esss.com.br Fri Nov 7 15:30:36 2003 From: nicodemus at esss.com.br (Nicodemus) Date: Fri, 07 Nov 2003 11:30:36 -0300 Subject: [C++-sig] redirect to file In-Reply-To: References: Message-ID: <3FABAC8C.60104@esss.com.br> F.G.Testa wrote: >Hi all! >I'm new to python and I'm embedding into a Win32 service application. >So far I couldn't redirect the output from Python's 'print' command to a >file. The CRT freopen seems not work. Also, when I call PyErr_Print() has >the same >behavior. > Try executing this code in Python: import sys sys.stdout = open('myfile', 'w') You can use PyRun_String() for that. HTH, Nicodemus. From nickm at sitius.com Fri Nov 7 15:09:51 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Fri, 07 Nov 2003 09:09:51 -0500 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FAA595E.1D5032CE@sitius.com> <3FAACB87.A97B992@sitius.com> Message-ID: <3FABA7AF.B1238883@sitius.com> David Abrahams wrote: > > Nikolay Mladenov writes: > > > param += (len(kv) > 1 ? " %s=%r" : " %s") % kv; > > Will > > param += str(len(kv) > 1 ? " %s=%r" : " %s") % kv; > > work? No. > > -- > Dave Abrahams > Boost Consulting > www.boost-consulting.com -- Nikolay Mladenov Sitius Automaion Inc. www.sitius.com From nickm at sitius.com Fri Nov 7 15:10:14 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Fri, 07 Nov 2003 09:10:14 -0500 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FAA595E.1D5032CE@sitius.com> <3FAACB87.A97B992@sitius.com> Message-ID: <3FABA7C6.F661FCFC@sitius.com> David Abrahams wrote: > > Nikolay Mladenov writes: > > > the problematic line is > > param += (len(kv) > 1 ? " %s=%r" : " %s") % kv; > > what about: > > param += const_cast(len(kv) > 1 ? " %s=%r" : " %s") % kv; > > ?? This works. > -- > Dave Abrahams > Boost Consulting > www.boost-consulting.com -- Nikolay Mladenov Sitius Automaion Inc. www.sitius.com From nickm at sitius.com Fri Nov 7 15:16:53 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Fri, 07 Nov 2003 09:16:53 -0500 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FA88949.E97E1AE2@sitius.com> <3FAAA1FF.24A66BB9@sitius.com> <3FAACC65.1EF1529C@sitius.com> Message-ID: <3FABA955.8EF371B@sitius.com> David Abrahams wrote: > > Nikolay Mladenov writes: > > > David Abrahams wrote: > >> > > > >> > So why having the option to stick signature in the docstring is bad? It > >> > is only an option. > >> > >> I didn't say it was; you were looking for something less intrusive. > > > > I see, but until we find it I like that one. > > > >> > >> > Combining the overloads docstrings shouldn't be a problem as well > >> > since one can supply a single docstring per name. > >> > >> Fine with me. > > > > Can I implement this? > > Do you mean, "will I accept your patch?" Yes. > Probably, though I'm not > sure I like the syntax for doing it optionally. An existing docstring > might already contain a %, for example. Yes I thought of that too, but the only other way I see is to change the type of the docstring parameter (of def) to something that expands to different strings based on parameters and default constructable from python::str, const char *, and std::string. Do you like that? I am not sure how this is going to fit in. > > -- > Dave Abrahams > Boost Consulting > www.boost-consulting.com -- Nikolay Mladenov Sitius Automaion Inc. www.sitius.com From nidoizo at yahoo.com Fri Nov 7 15:54:48 2003 From: nidoizo at yahoo.com (Nicolas Fleury) Date: Fri, 07 Nov 2003 09:54:48 -0500 Subject: [C++-sig] Boost.Python scope Message-ID: Hi, If I understand correctly (correct me if I'm wrong), the Boost.Python library purpose is mainly only to expose C++ in Python. It doesn't provide the equivalent of the C API and I wonder if it should be changed. I prefer to work with boost::python::objects than with PyObjects and I prefer C++ to C. Right now, I have to use the C API to do certain things (like read a pickled object in C++). Do you think the current Boost.Python scope should be enlarged to provide a complete C++ API? Or at least add a function to execute python code and store the result in a boost::python::object? Regards, Nicolas Fleury From seefeld at sympatico.ca Fri Nov 7 17:12:21 2003 From: seefeld at sympatico.ca (Stefan Seefeld) Date: Fri, 07 Nov 2003 11:12:21 -0500 Subject: [C++-sig] Boost.Python scope References: Message-ID: <8fdfeed745aa851bf46a83d33418c9bb3fabc158@Orthosoft.ca> Hi Nicolas, Nicolas Fleury wrote: > Hi, > If I understand correctly (correct me if I'm wrong), the Boost.Python > library purpose is mainly only to expose C++ in Python. It doesn't > provide the equivalent of the C API and I wonder if it should be > changed. I prefer to work with boost::python::objects than with > PyObjects and I prefer C++ to C. Right now, I have to use the C API to > do certain things (like read a pickled object in C++). Do you think the > current Boost.Python scope should be enlarged to provide a complete C++ > API? Or at least add a function to execute python code and store the > result in a boost::python::object? what you ask for is already there. I'm using it at work every day ;-) A+ Stefan From nidoizo at yahoo.com Fri Nov 7 18:04:02 2003 From: nidoizo at yahoo.com (Nicolas Fleury) Date: Fri, 07 Nov 2003 12:04:02 -0500 Subject: [C++-sig] Re: Boost.Python scope In-Reply-To: <8fdfeed745aa851bf46a83d33418c9bb3fabc158@Orthosoft.ca> References: <8fdfeed745aa851bf46a83d33418c9bb3fabc158@Orthosoft.ca> Message-ID: Stefan Seefeld wrote: > Hi Nicolas, > > Nicolas Fleury wrote: >> complete C++ API? Or at least add a function to execute python code >> and store the result in a boost::python::object? > > > what you ask for is already there. I'm using it at work every day ;-) > > A+ > > Stefan Hi Stefan, I guess I miss something in the doc... So how do I execute something like "import pickle; pickle.load(open('myfile'))" and store the result in a boost::python::object? (or any better way) Thx Nicolas From nico_ml at mgdesign.org Fri Nov 7 18:07:10 2003 From: nico_ml at mgdesign.org (Nicolas LELONG) Date: Fri, 7 Nov 2003 18:07:10 +0100 Subject: [C++-sig] Boost.Python scope References: <8fdfeed745aa851bf46a83d33418c9bb3fabc158@Orthosoft.ca> Message-ID: <010101c3a551$951940a0$cd00a8c0@nico> > what you ask for is already there. I'm using it at work every day ;-) no harm intended, I'm quite tired so I feel like making a small comment : I'm quite happy to know that, but your response is not very productive - perhaps you could share with us some pointer (into an existing tutorial for instance) that could enlighten us (or at least the original Nicolas who posted the question) ?! Cheers, Nicolas. From seefeld at sympatico.ca Fri Nov 7 18:16:51 2003 From: seefeld at sympatico.ca (Stefan Seefeld) Date: Fri, 07 Nov 2003 12:16:51 -0500 Subject: [C++-sig] Re: Boost.Python scope References: <8fdfeed745aa851bf46a83d33418c9bb3fabc158@Orthosoft.ca> Message-ID: <5281c8b7af6c0695276d09c4bc16e6103fabd076@Orthosoft.ca> Nicolas Fleury wrote: > Stefan Seefeld wrote: > >> Hi Nicolas, >> >> Nicolas Fleury wrote: >> >>> complete C++ API? Or at least add a function to execute python code >>> and store the result in a boost::python::object? >> >> >> >> what you ask for is already there. I'm using it at work every day ;-) >> >> A+ >> >> Stefan > > > Hi Stefan, > I guess I miss something in the doc... So how do I execute something > like "import pickle; pickle.load(open('myfile'))" and store the result > in a boost::python::object? (or any better way) python provides a couple of interfaces to deal with objects in general, and specific types (dicts, strings, tuples, etc.) in particular. These are mapped to C++ in boost.python, and the docs are here: http://www.boost.org/libs/python/doc/tutorial/doc/basic_interface.html http://www.boost.org/libs/python/doc/tutorial/doc/derived_object_types.html the only missing thing is the execution of a little python snippet (file or string), which is described at http://www.boost.org/libs/python/doc/tutorial/doc/using_the_interpreter.html hope this helps, Stefan From seefeld at sympatico.ca Fri Nov 7 18:18:39 2003 From: seefeld at sympatico.ca (Stefan Seefeld) Date: Fri, 07 Nov 2003 12:18:39 -0500 Subject: [C++-sig] Boost.Python scope References: <8fdfeed745aa851bf46a83d33418c9bb3fabc158@Orthosoft.ca> <010101c3a551$951940a0$cd00a8c0@nico> Message-ID: <0a1856f694e6efd4e76144acc8017c353fabd0e2@Orthosoft.ca> Nicolas LELONG wrote: >>what you ask for is already there. I'm using it at work every day ;-) > > > no harm intended, I'm quite tired so I feel like making a small comment : > I'm quite happy to know that, but your response is not very productive - > perhaps you could share with us some pointer (into an existing tutorial for > instance) that could enlighten us (or at least the original Nicolas who > posted the question) ?! I'm sorry, the original reply was meant to be sent in private (we are collegues). I hope my second reply is more helpful. Sorry again, Stefan From nidoizo at yahoo.com Fri Nov 7 18:51:14 2003 From: nidoizo at yahoo.com (Nicolas Fleury) Date: Fri, 07 Nov 2003 12:51:14 -0500 Subject: [C++-sig] Re: Boost.Python scope In-Reply-To: <0a1856f694e6efd4e76144acc8017c353fabd0e2@Orthosoft.ca> References: <8fdfeed745aa851bf46a83d33418c9bb3fabc158@Orthosoft.ca> <010101c3a551$951940a0$cd00a8c0@nico> <0a1856f694e6efd4e76144acc8017c353fabd0e2@Orthosoft.ca> Message-ID: Stefan Seefeld wrote: > I'm sorry, the original reply was meant to be sent in private (we are > collegues). I hope my second reply is more helpful. Sorry again, > > Stefan (Well, ex-collegues, you know I would have asked you first if I was still working there. No problem by the way) From nidoizo at yahoo.com Fri Nov 7 19:06:16 2003 From: nidoizo at yahoo.com (Nicolas Fleury) Date: Fri, 07 Nov 2003 13:06:16 -0500 Subject: [C++-sig] Re: Boost.Python scope In-Reply-To: <5281c8b7af6c0695276d09c4bc16e6103fabd076@Orthosoft.ca> References: <8fdfeed745aa851bf46a83d33418c9bb3fabc158@Orthosoft.ca> <5281c8b7af6c0695276d09c4bc16e6103fabd076@Orthosoft.ca> Message-ID: Stefan Seefeld wrote: > Nicolas Fleury wrote: >> Hi Stefan, >> I guess I miss something in the doc... So how do I execute >> something like "import pickle; pickle.load(open('myfile'))" and store >> the result in a boost::python::object? (or any better way) > > > python provides a couple of interfaces to deal with objects in general, > and specific types (dicts, strings, tuples, etc.) in particular. These > are mapped to C++ in boost.python, and the docs are here: > > http://www.boost.org/libs/python/doc/tutorial/doc/basic_interface.html > http://www.boost.org/libs/python/doc/tutorial/doc/derived_object_types.html > > the only missing thing is the execution of a little python snippet > (file or string), which is described at > > http://www.boost.org/libs/python/doc/tutorial/doc/using_the_interpreter.html > > > hope this helps, > Stefan Thx Stefan, If I undertand correctly, the way of doing it is something like: handle<> main_module(borrowed( PyImport_AddModule("__main__") )); main_namespace dict(handle<>(borrowed( PyModule_GetDict(main_module.get()) ))); object result(handle<>( PyRun_String("import pickle; pickle.load(open('myfile'))", Py_eval_input, main_namespace.ptr(), main_namespace.ptr()))) This is very nice, since I have a way of working with a boost::python::object. However, my question remain, should Boost.Python scope/goal be enlarged to have no need for Py... C functions, providing a full C++ API for Python/C++ interaction? Regards, Nicolas From rwgk at yahoo.com Fri Nov 7 19:56:29 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Fri, 7 Nov 2003 10:56:29 -0800 (PST) Subject: [C++-sig] Re: Boost.Python scope In-Reply-To: Message-ID: <20031107185629.1199.qmail@web20206.mail.yahoo.com> --- Nicolas Fleury wrote: > This is very nice, since I have a way of working with a > boost::python::object. However, my question remain, should Boost.Python > scope/goal be enlarged to have no need for Py... C functions, providing > a full C++ API for Python/C++ interaction? You are asking the right question. Some work on this was done more than a year ago. Basically the idea was to write a Python script that generates C++ wrappers for the entire Python "C" API with all reference counting handled by boost::python::object and boost::python::handle<>. Very unfortunately, how should I say, that horse was beaten dead somehow. Now we need an intrepid new horse to pull this off. If someone feels brave enough to step forward I'll try to help and dig out the work that was done before. Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From seefeld at sympatico.ca Fri Nov 7 19:56:11 2003 From: seefeld at sympatico.ca (Stefan Seefeld) Date: Fri, 07 Nov 2003 13:56:11 -0500 Subject: [C++-sig] Re: Boost.Python scope References: <8fdfeed745aa851bf46a83d33418c9bb3fabc158@Orthosoft.ca> <5281c8b7af6c0695276d09c4bc16e6103fabd076@Orthosoft.ca> Message-ID: <0ec33da95824b3caf4780702f43d2e343fabe7bf@Orthosoft.ca> Nicolas Fleury wrote: > If I undertand correctly, the way of doing it is something like: > > handle<> main_module(borrowed( PyImport_AddModule("__main__") )); > main_namespace dict(handle<>(borrowed( > PyModule_GetDict(main_module.get()) ))); > object result(handle<>( > PyRun_String("import pickle; pickle.load(open('myfile'))", > Py_eval_input, main_namespace.ptr(), > main_namespace.ptr()))) > > This is very nice, since I have a way of working with a > boost::python::object. However, my question remain, should Boost.Python > scope/goal be enlarged to have no need for Py... C functions, providing > a full C++ API for Python/C++ interaction? Beside their names all starting with 'Py' instead of 'boost::python::', what would be different in a C++ API for these remaining functions ? There is no automatic error / exception handling or ref counting that you could possibly gain... Or may be it's me who is missing something... Regards, Stefan From ron.clarke at hp.com Fri Nov 7 20:52:43 2003 From: ron.clarke at hp.com (CLARKE,RON (HP-Vancouver,ex1)) Date: Fri, 7 Nov 2003 11:52:43 -0800 Subject: [C++-sig] Wrapping class methods with array parameters Message-ID: I am in the process of wrapping two C++ classes, each of which has at least one method which takes a pointer, which is really the first item in an array of known length. My problem is I don't see how to do it! Given that Boost Python is so robust, I suspect I've missed something in all the documentation, or perhaps I read it and did not grasp its relevance. Here is one of the classes/methods: class scifidict { public: /* a bunch of stuff */ size_t getOwners(string* ps = NULL) throw (invalid_argument); /* more fun stuff */ }; The other C++ class' method is similar, but it uses an array of integers as one of its arguments. In the above method, ps is a std::string array passed in by the caller, which getOwners() than proceeds to populate. It works fine in C++. I've made numerous attempts to get code that works for Python, and either the code did not compile, or it did compile but then Python didn't like the method when I tried to execute it ("TypeError: bad argument type for built-in operation"). What is the proper way to wrap array arguments so the data can be passed back and forth between C++ and Python? Thanks in advance for the help. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nidoizo at yahoo.com Fri Nov 7 20:54:06 2003 From: nidoizo at yahoo.com (Nicolas Fleury) Date: Fri, 07 Nov 2003 14:54:06 -0500 Subject: [C++-sig] Re: Boost.Python scope In-Reply-To: <0ec33da95824b3caf4780702f43d2e343fabe7bf@Orthosoft.ca> References: <8fdfeed745aa851bf46a83d33418c9bb3fabc158@Orthosoft.ca> <5281c8b7af6c0695276d09c4bc16e6103fabd076@Orthosoft.ca> <0ec33da95824b3caf4780702f43d2e343fabe7bf@Orthosoft.ca> Message-ID: Stefan Seefeld wrote: > Beside their names all starting with 'Py' instead of 'boost::python::', > what would be different in a C++ API for these remaining functions ? They would mostly return boost::python::objects so all the ref counting stuff would be encapsulated (and use some C++ advantages like default values, overloading, etc.). The main advantage is to not have to deal with two different APIs. I already have to deal with boost::python::objects by using Boost.Python, so it would be nice to never have to know about PyObjects*. At least, it's possible to build a boost::python::object from a boost::python::handle, and the handle from a PyObject*, but it would be simpler to create these boost::python::object directly. Regards, Nicolas From nidoizo at yahoo.com Fri Nov 7 20:57:55 2003 From: nidoizo at yahoo.com (Nicolas Fleury) Date: Fri, 07 Nov 2003 14:57:55 -0500 Subject: [C++-sig] Re: Boost.Python scope In-Reply-To: <20031107185629.1199.qmail@web20206.mail.yahoo.com> References: <20031107185629.1199.qmail@web20206.mail.yahoo.com> Message-ID: Ralf W. Grosse-Kunstleve wrote: > You are asking the right question. Some work on this was done more than a year > ago. Basically the idea was to write a Python script that generates C++ > wrappers for the entire Python "C" API with all reference counting handled by > boost::python::object and boost::python::handle<>. Very unfortunately, how > should I say, that horse was beaten dead somehow. Now we need an intrepid new > horse to pull this off. If someone feels brave enough to step forward I'll try > to help and dig out the work that was done before. > Ralf Good, it means Boost.Python objective *is actually* to provide a full C++ API. We just need to find that "brave enough" person ;) Regards, Nicolas From s_sourceforge at nedprod.com Sun Nov 9 04:25:25 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Sun, 09 Nov 2003 03:25:25 -0000 Subject: [C++-sig] Pyste feature: class member deletion order solution Message-ID: <3FADB3A5.8061.7040232@localhost> Just encountered an interesting problem in my now fully working python test program - python does not delete class instance data members in the reverse order of which they were created. For example: class MainWindow(FXMainWindow): def __init__(self, app, title): FXMainWindow.__init__(self, app, title) self._vframe=FXVerticalFrame(self, LAYOUT_FILL) self._text=FXText(self._vframe, None, 0, LAYOUT_FILL) self._text.setEditable(False) self._text.setText("Hello World!") self._okb=FXButton(self._vframe, "&Close", None, app, FXApp.ID_QUIT) self.resize(320, 256) The problem is when python is deleting everything it goes to delete MainWindow - according to the python spec, if an instance data member starts with "_" then it gets "del" called upon it before all else (section 3.3.1 reference manual). Unfortunately, in the case above it deletes self._vframe before self._text. This is a problem because under C++ _text is a child of _vframe and deleting _vframe causes auto-delete of _text - and so when python comes to delete _text, the memory is vacant and nasty fatal exit happens. I was thinking that the obvious solution is for representations of C++ objects to be able to hold a boost::python::handle<> of their parent, thus ensuring that the parent stays alive as long as its children. For that, pyste would merely need to add a handle<> to the class wrapper with something like: struct FX_FXText_Wrapper: FX::FXText { handle<> parentHandle; PyObject* self; FX_FXText_Wrapper(PyObject* self_, FX::FXComposite* p0): FX::FXText(p0), parentHandle(object(p0 ? *p0 : 0).ptr()), self(self_) { } The only thing is, I've not determined if object() matches the FXComposite pointer to what it really is, a FXVerticalFrame. Thus Q: Does boost::python::object(type &) search a list of pointers to all known instantiated things and thus correctly increment the reference of the right thing? Or does it depend on type, which being that of a base class of FXVerticalFrame means it might get confused? Bruno, how easy is this to implement in pyste? Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From nicodemus at esss.com.br Sun Nov 9 19:45:50 2003 From: nicodemus at esss.com.br (Nicodemus) Date: Sun, 09 Nov 2003 15:45:50 -0300 Subject: [C++-sig] Boost.Python scope In-Reply-To: References: Message-ID: <3FAE8B5E.8020605@esss.com.br> Nicolas Fleury wrote: > Hi, > If I understand correctly (correct me if I'm wrong), the Boost.Python > library purpose is mainly only to expose C++ in Python. It doesn't > provide the equivalent of the C API and I wonder if it should be > changed. I prefer to work with boost::python::objects than with > PyObjects and I prefer C++ to C. Right now, I have to use the C API > to do certain things (like read a pickled object in C++). Do you > think the current Boost.Python scope should be enlarged to provide a > complete C++ API? Or at least add a function to execute python code > and store the result in a boost::python::object? I think that a good part of what you may want is already there, for instance, we have wrappers for python lists, tuples, dicts, etc, but the entire Python C API is not exposed. I think an effort to expose a larger part of it would be great, but I guess that Dave doesn't have time to do it, so the work must be done by volunteers. There's been some discussion in the past to write an wrapper for the interpreter part of the C API in C++ (allowing you to run python code through the it instead of using PyRun_String for instance) but the discussion died without generating anything useful. 8/ From RaoulGough at yahoo.co.uk Sun Nov 9 20:13:13 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Sun, 09 Nov 2003 19:13:13 +0000 Subject: [C++-sig] Re: Wrapping class methods with array parameters References: Message-ID: "CLARKE,RON (HP-Vancouver,ex1)" writes: > Please note that not everyone uses a HTML-capable viewer to read this mailing list. I, for one, would prefer postings to the list in plain text. [snip] > Here is one of the classes/methods: > class scifidict > { > public: > /* a bunch of stuff */ > size_t getOwners(string* ps = NULL) > throw (invalid_argument); > > > /* more fun stuff */ > }; > > > The other C++ class' method is similar, but it uses an array of > integers as one of its arguments. > > > In the above method, ps is a std::string array passed in by the > caller, which getOwners() than proceeds to populate. It works fine > in C++. As long as the caller allocates enough space, I suppose. > I've made numerous attempts to get code that works for > Python, and either the code did not compile, or it did compile but > then Python didn't like the method when I tried to execute it > ("TypeError: bad argument type for built-in operation"). > > What is the proper way to wrap array arguments so the data can be >passed back and forth between C++ and Python? I'm sure there are other solutions for this limited use of arrays, but maybe you should look into the indexing support suite, which is available in the CVS version of Boost (documentation is in libs/python/doc/v2/containers.html if you've downloaded Boost from the CVS). This currently allows you to wrap C++ vectors, so you could switch over to doing it that way. Alternatively, I've developed a new version of the indexing suite that also supports arrays, although it will definitely want to know how big the array is first, because it wouldn't be very Python-like to let code write past the end of the array. The new suite (indexing_v2) might make it into the next Boost release (1.31) but in the mean time, you would have to get it from a side-branch of CVS. Some details are on my website at http://home.clara.net/raoulgough/boost/ or by searching for indexing_v2 in this mailing list. -- Raoul Gough. (setq dabbrev-case-fold-search nil) From datafeedNOSPAM at SoftHome.net Sun Nov 9 20:44:19 2003 From: datafeedNOSPAM at SoftHome.net (M. Evans) Date: Sun, 9 Nov 2003 12:44:19 -0700 Subject: [C++-sig] XCircuit Message-ID: <1586809708.20031109124419@SoftHome.net> GPL circuit schematic editor with embedded Python interpreter. http://bach.ece.jhu.edu/~tim/programs/xcircuit/ The drawing engine is general purpose, e.g. http://bach.ece.jhu.edu/~tim/music/index.html Unfortunately, this SourceForge project seems to be switching from Python to TCL. http://bach.ece.jhu.edu/~tim/programs/xcircuit/install.html "Beginning with xcircuit version 3.1, the development platform is the Tcl-enabled version of xcircuit.... The command-line interface, and in particular, the Tcl version with its scripted GUI interface, is much more flexible than the original version with its hard-coded GUI.... The python and non-interpreter-based versions of xcircuit will be maintained, but not further developed." Maybe they just need some help from Boost Python. Mark From datafeedNOSPAM at SoftHome.net Sun Nov 9 21:04:59 2003 From: datafeedNOSPAM at SoftHome.net (M. Evans) Date: Sun, 9 Nov 2003 13:04:59 -0700 Subject: [C++-sig] Re: XCircuit In-Reply-To: <1586809708.20031109124419@SoftHome.net> References: <1586809708.20031109124419@SoftHome.net> Message-ID: <1547543685.20031109130459@SoftHome.net> Here are details on the Python side of it. http://xcircuit.ece.jhu.edu/python.html From dave at boost-consulting.com Mon Nov 10 01:12:48 2003 From: dave at boost-consulting.com (David Abrahams) Date: Sun, 09 Nov 2003 14:12:48 -1000 Subject: [C++-sig] Re: Boost.Python scope References: <20031107185629.1199.qmail@web20206.mail.yahoo.com> Message-ID: "Ralf W. Grosse-Kunstleve" writes: > --- Nicolas Fleury wrote: >> This is very nice, since I have a way of working with a >> boost::python::object. However, my question remain, should Boost.Python >> scope/goal be enlarged to have no need for Py... C functions, providing >> a full C++ API for Python/C++ interaction? > > You are asking the right question. Some work on this was done more than a year > ago. Basically the idea was to write a Python script that generates C++ > wrappers for the entire Python "C" API with all reference counting handled by > boost::python::object and boost::python::handle<>. Very unfortunately, how > should I say, that horse was beaten dead somehow. Now we need an intrepid new > horse to pull this off. If someone feels brave enough to step forward I'll try > to help and dig out the work that was done before. Yeah, it would be great if someone would pick this stuff up and flesh it out. Keep in mind that the existing API wrapping facilities are designed to keep extension modules which use the Boost.Python shared library as small as possible, so that many inline overloads of some of the function templates just end up converting their arguments and dispatching to an implementation function in the shared library which handles boost::python::object instances. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Mon Nov 10 01:19:02 2003 From: dave at boost-consulting.com (David Abrahams) Date: Sun, 09 Nov 2003 14:19:02 -1000 Subject: [C++-sig] Re: Pyste feature: class member deletion order solution References: <3FADB3A5.8061.7040232@localhost> Message-ID: "Niall Douglas" writes: > Just encountered an interesting problem in my now fully working > python test program - python does not delete class instance data > members in the reverse order of which they were created. For example: > > class MainWindow(FXMainWindow): > def __init__(self, app, title): > FXMainWindow.__init__(self, app, title) > self._vframe=FXVerticalFrame(self, LAYOUT_FILL) > self._text=FXText(self._vframe, None, 0, LAYOUT_FILL) > self._text.setEditable(False) > self._text.setText("Hello World!") > > self._okb=FXButton(self._vframe, "&Close", None, app, > FXApp.ID_QUIT) > self.resize(320, 256) > > The problem is when python is deleting everything it goes to delete > MainWindow - according to the python spec, if an instance data member > starts with "_" then it gets "del" called upon it before all else > (section 3.3.1 reference manual). Unfortunately, in the case above it > deletes self._vframe before self._text. > > This is a problem because under C++ _text is a child of _vframe and > deleting _vframe causes auto-delete of _text - and so when python > comes to delete _text, the memory is vacant and nasty fatal exit > happens. > > I was thinking that the obvious solution is for representations of > C++ objects to be able to hold a boost::python::handle<> of their > parent, thus ensuring that the parent stays alive as long as its > children. Won't help. You'll have a reference cycle. that have __del__() methods and are part of a reference cycle cause the entire reference cycle to be uncollectable, which will prevent the C++ object from being destroyed. > For that, pyste would merely need to add a handle<> to the > class wrapper with something like: > > struct FX_FXText_Wrapper: FX::FXText > { > handle<> parentHandle; > PyObject* self; > FX_FXText_Wrapper(PyObject* self_, FX::FXComposite* p0): > FX::FXText(p0), parentHandle(object(p0 ? *p0 : 0).ptr()), > self(self_) > { } > > The only thing is, I've not determined if object() matches the > FXComposite pointer to what it really is, a FXVerticalFrame. > > Thus Q: Does boost::python::object(type &) search a list of pointers > to all known instantiated things and thus correctly increment the > reference of the right thing? Or does it depend on type, which being > that of a base class of FXVerticalFrame means it might get confused? > > Bruno, how easy is this to implement in pyste? Do not try to solve this problem in Boost.Python or in Pyste. It's a Python issue, pure and simple. -- Dave Abrahams Boost Consulting www.boost-consulting.com From s_sourceforge at nedprod.com Mon Nov 10 01:45:14 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Mon, 10 Nov 2003 00:45:14 -0000 Subject: [C++-sig] Re: Pyste feature: class member deletion order solution In-Reply-To: Message-ID: <3FAEDF9A.32058.B97B72B@localhost> On 9 Nov 2003 at 14:19, David Abrahams wrote: > > I was thinking that the obvious solution is for representations of > > C++ objects to be able to hold a boost::python::handle<> of their > > parent, thus ensuring that the parent stays alive as long as its > > children. > > Won't help. You'll have a reference cycle. that have __del__() > methods and are part of a reference cycle cause the entire reference > cycle to be uncollectable, which will prevent the C++ object from > being destroyed. I can't see how that would happen. The bottom-most children (who don't have any extra things holding a reference to them) when deleted decrement the reference count of their parents. If a parent has no other thing using it, it too gets deleted. Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From dave at boost-consulting.com Mon Nov 10 01:52:25 2003 From: dave at boost-consulting.com (David Abrahams) Date: Sun, 09 Nov 2003 14:52:25 -1000 Subject: [C++-sig] Re: Pyste feature: class member deletion order solution References: <3FAEDF9A.32058.B97B72B@localhost> Message-ID: "Niall Douglas" writes: > On 9 Nov 2003 at 14:19, David Abrahams wrote: > >> > I was thinking that the obvious solution is for representations of >> > C++ objects to be able to hold a boost::python::handle<> of their >> > parent, thus ensuring that the parent stays alive as long as its >> > children. >> >> Won't help. You'll have a reference cycle. that have __del__() >> methods and are part of a reference cycle cause the entire reference >> cycle to be uncollectable, which will prevent the C++ object from >> being destroyed. > > I can't see how that would happen. The bottom-most children (who > don't have any extra things holding a reference to them) when deleted > decrement the reference count of their parents. If a parent has no > other thing using it, it too gets deleted. The children won't get deleted, because they are part of a reference cycle. Please think a bit more before arguing with me. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Mon Nov 10 02:02:59 2003 From: dave at boost-consulting.com (David Abrahams) Date: Sun, 09 Nov 2003 15:02:59 -1000 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FAA595E.1D5032CE@sitius.com> <3FAACB87.A97B992@sitius.com> <3FABA7C6.F661FCFC@sitius.com> Message-ID: Nikolay Mladenov writes: > David Abrahams wrote: >> >> Nikolay Mladenov writes: >> >> > the problematic line is >> > param += (len(kv) > 1 ? " %s=%r" : " %s") % kv; >> >> what about: >> >> param += const_cast(len(kv) > 1 ? " %s=%r" : " %s") % kv; >> >> ?? > > This works. OK, committed. Nikolay, could you post a patch which introduces a test case for this stuff? Remember it has to work regardless of how C++ names are mangled. -- Dave Abrahams Boost Consulting www.boost-consulting.com From s_sourceforge at nedprod.com Mon Nov 10 05:49:30 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Mon, 10 Nov 2003 04:49:30 -0000 Subject: [C++-sig] Re: Pyste feature: class member deletion o Message-ID: <3FAF18DA.16046.C7757D3@localhost> On 9 Nov 2003 at 14:52, David Abrahams wrote: > > I can't see how that would happen. The bottom-most children (who > > don't have any extra things holding a reference to them) when > > deleted decrement the reference count of their parents. If a > > parent has no other thing using it, it too gets deleted. > > The children won't get deleted, because they are part of a reference > cycle. Please think a bit more before arguing with me. You're right - I was forgetting that the parent object's __del__ only gets called when its reference count goes to zero, which never could happen if its children all were holding a reference to it. Hmm, back to the drawing board then. The best I've so far thought of is a custom __del__() method which deletes the children in reverse order. Perhaps though this could be automated by some code datestamping member creation and deleting them in reverse chronological order? Maybe some sort of bucket provided by Raoul's indexing suite. Hmm, the mind is a-ticking ... I take it there's no way of asking BPL to tell python to invalidate any references pointing to some C++ object? Perhaps I mean to say that BPL could be told that some object pointer is no longer valid, so it throws a python exception if anyone tries to use it. Cheers, Niall -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 208 bytes Desc: not available URL: From RaoulGough at yahoo.co.uk Mon Nov 10 13:25:44 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Mon, 10 Nov 2003 12:25:44 +0000 Subject: [C++-sig] Re: Unit test script problem with boost References: <20031106052302.72164.qmail@web21506.mail.yahoo.com> Message-ID: John Slater writes: > Hi, > > I have a problem using unittest script with Boost. > > I have a class as Command which is exposed to python through Boost. > If I run a failUnlessRaises() from python as below > > def testFunctionBounds(self): > command = Command() > self.failUnlessRaises(ValueError, command.Command, -1) > > This gives error saying > > apply(callableObj, args, kwargs) > TypeError: Bad argument type for built-in operation. > > This works fine if the Class is in python. > > Looking for a suggetion from ur end. I suggest you supply more details :-) Guessing wildly anyway, could it be that Boost.Python is just raising a different type of exception for the same problem? In that case, an easy solution would be to make the test robust enough to accept either type of exception. -- Raoul Gough. (setq dabbrev-case-fold-search nil) From nickm at sitius.com Mon Nov 10 15:16:32 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Mon, 10 Nov 2003 09:16:32 -0500 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FAA595E.1D5032CE@sitius.com> <3FAACB87.A97B992@sitius.com> <3FABA7C6.F661FCFC@sitius.com> Message-ID: <3FAF9DC0.5BD66A2D@sitius.com> David Abrahams wrote: > > Nikolay Mladenov writes: > > > David Abrahams wrote: > >> > >> Nikolay Mladenov writes: > >> > >> > the problematic line is > >> > param += (len(kv) > 1 ? " %s=%r" : " %s") % kv; > >> > >> what about: > >> > >> param += const_cast(len(kv) > 1 ? " %s=%r" : " %s") % kv; > >> > >> ?? > > > > This works. > > OK, committed. Nikolay, could you post a patch which introduces a > test case for this stuff? >Remember it has to work regardless of how > C++ names are mangled. I am not sure what are you asking me? Where did we come close to the name mangling? > > -- > Dave Abrahams > Boost Consulting > www.boost-consulting.com -- Nikolay Mladenov Sitius Automaion Inc. www.sitius.com From RaoulGough at yahoo.co.uk Mon Nov 10 16:22:30 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Mon, 10 Nov 2003 15:22:30 +0000 Subject: [C++-sig] Re: Boost.Python scope References: <20031107185629.1199.qmail@web20206.mail.yahoo.com> Message-ID: "Ralf W. Grosse-Kunstleve" writes: > --- Nicolas Fleury wrote: >> This is very nice, since I have a way of working with a >> boost::python::object. However, my question remain, should Boost.Python >> scope/goal be enlarged to have no need for Py... C functions, providing >> a full C++ API for Python/C++ interaction? > > You are asking the right question. Some work on this was done more > than a year ago. Basically the idea was to write a Python script > that generates C++ wrappers for the entire Python "C" API with all > reference counting handled by boost::python::object and > boost::python::handle<>. Very unfortunately, how should I say, that > horse was beaten dead somehow. Now we need an intrepid new horse to > pull this off. If someone feels brave enough to step forward I'll > try to help and dig out the work that was done before. Ralf Sounds interesting. I assume you had some kind of C function declaration parser to drive it? I'd be tempted to take a look, but I should probably be focusing on getting some gainful (i.e. paid) employment instead. How much work do you think was left in it? -- Raoul Gough. (setq dabbrev-case-fold-search nil) From dave at boost-consulting.com Mon Nov 10 18:02:25 2003 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 10 Nov 2003 07:02:25 -1000 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FAA595E.1D5032CE@sitius.com> <3FAACB87.A97B992@sitius.com> <3FABA7C6.F661FCFC@sitius.com> <3FAF9DC0.5BD66A2D@sitius.com> Message-ID: Nikolay Mladenov writes: > David Abrahams wrote: >> >> Nikolay Mladenov writes: >> >> > David Abrahams wrote: >> >> >> >> Nikolay Mladenov writes: >> >> >> >> > the problematic line is >> >> > param += (len(kv) > 1 ? " %s=%r" : " %s") % kv; >> >> >> >> what about: >> >> >> >> param += const_cast(len(kv) > 1 ? " %s=%r" : " %s") % kv; >> >> >> >> ?? >> > >> > This works. >> >> OK, committed. Nikolay, could you post a patch which introduces a >> test case for this stuff? >>Remember it has to work regardless of how >> C++ names are mangled. > > I am not sure what are you asking me? Where did we come close to the > name mangling? Sorry, I meant "regardless of how names are represented by boost::python::type_info::name()" -- Dave Abrahams Boost Consulting www.boost-consulting.com From RaoulGough at yahoo.co.uk Mon Nov 10 18:46:05 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Mon, 10 Nov 2003 17:46:05 +0000 Subject: [C++-sig] Re: boost::python::range and duplicate comdat under MSVC 6 References: Message-ID: David Abrahams writes: > Raoul Gough writes: > >>> However, a simple transformation ought to be enough to eliminate the >>> static data member, AFAICT. Do you need help working it out? >> >> It looks to me like the static member is only useful for the >> side-effects of its constructor. Is there an alternative way to >> achieve this? > > Sure; use a function-static variable in the constructor to make sure > that the side-effects only happen once, and then change > class_converters.hpp so that it constructs a shared_ptr_from_python > on the stack instead of calling force_instantiate. OK, I've gone with a static variable in register_class_from_python to force construction of the shared_ptr_from_python. This is wrapped in MSVC6 workaround guards, so that other compilers still use a class-static variable. No real reason for doing this, except that it would probably affect the initialization order on other platforms unnecessarily, and I just like to minimize the impact of fixes. Patches follow. OK to commit these on the CVS mainline? $ cvs diff -c boost/python/converter/shared_ptr_from_python.hpp boost/python/object/class_converters.hpp Index: boost/python/converter/shared_ptr_from_python.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/python/converter/shared_ptr_from_python.hpp,v retrieving revision 1.1 diff -c -r1.1 shared_ptr_from_python.hpp *** boost/python/converter/shared_ptr_from_python.hpp 2 Dec 2002 01:37:39 -0000 1.1 --- boost/python/converter/shared_ptr_from_python.hpp 10 Nov 2003 17:34:53 -0000 *************** *** 8,13 **** --- 8,14 ---- # include # include + # include namespace boost { namespace python { namespace converter { *************** *** 19,25 **** --- 20,29 ---- converter::registry::insert(&convertible, &construct, type_id >()); } + # if !BOOST_WORKAROUND (BOOST_MSVC, == 1200) + // This static var can cause duplicate comdat link errors with MSVC6 static shared_ptr_from_python const registration; + # endif private: static void* convertible(PyObject* p) { *************** *** 45,52 **** --- 49,58 ---- } }; + # if !BOOST_WORKAROUND (BOOST_MSVC, == 1200) template shared_ptr_from_python const shared_ptr_from_python::registration; + # endif }}} // namespace boost::python::converter Index: boost/python/object/class_converters.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/python/object/class_converters.hpp,v retrieving revision 1.15 diff -c -r1.15 class_converters.hpp *** boost/python/object/class_converters.hpp 21 May 2003 22:17:23 -0000 1.15 --- boost/python/object/class_converters.hpp 10 Nov 2003 17:34:53 -0000 *************** *** 18,23 **** --- 18,25 ---- # include + # include + namespace boost { namespace python { namespace objects { ////////////////////////////////////////////////////////////////////// *************** *** 76,83 **** template inline void register_class_from_python(Derived* = 0, Bases* = 0) { python::detail::force_instantiate(converter::shared_ptr_from_python::registration); ! // register all up/downcasts here register_dynamic_id(); --- 78,90 ---- template inline void register_class_from_python(Derived* = 0, Bases* = 0) { + # if BOOST_WORKAROUND (BOOST_MSVC, == 1200) + // Avoids duplicate comdat link errors with MSVC6 + static converter::shared_ptr_from_python shared_ptr_registration; + # else python::detail::force_instantiate(converter::shared_ptr_from_python::registration); ! # endif ! // register all up/downcasts here register_dynamic_id(); -- Raoul Gough. (setq dabbrev-case-fold-search nil) From dave at boost-consulting.com Mon Nov 10 23:25:26 2003 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 10 Nov 2003 12:25:26 -1000 Subject: [C++-sig] Re: boost::python::range and duplicate comdat under MSVC 6 References: Message-ID: Raoul Gough writes: > OK, I've gone with a static variable in register_class_from_python to > force construction of the shared_ptr_from_python. This is wrapped in > MSVC6 workaround guards, so that other compilers still use a > class-static variable. No real reason for doing this, except that it > would probably affect the initialization order on other platforms > unnecessarily, and I just like to minimize the impact of fixes. I think I prefer having only one version for all compilers. It will be very mysterious indeed if people see different behavior on the different platforms. -- Dave Abrahams Boost Consulting www.boost-consulting.com From rwgk at yahoo.com Mon Nov 10 21:44:22 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Mon, 10 Nov 2003 12:44:22 -0800 (PST) Subject: [C++-sig] Boost.Python FAQ expanded Message-ID: <20031110204422.27586.qmail@web20210.mail.yahoo.com> Based on contributions by Niall Douglas I've added these new points to the Boost.Python FAQ: http://cci.lbl.gov/~rwgk/shortcuts/boost/libs/python/doc/v2/faq.html#msvcthrowbug http://cci.lbl.gov/~rwgk/shortcuts/boost/libs/python/doc/v2/faq.html#voidptr http://cci.lbl.gov/~rwgk/shortcuts/boost/libs/python/doc/v2/faq.html#custom_string http://cci.lbl.gov/~rwgk/shortcuts/boost/libs/python/doc/v2/faq.html#topythonconversionfailed http://cci.lbl.gov/~rwgk/shortcuts/boost/libs/python/doc/v2/faq.html#threadsupport Please post any comments or corrections to this list. I'll integrate the changes if necessary. Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From rwgk at yahoo.com Mon Nov 10 23:43:52 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Mon, 10 Nov 2003 14:43:52 -0800 (PST) Subject: [C++-sig] Re: Boost.Python scope In-Reply-To: Message-ID: <20031110224352.54422.qmail@web20210.mail.yahoo.com> --- Raoul Gough wrote: Congratulations to the VC6/7 workarounds for the indexing suite! > Sounds interesting. Here are the main links: http://mail.python.org/pipermail/c++-sig/2002-June/001503.html http://mail.python.org/pipermail/c++-sig/2002-July/001672.html http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/python/Attic/py_interface.hpp?rev=1.2&view=auto http://cvs.sourceforge.net/viewcvs.py/boost/boost/libs/python/src/Attic/py_interface.cpp?rev=1.2&view=auto For easy viewing, the attachment of the last link unpacked: http://cci.lbl.gov/~rwgk/boost_python/api_project/py_api_gen.py > I assume you had some kind of C function declaration parser to drive it? Great idea; but to the best of my knowledge nobody was that ambitious so far. > I'd be tempted to take a look, but I should probably be focusing on > getting some gainful (i.e. paid) employment instead. Good luck! I am sure your work on the indexing suite makes for some good advertising. > How much work do you think was left in it? Hard to tell. It also depends on how ambitious you are. Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From dave at boost-consulting.com Tue Nov 11 12:59:57 2003 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 11 Nov 2003 01:59:57 -1000 Subject: [C++-sig] Re: Boost Python: Beyond handles In-Reply-To: <200311101403.hAAE3WL24378@ns.cricketthosting.co.uk> (Paul Grenyer's message of "Mon, 10 Nov 2003 14:03:32 GMT") References: <200311101403.hAAE3WL24378@ns.cricketthosting.co.uk> Message-ID: The following message is a courtesy copy of an article that has been posted to gmane.comp.lib.boost.user as well. "Paul Grenyer" writes: > Hi All > > I'm trying to embed the python interpreter in a C++ program so that > users can write simple scripts that can be executed when the program > runs. I've been following the "Using the the Interpretter" examples an > dhave had quite a lot of success, except with this one: > > handle<> main_module(borrowed( PyImport_AddModule("__main__") )); > > handle<> main_namespace(borrowed( PyModule_GetDict(main_module.get > ()) )); > > handle<> main_module( borrowed( PyImport_AddModule("__main__") )); > > main_namespace dict(handle<>(borrowed( PyModule_GetDict(main_module.get > ()) ))); > > handle<>( PyRun_String(" result = 5 ** 2", > Py_file_input, > main_namespace.ptr(), > main_namespace.ptr()) ); > > int five_squared = extract( main_namespace["result"] ); > > I'm using boost 1.30.0 and MSVC 7.1, along with the following warning > (?!!): > > builtin_converters.hpp(114) : warning C4267: 'argument' : conversion > from 'size_t' to 'int', possible loss of data > > I get the following errors: > > error C2146: syntax error : missing ';' before identifier 'dict' > error C2039: 'ptr' : is not a member of 'boost::python::handle<>' > error C2039: 'ptr' : is not a member of 'boost::python::handle<>' > error C2676: binary '[' : 'boost::python::handle<>' does not define > this operator or a conversion to a type acceptable to the predefined > operator > > The "missing ';' before identifier 'dict'" error I can understand and I > ppear to be able to fix by swapping "main_namespace" for "handle<>". I > can also fix the "'ptr' : is not a member of 'boost::python::handle<>'" > error by changing ptr to get. However, the final error has me stumped. I suggest posting Boost.Python questions to the C++-sig at http://www.boost.org/more/mailing_lists.htm#cplussig. I also suggest looking at the CVS version of the tutorial http://tinyurl.com/uiis or at: http://tinyurl.com/uiiu Which shows a working example. -- Dave Abrahams Boost Consulting www.boost-consulting.com From RaoulGough at yahoo.co.uk Tue Nov 11 11:44:59 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Tue, 11 Nov 2003 10:44:59 +0000 Subject: [C++-sig] Re: boost::python::range and duplicate comdat under MSVC 6 References: Message-ID: David Abrahams writes: > Raoul Gough writes: > >> OK, I've gone with a static variable in register_class_from_python to >> force construction of the shared_ptr_from_python. This is wrapped in >> MSVC6 workaround guards, so that other compilers still use a >> class-static variable. No real reason for doing this, except that it >> would probably affect the initialization order on other platforms >> unnecessarily, and I just like to minimize the impact of fixes. > > I think I prefer having only one version for all compilers. It will > be very mysterious indeed if people see different behavior on the > different platforms. OK, if you'd prefer it that way I'll change it. On the other hand, the initialization order is not fully specified by the standard, so I think inter-platform differences are to be expected anyway. What I was trying to avoid was that upgrading from 1.30 to 1.31 would alter things on the *same* platform. I think it's unlikely to be a big issue, though, so I'll make the change before comitting. -- Raoul Gough. (setq dabbrev-case-fold-search nil) From dave at boost-consulting.com Tue Nov 11 13:46:13 2003 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 11 Nov 2003 02:46:13 -1000 Subject: [C++-sig] Re: Boost.Python scope References: <20031110224352.54422.qmail@web20210.mail.yahoo.com> Message-ID: "Ralf W. Grosse-Kunstleve" writes: >> I assume you had some kind of C function declaration parser to drive it? > > Great idea; but to the best of my knowledge nobody was that ambitious so far. http://synopsis.sf.net has a fine C/C++ parser which integrates with Python. -- Dave Abrahams Boost Consulting www.boost-consulting.com From RaoulGough at yahoo.co.uk Tue Nov 11 13:19:05 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Tue, 11 Nov 2003 12:19:05 +0000 Subject: [C++-sig] Re: Boost.Python scope References: <20031110224352.54422.qmail@web20210.mail.yahoo.com> Message-ID: "Ralf W. Grosse-Kunstleve" writes: > --- Raoul Gough wrote: > Congratulations to the VC6/7 workarounds for the indexing suite! Wow - I haven't even announced the fixes yet! I guess you saw the CVS checkin (BTW, it *is* all fixed, as far as I can tell). The MSVC6 supplied breaks the test code, but there is a free update for this available from Dinkumware (will be documented when I check in the html update). I tested this by installing the updated header locally and altering the include path order to find the new version. > >> Sounds interesting. > > Here are the main links: > > http://mail.python.org/pipermail/c++-sig/2002-June/001503.html > http://mail.python.org/pipermail/c++-sig/2002-July/001672.html > > http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/python/Attic/py_interface.hpp?rev=1.2&view=auto > http://cvs.sourceforge.net/viewcvs.py/boost/boost/libs/python/src/Attic/py_interface.cpp?rev=1.2&view=auto > > For easy viewing, the attachment of the last link unpacked: > > http://cci.lbl.gov/~rwgk/boost_python/api_project/py_api_gen.py Scary. Maybe too scary for me. > >> I assume you had some kind of C function declaration parser to drive it? > > Great idea; but to the best of my knowledge nobody was that ambitious so far. It looks like David Hawkes did quite a bit of work on this. Judging by the approach he took, parsing the C declarations wouldn't be sufficient by itself, since he uses all kinds of decorations in the API_List like "{new,err=NULL}" for return conventions and "{decl=import_import}" for function renaming I guess. > >> I'd be tempted to take a look, but I should probably be focusing on >> getting some gainful (i.e. paid) employment instead. > > Good luck! I am sure your work on the indexing suite makes for some good > advertising. Thanks. I'm sure I'll find something. > >> How much work do you think was left in it? > > Hard to tell. It also depends on how ambitious you are. Well, put it another way - what, if anything, was wrong with what Dave Hawkes had already done? Did it get dropped simply because the hard (i.e. interesting) work was already done? -- Raoul Gough. (setq dabbrev-case-fold-search nil) From RaoulGough at yahoo.co.uk Tue Nov 11 18:05:02 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Tue, 11 Nov 2003 17:05:02 +0000 Subject: [C++-sig] Re: Pyste feature: class member deletion o References: <3FAF18DA.16046.C7757D3@localhost> Message-ID: "Niall Douglas" writes: > On 9 Nov 2003 at 14:52, David Abrahams wrote: > >> > I can't see how that would happen. The bottom-most children (who >> > don't have any extra things holding a reference to them) when >> > deleted decrement the reference count of their parents. If a >> > parent has no other thing using it, it too gets deleted. >> >> The children won't get deleted, because they are part of a reference >> cycle. Please think a bit more before arguing with me. > > You're right - I was forgetting that the parent object's __del__ only > gets called when its reference count goes to zero, which never could > happen if its children all were holding a reference to it. Generally, if A owns B and B owns A, you can solve the reference counting problems by treating the combined A-B cycle as a single object. You introduce a third object C that owns the combined A-B cycle, and nobody else is allowed to store any references to A or B as individual objects. When C gets destroyed, it breaks one of the links in the cycle before disappearing. Since nobody else had a reference to A or B, they both get destroyed at the same time. -- Raoul Gough. (setq dabbrev-case-fold-search nil) From mzhang at cpsc.ucalgary.ca Tue Nov 11 18:29:39 2003 From: mzhang at cpsc.ucalgary.ca (Yonghua (Michael) Zhang) Date: Tue, 11 Nov 2003 10:29:39 -0700 Subject: [C++-sig] Re: Pyste feature: class member deletion o References: <3FAF18DA.16046.C7757D3@localhost> Message-ID: <3FB11C83.4070209@cpsc.ucalgary.ca> Hi, I am trying to write a C program that can be called by Python. Will you please tell me where I can find some examples? Thanks, michael From dave at boost-consulting.com Tue Nov 11 21:45:34 2003 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 11 Nov 2003 10:45:34 -1000 Subject: [C++-sig] Re: boost::python::range and duplicate comdat under MSVC 6 References: Message-ID: Raoul Gough writes: > David Abrahams writes: > >> Raoul Gough writes: >> >>> OK, I've gone with a static variable in register_class_from_python to >>> force construction of the shared_ptr_from_python. This is wrapped in >>> MSVC6 workaround guards, so that other compilers still use a >>> class-static variable. No real reason for doing this, except that it >>> would probably affect the initialization order on other platforms >>> unnecessarily, and I just like to minimize the impact of fixes. >> >> I think I prefer having only one version for all compilers. It will >> be very mysterious indeed if people see different behavior on the >> different platforms. > > OK, if you'd prefer it that way I'll change it. On the other hand, the > initialization order is not fully specified by the standard, so I > think inter-platform differences are to be expected anyway. Not unless they're trying to "do useful things" before their module initialization function runs. > What I was trying to avoid was that upgrading from 1.30 to 1.31 > would alter things on the *same* platform. I think it's unlikely to > be a big issue, though, so I'll make the change before comitting. Thanks. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Tue Nov 11 21:48:44 2003 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 11 Nov 2003 10:48:44 -1000 Subject: [C++-sig] Re: Boost.Python scope References: <20031110224352.54422.qmail@web20210.mail.yahoo.com> Message-ID: Raoul Gough writes: >>> I assume you had some kind of C function declaration parser to drive it? >> >> Great idea; but to the best of my knowledge nobody was that ambitious so far. > > It looks like David Hawkes did quite a bit of work on this. Judging by > the approach he took, parsing the C declarations wouldn't be > sufficient by itself, since he uses all kinds of decorations in the > API_List like "{new,err=NULL}" for return conventions and > "{decl=import_import}" for function renaming I guess. Oh yeah; I think he was using the TeX source for the Python docs to do this. > Well, put it another way - what, if anything, was wrong with what Dave > Hawkes had already done? Did it get dropped simply because the hard > (i.e. interesting) work was already done? The problem IIRC was that his changes contained several bugs, and were of too great a scope to evaluate (I couldn't understand his code). I asked him to feed them to me in smaller pieces so that we could integrate them into the CVS a little at a time, but I think he was discouraged and gave up. I was very disappointed. -- Dave Abrahams Boost Consulting www.boost-consulting.com From RaoulGough at yahoo.co.uk Wed Nov 12 17:52:28 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Wed, 12 Nov 2003 16:52:28 +0000 Subject: [C++-sig] Re: boost::python::range and duplicate comdat under MSVC 6 References: Message-ID: David Abrahams writes: > Raoul Gough writes: > >> David Abrahams writes: >> >>> Raoul Gough writes: >>> >>>> OK, I've gone with a static variable in register_class_from_python to >>>> force construction of the shared_ptr_from_python. This is wrapped in >>>> MSVC6 workaround guards, so that other compilers still use a >>>> class-static variable. No real reason for doing this, except that it >>>> would probably affect the initialization order on other platforms >>>> unnecessarily, and I just like to minimize the impact of fixes. >>> >>> I think I prefer having only one version for all compilers. It will >>> be very mysterious indeed if people see different behavior on the >>> different platforms. >> >> OK, if you'd prefer it that way I'll change it. [snip] > Thanks. Re-tested (on MSVC6 and MinGW/gcc anyway) and checked in. -- Raoul Gough. (setq dabbrev-case-fold-search nil) From paul at paulgrenyer.co.uk Thu Nov 13 16:09:03 2003 From: paul at paulgrenyer.co.uk (Paul Grenyer) Date: Thu, 13 Nov 2003 15:09:03 GMT Subject: [C++-sig] PyErr_Print() Message-ID: <200311131509.hADF93115433@ns.cricketthosting.co.uk> Hi All I'm new to Boost.Python as of yesterday, but I have successfully integrated it into a C++ applciation. However, this has left me with a couple of questions: 1. Is there a version of PyErr_Print() that I can use to copy the exception message to a std::string (so I can throw my own exception) instead of std::err? 2. I retrieve the output from my python scripts in the following way: std::string sal = extract( main_namespace["result"] ); Is this the best way? I'm concerned that it may leak? Thanks! Regards Paul Please note the change of email address! Paul Grenyer Email: paul at paulgrenyer.co.uk Web: www.paulgrenyer.co.uk From mzhang at cpsc.ucalgary.ca Thu Nov 13 18:30:22 2003 From: mzhang at cpsc.ucalgary.ca (Yonghua (Michael) Zhang) Date: Thu, 13 Nov 2003 10:30:22 -0700 Subject: [C++-sig] how to find a image size in Python References: <200311131509.hADF93115433@ns.cricketthosting.co.uk> Message-ID: <3FB3BFAE.4030703@cpsc.ucalgary.ca> Hi all, I am new to python. Is there anybody know find the size of a given image? I tried as following: img1 = Image.open(fnamein1) w, h = 0,0 img1.size((w, h)) And the error message as following: Traceback (most recent call last): File "test.py", line 47, in ? img1.size((w,h)) TypeError: 'tuple' object is not callable Thank you very much for any suggestions, michael From mzhang at cpsc.ucalgary.ca Fri Nov 14 04:21:14 2003 From: mzhang at cpsc.ucalgary.ca (Yonghua (Michael) Zhang) Date: Thu, 13 Nov 2003 20:21:14 -0700 Subject: [C++-sig] fatal error when the C++ program return a list to python pro. References: <200311131509.hADF93115433@ns.cricketthosting.co.uk> <3FB3BFAE.4030703@cpsc.ucalgary.ca> Message-ID: <3FB44A2A.9030405@cpsc.ucalgary.ca> Hi, I got the following fatal error when the C++ program return a list python program. First my python program calls C function and I make the c function return as following: return Py_BuildValue ("(iiii)", (int)self->xpred[0], (int)(self->xpred[1]-self->refRec[2]), (int)self->refRec[3], (int)self->refRec[2]); The error message is: Fatal Python error: GC object already in linked list Abort Any idea? thank you, michael From bors_1 at hotmail.com Fri Nov 14 08:46:38 2003 From: bors_1 at hotmail.com (Dmitry Borisov) Date: Thu, 13 Nov 2003 23:46:38 -0800 Subject: [C++-sig] ossaudiodev behaves weird on Linux Message-ID: Hi, I've got Python 2.3.2 installed on my Linux Red Hat 8( 2.4.18-2 ) and tried to use ossaudiodev module. The following code works fine. import ossaudiodev snd= ossaudiodev.open( 'w' ) f= open( 'test.pcm', 'rb' ) s= f.read( 400000 ) snd.setparameters( 0x10, 2, 44100 ) snd.write( s ) Then I relaunch Python and try this one. import ossaudiodev snd= ossaudiodev.open( 'w' ) f= open( 'test.pcm', 'rb' ) s= f.read( 400000 ) snd.setparameters( 0x10, 2, 44100 ) snd.writeall( s ) Nope. It stucks on writeall(). Interestingly it stucks on select inside that function. After patching writeall in source like this: /* use select to wait for audio device to be available */ FD_ZERO(&write_set_fds); FD_SET(self->fd, &write_set_fds); // BEGIN CHANGE write(self->fd, "", 0); // END CHANGE while (size > 0) { Py_BEGIN_ALLOW_THREADS select_rv = select(self->fd+1, NULL, &write_set_fds, NULL, NULL); Everything works fine after all. I have Via EPIA- 500, all default sound drivers from Red Hat 8, including oss. If the group is wrong, please direct as needed. Regards, Dmitry/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave at boost-consulting.com Fri Nov 14 15:41:15 2003 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 14 Nov 2003 04:41:15 -1000 Subject: [C++-sig] Re: fatal error when the C++ program return a list to python pro. References: <200311131509.hADF93115433@ns.cricketthosting.co.uk> <3FB3BFAE.4030703@cpsc.ucalgary.ca> <3FB44A2A.9030405@cpsc.ucalgary.ca> Message-ID: "Yonghua (Michael) Zhang" writes: > Hi, > > I got the following fatal error when the C++ program return a list > python program. > First my python program calls C function and I make the c function > return as following: > > return Py_BuildValue ("(iiii)", > (int)self->xpred[0], > (int)(self->xpred[1]-self->refRec[2]), > (int)self->refRec[3], > (int)self->refRec[2]); > > The error message is: > > Fatal Python error: GC object already in linked list > Abort > > Any idea? thank you, This is not a C++-specific question. I suggest you ask on the python-list (comp.lang.python), where you're likely to find someone who knows the answer. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Fri Nov 14 15:41:52 2003 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 14 Nov 2003 04:41:52 -1000 Subject: [C++-sig] Re: ossaudiodev behaves weird on Linux References: Message-ID: "Dmitry Borisov" writes: > Hi, > I've got Python 2.3.2 installed on my Linux Red Hat 8( 2.4.18-2 ) and tried to use ossaudiodev module. > The following code works fine. This is not a C++-related question. Please post to the python-list (comp.lang.python) for general Python help. -- Dave Abrahams Boost Consulting www.boost-consulting.com From kent at cognitoy.com Fri Nov 14 23:16:36 2003 From: kent at cognitoy.com (kent at cognitoy.com) Date: Fri, 14 Nov 2003 17:16:36 -0500 Subject: [C++-sig] extending and callbacks in Boost.Python Message-ID: <48270-2200311514221636664@M2W039.mail2web.com> Hi. I hope this question isn't too naive, but I've spent a couple of days searching for the answer and haven't found it. I am trying to build an application that extends Python with a collection of C++ libraries. In one case, I want a library running an extended loop to call back into Python. I have set up something like this (sanitized for my protection): A C++ base class: --------- struct PythonCallback { virtual int perFrameCallback() = 0; }; struct PythonCallbackWrapper : PythonCallback { PythonCallbackWrapper(PyObject* self_) : self(self_) {} int perFrameCallback() { return call_method(self, "perFrameCallback"); } PyObject* self; }; --------- Then I have a callback registration function: --------- PyObject* mPythonCallback; void MyObject::setCallback(PyObject* p) { mPythonCallback = p; } --------- And in my loop, I'm trying to do: --------- call_method(mPythonCallback, "perFrameCallback"); --------- The import code is: --------- BOOST_PYTHON_MODULE(MyObject) { class_("MyObject") .def("doSomethingWithCallback", &MyObject::doSomethingWithCallback) .def("setCallback", &MyObject::setCallback) ; class_("PythonCallback") ; } --------- The python code looks like: --------- import MyObject class MyCallback(MyObject.PythonCallback): def perFrameCallback(): return 42 m = MyObject.MyObject() cb = MyCallback() m.setCallback(cb) m.doSomethingWithCallback() --------- So that's the whole system. When I run it, the script loads and runs, and I see that the setCallback method is receiving a PyObject*. But when I try to call the callback through that pointer, it throws an exception: boost::python::error_already_set My initial thought was that this must mean an error occurred earlier that I had failed to handle, so I put a call to PyErr_Occurred() before this to test that theory -- and it returned null (no outstanding errors). At this point I'm stuck. I haven't found a way to figure out what's going wrong. By the way, I've also tried a simpler approach of just placing a free function in Python and passing in a reference to it in setCallback, and then using the call function to call it. I get the same results. Please, I'd appreciate some help here. It feels really close...but something is going very wrong. I'd also greatly appreciate a pointer to some document somewhere that talks about setting up callbacks from C++ into Python where the Python code is running the outermost loop. And maybe a pointer to an explanation of what I can do with a PyObject*. Although I've read through every bit of documentation I can find, I feel as though I know a lot of disconnected facts without having any good overarching view of the system. Thanks! Kent --- Kent Quirk CTO CogniToy -------------------------------------------------------------------- mail2web - Check your email from the web at http://mail2web.com/ . From rwgk at yahoo.com Sat Nov 15 01:01:53 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Fri, 14 Nov 2003 16:01:53 -0800 (PST) Subject: [C++-sig] extending and callbacks in Boost.Python In-Reply-To: <48270-2200311514221636664@M2W039.mail2web.com> Message-ID: <20031115000153.6719.qmail@web20212.mail.yahoo.com> --- "kent at cognitoy.com" wrote: > import MyObject > > class MyCallback(MyObject.PythonCallback): > def perFrameCallback(): > return 42 At first I thought it smells like this: Page 8 of boost/libs/python/doc/PyConDC_2003/bpl.pdf in the latest CVS: ========================================================================== Because C++ object construction is a one-step operation, C++ instance data cannot be constructed until the arguments are available, in the init function: >>> class D(SomeBoostPythonClass): ... def init (self): ... pass ... >>> D().some boost python method() Traceback (most recent call last): File ????, line 1, in ? TypeError: bad argument type for built-in operation This happened because Boost.Python couldn?t find instance data of type SomeBoostPythonClass within the D instance; D?s init function masked construction of the base class. It could be corrected by either removing D?s init function or having it call SomeBoostPythonClass. init (...) explicitly. ========================================================================== Make sure you use the latest CVS because the .pdf file was broken before Nov 5. But you don't override the __init__ function, so I don't know. Anyway, I hope this pointer is useful somehow; maybe you have an __init__ function in your "real" application? Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From kent at cognitoy.com Sat Nov 15 01:27:01 2003 From: kent at cognitoy.com (kent at cognitoy.com) Date: Fri, 14 Nov 2003 19:27:01 -0500 Subject: [C++-sig] extending and callbacks in Boost.Python Message-ID: <147710-22003116150271781@M2W064.mail2web.com> Thank you for the reply. Sadly, my post was accurate in this area: as yet, there's no init method in any of my objects, and when learning I have a tendency to break things down into little steps anyway. In other words, I'll create an object first, then call a method on it in a second step. The pointer to the document you mention, however, is useful. It goes a long way toward helping me to understand what the heck is going on. But I'd greatly appreciate any other pointers and ideas you or others might have. Kent Original Message: ----------------- From: Ralf W. Grosse-Kunstleve rwgk at yahoo.com But you don't override the __init__ function, so I don't know. Anyway, I hope this pointer is useful somehow; maybe you have an __init__ function in your "real" application? -------------------------------------------------------------------- mail2web - Check your email from the web at http://mail2web.com/ . From mike at nospam.com Sat Nov 15 01:32:59 2003 From: mike at nospam.com (Mike Rovner) Date: Fri, 14 Nov 2003 16:32:59 -0800 Subject: [C++-sig] Re: extending and callbacks in Boost.Python References: <48270-2200311514221636664@M2W039.mail2web.com> Message-ID: kent at cognitoy.com wrote: > The python code looks like: > > --------- > import MyObject > > class MyCallback(MyObject.PythonCallback): > def perFrameCallback(): self argument missed > return 42 HTH, Mike From kent at cognitoy.com Sat Nov 15 01:43:44 2003 From: kent at cognitoy.com (kent at cognitoy.com) Date: Fri, 14 Nov 2003 19:43:44 -0500 Subject: [C++-sig] Re: extending and callbacks in Boost.Python Message-ID: <39020-220031161504344905@M2W038.mail2web.com> Good grief. That's all it took. I've been tearing my hair out for a couple of days. I suppose the benefit is that I now know a lot more than I did when I started. :-) Thank you! Kent Original Message: ----------------- From: Mike Rovner mike at nospam.com Date: Fri, 14 Nov 2003 16:32:59 -0800 To: c++-sig at python.org Subject: [C++-sig] Re: extending and callbacks in Boost.Python kent at cognitoy.com wrote: > The python code looks like: > > --------- > import MyObject > > class MyCallback(MyObject.PythonCallback): > def perFrameCallback(): self argument missed > return 42 HTH, Mike _______________________________________________ C++-sig mailing list C++-sig at python.org http://mail.python.org/mailman/listinfo/c++-sig -------------------------------------------------------------------- mail2web - Check your email from the web at http://mail2web.com/ . From dave at boost-consulting.com Sat Nov 15 01:54:15 2003 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 14 Nov 2003 14:54:15 -1000 Subject: [C++-sig] Re: extending and callbacks in Boost.Python References: <48270-2200311514221636664@M2W039.mail2web.com> Message-ID: "kent at cognitoy.com" writes: > So that's the whole system. But it's not. A complete example would be one that we could compile and run to reproduce the problem. You write things like, "And in my loop, I'm trying to do:", but you don't give us the loop. Please post a small example which shows the problem so we can help you. Thanks, -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Sat Nov 15 20:07:05 2003 From: dave at boost-consulting.com (David Abrahams) Date: Sat, 15 Nov 2003 09:07:05 -1000 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FA88949.E97E1AE2@sitius.com> <3FAAA1FF.24A66BB9@sitius.com> <3FAACC65.1EF1529C@sitius.com> <3FABA955.8EF371B@sitius.com> Message-ID: Nikolay Mladenov writes: > David Abrahams wrote: >> >> Nikolay Mladenov writes: >> >> > David Abrahams wrote: >> >> >> > >> >> > So why having the option to stick signature in the docstring is bad? It >> >> > is only an option. >> >> >> >> I didn't say it was; you were looking for something less intrusive. >> > >> > I see, but until we find it I like that one. >> > >> >> >> >> > Combining the overloads docstrings shouldn't be a problem as well >> >> > since one can supply a single docstring per name. >> >> >> >> Fine with me. >> > >> > Can I implement this? >> >> Do you mean, "will I accept your patch?" > > Yes. > >> Probably, though I'm not >> sure I like the syntax for doing it optionally. An existing docstring >> might already contain a %, for example. > > Yes I thought of that too, but the only other way I see is to change the > type > of the docstring parameter (of def) to something that expands to > different strings > based on parameters and default constructable from python::str, const > char *, and std::string. > Do you like that? I am not sure how this is going to fit in. I don't love it, but it seems better. More to the point: shouldn't including the signature be the default? -- Dave Abrahams Boost Consulting www.boost-consulting.com From nickm at sitius.com Tue Nov 18 20:55:29 2003 From: nickm at sitius.com (Nikolay Mladenov) Date: Tue, 18 Nov 2003 14:55:29 -0500 Subject: [C++-sig] Re: function::argument_error / overloads & docstrings References: <3FA29524.7B88DEA6@sitius.com> <3FA66A46.1A4D05EF@sitius.com> <3FA68406.755D7131@sitius.com> <3FA70227.546F2E0@sitius.com> <3FA88949.E97E1AE2@sitius.com> <3FAAA1FF.24A66BB9@sitius.com> <3FAACC65.1EF1529C@sitius.com> <3FABA955.8EF371B@sitius.com> Message-ID: <3FBA7931.85D3740F@sitius.com> David Abrahams wrote: > > Nikolay Mladenov writes: > > > David Abrahams wrote: > >> > >> Nikolay Mladenov writes: > >> > >> > David Abrahams wrote: > >> >> > >> > > >> >> > So why having the option to stick signature in the docstring is bad? It > >> >> > is only an option. > >> >> > >> >> I didn't say it was; you were looking for something less intrusive. > >> > > >> > I see, but until we find it I like that one. > >> > > >> >> > >> >> > Combining the overloads docstrings shouldn't be a problem as well > >> >> > since one can supply a single docstring per name. > >> >> > >> >> Fine with me. > >> > > >> > Can I implement this? > >> > >> Do you mean, "will I accept your patch?" > > > > Yes. > > > >> Probably, though I'm not > >> sure I like the syntax for doing it optionally. An existing docstring > >> might already contain a %, for example. > > > > Yes I thought of that too, but the only other way I see is to change the > > type > > of the docstring parameter (of def) to something that expands to > > different strings > > based on parameters and default constructable from python::str, const > > char *, and std::string. > > Do you like that? I am not sure how this is going to fit in. > > I don't love it, but it seems better. I looked into this and it seems not so easy to put this kind of changes. (and I am very busy with my work) > More to the point: shouldn't including the signature be the default? I would think yes. My current copy does only that. Do you see any other way this docstring behavior can be implemented? Relatively easy? > -- > Dave Abrahams > Boost Consulting > www.boost-consulting.com -- Nikolay Mladenov Sitius Automation Inc. www.sitius.com From nico_ml at mgdesign.org Wed Nov 19 14:00:17 2003 From: nico_ml at mgdesign.org (Nicolas LELONG) Date: Wed, 19 Nov 2003 14:00:17 +0100 Subject: [C++-sig] keeping weak_ptrs upon python objects smart_ptr holders Message-ID: <035401c3ae9d$152ee840$de00a8c0@nico> Hi everyone, I've been trying to wrap my Observer pattern implementation with BPL. I'm willing to be able to create new observers in Python. My listeners objects keep weak_ptrs upon their observers, these weak_ptrs are used to notify the observers and to be able to know if a given observer is still "alive". I have not been able to obtain a weak_ptr that references the real shared_ptr holding the observer objects. The weak_ptrs I get seem to reference a dummy smart_ptr which is destoyed after the execution of python::detail::caller_arity<>::impl<>::operator(). The 'problem' can be seen with the following code : **** c++ code ********************************************** struct A { virtual ~A(){} virtual std::string f() = 0; }; struct ACallback : A, Callback { ACallback (PyObject* self) : Callback(self) {} std::string f() { object self(handle<>(borrowed(mSelf))); return extract(self.attr("f")()); } }; boost::weak_ptr instance; void setInstance(boost::shared_ptr a) { instance = a; }; std::string doInstance() { boost::shared_ptr a = instance.lock(); if (a.get() == NULL) return "no more object here!"; else return a->f(); }; BOOST_PYTHON_MODULE( test ) { class_("A") .def("f", pure_virtual(&A::f)); def("setInstance", setInstance); def("doInstance", doInstance); } ******** python script *************************** from test import * class E(A): def f(self): return 'E::f' e = E() setInstance(e) res0 = doInstance() res1 = e.f() *************************************************** At the end of the script, res0 contains 'no more object here!' and res1 contains what I'd like res0 to contain : 'E::f' ! I did not find any information that could help me to solve this problem. Is there any known way to achieve this or am I doomed to get rid of weak_ptrs ?! Thanks, Nicolas. From dave at boost-consulting.com Wed Nov 19 23:38:32 2003 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 19 Nov 2003 12:38:32 -1000 Subject: [C++-sig] Re: keeping weak_ptrs upon python objects smart_ptr holders References: <035401c3ae9d$152ee840$de00a8c0@nico> Message-ID: "Nicolas LELONG" writes: > Hi everyone, > > I've been trying to wrap my Observer pattern implementation with > BPL. I'm willing to be able to create new observers in Python. My > listeners objects keep weak_ptrs upon their observers, these > weak_ptrs are used to notify the observers and to be able to know if > a given observer is still "alive". > > I have not been able to obtain a weak_ptr that references the real > shared_ptr holding the observer objects. The weak_ptrs I get seem to > reference a dummy smart_ptr which is destoyed after the execution of > python::detail::caller_arity<>::impl<>::operator(). It's not a dummy, but it is conjured up "from thin air" using a custom deleter which just manages a reference to the containing Python object. If you don't copy this into some other shared_ptr somewhere, it becomes the last one using that count after the call completes. If you change the way A is wrapped so it's held by shared_ptr: class_, boost::noncopyable>("A") ... ; and change: setInstance(boost::shared_ptr a) { instance = a; }; to setInstance(boost::shared_ptr& a) { instance = a; }; *then* the weak pointer will be using the shared_ptr inside the Python object. I think it might be better to do more to make this work automatically, but I'm not sure just what that "more" would be. > The 'problem' can be seen with the following code : > > **** c++ code ********************************************** > > struct A > { > virtual ~A(){} > virtual std::string f() = 0; > }; > > struct ACallback : A, Callback > { > ACallback (PyObject* self) : Callback(self) {} > > std::string f() > { > object self(handle<>(borrowed(mSelf))); > return extract(self.attr("f")()); > } > }; > > boost::weak_ptr instance; > > void setInstance(boost::shared_ptr a) { instance = a; }; > > std::string doInstance() > { > boost::shared_ptr a = instance.lock(); > if (a.get() == NULL) > return "no more object here!"; > else > return a->f(); > }; > > BOOST_PYTHON_MODULE( test ) > { > class_("A") > .def("f", pure_virtual(&A::f)); > > def("setInstance", setInstance); > def("doInstance", doInstance); > } > > ******** python script *************************** > > from test import * > > class E(A): > def f(self): > return 'E::f' > > e = E() > setInstance(e) > res0 = doInstance() > res1 = e.f() > > *************************************************** > > At the end of the script, res0 contains 'no more object here!' and res1 > contains what I'd like res0 to contain : 'E::f' ! > > I did not find any information that could help me to solve this problem. > Is there any known way to achieve this or am I doomed to get rid of > weak_ptrs ?! > > Thanks, > Nicolas. -- Dave Abrahams Boost Consulting www.boost-consulting.com From nlelong at mgdesign.org Thu Nov 20 11:10:50 2003 From: nlelong at mgdesign.org (Nicolas LELONG / mgdesign) Date: Thu, 20 Nov 2003 11:10:50 +0100 Subject: [C++-sig] Re: keeping weak_ptrs upon python objects smart_ptrholders References: <035401c3ae9d$152ee840$de00a8c0@nico> Message-ID: <002301c3af4e$933352b0$de00a8c0@nico> "David Abrahams" writes : > It's not a dummy, but it is conjured up "from thin air" using a custom > deleter which just manages a reference to the containing Python > object. If you don't copy this into some other shared_ptr somewhere, > it becomes the last one using that count after the call completes. Yep, I think that's what I meant by 'dummy' ;) > If you change the way A is wrapped so it's held by shared_ptr: > > class_, boost::noncopyable>("A") > ... > ; > > > and change: > > setInstance(boost::shared_ptr a) { instance = a; }; > > to > > setInstance(boost::shared_ptr& a) { instance = a; }; > > *then* the weak pointer will be using the shared_ptr inside the > Python object. Aargh, I thought about this, and I would have bet I tried it ! it seems that I made a mistake somewhere as it works now you tell me !... I think I should not have removed the explicit boost::shared_ptr holder specification (I thought that was the 'default' holder when not specified... I still have troubles grabbing every aspects of BPL holding scheme - and not enough time to dive into the doc/code...) It even works with 'setInstance(boost::shared_ptr a)' which I find more intuitive. I still have another "problem" : not every subclass of A is a subclass of ACallback (ie there are subclasses implemented in C++) - for those, I stumbled upon a conversion problem. So let's say I have the additional code : ******************************************************** struct D : A { virtual std::string f() { return "D::f()"; } }; /*....*/ class_, bases, boost::noncopyable>("D") .def("f", &D::f); implicitly_convertible< boost::shared_ptr, boost::shared_ptr >(); ********************************************************* with the following set of functions, I can have something working as I expect : ********************************************************* void setInstance(boost::shared_ptr a) { instance = a; }; void setInstance_wrapper(boost::shared_ptr a) { setInstance(a); }; void setInstance_wrapper2(boost::shared_ptr d) { setInstance(d); }; /*...*/ def("setInstance", setInstance); def("setInstance", setInstance_wrapper); def("setInstance", setInstance_wrapper2); ********************************************************* which seems to mean that I have to make a wrapper for every different holder defined in the hierachy tree. That's doable ! > I think it might be better to do more to make this > work automatically, but I'm not sure just what that "more" would be. hmm, of course, that would be great - I'm not used to the BPL internals so I may tell some wrong/stupid thing: wouldn't it be possible, when converting the arguments provided to a function, that if : - a shared_ptr (weak_ptr) argument is the 'target' of a specified implicit conversion whose source is the type of the provided value for the argument - AND the provided value wrapper is held by shared_ptr - THEN the shared_ptr " conjured up 'from thin air' " is contructed from the shared_ptr holding the provided value thus having a valid reference count I don't if/where/how all this could be done, and if it covers every aspect of the problem ! What do you think ? Thans once more for your help :) Nicolas. > From Benjamin.Golinvaux at euresys.com Thu Nov 20 18:04:41 2003 From: Benjamin.Golinvaux at euresys.com (Benjamin Golinvaux) Date: Thu, 20 Nov 2003 18:04:41 +0100 Subject: [C++-sig] Newbie : fastest way of sending floats Message-ID: hello i have joined this list because i need to wrap a big c++ library and i plan to use boost. i'm just at the very very beginning right now. i need to wrap a c++ function that takes an array a point coordinates on the python side, they are built that way : myList = [ [ 12.23 , 34.34 ] , [ 16.534, 34.8643] , .... ] right now, i wrap this function : void testObject(const boost::python::object& obj) { boost::python::list list(obj); double x,y; for(int i = 0; i < 5; ++i ) { x = PyFloat_AS_DOUBLE(boost::python::object(list[i][0]).ptr()); y = PyFloat_AS_DOUBLE(boost::python::object(list[i][1]).ptr()); _RPT3(_CRT_WARN,"point %d = (%f,%f)\n",i,x,y); } } And it somehow works I understand this really looks like horrible code, but these are just very very very early tests :) Could you please point me to some information on how to make this cleaner... I am not looking for the cleanest code, but for the FASTEST way to pass the array of floats. I am willing to use the raw C api if needed. Thanks Best, Benjamin Golinvaux www.euresys.com **************** The information contained in this message or any of its attachments may be privileged and confidential and intended for the exclusive use of the addressee. If you are not the addressee any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited. If you have received this transmission by error please notify the sender immediately and then delete this email. EURESYS shall not be liable for any loss of or damage to revenues, profits, goodwill, data, information systems or other special, incidental, indirect, consequential or punitive damages of any kind arising in connection with the use of information contained in this mail or its attachments. Email transmission cannot be guaranteed to be secure or error free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore is in no way liable for any errors or omissions in the content of this message, which may arise as a result of email transmission. If verification is required, please request a hard copy. Please note that neither EURESYS, nor the sender accepts any responsibility for viruses and it is your responsibility to scan attachments (if any). **************** From paustin at eos.ubc.ca Thu Nov 20 18:33:25 2003 From: paustin at eos.ubc.ca (Philip Austin) Date: Thu, 20 Nov 2003 09:33:25 -0800 Subject: [C++-sig] Newbie : fastest way of sending floats In-Reply-To: References: Message-ID: <16316.64229.451337.394451@gull.eos.ubc.ca> Benjamin Golinvaux writes: > > I am not looking for the cleanest code, but for the FASTEST way to pass > the array of floats. I am willing to use the raw C api if needed. The fastest way to pass an array of floats is to use Numerical Python (http://www.pfdubois.com/numpy). Boost supports conversions between numpy (and its eventual successor, numarray) and python. Here's an example of a wrapper for a spline interpolator, which also makes use of a boost/numpy support library available at http://www.eos.ubc.ca/research/clouds/num_util.html py::numeric::array splinewrap(py::numeric::array x, py::numeric::array y, double yp1, double ypn) { nbpl::check_rank(x,1); nbpl::check_type(x,PyArray_DOUBLE); int xsize=nbpl::size(x); nbpl::check_rank(y,1); nbpl::check_type(y,PyArray_DOUBLE); int ysize=nbpl::size(y); assert(xsize==ysize); double* xptr=(double*) nbpl::data(x); double* yptr=(double*) nbpl::data(y); py::numeric::array y2=nbpl::makeNum(ysize, PyArray_DOUBLE); double* y2ptr=(double*) nbpl::data(y2); spline(xptr,yptr,ysize,yp1,ypn,y2ptr); return y2; } Regards, Phil From manderso at cs.wisc.edu Thu Nov 20 22:34:08 2003 From: manderso at cs.wisc.edu (manderso at cs.wisc.edu) Date: Thu, 20 Nov 2003 15:34:08 -0600 Subject: [C++-sig] threading problem Message-ID: <16317.13136.459334.144952@gohan.cs.wisc.edu> Hi -- I've been using Boost.Python in my research work for about 6 months now, and I've just recently bumped into a problem with threading during PyFinalize. It has me confused, and I'm not entirely sure what path to pursue in trying to debug it. I don't expect anyone to be able to solve the problem from the information herein, but I'm hoping that someone will have an intuition on what *might* be the problem; candidates that I should try to track down. On a particular set of input (so only very occasionally, but repeatably), during interpreter shut down, the program halts while waiting for a mutex. From what the debugger is telling me, specifically it appears to be when the 'str' object is being removed from the global dictionary and destroyed, and the Boost.Python wrapper to this is destroying itself. My research software is not explicitly multi-threaded; any use of pthreads comes directly from the usage in Boost.Python or the python interpreter itself. The behavior is the same with Boost 1.30.2, and the Boost version in CVS as of yesterday evening. The behavior is the same with the multi-threaded Boost.Python debug build and the non-multi-threaded Boost.Python debug build. My project is organized as a central shared library which has all the main code but no wrappers, and a series of python modules which individually wrap classes and each link against the main shared library. The python script I'm executing is very simple; only about 20 lines. It comes down to a case whether or not I create a shared_ptr to an image (and allocate (new) the image it points to). If I do, the problem occurs. If I don't do this one thing, the problem does not occur. I am highly doubtful that this allocation is *causing* the problem, which suggests that some complex set of side effects are contributing to it, thus making it very difficult to isolate. The main library links against: gargamel: [canute/lib] > ldd libcanute.so libm.so.6 => /lib/libm.so.6 (0x4009d000) libboost_python-gcc-mt-d-1_31.so.1.31.0 => /u/m/a/manderso/research/lib/libboost_python-gcc-mt-d-1_31.so.1.31.0 (0x400bf000) libgdal.so => /u/m/a/manderso/research/lib/libgdal.so (0x40180000) libgcc_s.so.1 => /s/gcc-3.2.1/i386_rh72/lib/libgcc_s.so.1 (0x4043d000) libc.so.6 => /lib/libc.so.6 (0x40446000) libpthread.so.0 => /lib/libpthread.so.0 (0x4057c000) librt.so.1 => /lib/librt.so.1 (0x40593000) libstdc++.so.5 => /s/gcc-3.2.1/i386_rh72/lib/libstdc++.so.5 (0x405a5000) libungif.so.4 => /usr/lib/libungif.so.4 (0x40660000) libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x40669000) libpng.so.2 => /usr/lib/libpng.so.2 (0x40688000) libz.so.1 => /usr/lib/libz.so.1 (0x406aa000) libdl.so.2 => /lib/libdl.so.2 (0x406b8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000) libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x406bc000) The backtrace from the debugger, slightly annotated with the surrounding code which is executing at the time of the inability to get the lock on the mutex is listed below. (gdb) bt #0 0x403db9b6 in __sigsuspend (set=0xbfffdd80) at ../sysdeps/unix/sysv/linux/sigsuspend.c:45 #1 0x4002bd45 in __pthread_wait_for_restart_signal (self=0x400355a0) at pthread.c:978 #2 0x4002dbc3 in __pthread_alt_lock (lock=, self=0x0) at restart.h:34 #3 0x40029fb6 in __pthread_mutex_lock (mutex=0x818ee74) at mutex.c:120 #4 0x40b99c52 in ~pointer_holder (this=0x818eea4) at /u/m/a/manderso/research/include/boost/detail/lwm_pthreads.hpp:71 scoped_lock(lightweight_mutex & m): m_(m.m_) { --> pthread_mutex_lock(&m_); } #5 0x40a78192 in instance_dealloc (inst=0x818ee8c) at /scratch/src/boost_cvs/libs/python/src/object/class.cpp:282 for (instance_holder* p = kill_me->objects, *next; p != 0; p = next) { next = p->next(); --> p->~instance_holder(); instance_holder::deallocate(inst, dynamic_cast(p)); } #6 0x0806009f in subtype_dealloc (self=0x818ee8c) at Objects/typeobject.c:470 /* Call the base tp_dealloc() */ assert(basedealloc); --> basedealloc(self); #7 0x080dd4b9 in PyDict_SetItem (op=0x816e50c, key=0x816d8d8, value=0x80f827c) at Objects/dictobject.c:549 if (mp->ma_used > n_used && mp->ma_fill*3 >= (mp->ma_mask+1)*2) { --> if (dictresize(mp, mp->ma_used*2) != 0) return -1; } #8 0x080e071e in _PyModule_Clear (m=0xfffffffc) at Objects/moduleobject.c:136 while (PyDict_Next(d, &pos, &key, &value)) { if (value != Py_None && PyString_Check(key)) { char *s = PyString_AsString(key); if (s[0] != '_' || strcmp(s, "__builtins__") != 0) { if (Py_VerboseFlag > 1) PySys_WriteStderr("# clear[2] %s\n", s); --> PyDict_SetItem(d, key, Py_None); } } } #9 0x08095b73 in PyImport_Cleanup () at Python/import.c:322 #10 0x080a15b6 in Py_Finalize () at Python/pythonrun.c:226 #11 0x08054030 in Py_Main (argc=0, argv=0xbfffe0e4) at Modules/main.c:375 #12 0x08053c0b in main (argc=-4, argv=0xfffffffc) at Modules/python.c:10 #13 0x403c9336 in __libc_start_main (main=0x8053bf0
, argc=1, ubp_av=0xbfffe0e4, init=0x8052c88 <_init>, fini=0x80e54b0 <_fini>, rtld_fini=0x4000d2fc <_dl_fini>, stack_end=0xbfffe0dc) at ../sysdeps/generic/libc-start.c:129 Does anyone have any idea where to go, or what might be the cause of the problem? The codebase is fairly massive, and small changes in input or the execution of the program can cause the behavior to change (and not break). If some information not included would be helpful, I would be happy to post it. Thanks for any help / feedback you can provide. -- Matt C. Anderson -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- No thank you Delmar. A third of a gopher would only arouse my appetite without bedding her back down... -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- From s_sourceforge at nedprod.com Thu Nov 20 23:36:51 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Thu, 20 Nov 2003 22:36:51 -0000 Subject: [C++-sig] threading problem In-Reply-To: <16317.13136.459334.144952@gohan.cs.wisc.edu> Message-ID: <3FBD4203.25103.1FBBD72F@localhost> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 20 Nov 2003 at 15:34, manderso at cs.wisc.edu wrote: > I've been using Boost.Python in my research work for about 6 months > now, and I've just recently bumped into a problem with threading > during PyFinalize. It has me confused, and I'm not entirely sure what > path to pursue in trying to debug it. I don't expect anyone to be > able to solve the problem from the information herein, but I'm hoping > that someone will have an intuition on what *might* be the problem; > candidates that I should try to track down. Do you have that buggy version of glibc with the faulty NPTL threads implementation? It hangs randomly with mutexes. There's a fix available (new RPM for RH9 etc). Cheers, Niall -----BEGIN PGP SIGNATURE----- Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 iQA/AwUBP71CA8EcvDLFGKbPEQK3NwCfbKjxcBr9uekS7POZvram6mMx+UEAniqG rnsUm2o4pjp7WfjrHSEHsLqS =YZEA -----END PGP SIGNATURE----- From hupp at cs.wisc.edu Fri Nov 21 00:13:54 2003 From: hupp at cs.wisc.edu (Adam Hupp) Date: Thu, 20 Nov 2003 17:13:54 -0600 Subject: [C++-sig] threading problem In-Reply-To: <16317.13136.459334.144952@gohan.cs.wisc.edu> References: <16317.13136.459334.144952@gohan.cs.wisc.edu> Message-ID: <20031120231354.GA1854@upl.cs.wisc.edu> On Thu, Nov 20, 2003 at 03:34:08PM -0600, manderso at cs.wisc.edu wrote: > > I've been using Boost.Python in my research work for about 6 months > now, and I've just recently bumped into a problem with threading > during PyFinalize. It has me confused, and I'm not entirely sure what > path to pursue in trying to debug it. I don't expect anyone to be > able to solve the problem from the information herein, but I'm hoping > that someone will have an intuition on what *might* be the problem; > candidates that I should try to track down. Long time no see :) I have admittedly not read your whole mail, but I believe there is a known problem with calling PyFinalize when using boost::python. I'm sure there's something in the archives about it. -Adam From Benjamin.Golinvaux at euresys.com Fri Nov 21 12:22:26 2003 From: Benjamin.Golinvaux at euresys.com (Benjamin Golinvaux) Date: Fri, 21 Nov 2003 12:22:26 +0100 Subject: [C++-sig] Newbie : build & return a new list Message-ID: Hello I am creating a function like this : PyObject* testCreateList() { ... PyObject* newList = PyList_New(...); ... return newList; } can I assume that if I wrap it that way : def("testCreateList", testCreateList) Then will it behave correctly wrt references, i.e. is doing this : myList = myTestModule.testCreateList() the same as myList = [ .... ] ? or do I need to use the manage_new_object call policy ? I must say I don't understand when manage_new_object needs to be used. Also, and this is unrelated, is there a nicer way to create a list using boost ? I hope I'm not bothering you with my ultrabasic questions. If there is some example code I can read to help me going from the very simple tutorial to something more complex, I'd be glad to read it ! Thank you very much Benjamin -----Message d'origine----- De : c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] De la part de Adam Hupp Envoy? : vendredi 21 novembre 2003 0:14 ? : Development of Python/C++ integration Objet : Re: [C++-sig] threading problem On Thu, Nov 20, 2003 at 03:34:08PM -0600, manderso at cs.wisc.edu wrote: > > I've been using Boost.Python in my research work for about 6 months > now, and I've just recently bumped into a problem with threading > during PyFinalize. It has me confused, and I'm not entirely sure what > path to pursue in trying to debug it. I don't expect anyone to be > able to solve the problem from the information herein, but I'm hoping > that someone will have an intuition on what *might* be the problem; > candidates that I should try to track down. Long time no see :) I have admittedly not read your whole mail, but I believe there is a known problem with calling PyFinalize when using boost::python. I'm sure there's something in the archives about it. -Adam _______________________________________________ C++-sig mailing list C++-sig at python.org http://mail.python.org/mailman/listinfo/c++-sig **************** The information contained in this message or any of its attachments may be privileged and confidential and intended for the exclusive use of the addressee. If you are not the addressee any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited. If you have received this transmission by error please notify the sender immediately and then delete this email. EURESYS shall not be liable for any loss of or damage to revenues, profits, goodwill, data, information systems or other special, incidental, indirect, consequential or punitive damages of any kind arising in connection with the use of information contained in this mail or its attachments. Email transmission cannot be guaranteed to be secure or error free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore is in no way liable for any errors or omissions in the content of this message, which may arise as a result of email transmission. If verification is required, please request a hard copy. Please note that neither EURESYS, nor the sender accepts any responsibility for viruses and it is your responsibility to scan attachments (if any). **************** From dave at boost-consulting.com Fri Nov 21 13:33:31 2003 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 21 Nov 2003 07:33:31 -0500 Subject: [C++-sig] Re: Newbie : build & return a new list References: Message-ID: "Benjamin Golinvaux" writes: > Hello > > I am creating a function like this : > > PyObject* testCreateList() > { > ... > PyObject* newList = PyList_New(...); > ... > return newList; > } Don't do that; use boost::python::list instead: #include using namespace boost::python; list testCreateList() { list newList; ... return newList; }; > can I assume that if I wrap it that way : > > def("testCreateList", testCreateList) > > Then will it behave correctly wrt references, > i.e. is doing this : > > myList = myTestModule.testCreateList() > > the same as > > myList = [ .... ] > > ? > > or do I need to use the manage_new_object call policy ? > I must say I don't understand when manage_new_object needs > to be used. It's used when you are returning some object you've allocated with operator new and which would otherwise be leaked. > Also, and this is unrelated, is there a nicer way to create > a list using boost ? See above ;-) > I hope I'm not bothering you with my ultrabasic questions. > If there is some example code I can read to help me going > from the very simple tutorial to something more complex, > I'd be glad to read it ! http://www.boost.org/libs/python/test/list.cpp http://www.boost.org/libs/python/test/list.py might help a bit. -- Dave Abrahams Boost Consulting www.boost-consulting.com From jonw at mindless.com Sat Nov 22 00:48:04 2003 From: jonw at mindless.com (Jonathan Warrington) Date: Fri, 21 Nov 2003 16:48:04 -0700 Subject: [C++-sig] Exposing C++ objects to Python at runtime Message-ID: I'm working on writing a generic interface for scripting, so far I have a simple javascript implementation, and a very simple python implementation. What I'm looking for, is there any way to register c++ classes / objects at runtime? What I'd like to be able to do, is pass a string, and pointers (object, and function) into my interface which would then register them at runtime (dynamically)? It looks quite possible for just straight functions, but was wondering if anyone had done something similar, or had any suggestions on how to do it? Thanks Jon From dave at boost-consulting.com Sat Nov 22 13:57:35 2003 From: dave at boost-consulting.com (David Abrahams) Date: Sat, 22 Nov 2003 07:57:35 -0500 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime References: Message-ID: Jonathan Warrington writes: > I'm working on writing a generic interface for scripting, so far I > have a simple javascript implementation, and a very simple python > implementation. > > What I'm looking for, is there any way to register c++ classes / > objects at runtime? What I'd like to be able to do, is pass a string, > and pointers (object, and function) into my interface which would then > register them at runtime (dynamically)? It looks quite possible for > just straight functions, but was wondering if anyone had done > something similar, or had any suggestions on how to do it? Boost.Python already does that. Your module initialization function executes at runtime. -- Dave Abrahams Boost Consulting www.boost-consulting.com From RaoulGough at yahoo.co.uk Sun Nov 23 12:01:38 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Sun, 23 Nov 2003 11:01:38 +0000 Subject: [C++-sig] Re: Newbie : fastest way of sending floats References: <16316.64229.451337.394451@gull.eos.ubc.ca> Message-ID: Philip Austin writes: > Benjamin Golinvaux writes: > > > > I am not looking for the cleanest code, but for the FASTEST way > > to pass the array of floats. I am willing to use the raw C api if > > needed. > > The fastest way to pass an array of floats is to use Numerical > Python (http://www.pfdubois.com/numpy). Boost supports conversions > between numpy (and its eventual successor, numarray) and python. > Here's an example of a wrapper for a spline interpolator, which also > makes use of a boost/numpy support library available at > http://www.eos.ubc.ca/research/clouds/num_util.html > > py::numeric::array splinewrap(py::numeric::array x, py::numeric::array y, > double yp1, double ypn) > { > nbpl::check_rank(x,1); > nbpl::check_type(x,PyArray_DOUBLE); > int xsize=nbpl::size(x); > nbpl::check_rank(y,1); > nbpl::check_type(y,PyArray_DOUBLE); > int ysize=nbpl::size(y); > assert(xsize==ysize); > double* xptr=(double*) nbpl::data(x); > double* yptr=(double*) nbpl::data(y); > py::numeric::array y2=nbpl::makeNum(ysize, PyArray_DOUBLE); > double* y2ptr=(double*) nbpl::data(y2); > spline(xptr,yptr,ysize,yp1,ypn,y2ptr); > return y2; > } Another alternative would be to store the data in a C++ vector and access it from Python via the indexing suite (available in the CVS). From the looks of the above code, this would give you a more convenient interface, but there is an important performance trade-off to consider: every time you access the vector from Python, you go through the Boost.Python function dispatch code, which adds a significant overhead if the operation itself is very simple. It's not a problem when processing the entire vector in C++ via a single call from Python, but probably *is* a problem if you spend a lot of time handling or inserting single values from Python code. Here are some comparative performance results from my testing of the (indexing_v2) indexing suite: Operation on vector (sec) *Python list time (inverted) ========================= Fill: 1.95659923258 5.1706970443 Search: 0.0113099569917 0.0755311358728 (13.23957317) Reorder: 27.9347512044 7.83041287513 Sort: 0.153025035305 0.0575254278229 (17.3836169125) The test fills a vector, does some searches on it, scrambles the contents and then sorts the contents. The column at right shows the runtime relative to the same operations in pure Python using a Python list. As you can see, filling and reordering the vector (which handles values one at a time) from Python are 5 or 8 times slower, whereas the search and sort functions (which handle the whole vector in C++ via a single Python call) are 13 or 17 times faster. -- Raoul Gough. export LESS='-X' From nicodemus at esss.com.br Sun Nov 23 23:26:21 2003 From: nicodemus at esss.com.br (Nicodemus) Date: Sun, 23 Nov 2003 19:26:21 -0300 Subject: [C++-sig] tutorial html files out of date? In-Reply-To: <00da01c3a3f3$469d24f0$64646464@godzilla> References: <20031105193157.165.qmail@web20201.mail.yahoo.com> <3FA96C97.9010001@esss.com.br> <00da01c3a3f3$469d24f0$64646464@godzilla> Message-ID: <3FC1340D.3090001@esss.com.br> Joel de Guzman wrote: >Nicodemus wrote: > > >>Ralf W. Grosse-Kunstleve wrote: >> >> >> >>>Hi Joel and Bruno, >>> >>>The quickstart.txt file (in boost/libs/python/doc/tutorial/doc) seems to >>>contain much more material than is reflected in the html files in the same >>>directory. Is this something that we could fix before the 1.31 release? >>> >>> >>> >>Joel has the correctly configured quickdoc to generate the tutorial >>documentation... if Joel can't do it, I guess I can configure mine to >>handle the tutorial too (I think only the copyright needs to be changed). >> >> > >Thanks, I'd appreciate that a lot. Perhaps it's more Python savvy to >switch to ReST? I'm not sure. > > Ok, just commited the updated html files. Sorry everyone about the delay! Regards, Nicodemus. From joel at boost-consulting.com Mon Nov 24 16:30:57 2003 From: joel at boost-consulting.com (Joel de Guzman) Date: Mon, 24 Nov 2003 23:30:57 +0800 Subject: [C++-sig] tutorial html files out of date? References: <20031105193157.165.qmail@web20201.mail.yahoo.com> <3FA96C97.9010001@esss.com.br><00da01c3a3f3$469d24f0$64646464@godzilla> <3FC1340D.3090001@esss.com.br> Message-ID: <003601c3b29f$f9f82800$64646464@godzilla> Nicodemus wrote: > Joel de Guzman wrote: > Ok, just commited the updated html files. Sorry everyone about the delay! Man, you beat me to the punch! Thanks! -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net From jonw at mindless.com Mon Nov 24 18:03:01 2003 From: jonw at mindless.com (Jonathan Warrington) Date: Mon, 24 Nov 2003 10:03:01 -0700 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: References: Message-ID: <3FC239C5.2050103@mindless.com> David Abrahams wrote: > Jonathan Warrington writes: > > >>I'm working on writing a generic interface for scripting, so far I >>have a simple javascript implementation, and a very simple python >>implementation. >> >>What I'm looking for, is there any way to register c++ classes / >>objects at runtime? What I'd like to be able to do, is pass a string, >>and pointers (object, and function) into my interface which would then >>register them at runtime (dynamically)? It looks quite possible for >>just straight functions, but was wondering if anyone had done >>something similar, or had any suggestions on how to do it? > > > Boost.Python already does that. Your module initialization function > executes at runtime. > Hmm, I don't think I made what I was looking for quite clear enough, sorry. What I'd like to do, is register classes, and functions without using the Boost.Python macros, as I don't want to have Boost.Python dependencies in my other code. I want to keep those dependencies in an wrapper, and not expose Python or anything to the other developers. Hopefully this makes it a little more clear. I'm having trouble expressing what I want as I'm not sure of the correct terminology for what I'm trying to do. :( thanks Jon From jon at shirwin.com Mon Nov 24 18:03:37 2003 From: jon at shirwin.com (Jonathan Warrington) Date: Mon, 24 Nov 2003 10:03:37 -0700 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: References: Message-ID: <3FC239E9.90506@shirwin.com> David Abrahams wrote: > Jonathan Warrington writes: > > >>I'm working on writing a generic interface for scripting, so far I >>have a simple javascript implementation, and a very simple python >>implementation. >> >>What I'm looking for, is there any way to register c++ classes / >>objects at runtime? What I'd like to be able to do, is pass a string, >>and pointers (object, and function) into my interface which would then >>register them at runtime (dynamically)? It looks quite possible for >>just straight functions, but was wondering if anyone had done >>something similar, or had any suggestions on how to do it? > > > Boost.Python already does that. Your module initialization function > executes at runtime. > Hmm, I don't think I made what I was looking for quite clear enough, sorry. What I'd like to do, is register classes, and functions without using the Boost.Python macros, as I don't want to have Boost.Python dependencies in my other code. I want to keep those dependencies in an wrapper, and not expose Python or anything to the other developers. Hopefully this makes it a little more clear. I'm having trouble expressing what I want as I'm not sure of the correct terminology for what I'm trying to do. :( thanks Jon From jonw at mindless.com Mon Nov 24 18:03:22 2003 From: jonw at mindless.com (Jonathan Warrington) Date: Mon, 24 Nov 2003 10:03:22 -0700 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: References: Message-ID: <3FC239DA.4030401@mindless.com> David Abrahams wrote: > Jonathan Warrington writes: > > >>I'm working on writing a generic interface for scripting, so far I >>have a simple javascript implementation, and a very simple python >>implementation. >> >>What I'm looking for, is there any way to register c++ classes / >>objects at runtime? What I'd like to be able to do, is pass a string, >>and pointers (object, and function) into my interface which would then >>register them at runtime (dynamically)? It looks quite possible for >>just straight functions, but was wondering if anyone had done >>something similar, or had any suggestions on how to do it? > > > Boost.Python already does that. Your module initialization function > executes at runtime. > Hmm, I don't think I made what I was looking for quite clear enough, sorry. What I'd like to do, is register classes, and functions without using the Boost.Python macros, as I don't want to have Boost.Python dependencies in my other code. I want to keep those dependencies in an wrapper, and not expose Python or anything to the other developers. Hopefully this makes it a little more clear. I'm having trouble expressing what I want as I'm not sure of the correct terminology for what I'm trying to do. :( thanks Jon From jon at shirwin.com Mon Nov 24 18:03:37 2003 From: jon at shirwin.com (Jonathan Warrington) Date: Mon, 24 Nov 2003 10:03:37 -0700 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: References: Message-ID: <3FC239E9.90506@shirwin.com> David Abrahams wrote: > Jonathan Warrington writes: > > >>I'm working on writing a generic interface for scripting, so far I >>have a simple javascript implementation, and a very simple python >>implementation. >> >>What I'm looking for, is there any way to register c++ classes / >>objects at runtime? What I'd like to be able to do, is pass a string, >>and pointers (object, and function) into my interface which would then >>register them at runtime (dynamically)? It looks quite possible for >>just straight functions, but was wondering if anyone had done >>something similar, or had any suggestions on how to do it? > > > Boost.Python already does that. Your module initialization function > executes at runtime. > Hmm, I don't think I made what I was looking for quite clear enough, sorry. What I'd like to do, is register classes, and functions without using the Boost.Python macros, as I don't want to have Boost.Python dependencies in my other code. I want to keep those dependencies in an wrapper, and not expose Python or anything to the other developers. Hopefully this makes it a little more clear. I'm having trouble expressing what I want as I'm not sure of the correct terminology for what I'm trying to do. :( thanks Jon From olivier.ravard at novagrid.com Mon Nov 24 19:33:34 2003 From: olivier.ravard at novagrid.com (Olivier Ravard) Date: 24 Nov 2003 19:33:34 +0100 Subject: [C++-sig] numeric::array howto Message-ID: <1069698814.2044.23.camel@trantor.univ-rennes1.fr> Hi , I want to write an interface of a given library for python and my problem is to convert internal vectors (like standards C vectors) to numeric::array. After hundred of tests, nothing works. Is there examples which show how to use numeric::array ? My problems are : - to create a numeric::array of a given size (which is known at the runtime) - to acces the number of elements of a numeric::array (v.nelements() doesn't work) - to acces to the data pointer for a memcpy. Sorry if it is an FAQ. Thanks. Olivier Ravard [image] [image] [image] NovaGrid S.A. olivier.ravard at novagrid.com WEB : http://www.novagrid.com TEL/FAX : 02 23 23 62 32 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: petitlogo.gif Type: image/gif Size: 2078 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: rule-blue-right.png Type: image/png Size: 207 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: transparent.png Type: image/png Size: 144 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: rule-blue-center.png Type: image/png Size: 160 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: rule-blue-left.png Type: image/png Size: 207 bytes Desc: not available URL: From s_sourceforge at nedprod.com Mon Nov 24 18:46:55 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Mon, 24 Nov 2003 17:46:55 -0000 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: <3FC239DA.4030401@mindless.com> References: Message-ID: <3FC2440F.5268.334BD5E0@localhost> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 24 Nov 2003 at 10:03, Jonathan Warrington wrote: > > Boost.Python already does that. Your module initialization function > > executes at runtime. > > Hmm, I don't think I made what I was looking for quite clear enough, > sorry. What I'd like to do, is register classes, and functions > without using the Boost.Python macros, as I don't want to have > Boost.Python dependencies in my other code. I want to keep those > dependencies in an wrapper, and not expose Python or anything to the > other developers. > > Hopefully this makes it a little more clear. I'm having trouble > expressing what I want as I'm not sure of the correct terminology for > what I'm trying to do. :( That's easy - you hatch out all the boost.python and python stuff into its own DLL. If you want an example, http://tnfox.sourceforge.net/ provides a TnFOX C++ library with no python knowledge and a wrapper DLL called TnFOX.pyd which provides python bindings for the C++ library. Cheers, Niall -----BEGIN PGP SIGNATURE----- Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 iQA/AwUBP8JED8EcvDLFGKbPEQKiDgCgnkb3XoIvY8odBloMYJ4TWnzVGdkAmweF otYkPUzvAnTdI39h6zTr2JO1 =tzoL -----END PGP SIGNATURE----- From rwgk at yahoo.com Mon Nov 24 22:13:12 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Mon, 24 Nov 2003 13:13:12 -0800 (PST) Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: <3FC239E9.90506@shirwin.com> Message-ID: <20031124211312.89915.qmail@web20211.mail.yahoo.com> --- Jonathan Warrington wrote: > Hmm, I don't think I made what I was looking for quite clear enough, > sorry. What I'd like to do, is register classes, and functions without > using the Boost.Python macros, as I don't want to have Boost.Python > dependencies in my other code. I want to keep those dependencies in an > wrapper, and not expose Python or anything to the other developers. That's what Boost.Python is designed for: non-intrusive wrapping. Macros are not used very much. Most of the work is done with templates. I am afraid I still don't know what your actual question is. Did you already work through some simple examples? The tutorial is a very good starting point. Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From jon at shirwin.com Mon Nov 24 23:17:28 2003 From: jon at shirwin.com (Jonathan Warrington) Date: Mon, 24 Nov 2003 15:17:28 -0700 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: <20031124211312.89915.qmail@web20211.mail.yahoo.com> References: <3FC239E9.90506@shirwin.com> <20031124211312.89915.qmail@web20211.mail.yahoo.com> Message-ID: Ralf W. Grosse-Kunstleve wrote: > > That's what Boost.Python is designed for: non-intrusive wrapping. Macros are > not used very much. Most of the work is done with templates. > > I am afraid I still don't know what your actual question is. Did you already > work through some simple examples? The tutorial is a very good starting point. > > Ralf Yes I've looked at the tutorial, and all the examples use the macro BOOST_PYTHON_MODULE() which means the classes that will be scriptable will have to import the Boost.Python headers, and be compiled against Python. I want to have all my scriptable classes not need to know anything about any scripting languages, just import my scripting header (which also doesn't include Boost.Python) which has generic looking interface functions for execution, and registering functions and classes as being scriptable, and a dll which contains that actual implementations. For example (I know this isn't a javascript forum but it's an example) I also have a javascript dll implementing the same interface which for the "register function" function will take a name string (what it'll called in the script) and a function pointer (the function to be called.) So there is nothing language specific in the interface but the dll does parameter conversions between the javascript types, and c++ types. I've been sidetracked with other work today, but just looking through the straight Python C API I think I can get functions working like I have them working in javascript, but I would like to be able to register classes as well. The vague start of the interface is below, the idea is to be able to create dlls that implement the interface, so that if we want to change scripting languages for another project all we need to do, is throw a different dll in there, and then write the scripts in a new language. All the rest of the pieces of the system that register scriptable pieces don't even need to know anythings changed, as they still call the same functions to register scriptable components. //Script function takes an arg count, an arg array, and returns a value typedef void (*SCRIPT_FUNCTION)( int, ScriptVal**, ScriptVal* ); struct SW_ScriptEngine{ virtual void initialize() = 0; virtual void release() = 0; virtual ScriptVal* executeScript(String script) = 0; virtual bool registerFunction(String name, SCRIPT_FUNCTION func, String moduleName) = 0; }; From rwgk at yahoo.com Mon Nov 24 23:37:02 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Mon, 24 Nov 2003 14:37:02 -0800 (PST) Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: Message-ID: <20031124223702.24216.qmail@web20202.mail.yahoo.com> --- Jonathan Warrington wrote: > Yes I've looked at the tutorial, and all the examples use the macro > BOOST_PYTHON_MODULE() which means the classes that will be scriptable > will have to import the Boost.Python headers, and be compiled against > Python. Why would that be? You only have to compile the wrapper code using the Boost.Python headers (and with that the Python headers). your_wrapper.cpp: #include // first to meet a Python requirement #include BOOST_PYTHON_MODULE(foo) { boost::python::class_("your_class_bar"); } Compile and link against your_library.a or your_library.so. Look at the bjam toolsets to see how exactly it is done on each of the of platforms that Boost.Python was tested under (many). Ralf __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ From RaoulGough at yahoo.co.uk Mon Nov 24 23:54:00 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Mon, 24 Nov 2003 22:54:00 +0000 Subject: [C++-sig] indexing_v2 status update Message-ID: Here's a status report on the indexing_v2 work I've been doing: o I've improved the handling for containers of shared_ptr's, so that sorting and searching automatically do the right indirection. o Fixed various layout and naming convention issues o container_proxy is now strongly exception safe (commit or rollback) o The container_proxy Generator parameter now works even on MSVC6 o I've added a Flags parameter to allow expensive features (in terms of object code size) to be selectively disabled. o I've added convenience templates for use without partial template specialization support (vector_suite, map_suite, etc.) These last two points bring the interface a little closer to what Joel de Guzman had originally, although the flags that he used were passed separately as individual bool parameters instead of as flag bits. He certainly wasn't kidding about the extra effort in supporting MSVC6. So as far as I know, there is no outstanding coding work remaining for the current level of functionality. I'm now updating the documentation to reflect the recent changes, and then the suite, in my opinion, will be ready for release. One possible extension I've been thinking about, as suggested by Ralf W. Grosse-Kunstleve, is the idea of allowing construction of a container from a Python iterable object: e.g. v = Vector ([1,2,3]) The ideal way to do it would be to massage the single input parameter into two C++ iterators that could be passed to the templated vector constructor, but I haven't looked far enough into the constructor dispatching internals to know how to do this, or even if it is possible. The problem, AFAICS, would be knowing when to select that overload of the constructor and when not to, and how/where to insert the necessary code to create the two iterators from the single Python object. Any advice would be appreciated. This might also be significant for another of Ralf's suggestions - pickling support. So I have two loosely related questions - what do people thing about including the current indexing_v2 suite in release 1.31, and should I try adding the iterator-based constructor support? -- Raoul Gough. export LESS='-X' From jon at shirwin.com Tue Nov 25 00:01:20 2003 From: jon at shirwin.com (Jonathan Warrington) Date: Mon, 24 Nov 2003 16:01:20 -0700 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: <20031124223702.24216.qmail@web20202.mail.yahoo.com> References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> Message-ID: Ah, ok I think I see where the communication problem was now. What I was wanting to do, was have it so that my other components would only know of that scripting engine interface, and use that to register themselves at runtime when they are created, and therefore if my XYZ class changes all I have to do is recompile that. Not have to generate new Boost.Python registration code, and recompile that wrapper. So, App Starts App creates an instance of Scripting Engine App creates an instance of class XYZ App passes scripting engine to XYZ->Init() XYZ registers what it wants to be scriptable as scriptable So, if I want to use javascript instead, I tell App to create a javascript engine instead, and then nothing else would need to change except the scripts being called. No need to create new wrapper code. Does that make more sense as to what I'm wanting to be able to do? I'm assuming that it'd require certain restrictions on what can be registered, like the way I was doing the functions, where you can only register a specific function prototype, as long as it's not too restrictive, that's fine. Jon Ralf W. Grosse-Kunstleve wrote: > --- Jonathan Warrington wrote: > >>Yes I've looked at the tutorial, and all the examples use the macro >>BOOST_PYTHON_MODULE() which means the classes that will be scriptable >>will have to import the Boost.Python headers, and be compiled against >>Python. > > > Why would that be? You only have to compile the wrapper code using the > Boost.Python headers (and with that the Python headers). > > your_wrapper.cpp: > > #include // first to meet a Python requirement > #include > > BOOST_PYTHON_MODULE(foo) > { > boost::python::class_("your_class_bar"); > } > > Compile and link against your_library.a or your_library.so. Look at the bjam > toolsets to see how exactly it is done on each of the of platforms that > Boost.Python was tested under (many). > > Ralf > From dave at boost-consulting.com Tue Nov 25 01:31:25 2003 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 24 Nov 2003 19:31:25 -0500 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime References: <3FC239E9.90506@shirwin.com> <20031124211312.89915.qmail@web20211.mail.yahoo.com> Message-ID: Jonathan Warrington writes: > Ralf W. Grosse-Kunstleve wrote: >> That's what Boost.Python is designed for: non-intrusive >> wrapping. Macros are >> not used very much. Most of the work is done with templates. >> I am afraid I still don't know what your actual question is. Did you >> already >> work through some simple examples? The tutorial is a very good starting point. >> Ralf > > Yes I've looked at the tutorial, and all the examples use the macro > BOOST_PYTHON_MODULE() which means the classes that will be scriptable > will have to import the Boost.Python headers, and be compiled against > Python. Absolutely not. The wrapping code which uses the Boost.Python headers and is "compiled against" Python only needs the *declarations* of the classes being wrapped, not their definitions. Of course, you'll need to have an object file or library containing the definitions of the functions you're wrapping somewhere. > I want to have all my scriptable classes not need to know > anything about any scripting languages, Done. > just import my scripting > header (which also doesn't include Boost.Python) which has generic > looking interface functions for execution, and registering functions > and classes as being scriptable, and a dll which contains that actual > implementations. Not done. With Boost.Python you register your classes in a separate compilation unit from the rest of your code. You can even link your classes into a separate dynamic library so that they're not even in the same "link unit" with any Boost.Python code. > For example (I know this isn't a javascript forum but it's an example) > I also have a javascript dll implementing the same interface which for > the "register function" function will take a name string (what it'll > called in the script) and a function pointer (the function to be > called.) So there is nothing language specific in the interface but > the dll does parameter conversions between the javascript types, and > c++ types. > > I've been sidetracked with other work today, but just looking through > the straight Python C API I think I can get functions working like I > have them working in javascript, but I would like to be able to > register classes as well. > > The vague start of the interface is below, the idea is to be able to > create dlls that implement the interface, so that if we want to change > scripting languages for another project all we need to do, is throw a > different dll in there, and then write the scripts in a new > language. All the rest of the pieces of the system that register > scriptable pieces don't even need to know anythings changed, as they > still call the same functions to register scriptable components. > > //Script function takes an arg count, an arg array, and returns a value > typedef void (*SCRIPT_FUNCTION)( int, ScriptVal**, ScriptVal* ); > struct SW_ScriptEngine{ > virtual void initialize() = 0; > virtual void release() = 0; > virtual ScriptVal* executeScript(String script) = 0; > virtual bool registerFunction(String name, SCRIPT_FUNCTION func, > String moduleName) = 0; > }; Boost.Python doesn't work that way (and thank goodness!), so if you really are wedded to an interface like that one, I wish you good luck in your travels. I get the vague feeling that you're so used to working in a particular way that you're unable to see that Boost.Python would actually serve your needs, though I could be wrong. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Tue Nov 25 01:35:53 2003 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 24 Nov 2003 19:35:53 -0500 Subject: [C++-sig] Re: indexing_v2 status update References: Message-ID: Raoul Gough writes: > So I have two loosely related questions - what do people thing about > including the current indexing_v2 suite in release 1.31, 2 questions: a. Where can I browse the documentation? b. Where can I review the test code? > and should I try adding the iterator-based constructor support? IMO yes, but my opinion isn't strongly-held. -- Dave Abrahams Boost Consulting www.boost-consulting.com From RaoulGough at yahoo.co.uk Tue Nov 25 01:12:01 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Tue, 25 Nov 2003 00:12:01 +0000 Subject: [C++-sig] Re: indexing_v2 status update References: Message-ID: David Abrahams writes: > Raoul Gough writes: > >> So I have two loosely related questions - what do people thing about >> including the current indexing_v2 suite in release 1.31, > > 2 questions: > > a. Where can I browse the documentation? > > b. Where can I review the test code? Both are available on the indexing_v2 branch in libs/python, so you could just do an update -r indexing_v2 in that directory. The docco is then in libs/python/doc/v2/containers.html and the test code is in files like test__*.cpp and .py in libs/python/test/ Alternatively, the html-only portion of the documentation is available at: http://cvs.sourceforge.net/viewcvs.py/*checkout*/boost/boost/libs/python/doc/v2/Attic/containers.html?rev=1.1.2 I'm still working on some updates to this. > >> and should I try adding the iterator-based constructor support? > > IMO yes, but my opinion isn't strongly-held. I guess the real question is how to do it. I'll start looking into it a bit deeper, but I suspect I'll need some advice. Converting the Python iterable object to two C++ iterators isn't hard, but I don't know how to create the forwarding function and a sensible __iter__ overload that gets called (only) when appropriate. The problem is that there will be other container constructors that really do take just a single parameter, so how can the code decide whether to try one of them or whether to try making two C++ iterators out of the parameter. For one thing, it would be good if the code could use the normal copy constructor if passed a wrapped C++ object of the same type, or at least use C++ iterators directly rather than going through a C++ wrapper of a Python iterator that is actually a C++ iterator (C++ -> Python -> C++ dispatching). I don't know how realistic that idea is. -- Raoul Gough. export LESS='-X' From jonw at mindless.com Tue Nov 25 01:12:15 2003 From: jonw at mindless.com (Jonathan Warrington) Date: Mon, 24 Nov 2003 17:12:15 -0700 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: References: <3FC239E9.90506@shirwin.com> <20031124211312.89915.qmail@web20211.mail.yahoo.com> Message-ID: David Abrahams wrote: > > Boost.Python doesn't work that way (and thank goodness!), so if you > really are wedded to an interface like that one, I wish you good luck > in your travels. > > I get the vague feeling that you're so used to working in a particular way > that you're unable to see that Boost.Python would actually serve your > needs, though I could be wrong. > I'm not sure if it's that I'm used to working a particular way, or not (been awhile since I've coded in c++). I guess I'd come up with what I thought was a good idea for a plugable system where all that was required to change scripting languages was to change the call to CreateScriptEngine. Also not needing the developers to know anything about the scripting language, and the scripting system didn't need to know anything about the other components being written. Maybe I haven't given Boost.Python a fair enough look, I'll try to look at it without my preconceived notions of what I want, tommorrow. Thanks for all your help. Jon From RaoulGough at yahoo.co.uk Tue Nov 25 01:28:48 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Tue, 25 Nov 2003 00:28:48 +0000 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> Message-ID: Jonathan Warrington writes: > Ah, ok I think I see where the communication problem was now. > > What I was wanting to do, was have it so that my other components > would only know of that scripting engine interface, and use that to > register themselves at runtime when they are created, and therefore if > my XYZ class changes all I have to do is recompile that. Not have to > generate new Boost.Python registration code, and recompile that > wrapper. > > So, > App Starts > App creates an instance of Scripting Engine > App creates an instance of class XYZ > App passes scripting engine to XYZ->Init() > XYZ registers what it wants to be scriptable as scriptable Well, I don't know how realistic this is. IIUC, you want some kind of an abstract interface that allows you to add new functions, object types and methods to various scripting engines. In this way, your classes can expose themselves to any of the engines, while having compile-time dependencies only on the abstract interface. So consider the following: >>> //Script function takes an arg count, an arg array, and returns a >>> //value >>> typedef void (*SCRIPT_FUNCTION)( int, ScriptVal**, ScriptVal* ); >>> struct SW_ScriptEngine{ >>> virtual void initialize() = 0; >>> virtual void release() = 0; >>> virtual ScriptVal* executeScript(String script) = 0; >>> virtual bool registerFunction(String name, SCRIPT_FUNCTION >>> func, String moduleName) = 0; >>>}; class my_class { void function1(int); int function2() const; void register_self (SW_ScriptEngine *eng_ptr) { eng_ptr->registerFunction (&function1); eng_ptr->registerFunction (&function2); } }; Now the type of function1 is "void (my_class::*)(int)" and the type of function2 is "int (my_class::*)() const". How is registerFunction going to be able to deal with those member functions (and all possible others)? That's before you look at registering constructors, virtual functions and so on - in fact, all of the issues that Boost.Python already deals with in its own way. > > So, if I want to use javascript instead, I tell App to create a > javascript engine instead, and then nothing else would need to change > except the scripts being called. No need to create new wrapper code. > > Does that make more sense as to what I'm wanting to be able to do? > I'm assuming that it'd require certain restrictions on what can be > registered, like the way I was doing the functions, where you can only > register a specific function prototype, as long as it's not too > restrictive, that's fine. Separation of model, view and controller is all I can suggest (as others have already implicity done). Your XYZ classes are your model of the world, you create a script-enabled "view" on them in separate code, and control it from the scripts. Naturally, the view must be updated to reflect changes in the model. -- Raoul Gough. export LESS='-X' From dave at boost-consulting.com Tue Nov 25 02:36:22 2003 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 24 Nov 2003 20:36:22 -0500 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime References: <3FC239E9.90506@shirwin.com> <20031124211312.89915.qmail@web20211.mail.yahoo.com> Message-ID: Jonathan Warrington writes: > David Abrahams wrote: >> Boost.Python doesn't work that way (and thank goodness!), so if you >> really are wedded to an interface like that one, I wish you good luck >> in your travels. >> I get the vague feeling that you're so used to working in a >> particular way >> that you're unable to see that Boost.Python would actually serve your >> needs, though I could be wrong. >> > > I'm not sure if it's that I'm used to working a particular way, or not > (been awhile since I've coded in c++). I guess I'd come up with what > I thought was a good idea for a plugable system where all that was > required to change scripting languages was to change the call to > CreateScriptEngine. Also not needing the developers to know anything > about the scripting language, and the scripting system didn't need to > know anything about the other components being written. > > Maybe I haven't given Boost.Python a fair enough look, I'll try to > look at it without my preconceived notions of what I want, > tommorrow. Thanks for all your help. I think, now that I understand what you're doing, that Boost.Python won't do what you want. Your idea is a good one, but interestingly, it appears to still be intrusive. Your classes may not need to know about Python or Boost.Python, but they do (according to you) need to know about your scripting system interface. Boost.Python lets you wrap classes that know nothing of scripting or Python. The Boost.Python C++ wrapping interface doesn't, in principle, *need* to know about Python - more could be done through runtime polymorphism, to isolate the compilation of wrappers from specific target languages, but it would be costly in the size and speed of extension modules. I think the only way this makes sense is if you need to link support for multiple languages into the same library or application. Even then, I might be inclined to use a templated (compile-time polymorphic) interface to generate relatively fast-and-small wrappers. It doesn't seem as though there's a lot to be gained by having a single copy of the wrapping logic for a class, since it will end up doing many, many dynamic dispatches. The boost-langbinding project is trying to address the question of how to unify the implementations and syntax of Boost.Python and Luabind. It would be very interesting to think about how a "write the wrapping code once" system might come out of it. -- Dave Abrahams Boost Consulting www.boost-consulting.com From rwgk at yahoo.com Tue Nov 25 02:39:02 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Mon, 24 Nov 2003 17:39:02 -0800 (PST) Subject: [C++-sig] Re: indexing_v2 status update In-Reply-To: Message-ID: <20031125013902.27858.qmail@web20205.mail.yahoo.com> --- Raoul Gough wrote: > >> and should I try adding the iterator-based constructor support? > > > > IMO yes, but my opinion isn't strongly-held. I think it is really important. > I guess the real question is how to do it. I'll start looking into it > a bit deeper, but I suspect I'll need some advice. Converting the > Python iterable object to two C++ iterators isn't hard, but I don't > know how to create the forwarding function and a sensible __iter__ > overload that gets called (only) when appropriate. The problem is that > there will be other container constructors that really do take just a > single parameter, so how can the code decide whether to try one of > them or whether to try making two C++ iterators out of the parameter. > > For one thing, it would be good if the code could use the normal copy > constructor if passed a wrapped C++ object of the same type, or at > least use C++ iterators directly rather than going through a C++ > wrapper of a Python iterator that is actually a C++ iterator (C++ -> > Python -> C++ dispatching). I don't know how realistic that idea is. This sounds overly complicated to me. I believe you could get the job done in relatively little time if you started with the container conversions header from the scitbx: http://cvs.sourceforge.net/viewcvs.py/cctbx/scitbx/include/scitbx/boost_python/container_conversions.h?rev=1.10&view=auto Put the code in another namespace, remove to_tuple and the tuple_mapping* convenience templates. Instantiate from_python_sequence<> when a vector-style container is wrapped. Also automatically wrap the copy constructor of that vector-style container. My meta-programming is not very advanced. Therefore I dare suggesting that the from_python_sequence<> template and the copy consturctor should only be instantiated if the user supplies one of the policies (call them FromPythonSequencePolicies). Don't get side-tracked by performance considerations. If someone constructs a container from Python slow performance is expected. What counts for the Python programmer is convenience and flexibility. If you make it easy to wrap C++ containers users can quickly implement time-critical functions in C++. Ralf __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ From dave at boost-consulting.com Tue Nov 25 04:38:45 2003 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 24 Nov 2003 22:38:45 -0500 Subject: [C++-sig] Re: indexing_v2 status update References: Message-ID: Raoul Gough writes: > David Abrahams writes: > >> Raoul Gough writes: >> >>> So I have two loosely related questions - what do people thing about >>> including the current indexing_v2 suite in release 1.31, >> >> 2 questions: >> >> a. Where can I browse the documentation? >> >> b. Where can I review the test code? > > Both are available on the indexing_v2 branch in libs/python, so you > could just do an update -r indexing_v2 in that directory. The docco is > then in libs/python/doc/v2/containers.html and the test code is in > files like test__*.cpp and .py in libs/python/test/ > > Alternatively, the html-only portion of the documentation is available > at: > > http://cvs.sourceforge.net/viewcvs.py/*checkout*/boost/boost/libs/python/doc/v2/Attic/containers.html?rev=1.1.2 "Safety" is missing from the design goals. Was that not one of the goals? I was under the impression that this: Note: the suite hasn't yet been tested on a compiler without partial template specialization support. If you have any results with such a compiler (good or bad) please report them on the mailing list for the Python C++-SIG. is no longer true. Wrong? I don't like the use of abbrevs. like "algo_...." I'm concerned that iterator_range may duplicate functionality somewhere else in Boost. An iterator_range class has recently been discussed on the main list as part of a library review. Overall, after just a quick look, I'm impressed, though I don't think the documentation gives a clear picture of how to use all this stuff yet. I wouldn't be reeady to approve it until I can read some more complete docs, so that I can understand the whole enchilada. Internal policies detail The container_suite object typically adds more than one function to the Python class, and not all of those functions can, or should, use exactly the same policies. For instance, the Python len method, if provided, should always return its result by value. The library actually uses up to three different sets of policies derived from the one provided to the with_policies function. These are: The supplied policies, unchanged The supplied precall policy only, using default_call_policies for result conversion. The supplied precall policies, and the supplied result conversion policies applied to each element of a returned list You just drop any postcall component of supplied policies? Rationale? The "Extending and customizing" section isn't understandable, since you haven't even introduced the components you're discussing at that point. Is it important to make reference to def_visitor, or is that merely an implementation detail? If the latter, it should be dropped as a distraction. 2] Note that Algorithms and ContainerTraits don't represent individual templates in the diagram, but groups of related templates. For instance, there are actually templates called list_algorithms and assoc_algorithms, among others. Don't you mean that they represent concepts? "lessthan_comparable" should be "less_than_comparable". Why "visitor_helper", and not operator()? There's no description of what visitor_helper is for. has_copyable_iter can be determined by looking at iterator_traits::iterator_category (or better, iterator_traversal::type). The user shouldn't supply it. I don't understand is_reorderable. How is that different from is_convertible< iterator_traits::iterator_category , forward_iterator_tag >::value && is_non_const_lvalue_iterator::value && is_assignable::value ?? I realize we don't have is_assignable, but shouldn't you phrase this in terms of something fundamental like value_type assignability? We can ask all the other questions (see boost/iterator/is_lvalue_iterator.hpp). Once you tell the suite that "has_find" don't you also need to tell it how (i.e. via member function or otherwise)? The use of static constants in ContainerTraits is unattractive to me, because it's not particularly extensible. What about asking the user to provide an mpl::set of the property type tags: typedef mpl::set capabilities; or something? You actually have the name "value_traits_" in a table. Intended? ^ Why would you ask the user to supply the Container's size_type and iterator instead of deducing them from the container itself? I am a bit concerned about how reference documentation for various components and headers is grouped all into one file, containers.html. I don't believe the precedent set by the pickling support in this regard was a good one. We have a semi-coherent [;-)] reference manual organization - why should there be any supported public headers missing from it? IMO it would be better (though not a showstopper) if containers.html were just narrative/tutorial, with pointers to the hard-core reference material. I'd also like to hear if Joel has any concerns. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Tue Nov 25 04:52:29 2003 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 24 Nov 2003 22:52:29 -0500 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> Message-ID: Raoul Gough writes: > Jonathan Warrington writes: > >> Ah, ok I think I see where the communication problem was now. >> >> What I was wanting to do, was have it so that my other components >> would only know of that scripting engine interface, and use that to >> register themselves at runtime when they are created, and therefore if >> my XYZ class changes all I have to do is recompile that. Not have to >> generate new Boost.Python registration code, and recompile that >> wrapper. >> >> So, >> App Starts >> App creates an instance of Scripting Engine >> App creates an instance of class XYZ >> App passes scripting engine to XYZ->Init() >> XYZ registers what it wants to be scriptable as scriptable > > Well, I don't know how realistic this is. It can be done, and something which provides language-independent wrapping syntax is surely worthwhile. I don't know if it's worthwhile to do it with runtime polymorphism in this way. > IIUC, you want some kind of > an abstract interface that allows you to add new functions, object > types and methods to various scripting engines. In this way, your > classes can expose themselves to any of the engines, while having > compile-time dependencies only on the abstract interface. > > So consider the following: > >>>> //Script function takes an arg count, an arg array, and returns a >>>> //value >>>> typedef void (*SCRIPT_FUNCTION)( int, ScriptVal**, ScriptVal* ); >>>> struct SW_ScriptEngine{ >>>> virtual void initialize() = 0; >>>> virtual void release() = 0; >>>> virtual ScriptVal* executeScript(String script) = 0; >>>> virtual bool registerFunction(String name, SCRIPT_FUNCTION >>>> func, String moduleName) = 0; >>>>}; > > class my_class { > void function1(int); > int function2() const; > > void register_self (SW_ScriptEngine *eng_ptr) { > eng_ptr->registerFunction (&function1); > eng_ptr->registerFunction (&function2); > } > }; > > Now the type of function1 is "void (my_class::*)(int)" and the type of > function2 is "int (my_class::*)() const". How is registerFunction > going to be able to deal with those member functions (and all possible > others)? It's not that hard to imagine. registerFunction just needs to generate a scripting-language-independent wrapper around the member function which provides the means to invoke it and a way to get the arguments initialized... something like: struct function { virtual ~function() {} virtual std::size_t arity() = 0; virtual std::type_info const& result_type() = 0; virtual std::type_info const* const* arg_types() = 0; virtual void invoke( void* const* args_storage, void* result_storage) = 0; }; It's then the engine's job to line up the language specific converters for the types of the arguments and result and build a wrapper around *that*. In fact, now that I write it down it looks to me as though Boost.Python could be organized in roughly this way at little extra cost. Maybe in version 3... ;-> The biggest problem is that there are interfaces which really do require you to touch language-specific components in order to bind them well. -- Dave Abrahams Boost Consulting www.boost-consulting.com From amrak132 at yahoo.com Tue Nov 25 07:30:03 2003 From: amrak132 at yahoo.com (a b) Date: Mon, 24 Nov 2003 22:30:03 -0800 (PST) Subject: [C++-sig] How to call spam bayes using c++ Message-ID: <20031125063003.63176.qmail@web20706.mail.yahoo.com> Hi, I would like to use the spam bayes implementation for some filtering purposes. I simply to want to pass a filename and get a score back. But I would like to do this using c++. Is there a c++ implementation of the same. If not can some please help me out --------------------------------- Do you Yahoo!? Free Pop-Up Blocker - Get it now -------------- next part -------------- An HTML attachment was scrubbed... URL: From olivier.ravard at novagrid.com Tue Nov 25 11:08:26 2003 From: olivier.ravard at novagrid.com (Olivier Ravard) Date: 25 Nov 2003 11:08:26 +0100 Subject: [C++-sig] num_util question Message-ID: <1069754906.2044.57.camel@trantor.univ-rennes1.fr> Hi, When trying to use the num_util and I have an ImportError : undefined symbol: PyArrayHandle Is someone have an idea ? Thanks. Olivier Ravard [image] [image] [image] NovaGrid S.A. olivier.ravard at novagrid.com WEB : http://www.novagrid.com TEL/FAX : 02 23 23 62 32 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: petitlogo.gif Type: image/gif Size: 2078 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: rule-blue-right.png Type: image/png Size: 207 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: transparent.png Type: image/png Size: 144 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: rule-blue-center.png Type: image/png Size: 160 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: rule-blue-left.png Type: image/png Size: 207 bytes Desc: not available URL: From RaoulGough at yahoo.co.uk Tue Nov 25 13:43:26 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Tue, 25 Nov 2003 12:43:26 +0000 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> Message-ID: David Abrahams writes: > Raoul Gough writes: > >> Jonathan Warrington writes: [snip] >>> App Starts >>> App creates an instance of Scripting Engine >>> App creates an instance of class XYZ >>> App passes scripting engine to XYZ->Init() >>> XYZ registers what it wants to be scriptable as scriptable >> >> Well, I don't know how realistic this is. > > It can be done, and something which provides language-independent > wrapping syntax is surely worthwhile. I don't know if it's worthwhile > to do it with runtime polymorphism in this way. Yes - the runtime polymorphism is exactly the thing whose feasibility I doubt. > >> IIUC, you want some kind of >> an abstract interface that allows you to add new functions, object >> types and methods to various scripting engines. In this way, your >> classes can expose themselves to any of the engines, while having >> compile-time dependencies only on the abstract interface. >> >> So consider the following: >> >>>>> //Script function takes an arg count, an arg array, and returns a >>>>> //value >>>>> typedef void (*SCRIPT_FUNCTION)( int, ScriptVal**, ScriptVal* ); >>>>> struct SW_ScriptEngine{ >>>>> virtual void initialize() = 0; >>>>> virtual void release() = 0; >>>>> virtual ScriptVal* executeScript(String script) = 0; >>>>> virtual bool registerFunction(String name, SCRIPT_FUNCTION >>>>> func, String moduleName) = 0; >>>>>}; >> >> class my_class { >> void function1(int); >> int function2() const; >> >> void register_self (SW_ScriptEngine *eng_ptr) { >> eng_ptr->registerFunction (&function1); >> eng_ptr->registerFunction (&function2); >> } >> }; >> >> Now the type of function1 is "void (my_class::*)(int)" and the type of >> function2 is "int (my_class::*)() const". How is registerFunction >> going to be able to deal with those member functions (and all possible >> others)? > > It's not that hard to imagine. registerFunction just needs to > generate a scripting-language-independent wrapper around the member > function which provides the means to invoke it and a way to get the > arguments initialized... something like: However, that implies detailed knowledge of the type of the member function which (AFAICS) would only be available via function template parameter deduction (and therefore impossible for a virtual function). Compile-time polymorphism would be a different matter, for instance every class that wants to register itself with a scripting engine could have a member function template like this: // ... template static void register_self (ScriptEngine &engine) { engine.template register_class(); // Or some such engine.register_nonstatic_memfn (function1); // ... } }; Might be handy I guess. -- Raoul Gough. export LESS='-X' From yakumoklesk at yahoo.es Mon Nov 24 14:22:26 2003 From: yakumoklesk at yahoo.es (yakumoklesk at yahoo.es) Date: Mon, 24 Nov 2003 14:22:26 +0100 Subject: [C++-sig] num_util question In-Reply-To: <1069754906.2044.57.camel@trantor.univ-rennes1.fr> Message-ID: <3FC21422.30054.1CB5AF3@localhost> > > When trying to use the num_util and I have an ImportError : > > undefined symbol: PyArrayHandle > > Is someone have an idea ? > > Thanks. > > Olivier Ravard > > > > > > > > NovaGrid S.A. > > olivier.ravard at novagrid.com > WEB : http://www.novagrid.com > TEL/FAX : 02 23 23 62 32 > > Please!! Dont't attach PNGs nor any other image files in your messages. Change your signature, whatever. From dave at boost-consulting.com Tue Nov 25 16:44:17 2003 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 25 Nov 2003 10:44:17 -0500 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> Message-ID: Raoul Gough writes: >>> Now the type of function1 is "void (my_class::*)(int)" and the type of >>> function2 is "int (my_class::*)() const". How is registerFunction >>> going to be able to deal with those member functions (and all possible >>> others)? >> >> It's not that hard to imagine. registerFunction just needs to >> generate a scripting-language-independent wrapper around the member >> function which provides the means to invoke it and a way to get the >> arguments initialized... something like: > > However, that implies detailed knowledge of the type of the member > function which (AFAICS) would only be available via function template > parameter deduction (and therefore impossible for a virtual > function). Of course. You do that part of the work on the scripting-language-independent side of the abstraction barrier. Just think about how Boost.Function + Boost.Bind makes a whole bunch of differently-typed callable things into the same type. > Compile-time polymorphism would be a different matter, for > instance every class that wants to register itself with a scripting > engine could have a member function template like this: > > // ... > template > static void register_self (ScriptEngine &engine) { > engine.template register_class(); // Or some such > engine.register_nonstatic_memfn (function1); > // ... > } > }; > > Might be handy I guess. I've been trying to say that you you *can*, in principle, still do this with a single ScriptEngine type, so that registration code gets compiled once, scripting-language-independently. I've also been trying to say that requiring coupling of the scripting engine registration into the classes being scripted is a mistake. -- Dave Abrahams Boost Consulting www.boost-consulting.com From RaoulGough at yahoo.co.uk Tue Nov 25 16:35:24 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Tue, 25 Nov 2003 15:35:24 +0000 Subject: [C++-sig] Re: indexing_v2 status update References: Message-ID: David Abrahams writes: > Raoul Gough writes: [snip] > "Safety" is missing from the design goals. Was that not one of the > goals? Well that's a tough one. For instance, using return_by_reference when returning a value held in a container is pretty dangerous (consider deletions or vector reallocations). On the other hand, I wouldn't like to rule it out as an option merely on that basis. Certainly the container_proxy component does backflips to try and prevent any dangers, so perhaps this needs some mention of safety? All it says at the moment is this: Provide an emulation of Python reference semantics for /values/ in vector-like containers. > > I was under the impression that this: > > Note: the suite hasn't yet been tested on a compiler without partial > template specialization support. If you have any results with such a > compiler (good or bad) please report them on the mailing list for > the Python C++-SIG. > > is no longer true. Wrong? Yes, this is out of date. > > I don't like the use of abbrevs. like "algo_...." You mean algo_selector? I can rename this to algorithm_selector if you'd prefer, I don't mind either way. > > I'm concerned that iterator_range may duplicate functionality > somewhere else in Boost. An iterator_range class has recently been > discussed on the main list as part of a library review. OK - I'll keep an eye out for this and replace it when/if boost gets its own implementation. > Overall, after just a quick look, I'm impressed, though I don't think > the documentation gives a clear picture of how to use all this stuff > yet. I wouldn't be reeady to approve it until I can read some more > complete docs, so that I can understand the whole enchilada. > > Internal policies detail > > The container_suite object typically adds more than one function to > the Python class, and not all of those functions can, or should, use > exactly the same policies. For instance, the Python len method, if > provided, should always return its result by value. The library > actually uses up to three different sets of policies derived from > the one provided to the with_policies function. These are: > > The supplied policies, unchanged > > The supplied precall policy only, using default_call_policies for > result conversion. > > The supplied precall policies, and the supplied result conversion > policies applied to each element of a returned list > > You just drop any postcall component of supplied policies? Rationale? The supplied postcall currently gets dropped completely for functions that return integers or void (e.g. __len__ and sort) on the assumption that it is only intended for use when returning container elements. For instance, you don't want to use return_internal_reference on the result of a call to container.size(). I'm not entirely happy with this aspect myself, particularly as it relates to the absent pop() method which would always need some kind of by-value policy. I've thought of a clean solution, which would be to require a CallPolicies "package" that contains typedefs and factory functions for various different CallPolicies that the suite requires. For example len_policies, element_policies, pop_policies or maybe a slightly different level of granularity. > > The "Extending and customizing" section isn't understandable, since > you haven't even introduced the components you're discussing at that > point. > > Is it important to make reference to def_visitor, or is that merely > an implementation detail? If the latter, it should be dropped as a > distraction. OK. > > 2] Note that Algorithms and ContainerTraits don't represent > individual templates in the diagram, but groups of related > templates. For instance, there are actually templates called > list_algorithms and assoc_algorithms, among others. > > Don't you mean that they represent concepts? Well that seems to be the Boost term for it. I'd be happier using it if you could point me to a definition of the term, so I can embed a hyperlink to the definition. I don't think everyone who uses the Python or indexing suite documentation will be familiar with it otherwise (I know I wasn't initially). > > "lessthan_comparable" should be "less_than_comparable". OK. > > Why "visitor_helper", and not operator()? Static function. > > There's no description of what visitor_helper is for. By gum, you're right. Well spotted. > > has_copyable_iter can be determined by looking at > iterator_traits::iterator_category (or better, > iterator_traversal::type). The user shouldn't supply it. I guess this needs some explanation in the documentation - there is an iterator_traits template that deduces many properties automatically (for instance, has_copyable_iter is indeed determined by iterator category). I'll add some documentation for the case that client code wants to use the template as a base class, although there is certainly no necessity for it to do so. > > I don't understand is_reorderable. How is that different from > > is_convertible< > iterator_traits::iterator_category > , forward_iterator_tag > >::value > && is_non_const_lvalue_iterator::value > && is_assignable::value > > ?? > > I realize we don't have is_assignable, but shouldn't you phrase this > in terms of something fundamental like value_type assignability? We > can ask all the other questions (see > boost/iterator/is_lvalue_iterator.hpp). The iterator traits template I mentioned above just uses is_mutable_ref (with an obvious is_mutable_ref implementation). This actually deduces the wrong answer for std::map and even std::set with some standard libraries, so I ended up overriding it manually in set_traits and map_traits. > > Once you tell the suite that "has_find" don't you also need to tell > it how (i.e. via member function or otherwise)? Yes indeed. The ContainerTraits and Algorithms have to work together on this - you can't have "has_find" true and then not provide an implementation of find, count and maybe index in your Algorithms. I suppose I should really document the exact requirements. Also, I've recently added two static member functions to the ValueTraits concept for the less_than and equal_to comparisons. This is where the automatic shared_ptr handling happens. It's not documented yet. > > The use of static constants in ContainerTraits is unattractive to me, > because it's not particularly extensible. What about asking the user > to provide an mpl::set of the property type tags: > > typedef mpl::set capabilities; > > or something? Looks like a good idea. I'll give this a go. > > You actually have the name "value_traits_" in a table. Intended? > ^ There is a template called value_traits, so the ContainerTraits member type is called value_traits_ (underscore at end). A bit lame I guess. > > Why would you ask the user to supply the Container's size_type and > iterator instead of deducing them from the container itself? The client could use one of the existing ContainerTraits templates as a base class and avoid the need for defining this explicitly (needs documenting, as noted above). On the other hand, it is also possible to interface the suite with a container that doesn't provide anything like an STL-style interface, by completely replacing the traits and algorithms templates. > > I am a bit concerned about how reference > documentation for various components and headers is grouped all into > one file, containers.html. I don't believe the precedent set by the > pickling support in this regard was a good one. We have a > semi-coherent [;-)] reference manual organization - why should there > be any supported public headers missing from it? IMO it would be > better (though not a showstopper) if containers.html were just > narrative/tutorial, with pointers to the hard-core reference material. Yes, I think this is inevitable, given the weaknesses you've identified. I guess I was trying to economize on documentation effort, but I suppose it needs to be more rigorous. > > I'd also like to hear if Joel has any concerns. Me too. Thanks for your comments so far - I'll work on them as part of the current updates I'm doing. -- Raoul Gough. export LESS='-X' From RaoulGough at yahoo.co.uk Tue Nov 25 16:48:10 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Tue, 25 Nov 2003 15:48:10 +0000 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> Message-ID: David Abrahams writes: > Raoul Gough writes: > >> However, that implies detailed knowledge of the type of the member >> function which (AFAICS) would only be available via function >> template parameter deduction (and therefore impossible for a >> virtual function). > > Of course. You do that part of the work on the > scripting-language-independent side of the abstraction barrier. Just > think about how Boost.Function > + Boost.Bind makes a whole bunch of differently-typed callable things > into the same type. [from David Abrahams' earlier post] >>> struct function >>> { >>> virtual ~function() {} >>> virtual std::size_t arity() = 0; >>> virtual std::type_info const& result_type() = 0; >>> virtual std::type_info const* const* arg_types() = 0; >>> virtual void invoke( >>> void* const* args_storage, void* result_storage) = 0; >>> }; Oh, I get it - so you'd have a virtual function in the abstract base class that accepts some kind of pointer-to-function object as an argument? Each scripting engine would then extract the necessary information from the function object instead of via template parameters. You'd probably still need template parameter deduction to generate the function object, but you would gain some decoupling from the actual registration code. > >> Compile-time polymorphism would be a different matter, for >> instance every class that wants to register itself with a scripting >> engine could have a member function template like this: >> >> // ... >> template >> static void register_self (ScriptEngine &engine) { >> engine.template register_class(); // Or some such >> engine.register_nonstatic_memfn (function1); >> // ... >> } >> }; >> >> Might be handy I guess. > > I've been trying to say that you you *can*, in principle, still do > this with a single ScriptEngine type, so that registration code gets > compiled once, scripting-language-independently. Given a certain amount of wrapper code to set up a "function descriptor" object, I assume. > > I've also been trying to say that requiring coupling of the scripting > engine registration into the classes being scripted is a mistake. Sure. I recommended separating them in an earlier post. -- Raoul Gough. export LESS='-X' From dave at boost-consulting.com Tue Nov 25 18:09:43 2003 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 25 Nov 2003 12:09:43 -0500 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> Message-ID: Raoul Gough writes: > David Abrahams writes: > >> Raoul Gough writes: >> >>> However, that implies detailed knowledge of the type of the member >>> function which (AFAICS) would only be available via function >>> template parameter deduction (and therefore impossible for a >>> virtual function). >> >> Of course. You do that part of the work on the >> scripting-language-independent side of the abstraction barrier. Just >> think about how Boost.Function >> + Boost.Bind makes a whole bunch of differently-typed callable things >> into the same type. > > [from David Abrahams' earlier post] >>>> struct function >>>> { >>>> virtual ~function() {} >>>> virtual std::size_t arity() = 0; >>>> virtual std::type_info const& result_type() = 0; >>>> virtual std::type_info const* const* arg_types() = 0; >>>> virtual void invoke( >>>> void* const* args_storage, void* result_storage) = 0; >>>> }; > > Oh, I get it - so you'd have a virtual function in the abstract base > class that accepts some kind of pointer-to-function object as an > argument? Each scripting engine would then extract the necessary > information from the function object instead of via template > parameters. You'd probably still need template parameter deduction to > generate the function object, Unless you want to do it the hard way, yeah ;-) > but you would gain some decoupling from the actual registration > code. Yeah. I can even imagine that this arrangement would speed up compile times... >> I've been trying to say that you you *can*, in principle, still do >> this with a single ScriptEngine type, so that registration code gets >> compiled once, scripting-language-independently. > > Given a certain amount of wrapper code to set up a "function > descriptor" object, I assume. Yup. -- Dave Abrahams Boost Consulting www.boost-consulting.com From jonw at mindless.com Tue Nov 25 17:26:09 2003 From: jonw at mindless.com (Jonathan Warrington) Date: Tue, 25 Nov 2003 09:26:09 -0700 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> Message-ID: >>I've also been trying to say that requiring coupling of the scripting >>engine registration into the classes being scripted is a mistake. > > > Sure. I recommended separating them in an earlier post. > Actually, now that I think about it, yes they should be separated, however, the reason I'd been thinking of doing that way, is that whoever was writing a new class could decide which parts to expose to the scripting engine. Although this can still be done, just in a separate file, and not as a direct piece of the class. Jon From christophe.pradal at cirad.fr Tue Nov 25 17:39:45 2003 From: christophe.pradal at cirad.fr (Christophe Pradal) Date: Tue, 25 Nov 2003 17:39:45 +0100 Subject: [C++-sig] Re: Extension DLLs nonfunctioning with MSVC 7.1 (beta) In-Reply-To: References: Message-ID: <3FC385D1.7090902@cirad.fr> Hello, I have the same problem with MSVC 6 SP5 and STLport and a recent boost on cvs. When i try to import my module, i have the following message File "", line 1, in ? ImportError: DLL load failed: Invalid access to memory location. Is Raoul solve is problem? Thanks. Christophe Pradal Raoul Gough a ?crit: >David Abrahams writes: > > > >>Raoul Gough writes: >> >> >> >>>When I build the Python tests with MSVC (7.1 beta, version 13.10.2292) >>>I get non-functioning DLLs. With a debug build, importing an extension >>>module into Python aborts silently, and with the release builds it >>>reports "ImportError: DLL load failed: Invalid access to memory >>>location." I'm reasonably sure this was working a couple of weeks ago. >>> >>> >[snip] > > >>It's working for me with vc7.1 release and a debug-python build: >> >> >[snip] > >Niall Douglas also reports that it works for him. I guess I must have >trashed something in my environment, so I'll have to track it down >locally. Thanks to you both for confirming this. > > > From dave at boost-consulting.com Tue Nov 25 18:04:37 2003 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 25 Nov 2003 12:04:37 -0500 Subject: [C++-sig] Re: indexing_v2 status update References: Message-ID: Raoul Gough writes: > David Abrahams writes: > >> Raoul Gough writes: > [snip] >> "Safety" is missing from the design goals. Was that not one of the >> goals? > > Well that's a tough one. For instance, using return_by_reference when > returning a value held in a container is pretty dangerous (consider > deletions or vector reallocations). There are supposed to be proxies which just store an index and do range checks. Is that what container_proxy is? > On the other hand, I wouldn't like > to rule it out as an option merely on that basis. Certainly the > container_proxy component does backflips to try and prevent any > dangers, so perhaps this needs some mention of safety? Yes. If that's the safe one, it should be the default, and safety was a major goal of Joel's original work. > All it says at > the moment is this: > > Provide an emulation of Python reference semantics for /values/ > in vector-like containers. > >> >> I was under the impression that this: >> >> Note: the suite hasn't yet been tested on a compiler without partial >> template specialization support. If you have any results with such a >> compiler (good or bad) please report them on the mailing list for >> the Python C++-SIG. >> >> is no longer true. Wrong? > > Yes, this is out of date. > >> >> I don't like the use of abbrevs. like "algo_...." > > You mean algo_selector? I can rename this to algorithm_selector if > you'd prefer, I don't mind either way. I prefer. >> Overall, after just a quick look, I'm impressed, though I don't think >> the documentation gives a clear picture of how to use all this stuff >> yet. I wouldn't be reeady to approve it until I can read some more >> complete docs, so that I can understand the whole enchilada. >> >> Internal policies detail >> >> The container_suite object typically adds more than one function to >> the Python class, and not all of those functions can, or should, use >> exactly the same policies. For instance, the Python len method, if >> provided, should always return its result by value. The library >> actually uses up to three different sets of policies derived from >> the one provided to the with_policies function. These are: >> >> The supplied policies, unchanged >> >> The supplied precall policy only, using default_call_policies for >> result conversion. >> >> The supplied precall policies, and the supplied result conversion >> policies applied to each element of a returned list >> >> You just drop any postcall component of supplied policies? Rationale? > > The supplied postcall currently gets dropped completely for functions > that return integers or void (e.g. __len__ and sort) on the assumption > that it is only intended for use when returning container > elements. For instance, you don't want to use > return_internal_reference on the result of a call to container.size(). You need to document the postcall behaviors and the rationale. >> 2] Note that Algorithms and ContainerTraits don't represent >> individual templates in the diagram, but groups of related >> templates. For instance, there are actually templates called >> list_algorithms and assoc_algorithms, among others. >> >> Don't you mean that they represent concepts? > > Well that seems to be the Boost term for it. Not Boost: standard C++, STL, Generic Programming, CUJ, etc. all use this term. > I'd be happier using it if you could point me to a definition of the > term, so I can embed a hyperlink to the definition. http://www.boost.org/more/generic_programming.html#concept > I don't think everyone who uses the Python or indexing suite > documentation will be familiar with it otherwise (I know I wasn't > initially). >> >> "lessthan_comparable" should be "less_than_comparable". > > OK. > >> >> Why "visitor_helper", and not operator()? > > Static function. OK. The name sounds like it exposes implementation details. It should describe what it's for. >> has_copyable_iter can be determined by looking at >> iterator_traits::iterator_category (or better, >> iterator_traversal::type). The user shouldn't supply it. > > I guess this needs some explanation in the documentation - there is an > iterator_traits template that deduces many properties automatically Traits globs like std::iterator_traits are a bad idea; it's much better to define individual metafunctions. > (for instance, has_copyable_iter is indeed determined by iterator > category). I'll add some documentation for the case that client code > wants to use the template as a base class, although there is certainly > no necessity for it to do so. I don't understand why you would even give the user the option to supply information that you can correctly deduce ?? >> I don't understand is_reorderable. How is that different from >> >> is_convertible< >> iterator_traits::iterator_category >> , forward_iterator_tag >> >::value >> && is_non_const_lvalue_iterator::value >> && is_assignable::value >> >> ?? >> >> I realize we don't have is_assignable, but shouldn't you phrase this >> in terms of something fundamental like value_type assignability? We >> can ask all the other questions (see >> boost/iterator/is_lvalue_iterator.hpp). > > The iterator traits template I mentioned above just uses > is_mutable_ref Not a good idea; the standard doesn't place any requirements on the reference type of most iterators. > (with an obvious is_mutable_ref > implementation). This actually deduces the wrong answer for std::map > and even std::set with some standard libraries, so I ended up > overriding it manually in set_traits and map_traits. That's why I'm suggesting using the formula above. >> Once you tell the suite that "has_find" don't you also need to tell >> it how (i.e. via member function or otherwise)? > > Yes indeed. The ContainerTraits and Algorithms have to work together > on this - you can't have "has_find" true and then not provide an > implementation of find, count and maybe index in your Algorithms. I > suppose I should really document the exact requirements. Uh, I suppose ;-) > Also, I've recently added two static member functions to the > ValueTraits concept for the less_than and equal_to comparisons. This > is where the automatic shared_ptr handling happens. It's not > documented yet. That means little to me as I don't understand the system yet. >> The use of static constants in ContainerTraits is unattractive to me, >> because it's not particularly extensible. What about asking the user >> to provide an mpl::set of the property type tags: >> >> typedef mpl::set capabilities; >> >> or something? > > Looks like a good idea. I'll give this a go. We may need to whip mpl::set into shape. In the meantime you could use an mpl::vector, and mpl::find which will give slightly longer compiles but should work. >> You actually have the name "value_traits_" in a table. Intended? >> ^ > > There is a template called value_traits, so the ContainerTraits member > type is called value_traits_ (underscore at end). A bit lame I guess. Yeah, I think we should revisit these decisions. >> Why would you ask the user to supply the Container's size_type and >> iterator instead of deducing them from the container itself? > > The client could use one of the existing ContainerTraits templates as > a base class and avoid the need for defining this explicitly (needs > documenting, as noted above). On the other hand, it is also possible > to interface the suite with a container that doesn't provide anything > like an STL-style interface, by completely replacing the traits and > algorithms templates. The normal way to deal with that is to supply a metafunction: template struct container_value_type { typedef typename C::value_type type; }; And then have the user specialize it for other types. A slightly better implementation would look like: template struct container_value_type_impl { }; template struct container_value_type_impl { typedef typename C::value_type type; }; template struct container_value_type : container_value_type_impl::type, C> { }; On second thought, I guess I can understand why you want to give the user the ability to package the mapping into container-hood and hand it to you. This reminds me of the kind of explicit concept mapping you can do in Haskell. My feeling is that if you want to go this way, the user should be supplying a traits *generator*, not the traits themselves. >> I am a bit concerned about how reference >> documentation for various components and headers is grouped all into >> one file, containers.html. I don't believe the precedent set by the >> pickling support in this regard was a good one. We have a >> semi-coherent [;-)] reference manual organization - why should there >> be any supported public headers missing from it? IMO it would be >> better (though not a showstopper) if containers.html were just >> narrative/tutorial, with pointers to the hard-core reference material. > > Yes, I think this is inevitable, given the weaknesses you've > identified. I guess I was trying to economize on documentation > effort, I can understand the desire ;-) > but I suppose it needs to be more rigorous. Unfortunately, yes. If I can't understand it, it won't survive well in the BPL codebase. >> I'd also like to hear if Joel has any concerns. > > Me too. Thanks for your comments so far - I'll work on them as part of > the current updates I'm doing. My feeling at the moment is that this work is going to be great, but that it probably won't be ready (or I won't be comfortable with it) in time for 1.31.0. We can still try, but I'm going to be busy... > -- > Raoul Gough. > export LESS='-X' I read the help on less -X, but I don't understand why I'd want this? -- Dave Abrahams Boost Consulting www.boost-consulting.com From cleung at eos.ubc.ca Tue Nov 25 22:04:03 2003 From: cleung at eos.ubc.ca (Charles Leung) Date: Tue, 25 Nov 2003 13:04:03 -0800 (PST) Subject: [C++-sig] num_util question In-Reply-To: <1069754906.2044.57.camel@trantor.univ-rennes1.fr> References: <1069754906.2044.57.camel@trantor.univ-rennes1.fr> Message-ID: <60423.137.82.23.138.1069794243.squirrel@webmail.eos.ubc.ca> Hi Olivier, I believe it's actually a requirement from Numeric that to write extension module in C++ involving NumPy, you must define a PY_ARRAY_UNIQUE_SYMBOL inorder to use NumPy features in extension module that is implemented across multiple source files. We just happened to pick the name PyArrayHandle. The short answer is... for every source file that includes (other than the one where the BOOST_PYTHON_MODULE macro is defined), put: #define PY_ARRAY_UNIQUE_SYMBOL PyArrayHandle #define NO_IMPORT_ARRAY for the source file that actually uses the BOOST_PYTHON_MODULE macro, put: #define PY_ARRAY_UNIQUE_SYMBOL PyArrayHandle I hope this helps, please let me know if it works out. Charles > Hi, > > When trying to use the num_util and I have an ImportError : > > undefined symbol: PyArrayHandle > > Is someone have an idea ? > > Thanks. > > Olivier Ravard > > [image] > [image] > [image] > > NovaGrid S.A. > > olivier.ravard at novagrid.com > WEB : http://www.novagrid.com > TEL/FAX : 02 23 23 62 32 > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From RaoulGough at yahoo.co.uk Wed Nov 26 11:21:27 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Wed, 26 Nov 2003 10:21:27 +0000 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> Message-ID: David Abrahams writes: > Raoul Gough writes: > >> David Abrahams writes: [snip] >>> I've been trying to say that you you *can*, in principle, still do >>> this with a single ScriptEngine type, so that registration code gets >>> compiled once, scripting-language-independently. >> >> Given a certain amount of wrapper code to set up a "function >> descriptor" object, I assume. > > Yup. The only difficulty I've thought of would be handling return values. For instance, somewhere you have to have a conversion from the C++ return type to a PyObject * (for the Python engine) or the corresponding type for different engines. Maybe a double-dispatch would handle this, meaning a certain amount of scripting language dependant code in the function descriptor base class? -- Raoul Gough. export LESS='-X' From RaoulGough at yahoo.co.uk Wed Nov 26 11:34:14 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Wed, 26 Nov 2003 10:34:14 +0000 Subject: [C++-sig] Re: Extension DLLs nonfunctioning with MSVC 7.1 (beta) References: <3FC385D1.7090902@cirad.fr> Message-ID: Christophe Pradal writes: > Raoul Gough a ?crit: > >>David Abrahams writes: >> >> >>>Raoul Gough writes: >>> >>> >>>>When I build the Python tests with MSVC (7.1 beta, version 13.10.2292) >>>>I get non-functioning DLLs. With a debug build, importing an extension >>>>module into Python aborts silently, and with the release builds it >>>>reports "ImportError: DLL load failed: Invalid access to memory >>>>location." I'm reasonably sure this was working a couple of weeks ago. >>>> >>[snip] >> >>>It's working for me with vc7.1 release and a debug-python build: >>> >>[snip] >> >>Niall Douglas also reports that it works for him. I guess I must have >>trashed something in my environment, so I'll have to track it down >>locally. Thanks to you both for confirming this. > > Hello, > I have the same problem with MSVC 6 SP5 and STLport and a recent > boost on cvs. > When i try to import my module, > i have the following message > > File "", line 1, in ? > ImportError: DLL load failed: Invalid access to memory location. > > Is Raoul solve is problem? No, I haven't ever figured out why this occurs, because I usually use g++ anyway. I did determine that the generated DLLs are broken internally in some way, for instance the dependency walker sometimes just reports that the DLL is corrupt. I've tried different versions of the Microsoft linker with identical results, so I was guessing that the problem is introduced during the compilation phase. On the other hand, your environment is quite different to mine - I have the beta version of the .NET compiler (MSVC 7.1 beta) and the Microsoft-supplied (Dinkumware?) standard library. This is all very weird, but I'll try to investigate it further. Any more details about your experiences with this could be helpful. -- Raoul Gough. export LESS='-X' From dalwan01 at student.umu.se Wed Nov 26 11:44:37 2003 From: dalwan01 at student.umu.se (Daniel Wallin) Date: Wed, 26 Nov 2003 11:44:37 +0100 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> Message-ID: <3FC48415.9020200@student.umu.se> Raoul Gough wrote: > David Abrahams writes: > > >>Raoul Gough writes: >> >> >>>David Abrahams writes: > > [snip] > >>>>I've been trying to say that you you *can*, in principle, still do >>>>this with a single ScriptEngine type, so that registration code gets >>>>compiled once, scripting-language-independently. >>> >>>Given a certain amount of wrapper code to set up a "function >>>descriptor" object, I assume. >> >>Yup. > > > The only difficulty I've thought of would be handling return values. > For instance, somewhere you have to have a conversion from the C++ > return type to a PyObject * (for the Python engine) or the > corresponding type for different engines. Maybe a double-dispatch > would handle this, meaning a certain amount of scripting language > dependant code in the function descriptor base class? I thought it would just work like: PyObject* python_function_wrapper() { function& fn = /* something */; const type_info* args = fn.arg_types(); void** storage_table = /* something */; for (int i = 0; i < fn.arity(); ++i) { void* storage = allocate_storage_for_converter(args[i]); perform_conversion(args[i], i, storage, py_args); storage_table[i] = storage; } void* result_storage = allocate_storage_for_converter( fn.result_type() ); fn.invoke(storage_table, result_storage); return perform_result_conversion( fn.result_type() , result_storage ); } and function::invoke, simplified, would just do.. void function::invoke(void* const* args_storage, void* result_storage) { new (result_storage) ResultType( m_fn( static_cast(args_storage[0]) , static_cast(args_storage[1]) , etc.. ) ); } I guess you'd also need a virtual tail call that can destroy the result.. Of course, the converter lookup would be done at init time and stored. -- Daniel Wallin From RaoulGough at yahoo.co.uk Wed Nov 26 12:17:57 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Wed, 26 Nov 2003 11:17:57 +0000 Subject: [C++-sig] Re: indexing_v2 status update References: Message-ID: David Abrahams writes: > Raoul Gough writes: > >> David Abrahams writes: >> >>> Raoul Gough writes: >> [snip] >>> "Safety" is missing from the design goals. Was that not one of the >>> goals? >> >> Well that's a tough one. For instance, using return_by_reference when >> returning a value held in a container is pretty dangerous (consider >> deletions or vector reallocations). > > There are supposed to be proxies which just store an index and do > range checks. Is that what container_proxy is? The container_proxy is a container wrapper, and it returns element proxies that do the range checking - they cooperate on tracking element movement due to inserts/deletes. However, container_proxy is completely optional and only works with vector-like containers anyway (e.g. deque works, list doesn't). > >> On the other hand, I wouldn't like >> to rule it out as an option merely on that basis. Certainly the >> container_proxy component does backflips to try and prevent any >> dangers, so perhaps this needs some mention of safety? > > Yes. If that's the safe one, it should be the default, and safety > was a major goal of Joel's original work. I don't think it can be the default, since it isn't embedded in the suite. It provides an interface which is compatible with the indexing suite, but is also designed to be reasonably convenient to use directly in C++. This is important, since there might be C++ code that modifies the container while Python code still holds proxies pointing into it. This was one of the issues I raised early on with the previous version of the suite, since the proxying was actually hidden from the C++ code. As I said then, the ideal solution is to use a container of shared pointers anyway - if that's not possible, exposing a container_proxy wrapper of the container is an option for vector-like containers. [snip] >>> I don't like the use of abbrevs. like "algo_...." >> >> You mean algo_selector? I can rename this to algorithm_selector if >> you'd prefer, I don't mind either way. > > I prefer. OK - will change this. [snip] >> The supplied postcall currently gets dropped completely for functions >> that return integers or void (e.g. __len__ and sort) on the assumption >> that it is only intended for use when returning container >> elements. For instance, you don't want to use >> return_internal_reference on the result of a call to container.size(). > > You need to document the postcall behaviors and the rationale. OK. > >>> 2] Note that Algorithms and ContainerTraits don't represent >>> individual templates in the diagram, but groups of related >>> templates. For instance, there are actually templates called >>> list_algorithms and assoc_algorithms, among others. >>> >>> Don't you mean that they represent concepts? >> >> Well that seems to be the Boost term for it. > > Not Boost: standard C++, STL, Generic Programming, CUJ, etc. all use > this term. > >> I'd be happier using it if you could point me to a definition of the >> term, so I can embed a hyperlink to the definition. > > http://www.boost.org/more/generic_programming.html#concept Thanks for this - I wish I'd seen that when I first started reading the Python docs. By the way, I'm pretty sure the C++ standard never uses the word "Concept" in this context. It refers to "requirements" like "LessThanComparable" or "Assignable", which is more or less the same thing but with a different name. > >> I don't think everyone who uses the Python or indexing suite >> documentation will be familiar with it otherwise (I know I wasn't >> initially). >>> >>> "lessthan_comparable" should be "less_than_comparable". >> >> OK. >> >>> >>> Why "visitor_helper", and not operator()? >> >> Static function. > > OK. The name sounds like it exposes implementation details. It > should describe what it's for. I couldn't think of anything better at the time. It's just a hook to let the algorithms, container traits or value traits do any additional set up during the def() call for the whole suite. Maybe def_hook? > >>> has_copyable_iter can be determined by looking at >>> iterator_traits::iterator_category (or better, >>> iterator_traversal::type). The user shouldn't supply it. >> >> I guess this needs some explanation in the documentation - there is an >> iterator_traits template that deduces many properties automatically > > Traits globs like std::iterator_traits are a bad idea; it's much > better to define individual metafunctions. > >> (for instance, has_copyable_iter is indeed determined by iterator >> category). I'll add some documentation for the case that client code >> wants to use the template as a base class, although there is certainly >> no necessity for it to do so. > > I don't understand why you would even give the user the option to > supply information that you can correctly deduce ?? ... can correctly deduce /for STL-like containers/. > >>> I don't understand is_reorderable. How is that different from >>> >>> is_convertible< >>> iterator_traits::iterator_category >>> , forward_iterator_tag >>> >::value >>> && is_non_const_lvalue_iterator::value >>> && is_assignable::value >>> >>> ?? >>> >>> I realize we don't have is_assignable, but shouldn't you phrase this >>> in terms of something fundamental like value_type assignability? We >>> can ask all the other questions (see >>> boost/iterator/is_lvalue_iterator.hpp). >> >> The iterator traits template I mentioned above just uses >> is_mutable_ref > > Not a good idea; the standard doesn't place any requirements on the > reference type of most iterators. That probably explains the troubles. I'll look into using the value_type instead. > >> (with an obvious is_mutable_ref >> implementation). This actually deduces the wrong answer for std::map >> and even std::set with some standard libraries, so I ended up >> overriding it manually in set_traits and map_traits. > > That's why I'm suggesting using the formula above. > >>> Once you tell the suite that "has_find" don't you also need to tell >>> it how (i.e. via member function or otherwise)? >> >> Yes indeed. The ContainerTraits and Algorithms have to work together >> on this - you can't have "has_find" true and then not provide an >> implementation of find, count and maybe index in your Algorithms. I >> suppose I should really document the exact requirements. > > Uh, I suppose ;-) > >> Also, I've recently added two static member functions to the >> ValueTraits concept for the less_than and equal_to comparisons. This >> is where the automatic shared_ptr handling happens. It's not >> documented yet. > > That means little to me as I don't understand the system yet. > >>> The use of static constants in ContainerTraits is unattractive to me, >>> because it's not particularly extensible. What about asking the user >>> to provide an mpl::set of the property type tags: >>> >>> typedef mpl::set capabilities; >>> >>> or something? >> >> Looks like a good idea. I'll give this a go. > > We may need to whip mpl::set into shape. In the meantime you could > use an mpl::vector, and mpl::find which will give slightly longer > compiles but should work. It should ideally support by-value element removal, so set is the right abstraction. Are you suggesting that it isn't fully functional? > >>> You actually have the name "value_traits_" in a table. Intended? >>> ^ >> >> There is a template called value_traits, so the ContainerTraits member >> type is called value_traits_ (underscore at end). A bit lame I guess. > > Yeah, I think we should revisit these decisions. > >>> Why would you ask the user to supply the Container's size_type and >>> iterator instead of deducing them from the container itself? >> >> The client could use one of the existing ContainerTraits templates as >> a base class and avoid the need for defining this explicitly (needs >> documenting, as noted above). On the other hand, it is also possible >> to interface the suite with a container that doesn't provide anything >> like an STL-style interface, by completely replacing the traits and >> algorithms templates. > > The normal way to deal with that is to supply a metafunction: > > template > struct container_value_type > { > typedef typename C::value_type type; > }; > > And then have the user specialize it for other types. A slightly > better implementation would look like: > > > template > struct container_value_type_impl > { > }; > > template > struct container_value_type_impl > { > typedef typename C::value_type type; > }; > > template > struct container_value_type > : container_value_type_impl::type, C> > { > }; > > On second thought, I guess I can understand why you want to give the > user the ability to package the mapping into container-hood and hand > it to you. This reminds me of the kind of explicit concept mapping > you can do in Haskell. Yes, I don't see how doing it via specializations for each individual property would make things more convenient for the client code. I guess I'll document the available base classes that perform the automatic deductions when I provide separate HTML files for each header. This makes it more or less trivial for STL-like containers, without actually requiring it. > > My feeling is that if you want to go this way, the user should be > supplying a traits *generator*, not the traits themselves. > >>> I am a bit concerned about how reference >>> documentation for various components and headers is grouped all into >>> one file, containers.html. I don't believe the precedent set by the >>> pickling support in this regard was a good one. We have a >>> semi-coherent [;-)] reference manual organization - why should there >>> be any supported public headers missing from it? IMO it would be >>> better (though not a showstopper) if containers.html were just >>> narrative/tutorial, with pointers to the hard-core reference material. >> >> Yes, I think this is inevitable, given the weaknesses you've >> identified. I guess I was trying to economize on documentation >> effort, > > I can understand the desire ;-) > >> but I suppose it needs to be more rigorous. > > Unfortunately, yes. If I can't understand it, it won't survive well > in the BPL codebase. Makes sense. > >>> I'd also like to hear if Joel has any concerns. >> >> Me too. Thanks for your comments so far - I'll work on them as part of >> the current updates I'm doing. > > My feeling at the moment is that this work is going to be great, but > that it probably won't be ready (or I won't be comfortable with it) in > time for 1.31.0. We can still try, but I'm going to be busy... OK - there's a fair bit here to chew on. > >> export LESS='-X' > > I read the help on less -X, but I don't understand why I'd want this? Here's the answer: Disables sending the termcap initialization and deinitialization strings to the terminal. This is sometimes desirable if the deinitialization string does something unnecessary, like clear- ing the screen. every GNU-based system I've ever worked on clears the screen by default on exit from less. Annoys the hell out of me, when I've just scanned a man page to the information that I want, hit "q" and then the information disappears! What morons! :-) -- Raoul Gough. export LESS='-X' From dave at boost-consulting.com Wed Nov 26 13:40:51 2003 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 26 Nov 2003 07:40:51 -0500 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> <3FC48415.9020200@student.umu.se> Message-ID: Daniel Wallin writes: > Of course, the converter lookup would be done at init time and stored. I'm not sure. Converters come on-line dynamically. Unless, of course, you mean that the converter search chain lookup would be done at init time? -- Dave Abrahams Boost Consulting www.boost-consulting.com From dalwan01 at student.umu.se Wed Nov 26 12:46:54 2003 From: dalwan01 at student.umu.se (Daniel Wallin) Date: Wed, 26 Nov 2003 12:46:54 +0100 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> <3FC48415.9020200@student.umu.se> Message-ID: <3FC492AE.8090102@student.umu.se> David Abrahams wrote: > Daniel Wallin writes: > > >>Of course, the converter lookup would be done at init time and stored. > > > I'm not sure. Converters come on-line dynamically. Unless, of > course, you mean that the converter search chain lookup would be done > at init time? Yeah, that's exactly what I meant. Sorry for the confusion. -- Daniel Wallin From dave at boost-consulting.com Wed Nov 26 14:33:06 2003 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 26 Nov 2003 08:33:06 -0500 Subject: [C++-sig] Re: indexing_v2 status update References: Message-ID: Raoul Gough writes: >>> export LESS='-X' >> >> I read the help on less -X, but I don't understand why I'd want this? > > Here's the answer: > > Disables sending the termcap initialization and deinitialization > strings to the terminal. This is sometimes desirable if the > deinitialization string does something unnecessary, like clear- > ing the screen. > > every GNU-based system I've ever worked on clears the screen by > default on exit from less. Annoys the hell out of me, when I've just > scanned a man page to the information that I want, hit "q" and then > the information disappears! What morons! :-) YES!! you are the MAN!! -- Dave Abrahams Boost Consulting www.boost-consulting.com From christophe.pradal at cirad.fr Wed Nov 26 15:18:35 2003 From: christophe.pradal at cirad.fr (Christophe Pradal) Date: Wed, 26 Nov 2003 15:18:35 +0100 Subject: [C++-sig] Re: Extension DLLs nonfunctioning with MSVC 7.1 (beta) In-Reply-To: References: <3FC385D1.7090902@cirad.fr> Message-ID: <3FC4B63B.2080304@cirad.fr> i work with Python2.3, Visual C++ SP5, STLPort . i have my own shared_pointer ( RefCountPtr )and want to use it with boost. If i add an assignement operator with implicit cast: template RefCountPtr( const RefCountPtr&ptr ) {...} i have the following message ImportError: DLL load failed: Invalid access to memory location. But when i comment this line, all is OK. What i want to do is: in C++: class A {}; class B : A {}; void f(const RefCountPtr&) In python b= B() f(b) I think it is a Visual C++ bug, but i don't know how to bypass it. Thanks again for your help. Raoul Gough a ?crit: >Christophe Pradal writes: > > > >>Raoul Gough a ?crit: >> >> >> >>>David Abrahams writes: >>> >>> >>> >>> >>>>Raoul Gough writes: >>>> >>>> >>>> >>>> >>>>>When I build the Python tests with MSVC (7.1 beta, version 13.10.2292) >>>>>I get non-functioning DLLs. With a debug build, importing an extension >>>>>module into Python aborts silently, and with the release builds it >>>>>reports "ImportError: DLL load failed: Invalid access to memory >>>>>location." I'm reasonably sure this was working a couple of weeks ago. >>>>> >>>>> >>>>> >>>[snip] >>> >>> >>> >>>>It's working for me with vc7.1 release and a debug-python build: >>>> >>>> >>>> >>>[snip] >>> >>>Niall Douglas also reports that it works for him. I guess I must have >>>trashed something in my environment, so I'll have to track it down >>>locally. Thanks to you both for confirming this. >>> >>> >>Hello, >>I have the same problem with MSVC 6 SP5 and STLport and a recent >>boost on cvs. >>When i try to import my module, >>i have the following message >> >>File "", line 1, in ? >>ImportError: DLL load failed: Invalid access to memory location. >> >>Is Raoul solve is problem? >> >> > >No, I haven't ever figured out why this occurs, because I usually use >g++ anyway. I did determine that the generated DLLs are broken >internally in some way, for instance the dependency walker sometimes >just reports that the DLL is corrupt. I've tried different versions of >the Microsoft linker with identical results, so I was guessing that >the problem is introduced during the compilation phase. > >On the other hand, your environment is quite different to mine - I >have the beta version of the .NET compiler (MSVC 7.1 beta) and the >Microsoft-supplied (Dinkumware?) standard library. This is all very >weird, but I'll try to investigate it further. Any more details about >your experiences with this could be helpful. > > > From RaoulGough at yahoo.co.uk Wed Nov 26 19:50:30 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Wed, 26 Nov 2003 18:50:30 +0000 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> <3FC48415.9020200@student.umu.se> Message-ID: Daniel Wallin writes: > Raoul Gough wrote: >> David Abrahams writes: >> >>>Raoul Gough writes: >>> [snip] >> The only difficulty I've thought of would be handling return values. >> For instance, somewhere you have to have a conversion from the C++ >> return type to a PyObject * (for the Python engine) or the >> corresponding type for different engines. Maybe a double-dispatch >> would handle this, meaning a certain amount of scripting language >> dependant code in the function descriptor base class? > > I thought it would just work like: > > PyObject* python_function_wrapper() > { > function& fn = /* something */; > > const type_info* args = fn.arg_types(); > > void** storage_table = /* something */; > > for (int i = 0; i < fn.arity(); ++i) > { > void* storage = allocate_storage_for_converter(args[i]); > perform_conversion(args[i], i, storage, py_args); So perform_conversion knows (a) what the scripting engine argument type is and (b) what the required C++ argument type is. For example, you have a C++ function: void do_something (some_udt); and we need code somewhere to create a some_udt object from a PyObject *, from a lua_State * or whatever. I guess that means the function descriptor can't be truly universal, since it is supposed to be the only place that has compile-time knowledge of the C++ types involved. e.g. function<...>::convert_argument0 (PyObject *src, void *dst) { // create an arg_vector<0> type from PyObject at dst } function<...>::convert_argument0 (lua_State *src, void *dst) { // create an arg_vector<0> object from lua_State at dst } etc. > storage_table[i] = storage; > } > > void* result_storage = allocate_storage_for_converter( > fn.result_type() > ); > > fn.invoke(storage_table, result_storage); > > return perform_result_conversion( > fn.result_type() > , result_storage > ); If I'm right about the parameter conversions, then the same would apply here for the return value conversion. > } > > and function::invoke, simplified, would just do.. > > void function::invoke(void* const* args_storage, void* result_storage) > { > new (result_storage) ResultType( > m_fn( > static_cast(args_storage[0]) > , static_cast(args_storage[1]) > , etc.. > ) > ); > } > > I guess you'd also need a virtual tail call that can destroy the > result.. > > Of course, the converter lookup would be done at init time and stored. But where does the C++ code for the converter (with compile-time knowledge of the C++ types) come from? -- Raoul Gough. export LESS='-X' From RaoulGough at yahoo.co.uk Wed Nov 26 19:55:45 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Wed, 26 Nov 2003 18:55:45 +0000 Subject: [C++-sig] Re: indexing_v2 status update References: Message-ID: David Abrahams writes: > Raoul Gough writes: [snip] >> every GNU-based system I've ever worked on clears the screen by >> default on exit from less. Annoys the hell out of me, when I've just >> scanned a man page to the information that I want, hit "q" and then >> the information disappears! What morons! :-) > > YES!! you are the MAN!! Why, thank you. I knew I wasn't the only one who hated this. Glad to think it's helping someone - it took me ages to realize that it was configurable behaviour. -- Raoul Gough. export LESS='-X' From bob at redivi.com Wed Nov 26 20:10:08 2003 From: bob at redivi.com (Bob Ippolito) Date: Wed, 26 Nov 2003 14:10:08 -0500 Subject: [C++-sig] Re: indexing_v2 status update In-Reply-To: References: Message-ID: <26AA05DE-2044-11D8-9342-000A95686CD8@redivi.com> On Nov 26, 2003, at 1:55 PM, Raoul Gough wrote: > David Abrahams writes: > >> Raoul Gough writes: > [snip] >>> every GNU-based system I've ever worked on clears the screen by >>> default on exit from less. Annoys the hell out of me, when I've just >>> scanned a man page to the information that I want, hit "q" and then >>> the information disappears! What morons! :-) >> >> YES!! you are the MAN!! > > Why, thank you. I knew I wasn't the only one who hated this. Glad to > think it's helping someone - it took me ages to realize that it was > configurable behaviour. You definitely are the man! It's always bothered me too, never looked into fixing it. Thanks! -bob -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2357 bytes Desc: not available URL: From dalwan01 at student.umu.se Wed Nov 26 20:40:54 2003 From: dalwan01 at student.umu.se (Daniel Wallin) Date: Wed, 26 Nov 2003 20:40:54 +0100 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> <3FC48415.9020200@student.umu.se> Message-ID: <3FC501C6.9080809@student.umu.se> Raoul Gough wrote: > Daniel Wallin writes: > > >>Raoul Gough wrote: >> >>>David Abrahams writes: >>> >>> >>>>Raoul Gough writes: >>>> > > [snip] > >>>The only difficulty I've thought of would be handling return values. >>>For instance, somewhere you have to have a conversion from the C++ >>>return type to a PyObject * (for the Python engine) or the >>>corresponding type for different engines. Maybe a double-dispatch >>>would handle this, meaning a certain amount of scripting language >>>dependant code in the function descriptor base class? >> >>I thought it would just work like: >> >> PyObject* python_function_wrapper() >> { >> function& fn = /* something */; >> >> const type_info* args = fn.arg_types(); >> >> void** storage_table = /* something */; >> >> for (int i = 0; i < fn.arity(); ++i) >> { >> void* storage = allocate_storage_for_converter(args[i]); >> perform_conversion(args[i], i, storage, py_args); > > > So perform_conversion knows (a) what the scripting engine argument > type is and (b) what the required C++ argument type is. For example, > you have a C++ function: > > void do_something (some_udt); > > and we need code somewhere to create a some_udt object from a PyObject > *, from a lua_State * or whatever. I guess that means the function > descriptor can't be truly universal, since it is supposed to be the > only place that has compile-time knowledge of the C++ types > involved. e.g. The code which does the actual conversion is separated from the function descriptor. perform_conversion() is completetly language dependent and just an implementation detail in this case. > function<...>::convert_argument0 (PyObject *src, void *dst) { > // create an arg_vector<0> type from PyObject at dst > } > > function<...>::convert_argument0 (lua_State *src, void *dst) { > // create an arg_vector<0> object from lua_State at dst > } That isn't necessary. function doesn't need to care about what the source type is, it just supplies the argument type_info's and invokes a function on a list of argument objects. > etc. > > >> storage_table[i] = storage; >> } >> >> void* result_storage = allocate_storage_for_converter( >> fn.result_type() >> ); >> >> fn.invoke(storage_table, result_storage); >> >> return perform_result_conversion( >> fn.result_type() >> , result_storage >> ); > > > If I'm right about the parameter conversions, then the same would > apply here for the return value conversion. > > >> } >> >>and function::invoke, simplified, would just do.. >> >> void function::invoke(void* const* args_storage, void* result_storage) >> { >> new (result_storage) ResultType( >> m_fn( >> static_cast(args_storage[0]) >> , static_cast(args_storage[1]) >> , etc.. >> ) >> ); >> } >> >>I guess you'd also need a virtual tail call that can destroy the >>result.. >> >>Of course, the converter lookup would be done at init time and stored. > > > But where does the C++ code for the converter (with compile-time > knowledge of the C++ types) come from? From anywhere the language backend wants. It doesn't matter, the only thing that matters is that the scripting backend is capable of generating instances of some types, given by const type_info*'s. We don't really need that much compile time knowledge to perform most conversions. For instance, all UDT conversions for types registered by class_<> goes through the same converter. -- Daniel Wallin From RaoulGough at yahoo.co.uk Wed Nov 26 22:53:35 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Wed, 26 Nov 2003 21:53:35 +0000 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> <3FC48415.9020200@student.umu.se> <3FC501C6.9080809@student.umu.se> Message-ID: Daniel Wallin writes: > Raoul Gough wrote: >> Daniel Wallin writes: [snip] >>>I thought it would just work like: >>> >>> PyObject* python_function_wrapper() >>> { >>> function& fn = /* something */; >>> >>> const type_info* args = fn.arg_types(); >>> >>> void** storage_table = /* something */; >>> >>> for (int i = 0; i < fn.arity(); ++i) >>> { >>> void* storage = allocate_storage_for_converter(args[i]); >>> perform_conversion(args[i], i, storage, py_args); >> So perform_conversion knows (a) what the scripting engine argument >> type is and (b) what the required C++ argument type is. For example, >> you have a C++ function: >> void do_something (some_udt); >> and we need code somewhere to create a some_udt object from a >> PyObject >> *, from a lua_State * or whatever. I guess that means the function >> descriptor can't be truly universal, since it is supposed to be the >> only place that has compile-time knowledge of the C++ types >> involved. e.g. > > The code which does the actual conversion is separated from the function > descriptor. perform_conversion() is completetly language dependent and > just an implementation detail in this case. The point I'm trying to make is that I believe the code in perform_conversion (at some point down the call chain) has to have compile-time knowledge of the C++ type. This means that a simple abstract base class interface will not suffice (at least, not one that is independent of the scripting language in question). > >> function<...>::convert_argument0 (PyObject *src, void *dst) { >> // create an arg_vector<0> type from PyObject at dst >> } >> function<...>::convert_argument0 (lua_State *src, void *dst) { >> // create an arg_vector<0> object from lua_State at dst >> } > > That isn't necessary. function doesn't need to care about what the > source type is, it just supplies the argument type_info's and invokes a > function on a list of argument objects. On a list of C++ arguments? I can agree with that, but I don't understand how those C++ arguments are generated without somebody who understands the scripting langauge objects also knowing what C++ types are involved. [snip] >> But where does the C++ code for the converter (with compile-time >> knowledge of the C++ types) come from? > > From anywhere the language backend wants. It doesn't matter, the only > thing that matters is that the scripting backend is capable of > generating instances of some types, given by const type_info*'s. I don't see how a type_info object will allow you to create an instance of the class it represents. All it gives you is the following: class type_info { public: virtual ~type_info(); bool operator==(const type_info& rhs) const; bool operator!=(const type_info& rhs) const; bool before(const type_info& rhs) const; const char* name() const; private: type_info(const type_info& rhs); type_info& operator=(const type_info& rhs); }; So the scripting language dependant backend receives the type_info, looks it up in its own data structures and then calls some code that knows how to convert a PyObject * (or whatever) into the UDT. My question is, where does that called code come from? > > We don't really need that much compile time knowledge to perform most > conversions. For instance, all UDT conversions for types registered by > class_<> goes through the same converter. ... which dispatches via its own lookup tables to code generated from scripting language dependant templates. For instance, take a look at boost/python/object/make_instance.hpp I'm not trying to say that there is no scope for some compile-time decoupling between the scripting engine and the registration code, just that it will never be complete. -- Raoul Gough. export LESS='-X' From RaoulGough at yahoo.co.uk Wed Nov 26 23:16:58 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Wed, 26 Nov 2003 22:16:58 +0000 Subject: [C++-sig] Re: Extension DLLs nonfunctioning with MSVC 7.1 (beta) References: <3FC385D1.7090902@cirad.fr> <3FC4B63B.2080304@cirad.fr> Message-ID: Christophe Pradal writes: > i work with Python2.3, Visual C++ SP5, STLPort . > > i have my own shared_pointer ( RefCountPtr )and want to use it with boost. > If i add an assignement operator with implicit cast: > template RefCountPtr( const RefCountPtr&ptr ) {...} > i have the following message > > ImportError: DLL load failed: Invalid access to memory location. > > But when i comment this line, all is OK. Weird. I've tracked down my problem, but I'm not sure it would explain what you've described here. In my case, it looks like I generated at some stage a different version of python22.lib for use with g++. I have to admit that I don't recall why I did this, except that the standard one probably didn't work with GNU ld for some reason. Anyway, the link command for MSVC was also picking up this .lib file (after I'd long since forgotten replacing it) and generating an invalid boost_python.dll which was crashing during __DllMainCRTStartup or __CRT_INIT. Kind of embarrasing, really. -- Raoul Gough. export LESS='-X' From s_sourceforge at nedprod.com Wed Nov 26 23:35:13 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Wed, 26 Nov 2003 22:35:13 -0000 Subject: [C++-sig] Re: Extension DLLs nonfunctioning with MSVC 7.1 (beta) In-Reply-To: Message-ID: <3FC52AA1.27130.3EA082B1@localhost> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 26 Nov 2003 at 10:34, Raoul Gough wrote: > > Is Raoul solve is problem? > > No, I haven't ever figured out why this occurs, because I usually use > g++ anyway. I did determine that the generated DLLs are broken > internally in some way, for instance the dependency walker sometimes > just reports that the DLL is corrupt. I've tried different versions of > the Microsoft linker with identical results, so I was guessing that > the problem is introduced during the compilation phase. Have either of you guys enabled incremental linking? If so then don't, it's a bit flaky even still. Just pass /INCREMENTAL:NO to the linker. Cheers, Niall -----BEGIN PGP SIGNATURE----- Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 iQA/AwUBP8UqosEcvDLFGKbPEQLIfACfWotrwGjccF0St7zr1VytXHD46dcAnAz9 Cuj2s0AAPGowQuPgZZCAI65g =fbu9 -----END PGP SIGNATURE----- From s_sourceforge at nedprod.com Wed Nov 26 23:39:40 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Wed, 26 Nov 2003 22:39:40 -0000 Subject: [C++-sig] Re: indexing_v2 status update In-Reply-To: Message-ID: <3FC52BAC.8927.3EA4955B@localhost> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 26 Nov 2003 at 11:17, Raoul Gough wrote: > every GNU-based system I've ever worked on clears the screen by > default on exit from less. Annoys the hell out of me, when I've just > scanned a man page to the information that I want, hit "q" and then > the information disappears! What morons! :-) I guess I'm too used to GUI-based programming - been doing it since 1990 - I use that Help application with KDE to view man pages. I just really, really wish it'd let you open more than one at once :( Other trick is to have many open terminals just for viewing man pages. Cheers, Niall -----BEGIN PGP SIGNATURE----- Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 iQA/AwUBP8UrrcEcvDLFGKbPEQLD2ACfasRvCvKYRopbjJzoVZiZ3rK12lEAn2uP iieCwvEGg4DXEKguCP3aZZIK =xwg/ -----END PGP SIGNATURE----- From dalwan01 at student.umu.se Thu Nov 27 10:34:59 2003 From: dalwan01 at student.umu.se (Daniel Wallin) Date: Thu, 27 Nov 2003 10:34:59 +0100 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> <3FC48415.9020200@student.umu.se> <3FC501C6.9080809@student.umu.se> Message-ID: <3FC5C543.5050902@student.umu.se> Raoul Gough wrote: > Daniel Wallin writes: > > >>Raoul Gough wrote: >> >>>Daniel Wallin writes: > > [snip] > >> >>The code which does the actual conversion is separated from the function >>descriptor. perform_conversion() is completetly language dependent and >>just an implementation detail in this case. > > > The point I'm trying to make is that I believe the code in > perform_conversion (at some point down the call chain) has to have > compile-time knowledge of the C++ type. This means that a simple > abstract base class interface will not suffice (at least, not one that > is independent of the scripting language in question). Custom converters aside, there are really very few conversion left that depend on the wrapped language; conversions to/from primitive types, and conversions to/from UDT's wrapped with class_<>. The UDT conversion is only dependent on the wrapped language in that it needs to be able to extract a void* to the UDT object from the argument, it doesn't require any compile time knowledge to generate code that depends on the language. >>>function<...>::convert_argument0 (PyObject *src, void *dst) { >>> // create an arg_vector<0> type from PyObject at dst >>>} >>>function<...>::convert_argument0 (lua_State *src, void *dst) { >>> // create an arg_vector<0> object from lua_State at dst >>>} >> >>That isn't necessary. function doesn't need to care about what the >>source type is, it just supplies the argument type_info's and invokes a >>function on a list of argument objects. > > > On a list of C++ arguments? I can agree with that, but I don't > understand how those C++ arguments are generated without somebody who > understands the scripting langauge objects also knowing what C++ types > are involved. The scripting language obviously has to have converters written to convert primitive types. > [snip] > >>>But where does the C++ code for the converter (with compile-time >>>knowledge of the C++ types) come from? >> >> From anywhere the language backend wants. It doesn't matter, the only >>thing that matters is that the scripting backend is capable of >>generating instances of some types, given by const type_info*'s. > > > I don't see how a type_info object will allow you to create an > instance of the class it represents. All it gives you is the > following: > > class type_info { > public: > virtual ~type_info(); > bool operator==(const type_info& rhs) const; > bool operator!=(const type_info& rhs) const; > bool before(const type_info& rhs) const; > const char* name() const; > private: > type_info(const type_info& rhs); > type_info& operator=(const type_info& rhs); > }; > > So the scripting language dependant backend receives the type_info, > looks it up in its own data structures and then calls some code that > knows how to convert a PyObject * (or whatever) into the UDT. My > question is, where does that called code come from? Like I said, in the case of a primitive type; from the language backend. In the case of a UDT (non-custom converter), extract void* and use language independent code to do the casts or instantiate the object. >>We don't really need that much compile time knowledge to perform most >>conversions. For instance, all UDT conversions for types registered by >>class_<> goes through the same converter. > > > ... which dispatches via its own lookup tables to code generated from > scripting language dependant templates. For instance, take a look at > boost/python/object/make_instance.hpp I know how the conversion process works. Just because the code you referred to couples Python-calls with the code to instantiate the C++ type in a holder doesn't mean it has to be that way. > I'm not trying to say that there is no scope for some compile-time > decoupling between the scripting engine and the registration code, > just that it will never be complete. If we ignore custom converters (which would need to be written separatly for every language backend) and policies, I think it could be. -- Daniel Wallin From christophe.pradal at cirad.fr Thu Nov 27 10:52:23 2003 From: christophe.pradal at cirad.fr (Christophe Pradal) Date: Thu, 27 Nov 2003 10:52:23 +0100 Subject: [C++-sig] smart pointer and polymorphism problem Message-ID: <3FC5C957.6040209@cirad.fr> I use an intrusive refcount pointer as described by Scott Meyers in "More effective C++" and improved by adding template casting operator (Scott Meyers again, but later). Considering RefCountObject as the base class for pointed objects and RefCountPtr the smart pointer template, I built a small example reproducing the error: class O: public virtual RefCountObject { public: O(): RefCountObject() {} virtual ~O() {} virtual int get() = 0; }; class A: public O { public: int _a; A(): O(), _a(1) {} virtual ~A( ) {} int get() {return _a;} }; typedef RCPtr OPtr; typedef RCPtr APtr; int foo(const OPtr& p) { return p->get(); } BOOST_PYTHON_MODULE(test) { class_< O, OPtr, boost::noncopyable >("O", no_init); class_< A, APtr, bases,boost::noncopyable >("A", init<>()); def( "foo",foo ); }; In python, the following test fail: >>> import test >>> a= test.A() >>> test.foo(a) Traceback (most recent call last): File "", line 1, in ? Boost.Python.ArgumentError: Python argument types in test.foo(A) did not match C++ signature: foo(class TOOLS::RefCountPtr) Any idea? -- Christophe PRADAL From RaoulGough at yahoo.co.uk Thu Nov 27 11:15:39 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Thu, 27 Nov 2003 10:15:39 +0000 Subject: [C++-sig] Re: smart pointer and polymorphism problem References: <3FC5C957.6040209@cirad.fr> Message-ID: Christophe Pradal writes: > I use an intrusive refcount pointer as described by Scott Meyers in > "More effective C++" and improved by adding template casting operator > (Scott Meyers again, but later). > Considering RefCountObject as the base class for pointed objects and > RefCountPtr the smart pointer template, I built a small example > reproducing the error: > > class O: public virtual RefCountObject > { > public: > O(): RefCountObject() {} > virtual ~O() {} > virtual int get() = 0; > }; > > class A: public O > { > public: > int _a; > A(): O(), _a(1) {} > virtual ~A( ) {} > int get() {return _a;} > }; > > typedef RCPtr OPtr; > typedef RCPtr APtr; > > int foo(const OPtr& p) { return p->get(); } > > BOOST_PYTHON_MODULE(test) > { > class_< O, OPtr, boost::noncopyable >("O", no_init); > class_< A, APtr, bases,boost::noncopyable >("A", init<>()); > def( "foo",foo ); > }; > > In python, the following test fail: > > >>> import test > >>> a= test.A() > >>> test.foo(a) > Traceback (most recent call last): > File "", line 1, in ? > Boost.Python.ArgumentError: Python argument types in > test.foo(A) > did not match C++ signature: > foo(class TOOLS::RefCountPtr) > > > Any idea? When there is an implicit conversion between types (other than derived to base conversions, I mean), you can register it with something like: boost::python::implicitly_convertible(); Of course, in this case you already have this conversion since you registered O as a base class of A. I notice that foo takes a smart pointer rather than a reference to O, so maybe you would need this: boost::python::implicitly_convertible, RefCountPtr >(); On the other hand, I'm not sure if that will work because Ptr and Ptr are only held types and not the actual class_<> types. It's worth a go I suppose, but you wouldn't have any problem if foo took an O &. -- Raoul Gough. export LESS='-X' From christophe.pradal at cirad.fr Thu Nov 27 11:33:48 2003 From: christophe.pradal at cirad.fr (Christophe Pradal) Date: Thu, 27 Nov 2003 11:33:48 +0100 Subject: [C++-sig] Re: smart pointer and polymorphism problem In-Reply-To: References: <3FC5C957.6040209@cirad.fr> Message-ID: <3FC5D30C.2030806@cirad.fr> Thank you very much. All is OK. Raoul Gough a ?crit: >Christophe Pradal writes: > > > >>I use an intrusive refcount pointer as described by Scott Meyers in >>"More effective C++" and improved by adding template casting operator >>(Scott Meyers again, but later). >>Considering RefCountObject as the base class for pointed objects and >>RefCountPtr the smart pointer template, I built a small example >>reproducing the error: >> >>class O: public virtual RefCountObject >>{ >>public: >> O(): RefCountObject() {} >> virtual ~O() {} >> virtual int get() = 0; >>}; >> >>class A: public O >>{ >>public: >> int _a; >> A(): O(), _a(1) {} >> virtual ~A( ) {} >> int get() {return _a;} >>}; >> >>typedef RCPtr OPtr; >>typedef RCPtr APtr; >> >>int foo(const OPtr& p) { return p->get(); } >> >>BOOST_PYTHON_MODULE(test) >>{ >> class_< O, OPtr, boost::noncopyable >("O", no_init); >> class_< A, APtr, bases,boost::noncopyable >("A", init<>()); >> def( "foo",foo ); >>}; >> >>In python, the following test fail: >> >> >>> import test >> >>> a= test.A() >> >>> test.foo(a) >>Traceback (most recent call last): >> File "", line 1, in ? >>Boost.Python.ArgumentError: Python argument types in >> test.foo(A) >>did not match C++ signature: >> foo(class TOOLS::RefCountPtr) >> >> >>Any idea? >> >> > >When there is an implicit conversion between types (other than derived >to base conversions, I mean), you can register it with something like: > >boost::python::implicitly_convertible(); > >Of course, in this case you already have this conversion since you >registered O as a base class of A. I notice that foo takes a smart >pointer rather than a reference to O, so maybe you would need this: > >boost::python::implicitly_convertible, RefCountPtr >(); > >On the other hand, I'm not sure if that will work because Ptr and >Ptr are only held types and not the actual class_<> types. It's >worth a go I suppose, but you wouldn't have any problem if foo took an >O &. > > > From RaoulGough at yahoo.co.uk Thu Nov 27 12:53:59 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Thu, 27 Nov 2003 11:53:59 +0000 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> <3FC48415.9020200@student.umu.se> <3FC501C6.9080809@student.umu.se> <3FC5C543.5050902@student.umu.se> Message-ID: Daniel Wallin writes: > Raoul Gough wrote: >> Daniel Wallin writes: >> >>>Raoul Gough wrote: >>> >>>>Daniel Wallin writes: >> [snip] >> >>> >>>The code which does the actual conversion is separated from the function >>>descriptor. perform_conversion() is completetly language dependent and >>>just an implementation detail in this case. >> The point I'm trying to make is that I believe the code in >> perform_conversion (at some point down the call chain) has to have >> compile-time knowledge of the C++ type. This means that a simple >> abstract base class interface will not suffice (at least, not one that >> is independent of the scripting language in question). > > Custom converters aside, there are really very few conversion left that > depend on the wrapped language; conversions to/from primitive types, and > conversions to/from UDT's wrapped with class_<>. The UDT conversion is > only dependent on the wrapped language in that it needs to be able to > extract a void* to the UDT object from the argument, it doesn't require > any compile time knowledge to generate code that depends on the > language. [snip] OK, I see what you mean. Once you've got a void * to the real C++ object, you can pass this through a simple abstract interface to handle value extraction, allocation, copying, destruction and so on. The templated code would then only have to provide implementations based on void * instead of per-scripting-language. Sounds very interesting for multi-language support. Implementation, anyone? -- Raoul Gough. export LESS='-X' From paul at paulgrenyer.co.uk Thu Nov 27 13:07:11 2003 From: paul at paulgrenyer.co.uk (Paul Grenyer) Date: Thu, 27 Nov 2003 12:07:11 GMT Subject: [C++-sig] Displaying PyErr_Print() error Message-ID: <200311271207.hARC7BY21012@ns.cricketthosting.co.uk> Hi I originally asked this question some weeks ago, but didn't receive a reply. I've seen from googling that other people have had this problem, but I haven't seen a solution yet. I've intergrated boost.python into a COM object and therefore there is no std::cerr console to display the error message generated by PyErr_Print() after an exception is thrown. I've tried redirecting std::cerr to a stream: catch( const error_already_set& ) { std::stringstream str; std::streambuf* streamBuffer = std::cerr.rdbuf( str.rdbuf() ); PyErr_Print(); std::cerr << python << std::endl; std::cerr.rdbuf( streamBuffer ); throw BadPython( str.str(), __FILE__, __LINE__ ); } The contents of "python", a string holding the python code that generated the exception, is correctly send to "str", but the exception message isn't. Am I doing something wrong? Is there another way to get the error generated by PyErr_Print() in a string? Regards Paul Please note the change of email address! Paul Grenyer Email: paul at paulgrenyer.co.uk Web: www.paulgrenyer.co.uk From paul at paulgrenyer.co.uk Thu Nov 27 13:14:11 2003 From: paul at paulgrenyer.co.uk (Paul Grenyer) Date: Thu, 27 Nov 2003 12:14:11 GMT Subject: [C++-sig] Boost.Python Deployment Dependencies Message-ID: <200311271214.hARCEBq21406@ns.cricketthosting.co.uk> Hi I?m in the process of trying to deploy an application that uses boost.python. I started off by just including the python23.dll (as well as the boost.python dll), but when our python code is executed via boost.python, we get an error suggesting that site.py cannot be found. I then tried installing the python interpreter and libraries as well as our new application, this worked. I then renamed the python23 directory, expecting our application to now fail. It didn?t. I am now somewhat confused about what boost.python actually depends on???? I don?t want to have to install python on every machine where we want to install our application, I want to be able to include the necessary boost.python dependencies in our install script. Any ideas? Regards Paul Please note the change of email address! Paul Grenyer Email: paul at paulgrenyer.co.uk Web: www.paulgrenyer.co.uk From dalwan01 at student.umu.se Thu Nov 27 13:19:11 2003 From: dalwan01 at student.umu.se (Daniel Wallin) Date: Thu, 27 Nov 2003 13:19:11 +0100 Subject: [C++-sig] Re: Exposing C++ objects to Python at runtime In-Reply-To: References: <20031124223702.24216.qmail@web20202.mail.yahoo.com> <3FC48415.9020200@student.umu.se> <3FC501C6.9080809@student.umu.se> <3FC5C543.5050902@student.umu.se> Message-ID: <3FC5EBBF.2070703@student.umu.se> Raoul Gough wrote: > [snip] > > OK, I see what you mean. Once you've got a void * to the real C++ > object, you can pass this through a simple abstract interface to > handle value extraction, allocation, copying, destruction and so > on. The templated code would then only have to provide implementations > based on void * instead of per-scripting-language. Sounds very > interesting for multi-language support. Implementation, anyone? Yes, we are discussing this for boost-langbinding. -- Daniel Wallin From collar at gamic.com Thu Nov 27 15:39:07 2003 From: collar at gamic.com (Benjamin Collar) Date: Thu, 27 Nov 2003 15:39:07 +0100 Subject: [C++-sig] Displaying PyErr_Print() error In-Reply-To: <200311271207.hARC7BY21012@ns.cricketthosting.co.uk> References: <200311271207.hARC7BY21012@ns.cricketthosting.co.uk> Message-ID: <200311271539.07505.collar@gamic.com> Greetings The solution I found suggests making an object in python that has a function, 'write(self, stuff)' . Anything written is kept in an instance string. Instantiate that class in the interpreter and replace sys.stderr with it. In your catch, query that object for its string. I'm not sure if this example is correct / valid / safe / anything else. However, it works for me. If anyone has any suggestions, fire away! (I'm guessing the first suggestion will be, 'why not make the OutputCatcher an exposed c++ class' Good suggestion, that; the python version was simply faster for me to implement.) try { .... python::handle<> rxa( PyRun_String("class OutputCatcher:\n" "\tdef __init__(self):\n" "\t\tself.data=''\n" "\tdef write(self, stuff):\n" "\t\tself.data = self.data + stuff\n\n" "import sys\n" "_catcher = OutputCatcher()\n" "sys.stderr = _catcher\n", Py_file_input, m_main_namespace.ptr(), m_main_namespace.ptr())); .... } catch { // this prints the exception to the catcher object. PyErr_Print(); // get the string data out of this object. QString extractedError="cannot print exception"; python::object catcher(m_main_namespace["_catcher"]); python::object cstr(catcher.attr("data")); if (char *sstr = PyString_AsString(cstr.ptr())) extractedError=sstr; } Ben On Thursday 27 November 2003 13:07, Paul Grenyer wrote: > Hi > > I originally asked this question some weeks ago, but didn't receive a > reply. I've seen from googling that other people have had this problem, > but I haven't seen a solution yet. > > I've intergrated boost.python into a COM object and therefore there is > no std::cerr console to display the error message generated by > PyErr_Print() after an exception is thrown. > > I've tried redirecting std::cerr to a stream: > > catch( const error_already_set& ) > { > std::stringstream str; > std::streambuf* streamBuffer = std::cerr.rdbuf( str.rdbuf() ); > > PyErr_Print(); > std::cerr << python << std::endl; > > std::cerr.rdbuf( streamBuffer ); > throw BadPython( str.str(), __FILE__, __LINE__ ); > } > > The contents of "python", a string holding the python code that > generated the exception, is correctly send to "str", but the exception > message isn't. > > Am I doing something wrong? Is there another way to get the error > generated by PyErr_Print() in a string? > > Regards > Paul > > Please note the change of email address! > > Paul Grenyer > Email: paul at paulgrenyer.co.uk > Web: www.paulgrenyer.co.uk > > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig -- ---------------------------------------- (o__ Benjamin Collar //\ GAMIC mbH ++49 (0)241 889 110 V_/_ Developer/System Administrator To know recursion, you must first know recursion From rwgk at yahoo.com Thu Nov 27 18:18:54 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 27 Nov 2003 09:18:54 -0800 (PST) Subject: [C++-sig] Boost.Python Deployment Dependencies In-Reply-To: <200311271214.hARCEBq21406@ns.cricketthosting.co.uk> Message-ID: <20031127171854.17293.qmail@web20204.mail.yahoo.com> --- Paul Grenyer wrote: > I then tried installing the python interpreter and libraries as well as > our new application, this worked. I then renamed the python23 > directory, expecting our application to now fail. It didn?t. I am now > somewhat confused about what boost.python actually depends on???? I don't have an answer, but here are some related thoughts: Relocating Python under Unix works without problems, but I've not tried to do this under Windows. It would be great if it worked, but I am a bit concerned about registry entries which are global to the machine (as opposed to a login session). E.g.: C:\>assoc .py .py=Python.File C:\>ftype Python.File Python.File=C:\Python23\python.exe "%1" %* C:\>assoc .pyc .pyc=Python.CompiledFile C:\>ftype Python.CompiledFile Python.CompiledFile=C:\Python23\python.exe "%1" %* C:\>assoc .pyo .pyo=Python.CompiledFile C:\>ftype Python.CompiledFile Python.CompiledFile=C:\Python23\python.exe "%1" %* I am not sure if there are other associations. Maybe you are lucky and you don't depend on any of these? > I don?t want to have to install python on every machine where we want > to install our application, I want to be able to include the necessary > boost.python dependencies in our install script. If you figure it would be nice if you could post a summary. Ralf __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ From rwgk at yahoo.com Thu Nov 27 18:23:26 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 27 Nov 2003 09:23:26 -0800 (PST) Subject: [C++-sig] Displaying PyErr_Print() error In-Reply-To: <200311271539.07505.collar@gamic.com> Message-ID: <20031127172326.85187.qmail@web20211.mail.yahoo.com> --- Benjamin Collar wrote: > 'write(self, stuff)' . Anything written is kept in an instance string. > Instantiate that class in the interpreter and replace sys.stderr with it. In > your catch, query that object for its string. A minor remark: you can use StringIO or cStringIO for this purpose. I.e. you don't have to write a class with a write method yourself. Ralf __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree From s_sourceforge at nedprod.com Thu Nov 27 20:05:53 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Thu, 27 Nov 2003 19:05:53 -0000 Subject: [C++-sig] Displaying PyErr_Print() error In-Reply-To: <200311271207.hARC7BY21012@ns.cricketthosting.co.uk> Message-ID: <3FC64B11.3794.43073504@localhost> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 27 Nov 2003 at 12:07, Paul Grenyer wrote: > I originally asked this question some weeks ago, but didn't receive a > reply. I've seen from googling that other people have had this > problem, but I haven't seen a solution yet. I remember us beginning to talk about this, and then going off on the tangent of whether writing to stdout appears in idle or not. > Am I doing something wrong? Is there another way to get the error > generated by PyErr_Print() in a string? I wouldn't take that approach. As it happens, very shortly I'll be doing the same thing as you want to do for my own TnFOX library - I can't see it being later than early next week, maybe even this weekend. I was going to use the Python C API to interrogate the exception object and from that build a custom FXException which is my library's exception base class. That code should solve your problems. Want me to get back to you when I'm done? Cheers, Niall -----BEGIN PGP SIGNATURE----- Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 iQA/AwUBP8ZLEcEcvDLFGKbPEQLDPgCfZFvKbG+Oo4i3S63w8Pf4BrKwwvYAn3CU o1Mp9kgBZL5Y7fv8JwEuYOxJ =XTmW -----END PGP SIGNATURE----- From s_sourceforge at nedprod.com Thu Nov 27 20:09:36 2003 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Thu, 27 Nov 2003 19:09:36 -0000 Subject: [C++-sig] Boost.Python Deployment Dependencies In-Reply-To: <200311271214.hARCEBq21406@ns.cricketthosting.co.uk> Message-ID: <3FC64BF0.4167.430A9F1A@localhost> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 27 Nov 2003 at 12:14, Paul Grenyer wrote: > I then tried installing the python interpreter and libraries as well > as our new application, this worked. I then renamed the python23 > directory, expecting our application to now fail. It didn?t. I am now > somewhat confused about what boost.python actually depends on???? It probably found the installation via $PYTHON_LIB or something. > I don?t want to have to install python on every machine where we want > to install our application, I want to be able to include the necessary > boost.python dependencies in our install script. You have two choices - python needs some of its core libraries to work properly so these need supplying. Either you work out what's minimally needed and supply them or (much easier) you just install python on each machine. I personally would go for the latter because maintainence is much easier. When it comes to time for upgrades, you just upgrade. If you go for the former, there's a project on sourceforge somewhere which lets you package your python script as a Win32 executable which is totally self-contained. BitTorrent uses this. Find that and it'll give you a good head-start. Cheers, Niall -----BEGIN PGP SIGNATURE----- Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 iQA/AwUBP8ZL8cEcvDLFGKbPEQKeUQCfZ5hvHmlrAryXcQGBB45ngrkmj6IAoOQJ SivMfDD2QTOA18+bywT9pQHU =uu20 -----END PGP SIGNATURE----- From paul at paulgrenyer.co.uk Fri Nov 28 09:28:07 2003 From: paul at paulgrenyer.co.uk (Paul Grenyer) Date: Fri, 28 Nov 2003 08:28:07 GMT Subject: [C++-sig] Displaying PyErr_Print() error Message-ID: <200311280828.hAS8S7X14837@ns.cricketthosting.co.uk> Hi > I wouldn't take that approach. As it happens, very shortly I'll be > doing the same thing as you want to do for my own TnFOX library - I > can't see it being later than early next week, maybe even this > weekend. I was going to use the Python C API to interrogate the > exception object and from that build a custom FXException which is my > library's exception base class. That code should solve your problems. Sounds good! > Want me to get back to you when I'm done? Yes, please!!! Regards Paul Please note the change of email address! Paul Grenyer Email: paul at paulgrenyer.co.uk Web: www.paulgrenyer.co.uk From k.dejong at geog.uu.nl Fri Nov 28 11:07:00 2003 From: k.dejong at geog.uu.nl (Kor de Jong) Date: Fri, 28 Nov 2003 11:07:00 +0100 Subject: [C++-sig] Problem using wrapped void* in Python Message-ID: <3FC71E44.7030402@geog.uu.nl> Hi all, I am trying to wrap a C struct with Boost.Python which among other members has an opaque pointer to some data, for example: // A class in C. typedef struct AClass { ENUM1 v1; void *data; } AClass; // Boost.Python code to wrap AClass. BOOST_PYTHON_MODULE(amodule) { enum_("ENUM1") .value("first", first) .value("second", second) ; class_("AClass") .def_readwrite("v1", &A::v1) .def_readwrite("data", &A::data) ; } // Python code which uses AClass. import amodule var = amodule.AClass() print var.v1 print var.data This results in the following error message when run: print var.data TypeError: No to_python (by-value) converter found for C++ type: Pv I don't want to use the value pointed to by the void pointer in Python (which can't be done anyway I suppose), I just want to copy it around and pass it to wrapped C functions again. So, what I am looking for is a way to tell Boost.Python how to convert from void* to Python and back. I have tried various things, like the opaque_pointer_converter and the to_python_converter, but I end up with code which I don't understand anymore and/or which doesn't compile. I would be very grateful if one of you could provide me with a bit of code to get me going again. Thanks in advance! Kor de Jong From jacek.generowicz at cern.ch Fri Nov 28 14:23:15 2003 From: jacek.generowicz at cern.ch (Jacek Generowicz) Date: 28 Nov 2003 14:23:15 +0100 Subject: [C++-sig] vector -> list, preserving identity Message-ID: Imagine I have wrapped (using Boost.Python) 1. a C++ class 2. a function (or method) which returns vector of pointers to said class. I would like to receive the vector as a Python list of instances of the class, but would like the identity of the objects to preserved. IOW, I want the original C++ object at the end of the pointer to be referenced by the Python object which holds it, rather than a new C++ object being instantiated. Here's a minimalized sample of source to demonstrate the situation: #include #include #include #include using namespace boost::python; struct foo { foo () { std::cout << "Creating foo at " << this << std::endl; } void pointer() { std::cout << this << std::endl; } }; std::vector makefoos(int n) { std::vector fv; for (int i=0; i("foo", no_init) .def("pointer", &foo::pointer); def ("makefoos", makefoos); } How should I write a converter for the std::vector, in order to preserve the identity of the foos ? (In the library I am wrapping, the return type of makefoos is actually const std::vector&) Thanks, From RaoulGough at yahoo.co.uk Fri Nov 28 16:29:49 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Fri, 28 Nov 2003 15:29:49 +0000 Subject: [C++-sig] Re: vector -> list, preserving identity References: Message-ID: Jacek Generowicz writes: > Imagine I have wrapped (using Boost.Python) > > 1. a C++ class > > 2. a function (or method) which returns vector of pointers to said class. > > I would like to receive the vector as a Python list of instances of > the class, but would like the identity of the objects to > preserved. IOW, I want the original C++ object at the end of the > pointer to be referenced by the Python object which holds it, rather > than a new C++ object being instantiated. > > Here's a minimalized sample of source to demonstrate the situation: > > #include > #include > #include > #include > using namespace boost::python; > > struct foo { > foo () { std::cout << "Creating foo at " << this << std::endl; } > void pointer() { std::cout << this << std::endl; } > }; > > std::vector makefoos(int n) { > std::vector fv; > for (int i=0; i fv.push_back(new foo); > } > return fv; > } > > BOOST_PYTHON_MODULE( nocopy ) { > > class_("foo", no_init) > .def("pointer", &foo::pointer); > > def ("makefoos", makefoos); > } > > > How should I write a converter for the std::vector, in order to > preserve the identity of the foos ? > > (In the library I am wrapping, the return type of makefoos is actually > const std::vector&) I'm not sure how you would handle this, except by switching to boost::shared_ptr instead of plain pointers. You would end up with something like this: std::vector > makefoos(int n) { // ... } BOOST_PYTHON_MODULE( nocopy ) { class_ >("foo", no_init) .def("pointer", &foo::pointer); class_ > > ("foo_vector") .def (SOMETHING >()); def ("makefoos", makefoos); } Where SOMETHING would use either the current indexing suite (available from CVS) or the new indexing_v2 one (available from a CVS branch). Alternatively, if you only need to iterate over the vector in Python (e.g. "for x in makefoos()"), you could use boost::python::range. None of these will work until you've got the vector element type working by itself though, hence the suggestion to switch to shared_ptr. -- Raoul Gough. export LESS='-X' From RaoulGough at yahoo.co.uk Fri Nov 28 16:46:18 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Fri, 28 Nov 2003 15:46:18 +0000 Subject: [C++-sig] Re: vector -> list, preserving identity References: Message-ID: Raoul Gough writes: > Jacek Generowicz writes: > >> Imagine I have wrapped (using Boost.Python) >> >> 1. a C++ class >> >> 2. a function (or method) which returns vector of pointers to said class. [snip] > std::vector > makefoos(int n) { > // ... > } > > BOOST_PYTHON_MODULE( nocopy ) { > class_ >("foo", no_init) > .def("pointer", &foo::pointer); > > class_ > > ("foo_vector") > .def (SOMETHING >()); > > def ("makefoos", makefoos); > } > > Where SOMETHING would use either the current indexing suite [snip] I should have mentioned the other obvious alternative - package the shared pointers directly into a real Python list. e.g. boost::python::list makefoos (int n) { boost::python::list result; for (...) { result.append (boost::shared_ptr (new ...)); } return result; } -- Raoul Gough. export LESS='-X' From RaoulGough at yahoo.co.uk Fri Nov 28 17:09:23 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Fri, 28 Nov 2003 16:09:23 +0000 Subject: [C++-sig] Re: indexing_v2 status update References: Message-ID: David Abrahams writes: > Raoul Gough writes: > >> David Abrahams writes: [snip] >>> The use of static constants in ContainerTraits is unattractive to >>> me, because it's not particularly extensible. What about asking >>> the user to provide an mpl::set of the property type tags: >>> >>> typedef mpl::set capabilities; >>> >>> or something? >> >> Looks like a good idea. I'll give this a go. > > We may need to whip mpl::set into shape. In the meantime you could > use an mpl::vector, and mpl::find which will give slightly longer > compiles but should work. Actually, I'm not so sure about the benefits of making this change now. For instance, the current boolean flag approach is the same one used in std::numeric_limits. What would you think about using bitwise-combinations of flags? I've recently introduced this as a way to disable expensive features that you don't need, and it seems pretty convenient. The only drawback I can think of is a limitation (on many systems anyway) to 32 selectable properties. Is there anything else that using mpl::set or mpl::vector would get us in terms of functionality that bitsets (or seperate bools) don't have? -- Raoul Gough. export LESS='-X' From dave at boost-consulting.com Fri Nov 28 20:40:10 2003 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 28 Nov 2003 14:40:10 -0500 Subject: [C++-sig] Re: indexing_v2 status update References: Message-ID: Raoul Gough writes: > David Abrahams writes: > >> Raoul Gough writes: >> >>> David Abrahams writes: > [snip] >>>> The use of static constants in ContainerTraits is unattractive to >>>> me, because it's not particularly extensible. What about asking >>>> the user to provide an mpl::set of the property type tags: >>>> >>>> typedef mpl::set capabilities; >>>> >>>> or something? >>> >>> Looks like a good idea. I'll give this a go. >> >> We may need to whip mpl::set into shape. In the meantime you could >> use an mpl::vector, and mpl::find which will give slightly longer >> compiles but should work. > > Actually, I'm not so sure about the benefits of making this change > now. For instance, the current boolean flag approach is the same one > used in std::numeric_limits. numeric_limits is hardly a model of good (based on the best information we have today) design. > What would you think about using bitwise-combinations of flags? > I've recently introduced this as a way to disable expensive features > that you don't need, and it seems pretty convenient. The only > drawback I can think of is a limitation (on many systems anyway) to > 32 selectable properties. As you say, it's also limiting, but it's not terrible. > Is there anything else that using mpl::set or mpl::vector would get us > in terms of functionality that bitsets (or seperate bools) don't have? Yes. These symbolic tags can have operations built into them, so that when you process them you don't have to keep the knowledge about each one's meaning in one monolithic place. Instead you can let the tags themselves do the work, leading to better modularity and extensibility... at least, this may be possible. -- Dave Abrahams Boost Consulting www.boost-consulting.com From RaoulGough at yahoo.co.uk Fri Nov 28 21:10:54 2003 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Fri, 28 Nov 2003 20:10:54 +0000 Subject: [C++-sig] Re: indexing_v2 status update References: Message-ID: David Abrahams writes: > Raoul Gough writes: > >> David Abrahams writes: >> >>> Raoul Gough writes: >>> >>>> David Abrahams writes: >> [snip] >>>>> The use of static constants in ContainerTraits is unattractive to >>>>> me, because it's not particularly extensible. What about asking >>>>> the user to provide an mpl::set of the property type tags: >>>>> >>>>> typedef mpl::set capabilities; >>>>> >>>>> or something? >>>> >>>> Looks like a good idea. I'll give this a go. >>> >>> We may need to whip mpl::set into shape. In the meantime you could >>> use an mpl::vector, and mpl::find which will give slightly longer >>> compiles but should work. >> >> Actually, I'm not so sure about the benefits of making this change >> now. For instance, the current boolean flag approach is the same one >> used in std::numeric_limits. > > numeric_limits is hardly a model of good (based on the best > information we have today) design. > >> What would you think about using bitwise-combinations of flags? >> I've recently introduced this as a way to disable expensive features >> that you don't need, and it seems pretty convenient. The only >> drawback I can think of is a limitation (on many systems anyway) to >> 32 selectable properties. > > As you say, it's also limiting, but it's not terrible. It's also very cheap in terms of compile time and mangled name lengths. > >> Is there anything else that using mpl::set or mpl::vector would get us >> in terms of functionality that bitsets (or seperate bools) don't have? > > Yes. These symbolic tags can have operations built into them, so that > when you process them you don't have to keep the knowledge about each > one's meaning in one monolithic place. Instead you can let the tags > themselves do the work, leading to better modularity and > extensibility... at least, this may be possible. Interesting. I was wondering about this, because just replacing tests like traits::has_mutable_ref with traits::property_set::includes::value doesn't seem like much of a win by itself. Being able to do something like "apply each property to this class_ instance" would be a different story. This would also provide a neater way of extending the suite with new Python methods, compared to the current visitor_helper hooks. On the other hand, some of the Python methods are provided only when multiple abilities are present, e.g. "sort" requires is_reorderable and value_traits_::less_than_comparable. Such decisions are currently localized in the visitor template, the "monolithic repository" of this knowledge. I'm not sure that it would make sense to have ContainerTraits provide a ready-made set of Python methods to inject instead of just describing the relevant capabilities of the container. i.e. I'm starting to think that the capabilities are better off being just on/off flags in one form or another. -- Raoul Gough. export LESS='-X' From darylew at hotmail.com Sat Nov 29 03:06:28 2003 From: darylew at hotmail.com (Daryle Walker) Date: Fri, 28 Nov 2003 21:06:28 -0500 Subject: [C++-sig] Displaying PyErr_Print() error In-Reply-To: <200311271207.hARC7BY21012@ns.cricketthosting.co.uk> Message-ID: On 11/27/03 7:07 AM, "Paul Grenyer" wrote: > I've intergrated boost.python into a COM object and therefore there is > no std::cerr console to display the error message generated by > PyErr_Print() after an exception is thrown. I'm only on this list because I'm involved with Boost and it suggested that this list is used for Boost.Python discussion. > I've tried redirecting std::cerr to a stream: > > catch( const error_already_set& ) > { > std::stringstream str; > std::streambuf* streamBuffer = std::cerr.rdbuf( str.rdbuf() ); > > PyErr_Print(); > std::cerr << python << std::endl; > > std::cerr.rdbuf( streamBuffer ); > throw BadPython( str.str(), __FILE__, __LINE__ ); > } If you got Boost (for Boost.Python), there's a different file, called "ios_state.hpp" with a class template called "basic_ios_rdbuf_saver" that can encapsulate your stream-buffer switching under RAII. (In your code above, you could use an std::stringbuf object directly instead of a std::stringstream.) > The contents of "python", a string holding the python code that > generated the exception, is correctly send to "str", but the exception > message isn't. > > Am I doing something wrong? Is there another way to get the error > generated by PyErr_Print() in a string? A general programming suggestion: do you even know if "PyErr_Print" actually uses immediate calls to "std::cerr" in its implementation? Your plan won't work if the answer is "no". -- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com From rwgk at yahoo.com Sat Nov 29 17:52:52 2003 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Sat, 29 Nov 2003 08:52:52 -0800 (PST) Subject: [C++-sig] Problem using wrapped void* in Python In-Reply-To: <3FC71E44.7030402@geog.uu.nl> Message-ID: <20031129165252.53194.qmail@web20208.mail.yahoo.com> > So, what I am looking for is a way to tell Boost.Python how to convert > from void* to Python and back. I have tried various things, like the > opaque_pointer_converter and the to_python_converter, but I end up with > code which I don't understand anymore and/or which doesn't compile. I > would be very grateful if one of you could provide me with a bit of code > to get me going again. Recently Niall Douglas added this to the Boost.Python FAQ: http://cci.lbl.gov/~rwgk/shortcuts/boost/libs/python/doc/v2/faq.html#voidptr Does this help in your case? Ralf __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ From dave at boost-consulting.com Sat Nov 29 23:26:16 2003 From: dave at boost-consulting.com (David Abrahams) Date: Sat, 29 Nov 2003 17:26:16 -0500 Subject: [C++-sig] Re: Dereferenceable concept proposal References: <1068140778.13378.43.camel@pbarbier> <1068196067.6088.48.camel@pbarbier> Message-ID: Pierre Barbier de Reuille writes: > Ok, I made a patch that work for me. I hope I did not modify to many > files (there were a lot of .get not for pointers) > > The patch was simply made with a > > cvs diff > no_get.patch > > on the boost/python directory. > > Le jeu 06/11/2003 ? 22:22, David Abrahams a ?crit : >> Pierre Barbier de Reuille writes: >> >> > And perhaps this solution has tons of defaults I don't see :-/ >> >> Do you mean "implications", perhaps? > > Not really, I meant "problems" ... defaults was a frenchism :o) > > -- > Pierre Barbier de Reuille > > INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP > Botanique et Bio-informatique de l'Architecture des Plantes > TA40/PSII, Boulevard de la Lironde > 34398 MONTPELLIER CEDEX 5, France > > tel : (33) 4 67 61 65 77 fax : (33) 4 67 61 56 68 Thanks for the patch; it's applied, with some platform workarounds to go with it, and docs. -- Dave Abrahams Boost Consulting www.boost-consulting.com