From dholth at fastmail.fm Sun Feb 1 01:43:10 2004 From: dholth at fastmail.fm (Daniel Holth) Date: Sat, 31 Jan 2004 19:43:10 -0500 Subject: [C++-sig] Boost.Python functions and Python functions Message-ID: <1075596189.31783.69.camel@bluefish> Boost.Python functions don't inherit from the Python function type, but if they did the current version of pydoc would show their docstring. So, if we want help(boost_module_with_functions) to show something, we can change pydoc so it knows about Boost.Python functions, or change Boost.Python functions to inherit from the Python function type. Is there a good reason that Boost doesn't currently subtype Python's Function Type for its functions? - dwh From dave at boost-consulting.com Sun Feb 1 03:22:10 2004 From: dave at boost-consulting.com (David Abrahams) Date: Sat, 31 Jan 2004 21:22:10 -0500 Subject: [C++-sig] Re: iterator interface question (progress!) References: Message-ID: Neal Becker writes: >> Better make begin and end functions use return_internal_reference, so >> the iterators won't outlive the container. UNfortunately, they're >> still not safe since they can still run off the end of the vector or >> become invalidated. These are the sorts of issues that the indexing >> suites should handle. >> > > Thanks for the help, but I still have 1 question about your reply (the > meaning of "should"). Do you mean the indexing suites already do provide a > better solution (and I should look at it) or do you mean that you wish the > indexing suites provided a better solution, and may in the future? I mean that they already do provide better solutions. That said, they don't expose a C++ iterator idiom; they expose a Python iterator idiom. It's generally accepted that C++ code wrapped in Python should behave Pythonically. Python users probably won't understand your crazy begin()/end() interface ;-) -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Sun Feb 1 03:29:23 2004 From: dave at boost-consulting.com (David Abrahams) Date: Sat, 31 Jan 2004 21:29:23 -0500 Subject: [C++-sig] Re: Boost.Python functions and Python functions References: <1075596189.31783.69.camel@bluefish> Message-ID: Daniel Holth writes: > Boost.Python functions don't inherit from the Python function type, but > if they did the current version of pydoc would show their docstring. > > So, if we want help(boost_module_with_functions) to show something, we > can change pydoc so it knows about Boost.Python functions, or change > Boost.Python functions to inherit from the Python function type. If pydoc really only works on classes derived from Python's builtin function types, it probably *should* be changed. > Is there a good reason that Boost doesn't currently subtype Python's > Function Type for its functions? You mean aside from: >>> def f():pass ... >>> f.__class__ >>> class x(f.__class__): ... pass ... Traceback (most recent call last): File "", line 1, in ? TypeError: type 'function' is not an acceptable base type ?? -- Dave Abrahams Boost Consulting www.boost-consulting.com From dholth at fastmail.fm Sun Feb 1 10:45:08 2004 From: dholth at fastmail.fm (Daniel Holth) Date: Sun, 01 Feb 2004 04:45:08 -0500 Subject: [C++-sig] Re: Boost.Python functions and Python functions In-Reply-To: References: <1075596189.31783.69.camel@bluefish> Message-ID: <1075628708.4490.33.camel@bluefish> On Sat, 2004-01-31 at 21:29, David Abrahams wrote: > If pydoc really only works on classes derived from Python's builtin > function types, it probably *should* be changed. > > > Is there a good reason that Boost doesn't currently subtype Python's > > Function Type for its functions? > > You mean aside from: ... > TypeError: type 'function' is not an acceptable base type > > ?? This is the exact test pydoc (via inspect.py) uses to determine if something is a function: "isinstance(object, types.FunctionType)". This evaluates to true for PyCFunction and PyFunction, builtin functions and normal Python functions, so perhaps Boost's functions can be made to to pass this test. pydoc could also be changed to document as a function anything that had a __call__ property. - dwh From dave at boost-consulting.com Mon Feb 2 23:23:40 2004 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 02 Feb 2004 17:23:40 -0500 Subject: [C++-sig] Re: Manipulating arguments with CallPolicies::precall? References: Message-ID: Arve Knudsen writes: > Hi > > I want to wrap a native C Python object in a C++ object that takes > care of constructing and destructing it properly I don't understand. Do you mean something akin to boost::python::list, or something entirely different? > (there isn't any way > to specify custom allocation/deallocation routines are > there?) I don't understand the question. allocation/deallocation routines for what? > However, I would like to send this object directly to the > associated routines (its part of an existing Python extension). What associated routines. > I haven't found any direct support for this kind of thing within > boost::python, since everything seems strongly tied to the contained > type (my wrapping C++ class). But, I figured it might be possible to > manipulate the Python argument tuple within CallPolicies::precall? Sorry, I'm completely lost. I suggest you show some code that demonstrates what you'd like to be able to do, but which isn't supported. I didn't try very hard to understand the rest of the message, because I didn't even get this far :( -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Mon Feb 2 23:24:57 2004 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 02 Feb 2004 17:24:57 -0500 Subject: [C++-sig] Re: Problem with pickling returning a boost::python::dict object References: <1074868452.24889.35.camel@pbarbier> <20040123175330.51923.qmail@web20204.mail.yahoo.com> Message-ID: "Ralf W. Grosse-Kunstleve" writes: > (something like dict save; make_tuple(object_dict, save)). or make_tuple(object_dict, dict()) ? -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Mon Feb 2 23:34:47 2004 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 02 Feb 2004 17:34:47 -0500 Subject: [C++-sig] Re: implicitly_convertible References: <200401201633.i0KGXK3N2721117@vracs001.vrac.iastate.edu> Message-ID: "aashish" writes: > Hi, > > I wanted to have a function like this where when I pass a list I will either > get return as set of integers or std::vector of double. > > I tried to implement the function in this manner ..... > > C++-------------------------------- > int make_vector(bp::list vlist) > { > //std::vector vector_list; > int k = extract(vlist.attr("__len__")()); > > /*for (int i=0;i<10;i++) > { > > vector_list.push_back(extract(lt.attr("__getitem__")(i))); That's the hard/ugly way. Why not: vector_list.push_back(extract(lt[i])); ?? > } > > return vector_list;*/ > > int kk = extract(vlist.attr("__getitem__")(0)); > > return kk; > } > Python----------------------------- > > L = ['1','2','3'] > a = make_vector(L) > print a > > The problem is that I am getting the correct value for 'k' here but then it > does throws error saying that > > Tracekack(most recent call last) > File "pytest2.py" , line 30, in ? > A = "make.vector"(L) ^^^^^^^^^^^^^ I can't believe that you copied this error message correctly. > Typeerror: No registered converter was able to produce a C++ rvalue of type > int from this Python object of type str. > > Now what does this error mean?? The error means that you tried to extract from a Python string object. > And How can sole this problem. Store ints instead of strings in L L = [ 1, 2, 3 ] ?? -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Mon Feb 2 23:37:18 2004 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 02 Feb 2004 17:37:18 -0500 Subject: [C++-sig] Re: implicitly_convertible References: <200401201531.i0KFVg3N2714865@vracs001.vrac.iastate.edu> Message-ID: "aashish" writes: > Hi, > > This might be a very simple question but I am wondering when I should use > > implicitly_convertible as I found that in certain cases the coversion from > Python type to C++ type is possible without using it. implicitly_convertible isn't there just to enable Python->C++ conversions. Many built-in conversions work automatically. if there exists a conversion from Python type P -> C++ type C implicitly_convertible(); will enable a conversion from Python type P -> C++ type D -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Mon Feb 2 23:44:08 2004 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 02 Feb 2004 17:44:08 -0500 Subject: [C++-sig] Re: Operator== for reflected enums can return True when it shouldn't? References: Message-ID: "Pete Bartlett" writes: > (Apologies if this issue has been raised before - I must have put the > wrong search terms into Google) > > On my setup (Python 2.3, boost-cvs from early December, MSVC 7.1), > Python returns True when comparing two reflected enums of different type > that have the same internal integer representation. Though I am sure it > is bad Python style to compare different types, would it right and > possible to return False in this case? It depends how you view enums. Many people use them for simple constants, and in that case they should behave as C++ enums do, so they are comparable with other same-valued enums. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Mon Feb 2 23:42:10 2004 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 02 Feb 2004 17:42:10 -0500 Subject: [C++-sig] Re: New slice implementation References: <1073361918.13426.31.camel@illuvatar> <1073518393.1796.15.camel@illuvatar> <1073595081.19758.430.camel@illuvatar> <1073620180.19759.565.camel@illuvatar> <1073665816.19758.775.camel@illuvatar> <65fk1opl.fsf@boost-consulting.com> <1073970573.27246.67.camel@illuvatar> <1074047914.1215.43.camel@illuvatar> <1074473408.8246.3.camel@illuvatar> <1075252218.12314.14.camel@illuvatar> Message-ID: Jonathan Brandmeyer writes: >> sourceforge user id (the textual one) and I'll give you Boost CVS >> access so you can check this in yourself. > > My Sourceforge ID is "jbrandmeyer". Added. > There is also (hopefully only) one > remaining detail. How exactly is the testsuite driven? Or, phrased > differently, what do I need to do to get the tests to run automatically > when you execute `bjam test`? If it isn't obvious after looking at libs/python/test/Jamfile, let me know and I'll give you more detail. -- Dave Abrahams Boost Consulting www.boost-consulting.com From aashish at vrac.iastate.edu Tue Feb 3 16:49:38 2004 From: aashish at vrac.iastate.edu (aashish) Date: Tue, 3 Feb 2004 09:49:38 -0600 Subject: [C++-sig] Re: CVS version on VC++ 7.0 In-Reply-To: Message-ID: <200402031550.i13Fop3N9677172@vracs001.vrac.iastate.edu> Hi, I need to use the new conversion -> register_ptr_to_python.hpp in my project and register_ptr_to_python.hpp is only available in the CVS version of the boost. So what I did is I got the cvs version and was trying to add the project file into my project using Microsoft VC++ 7.0. For that I was trying to include the boost/libs/python/build/VisualStudio/"project file". It was asking me whether it should be converted for VC7.0. When you do that it says the file is corrupted "unable to load the project". Please let me know how to get the project file of boost.python on VC++ 7.0. ~regards, Aashish From aknuds-1 at broadpark.no Tue Feb 3 20:12:08 2004 From: aknuds-1 at broadpark.no (Arve Knudsen) Date: Tue, 03 Feb 2004 20:12:08 +0100 Subject: [C++-sig] Re: Manipulating arguments with CallPolicies::precall? In-Reply-To: References: Message-ID: Hi, thanks for taking time. I'll try to explain what it is I'm trying to achieve, maybe I'm going at it the completely wrong way. Thing is I need to work with an existing Python persistence framework written in C, where you're supposed to derive from a certain PyTypeObject. There isn't currently any way to inherit directly from a Python class defined outside of boost::python is there? I've tried registering the inheritance from within Python itself, but Python complains about incompatible instance layouts (or something). As a workaround I've tried creating a thin wrapper C++ class_, where I fill in the Python interface (.def) by looping over the PyTypeObject's (the one I want to inherit from) method definitions. By doing this I implicitly expose the PyTypeObject's methods without writing explicit wrapping methods, so my class can adapt to an eventual change in interface. I have some mock-up code that seems to work: PyMethodDef *md(typ->tp_methods); string mn; while (md->ml_name) { if (static_cast(md->ml_meth)) { mn = md->ml_name; if (md->ml_flags == METH_NOARGS) cls.def(mn.c_str(), (PyObject *(*)(PyObject *)) md->ml_meth); else if (md->ml_flags == METH_O) { cls.def(mn.c_str(), (PyObject *(*)(PyObject *, PyObject *)) md->ml_meth); } ++md; } } Since the exposed raw C functions expect a certain type of object however, I have to either derive my C++ class from the expected C struct, or extract a suitable struct from my C++ wrapper object. Deriving from the C struct seems to work, but at least I can't call the designated destructor (tp_dealloc) on my own object. Thus I'd prefer to wrap the C struct through composition, but I would need a way to extract this from an instance of my class and pass this to the raw C functions. I figured I could do this with CallPolicies::precall, but it would be hackish at best. Anyway, to sum up. I would like to inherit (in the Python sense) my class_ from an existing Python class, one way or the other :_) I apologize if there's some obvious approach which has evaded me. Thanks Arve Knudsen. On Mon, 02 Feb 2004 17:23:40 -0500, David Abrahams wrote: > Arve Knudsen writes: > >> Hi >> >> I want to wrap a native C Python object in a C++ object that takes >> care of constructing and destructing it properly > > I don't understand. Do you mean something akin to > boost::python::list, or something entirely different? >> (there isn't any way >> to specify custom allocation/deallocation routines are >> there?) > > I don't understand the question. allocation/deallocation routines > for what? >> However, I would like to send this object directly to the >> associated routines (its part of an existing Python extension). > > What associated routines. >> I haven't found any direct support for this kind of thing within >> boost::python, since everything seems strongly tied to the contained >> type (my wrapping C++ class). But, I figured it might be possible to >> manipulate the Python argument tuple within CallPolicies::precall? > > Sorry, I'm completely lost. I suggest you show some code that > demonstrates what you'd like to be able to do, but which isn't > supported. > > I didn't try very hard to understand the rest of the message, because > I didn't even get this far :( > From mike at nospam.com Tue Feb 3 20:21:40 2004 From: mike at nospam.com (Mike Rovner) Date: Tue, 3 Feb 2004 11:21:40 -0800 Subject: [C++-sig] Re: Re: CVS version on VC++ 7.0 References: <200402031550.i13Fop3N9677172@vracs001.vrac.iastate.edu> Message-ID: aashish wrote: > file". It was asking me whether it should be converted for VC7.0. > When you do that it says the file is corrupted "unable to load the Make sure you have windoze file ending, ie "\r\n" before convertion. HTH, Mike From aashish at iastate.edu Tue Feb 3 20:49:26 2004 From: aashish at iastate.edu (Aashish Chaudhary) Date: Tue, 3 Feb 2004 13:49:26 -0600 (CST) Subject: [C++-sig] Re: Re: CVS version on VC++ 7.0 Message-ID: <264913311042330@webmail.iastate.edu> Hi, I didn't get that quite well. Could you please explain it. ~regards, Aashish > aashish wrote: > > file". It was asking me whether it should be converted for VC7.0. > > When you do that it says the file is corrupted "unable to load the > > Make sure you have windoze file ending, ie "\r\n" before convertion. > > HTH, > Mike > > > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > __________________________________________________________________________ Aashish Chaudhary Research Assistant Iowa State University E-Mail: aashish at iastate.edu Ames, Iowa Telephone: +1 515-441-1178 From mike at nospam.com Tue Feb 3 21:53:12 2004 From: mike at nospam.com (Mike Rovner) Date: Tue, 3 Feb 2004 12:53:12 -0800 Subject: [C++-sig] Re: Re: Re: CVS version on VC++ 7.0 References: <264913311042330@webmail.iastate.edu> Message-ID: Aashish, Different OSes has different text files lines separation conventions. Unix uses single character '\n' (0xA) as line end symbol, DOS/Windows uses pair "\r\n" (0xD , 0xA) for that. Microsoft _requeres_ that project files (.sln, .vcproj for 7.x, .dsw, .dsp for 6.0) has DOS line ending. Unix text editors often convert files on save to unix convention and you could get such file from cvs. Also you can check out file from CVS as text file and (client permitting) explicitly set line ending to DOS dtyle. Also you can use simple tools like unix2dos.exe or even python2.3 script to do that (untested): import sys try: _, in, out = sys.argv except ValueError: print "Usage: python %s input_text_file output_file_dos_eol_style" % sys.argv[0] sys.exit() out=file(out, "w") for line in file(in, "rU").xreadlines(): print >>out, line Regards, Mike Aashish Chaudhary wrote: > Hi, > > I didn't get that quite well. Could you please explain it. > > ~regards, > Aashish > > >> aashish wrote: >>> file". It was asking me whether it should be converted for VC7.0. >>> When you do that it says the file is corrupted "unable to load the >> >> Make sure you have windoze file ending, ie "\r\n" before convertion. >> >> HTH, >> Mike >> >> >> >> >> _______________________________________________ >> C++-sig mailing list >> C++-sig at python.org >> http://mail.python.org/mailman/listinfo/c++-sig >> > > > __________________________________________________________________________ > Aashish Chaudhary > > Research Assistant > Iowa State University E-Mail: aashish at iastate.edu > Ames, Iowa Telephone: +1 515-441-1178 From aashish at iastate.edu Tue Feb 3 22:42:06 2004 From: aashish at iastate.edu (Aashish Chaudhary) Date: Tue, 3 Feb 2004 15:42:06 -0600 (CST) Subject: [C++-sig] Re: Re: Re: CVS version on VC++ 7.0 Message-ID: <64215311042330@webmail.iastate.edu> Thansk Mike. But unix2dos couldn't do it and the script didn't run .. Are you so sure that the problem is occuring because of that reason ?? ~regards, Aashish > Aashish, > > Different OSes has different text files lines separation conventions. > Unix uses single character '\n' (0xA) as line end symbol, > DOS/Windows uses pair "\r\n" (0xD , 0xA) for that. > > Microsoft _requeres_ that project files (.sln, .vcproj for 7.x, .dsw, .dsp > for 6.0) > has DOS line ending. > > Unix text editors often convert files on save to unix convention and you > could get such file from cvs. Also you can check out file from CVS as text > file and (client permitting) explicitly set line ending to DOS dtyle. Also > you can use simple tools like unix2dos.exe or even python2.3 script to do > that (untested): > > import sys > try: > _, in, out = sys.argv > except ValueError: > print "Usage: python %s input_text_file output_file_dos_eol_style" % > sys.argv[0] > sys.exit() > out=file(out, "w") > for line in file(in, "rU").xreadlines(): > print >>out, line > > Regards, > Mike > > Aashish Chaudhary wrote: > > Hi, > > > > I didn't get that quite well. Could you please explain it. > > > > ~regards, > > Aashish > > > > > >> aashish wrote: > >>> file". It was asking me whether it should be converted for VC7.0. > >>> When you do that it says the file is corrupted "unable to load the > >> > >> Make sure you have windoze file ending, ie "\r\n" before convertion. > >> > >> HTH, > >> Mike > >> > >> > >> > >> > >> _______________________________________________ > >> C++-sig mailing list > >> C++-sig at python.org > >> http://mail.python.org/mailman/listinfo/c++-sig > >> > > > > > > __________________________________________________________________________ > > Aashish Chaudhary > > > > Research Assistant > > Iowa State University E-Mail: aashish at iastate.edu > > Ames, Iowa Telephone: +1 515-441-1178 > > > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > __________________________________________________________________________ Aashish Chaudhary Research Assistant Iowa State University E-Mail: aashish at iastate.edu Ames, Iowa Telephone: +1 515-441-1178 From mike at nospam.com Wed Feb 4 02:05:06 2004 From: mike at nospam.com (Mike Rovner) Date: Tue, 3 Feb 2004 17:05:06 -0800 Subject: [C++-sig] Re: Re: Re: Re: CVS version on VC++ 7.0 References: <64215311042330@webmail.iastate.edu> Message-ID: Aashish Chaudhary wrote: > Thansk Mike. But unix2dos couldn't do it and the script didn't run .. > Are you so sure that the problem is occuring > because of that reason ?? To be sure you provided too little information ;). I just had smilar problem and solve it that way. Mike From fabrizio.duhem at free.fr Wed Feb 4 21:02:13 2004 From: fabrizio.duhem at free.fr (Fabrizio) Date: Wed, 4 Feb 2004 21:02:13 +0100 Subject: [C++-sig] PyErr_Print() as string ? Message-ID: hi, sorry for my english i want to get python error as string. i try to redirect PyErr_Print() into std::cerr.rdbuf but doesn't work any idea ? Thanks in advance. fabrizio --- Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.577 / Virus Database: 366 - Release Date: 03/02/2004 From s_sourceforge at nedprod.com Wed Feb 4 22:19:25 2004 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Wed, 04 Feb 2004 21:19:25 -0000 Subject: [C++-sig] Digital Mars compiler Message-ID: <402161DD.28199.3A7DF11A@localhost> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, Just wondering if anyone's used the above compiler with Boost.Python? If so, was it faster, did it produce smaller output and could it generate full debug info usable by MSVC's debugger? Cheers, Niall -----BEGIN PGP SIGNATURE----- Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 iQA/AwUBQCFh38EcvDLFGKbPEQI4xACg5CqajR4I8EqJ2lObVmfx+2Pq0bQAoOfT 1gFI313AjMhlvKcKE8p/5O2N =RvFr -----END PGP SIGNATURE----- From pierre.barbier at cirad.fr Thu Feb 5 09:48:35 2004 From: pierre.barbier at cirad.fr (Pierre Barbier de Reuille) Date: Thu, 05 Feb 2004 09:48:35 +0100 Subject: [C++-sig] PyErr_Print() as string ? In-Reply-To: References: Message-ID: <1075970915.11862.44.camel@pbarbier> You can redefine sys.stderr to be a StringIO (or any class behaving as a file...). Then, when you call PyErr_Print() it will "print" the error in your class ... so it will be in your string. But this is bot a Boost.Python question, this question should be in a Python mailing list ... Pierre On Wed, 2004-02-04 at 21:02, Fabrizio wrote: > hi, sorry for my english > > i want to get python error as string. > i try to redirect PyErr_Print() into std::cerr.rdbuf but doesn't work > > any idea ? > > Thanks in advance. > > fabrizio > > > > --- > > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.577 / Virus Database: 366 - Release Date: 03/02/2004 > > > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig -- 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 RaoulGough at yahoo.co.uk Thu Feb 5 19:21:07 2004 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Thu, 05 Feb 2004 18:21:07 +0000 Subject: [C++-sig] MSVC6 problems upgrading to Version_1_31_0 tag Message-ID: For some now forgotten reason, I decided to start testing my indexing_v2 code with Version_1_31_0 of the rest of boost. I'm now having trouble compiling python/src/object/inheritance.cpp on MSVC6 - errors are reported in boost/graph/detail/adjacency_list.hpp and boost/mem_fn.hpp (full details below). This error *might* be because I still have some things around from the indexing_v2 branch, although I've tried to eliminate this possibility by reverting most of the libs/python/src tree and virtually all of the boost headers to the Version_1_31_0 tag. BTW, I don't see any Python test results at http://boost.sourceforge.net/regression-logs/cs-win32.html but MSVC6 has a bunch of fails in the graph and function libraries. Any insight into this? ----- build output (I'm pretty sure I'm using v1 of the build tools) - "C:\Program Files\Microsoft Visual Studio\VC98\bin\cl" /Zm800 -nologo -GX -c -DBOOST_PYTHON_DYNAMIC_LIB -DBOOST_PYTHON_SOURCE /Z7 /Od /Ob0 /GX /GR /MDd -I"c:\home\rgough\build\bin\boost\libs\python\build" -I"C:\home\rgough\boost" -I"c:\Python23\include" -I"c:\home\rgough\msvc" -Fo"c:\home\rgough\build\bin\boost\libs\python\build\boost_python.dll\msvc\debug\inheritance.obj" -Tp"C:\home\rgough\boost\libs\python\build\../src/object\inheritance.cpp" inheritance.cpp C:\home\rgough\boost\boost/graph/detail/adjacency_list.hpp(1055) : error C2244: 'bidirectional_graph_helper_with_property::remove_edge' : unable to resolve function overload C:\home\rgough\boost\boost/graph/detail/adjacency_list.hpp(1057) : error C2954: template definitions cannot nest C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2039: 'dm' : is not a member of '_mfi' C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2143: syntax error : missing ';' before '<' C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2501: 'dm' : missing storage-class or type specifiers C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2059: syntax error : ';' C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2059: syntax error : '<' C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2653: 'T' : is not a class or namespace name C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2645: no qualified name for pointer to member (found ':: *') C:\home\rgough\boost\boost/mem_fn.hpp(320) : error C2143: syntax error : missing ';' before '}' C:\home\rgough\boost\boost/mem_fn.hpp(320) : fatal error C1506: unrecoverable block scoping error ...failed vc-C++ c:\home\rgough\build\bin\boost\libs\python\build\boost_python.dll\msvc\debug\inheritance.obj... -- Raoul Gough. export LESS='-X' From aashish at vrac.iastate.edu Thu Feb 5 21:27:03 2004 From: aashish at vrac.iastate.edu (aashish) Date: Thu, 5 Feb 2004 14:27:03 -0600 Subject: [C++-sig] Re: implicitly_convertible In-Reply-To: Message-ID: <200402052028.i15KS83N9780877@vracs001.vrac.iastate.edu> Hi, Well as I posted some problems before regarding boost.python project file for the Windows ...as when I didn't make it I started compiling myself using MSVC 7.0 and it came out fime but just one error (well some more and they all belongs to this line) In the header file: Function_trmplate.hpp this->manager = &detail::function::trivial_manager; c:\users\aashish\learning\software\boost-1.30.2\boost\function\function_temp late.hpp(511) : error C2563: mismatch in formal parameter list c:\users\aashish\deere6\learning\software\boost-1.30.2\boost\function\functi on_template.hpp(511) : error C2568: '=' : unable to resolve function overload c:\users\aashish\deere6\learning\software\boost-1.30.2\boost\function\functi on_base.hpp(192): could be 'boost::detail::function::any_pointer boost::detail::function::trivial_manager(boost::detail::function::any_pointe r,boost::detail::function::functor_manager_operation_type)' Any help will be appreciated.. Thanks, Aashish From aashish at vrac.iastate.edu Thu Feb 5 21:54:28 2004 From: aashish at vrac.iastate.edu (aashish) Date: Thu, 5 Feb 2004 14:54:28 -0600 Subject: [C++-sig] Re: Boost.Python compiling on windws (MSVC 7.0) Message-ID: <200402052055.i15KtX3N9784574@vracs001.vrac.iastate.edu> -----Original Message----- From: aashish [mailto:aashish at vrac.iastate.edu] Sent: Thursday, February 05, 2004 2:27 PM To: 'Development of Python/C++ integration' Subject: RE: [C++-sig] Re: implicitly_convertible Hi, Well as I posted some problems before regarding boost.python project file for the Windows ...as when I didn't make it I started compiling myself using MSVC 7.0 and it came out fime but just one error (well some more and they all belongs to this line) In the header file: Function_trmplate.hpp this->manager = &detail::function::trivial_manager; c:\users\aashish\learning\software\boost-1.30.2\boost\function\function_temp late.hpp(511) : error C2563: mismatch in formal parameter list c:\users\aashish\deere6\learning\software\boost-1.30.2\boost\function\functi on_template.hpp(511) : error C2568: '=' : unable to resolve function overload c:\users\aashish\deere6\learning\software\boost-1.30.2\boost\function\functi on_base.hpp(192): could be 'boost::detail::function::any_pointer boost::detail::function::trivial_manager(boost::detail::function::any_pointe r,boost::detail::function::functor_manager_operation_type)' Any help will be appreciated.. Thanks, Aashish From rwgk at yahoo.com Thu Feb 5 22:47:55 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 5 Feb 2004 13:47:55 -0800 (PST) Subject: [C++-sig] Re: implicitly_convertible In-Reply-To: <200402052028.i15KS83N9780877@vracs001.vrac.iastate.edu> Message-ID: <20040205214755.26675.qmail@web20203.mail.yahoo.com> My guess is that this is a secondary error and the real problem is somewhere else. Could you try to strip down your code to a minimum and then post the remaining rest, along with the command line that you use for compiling? Ralf --- aashish wrote: > Hi, > > Well as I posted some problems before regarding boost.python project file > for the Windows ...as when I didn't make it I started compiling myself using > > MSVC 7.0 and it came out fime but just one error (well some more and they > all belongs to this line) > > In the header file: > > Function_trmplate.hpp > > this->manager = &detail::function::trivial_manager; > > c:\users\aashish\learning\software\boost-1.30.2\boost\function\function_temp > late.hpp(511) : error C2563: mismatch in formal parameter list > > c:\users\aashish\deere6\learning\software\boost-1.30.2\boost\function\functi > on_template.hpp(511) : error C2568: '=' : unable to resolve function > overload > > c:\users\aashish\deere6\learning\software\boost-1.30.2\boost\function\functi > on_base.hpp(192): could be 'boost::detail::function::any_pointer > boost::detail::function::trivial_manager(boost::detail::function::any_pointe > r,boost::detail::function::functor_manager_operation_type)' > > Any help will be appreciated.. > > Thanks, > Aashish __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html From aashish at iastate.edu Thu Feb 5 22:56:14 2004 From: aashish at iastate.edu (Aashish Chaudhary) Date: Thu, 5 Feb 2004 15:56:14 -0600 (CST) Subject: [C++-sig] Re: implicitly_convertible Message-ID: <145615511044350@webmail.iastate.edu> The code is there in boost.python and part of it (from boost/python/function_template.hpp) void assign_to(const reference_wrapper& f, detail::function::function_obj_ref_tag) { if (!detail::function::has_empty_target(f.get_pointer())) { typedef typename detail::function::BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER< FunctionObj, R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS >::type invoker_type; invoker = &invoker_type::invoke; this->manager = &detail::function::trivial_manager; //LINE 511 error showing here !! this->functor = this->manager( detail::function::make_any_pointer( const_cast(f.get_pointer())), detail::function::clone_functor_tag); } } The command line options are /Od /I "../../../../" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "BOOST_PYTHON_DYNAMIC_LIB" /D "BOOST_PYTHON _SOURCE" /D "_MBCS" /D "_WINDLL" /FD /EHsc /RTC1 /MDd /GS /GR /Fp".\debug-obj/boost_python.pch" /Fo".\debug- obj/" /Fd".\debug-obj/" /W3 /nologo /c /Zi I have got the cvs version as the version on the web does not has the some of the converters that I am using. ~regads, Aashish > My guess is that this is a secondary error and the real problem is somewhere > else. Could you try to strip down your code to a minimum and then post the > remaining rest, along with the command line that you use for compiling? > Ralf > > --- aashish wrote: > > Hi, > > > > Well as I posted some problems before regarding boost.python project file > > for the Windows ...as when I didn't make it I started compiling myself using > > > > MSVC 7.0 and it came out fime but just one error (well some more and they > > all belongs to this line) > > > > In the header file: > > __________________________________________________________________________ Aashish Chaudhary Research Assistant Iowa State University E-Mail: aashish at iastate.edu Ames, Iowa Telephone: +1 515-441-1178 From rwgk at yahoo.com Fri Feb 6 01:57:46 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 5 Feb 2004 16:57:46 -0800 (PST) Subject: [C++-sig] Re: implicitly_convertible In-Reply-To: <145615511044350@webmail.iastate.edu> Message-ID: <20040206005746.52838.qmail@web20201.mail.yahoo.com> --- Aashish Chaudhary wrote: > The code is there in boost.python and part of it (from > boost/python/function_template.hpp) What is the .cpp file that you are trying to compile? What happens if you try to compile without pre-compiled headers? I saw other people mentioning issues with PCH, but I've never tried it myself. Maybe someone else can help if the use of PCH is part of the problem. Ralf __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html From aashish at vrac.iastate.edu Fri Feb 6 02:22:21 2004 From: aashish at vrac.iastate.edu (aashish) Date: Thu, 5 Feb 2004 19:22:21 -0600 Subject: [C++-sig] Re: implicitly_convertible In-Reply-To: <20040206005746.52838.qmail@web20201.mail.yahoo.com> Message-ID: <200402060123.i161NQ3N9762300@vracs001.vrac.iastate.edu> Ohh the PCH is not really a problem... what I am trying to do is compiling all the boost.python source files and hence creating the DLL which will be used by my C++ and Python programs ... ~regards, Aashish -----Original Message----- From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] On Behalf Of Ralf W. Grosse-Kunstleve Sent: Thursday, February 05, 2004 6:58 PM To: Development of Python/C++ integration Subject: RE: [C++-sig] Re: implicitly_convertible --- Aashish Chaudhary wrote: > The code is there in boost.python and part of it (from > boost/python/function_template.hpp) What is the .cpp file that you are trying to compile? What happens if you try to compile without pre-compiled headers? I saw other people mentioning issues with PCH, but I've never tried it myself. Maybe someone else can help if the use of PCH is part of the problem. Ralf __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html _______________________________________________ C++-sig mailing list C++-sig at python.org http://mail.python.org/mailman/listinfo/c++-sig From iceryeah2000 at 163.com Fri Feb 6 03:19:17 2004 From: iceryeah2000 at 163.com (iceryeah) Date: Fri, 6 Feb 2004 10:19:17 +0800 Subject: [C++-sig] how to expose the func like "print( char * str, ... Message-ID: hello, i have 2 problems: problem 1: i can expose the function like void a( void ) def( "a", a ); but there is anthor function like this: void DebugMessage( char *msg,... ); i don't know how to expose this function. problem 2: module test int num = 0; void set( int a ) { num = a; } then i expose set func , and do this in script: import test test.set( 10 ) and then in host app, i check the var num, it is not 10,why? thanks very much. From steam at nurfuerspam.de Fri Feb 6 11:22:06 2004 From: steam at nurfuerspam.de (Hanz Meizer) Date: Fri, 06 Feb 2004 11:22:06 +0100 Subject: [C++-sig] Problem with different return types. Message-ID: Hello, I've got an abstract class that has one function name with 2 different definition: virtual const C& getC(void ) const = 0; virtual C& getC(void) = 0; Is it possible to export both functions? Is it possible to export one of them, and ignore the other? I've tried several ways to include it, but both did not work out. Currently I'm using pythe to generate the interface class. So my other question is: If it's possible, how can I integrate the solution in pyste? :) Regards, Hanz. From xavier.warin at der.edfgdf.fr Fri Feb 6 11:38:36 2004 From: xavier.warin at der.edfgdf.fr (Xavier WARIN(Compte LOCAL) - I23) Date: Fri, 06 Feb 2004 11:38:36 +0100 Subject: [C++-sig] Problems to compile Boost 1.31.0 Message-ID: <40236EAC.9070606@der.edfgdf.fr> Hi, I used to compile version 1_30_2 on redhat 7.2 with g++ 3.04 and 3.2.3 for python 2.2.3. I tried to move to version 1_31_0 : - no problem with g++ 3.2.3 - with g++ 3.0.4 i get this message trying to compile with bjam : gcc-C++-action bin/boost/libs/python/build/libboost_python.a/gcc/debug/threading-multi/inheritance.o /local/SOFTWARE/boost_1_31_0_gcc3.0.4/boost/iterator/iterator_traits.hpp: In function `void std::distance(_InputIterator, _InputIterator, _Distance&) [with _InputIterator = std::__normal_iterator::index_entry*, std::vector::index_entry, std::allocator::index_entry> > >, _Distance = ptrdiff_t]': /local/SOFT_GCC3.0.4_PYTHON2.2.3/include/g++-v3/bits/stl_algo.h:2211: instantiated from `_ForwardIter std::__lower_bound(_ForwardIter, _ForwardIter, const _Tp&, _Compare, _Distance*) [with _ForwardIter = std::__normal_iterator::index_entry*, std::vector::index_entry, std::allocator::index_entry> > >, _Tp = boost::tuples::tuple::class_id, vertex_t, boost::python::objects::dynamic_id_t (*)(void*), boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, _Compare = boost::_bi::bind_t::class_id>, boost::_bi::list2::class_id, boost::::select1st::index_entry*, std::vector::index_entry, std::allocator::index_entry> > > boost::::type_position(boost::python::type_info)::entry>, boost::_bi::list1 > >, boost::_bi::bind_t::class_id, boost::::select1st::index_entry*, std::vector::index_entry, std::allocator::index_entry> > > boost::::type_position(boost::python::type_info)::entry>, boost::_bi::list1 > > > >, _Distance = ptrdiff_t]' etc .. Has anybody seen this problem before ? I saw on boost web site that this compiler has been tested. Has anybody tried to compile with g++ 3.3.2 ? Thank you Xavier From schmitt at num.uni-sb.de Fri Feb 6 15:06:07 2004 From: schmitt at num.uni-sb.de (Uwe Schmitt) Date: Fri, 6 Feb 2004 15:06:07 +0100 Subject: [C++-sig] type conversion Message-ID: Hi, how can I instruct boost to convert std::pair to a Python tuple ??? I did not find anything in the archive... Greetings, Uwe From w.d.jonge at cebra.tue.nl Fri Feb 6 17:26:50 2004 From: w.d.jonge at cebra.tue.nl (Willem de Jonge) Date: Fri, 6 Feb 2004 17:26:50 +0100 Subject: [C++-sig] Re: MSVC6 problems upgrading to Version_1_31_0 tag References: Message-ID: I'm having the same problem. I used a "clean" 1.31.0 version (.zip downloaded from sourceforge). I also did a new checkout from the CVS today, which also doesn't compile. I did a CVS checkout on 21-1-2004 which compiled fine (and still does). Any help appreciated. Willem de Jonge "Raoul Gough" wrote in message news:usmhpz8to.fsf at yahoo.co.uk... > For some now forgotten reason, I decided to start testing my > indexing_v2 code with Version_1_31_0 of the rest of boost. I'm now > having trouble compiling python/src/object/inheritance.cpp on MSVC6 - > errors are reported in boost/graph/detail/adjacency_list.hpp and > boost/mem_fn.hpp (full details below). > > This error *might* be because I still have some things around from the > indexing_v2 branch, although I've tried to eliminate this possibility > by reverting most of the libs/python/src tree and virtually all of the > boost headers to the Version_1_31_0 tag. > > BTW, I don't see any Python test results at > http://boost.sourceforge.net/regression-logs/cs-win32.html but MSVC6 > has a bunch of fails in the graph and function libraries. Any insight > into this? > > ----- build output (I'm pretty sure I'm using v1 of the build tools) - > > "C:\Program Files\Microsoft Visual Studio\VC98\bin\cl" /Zm800 > -nologo -GX -c -DBOOST_PYTHON_DYNAMIC_LIB -DBOOST_PYTHON_SOURCE /Z7 > /Od /Ob0 /GX /GR /MDd > -I"c:\home\rgough\build\bin\boost\libs\python\build" > -I"C:\home\rgough\boost" -I"c:\Python23\include" > -I"c:\home\rgough\msvc" > -Fo"c:\home\rgough\build\bin\boost\libs\python\build\boost_python.dll\msvc \debug\inheritance.obj" > -Tp"C:\home\rgough\boost\libs\python\build\../src/object\inheritance.cpp" > > inheritance.cpp > C:\home\rgough\boost\boost/graph/detail/adjacency_list.hpp(1055) : error C2244: 'bidirectional_graph_helper_with_property::remove_edge' : unable to resolve function overload > C:\home\rgough\boost\boost/graph/detail/adjacency_list.hpp(1057) : error C2954: template definitions cannot nest > C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2039: 'dm' : is not a member of '_mfi' > C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2143: syntax error : missing ';' before '<' > C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2501: 'dm' : missing storage-class or type specifiers > C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2059: syntax error : ';' > C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2059: syntax error : '<' > C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2653: 'T' : is not a class or namespace name > C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2645: no qualified name for > pointer to member (found ':: *') > C:\home\rgough\boost\boost/mem_fn.hpp(320) : error C2143: syntax error : missing ';' before '}' > C:\home\rgough\boost\boost/mem_fn.hpp(320) : fatal error C1506: unrecoverable block scoping error > ...failed vc-C++ c:\home\rgough\build\bin\boost\libs\python\build\boost_python.dll\msvc\debug \inheritance.obj... > > -- > Raoul Gough. > export LESS='-X' From RaoulGough at yahoo.co.uk Fri Feb 6 18:58:45 2004 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Fri, 06 Feb 2004 17:58:45 +0000 Subject: [C++-sig] Re: MSVC6 problems upgrading to Version_1_31_0 tag References: Message-ID: "Willem de Jonge" writes: > "Raoul Gough" wrote in message > news:usmhpz8to.fsf at yahoo.co.uk... [reformatting...] >> I'm now having trouble compiling python/src/object/inheritance.cpp >> on MSVC6 - errors are reported in >> boost/graph/detail/adjacency_list.hpp and boost/mem_fn.hpp (full >> details below). > > I'm having the same problem. I used a "clean" 1.31.0 version (.zip > downloaded from sourceforge). I also did a new checkout from the CVS > today, which also doesn't compile. I did a CVS checkout on 21-1-2004 > which compiled fine (and still does). Any help appreciated. That's bad - it's starting to look like Boost.Python may be broken on MSVC6 in the 1.31.0 release... I can't imagine it was a conscious decision to drop support for this compiler, but it could be that the Windows regression tests don't include Boost.Python [see below]. Maybe Ralf knows more about the situation? [snip] >> I don't see any Python test results at >> http://boost.sourceforge.net/regression-logs/cs-win32.html but MSVC6 >> has a bunch of fails in the graph and function libraries. Any insight >> into this? >> >> ----- build output (I'm pretty sure I'm using v1 of the build tools) - >> >> "C:\Program Files\Microsoft Visual Studio\VC98\bin\cl" /Zm800 >> -nologo -GX -c -DBOOST_PYTHON_DYNAMIC_LIB -DBOOST_PYTHON_SOURCE /Z7 >> /Od /Ob0 /GX /GR /MDd >> -I"c:\home\rgough\build\bin\boost\libs\python\build" >> -I"C:\home\rgough\boost" -I"c:\Python23\include" >> -I"c:\home\rgough\msvc" >> -Fo"c:\home\rgough\build\bin\boost\libs\python\build\boost_python.dll\msvc > \debug\inheritance.obj" >> -Tp"C:\home\rgough\boost\libs\python\build\../src/object\inheritance.cpp" >> >> inheritance.cpp >> C:\home\rgough\boost\boost/graph/detail/adjacency_list.hpp(1055) : error > C2244: 'bidirectional_graph_helper_with_property::remove_edge' : > unable to resolve function overload >> C:\home\rgough\boost\boost/graph/detail/adjacency_list.hpp(1057) : error > C2954: template definitions cannot nest >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2039: 'dm' : is not a > member of '_mfi' >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2143: syntax error : > missing ';' before '<' >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2501: 'dm' : missing > storage-class or type specifiers >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2059: syntax error : > ';' >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2059: syntax error : > '<' >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2653: 'T' : is not a > class or namespace name >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2645: no qualified > name for >> pointer to member (found ':: *') >> C:\home\rgough\boost\boost/mem_fn.hpp(320) : error C2143: syntax error : > missing ';' before '}' >> C:\home\rgough\boost\boost/mem_fn.hpp(320) : fatal error C1506: > unrecoverable block scoping error >> ...failed vc-C++ > c:\home\rgough\build\bin\boost\libs\python\build\boost_python.dll\msvc\debug > \inheritance.obj... -- Raoul Gough. export LESS='-X' From aashish at iastate.edu Fri Feb 6 19:49:41 2004 From: aashish at iastate.edu (Aashish Chaudhary) Date: Fri, 6 Feb 2004 12:49:41 -0600 (CST) Subject: [C++-sig] Re: MSVC6 problems upgrading to Version_1_31_0 tag Message-ID: <414912611045360@webmail.iastate.edu> I had some sort of same probelm with the MSVC7.0 !! compiling the cvs version of Boost.Python... ~aashish > "Willem de Jonge" writes: > > "Raoul Gough" wrote in message > > news:usmhpz8to.fsf at yahoo.co.uk... > > [reformatting...] > >> I'm now having trouble compiling python/src/object/inheritance.cpp > >> on MSVC6 - errors are reported in > >> boost/graph/detail/adjacency_list.hpp and boost/mem_fn.hpp (full > >> details below). > > > > I'm having the same problem. I used a "clean" 1.31.0 version (.zip > > downloaded from sourceforge). I also did a new checkout from the CVS > > today, which also doesn't compile. I did a CVS checkout on 21-1-2004 > > which compiled fine (and still does). Any help appreciated. > > That's bad - it's starting to look like Boost.Python may be broken on > MSVC6 in the 1.31.0 release... I can't imagine it was a conscious > decision to drop support for this compiler, but it could be that the > Windows regression tests don't include Boost.Python [see below]. > Maybe Ralf knows more about the situation? > > [snip] > >> I don't see any Python test results at > >> http://boost.sourceforge.net/regression-logs/cs-win32.html but MSVC6 > >> has a bunch of fails in the graph and function libraries. Any insight > >> into this? > >> > >> ----- build output (I'm pretty sure I'm using v1 of the build tools) - > >> > >> "C:\Program Files\Microsoft Visual Studio\VC98\bin\cl" /Zm800 > >> -nologo -GX -c -DBOOST_PYTHON_DYNAMIC_LIB -DBOOST_PYTHON_SOURCE /Z7 > >> /Od /Ob0 /GX /GR /MDd > >> -I"c:\home\rgough\build\bin\boost\libs\python\build" > >> -I"C:\home\rgough\boost" -I"c:\Python23\include" > >> -I"c:\home\rgough\msvc" > >> -Fo"c:\home\rgough\build\bin\boost\libs\python\build\boost_python.dll\msvc > > \debug\inheritance.obj" > >> -Tp"C:\home\rgough\boost\libs\python\build\../src/object\inheritance.cpp" > >> > >> inheritance.cpp > >> C:\home\rgough\boost\boost/graph/detail/adjacency_list.hpp(1055) : error > > C2244: 'bidirectional_graph_helper_with_property::remove_edge' : > > unable to resolve function overload > >> C:\home\rgough\boost\boost/graph/detail/adjacency_list.hpp(1057) : error > > C2954: template definitions cannot nest > >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2039: 'dm' : is not a > > member of '_mfi' > >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2143: syntax error : > > missing ';' before '<' > >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2501: 'dm' : missing > > storage-class or type specifiers > >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2059: syntax error : > > ';' > >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2059: syntax error : > > '<' > >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2653: 'T' : is not a > > class or namespace name > >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2645: no qualified > > name for > >> pointer to member (found ':: *') > >> C:\home\rgough\boost\boost/mem_fn.hpp(320) : error C2143: syntax error : > > missing ';' before '}' > >> C:\home\rgough\boost\boost/mem_fn.hpp(320) : fatal error C1506: > > unrecoverable block scoping error > >> ...failed vc-C++ > > c:\home\rgough\build\bin\boost\libs\python\build\boost_python.dll\msvc\debug > > \inheritance.obj... > > -- > Raoul Gough. > export LESS='-X' > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > __________________________________________________________________________ Aashish Chaudhary Research Assistant Iowa State University E-Mail: aashish at iastate.edu Ames, Iowa Telephone: +1 515-441-1178 From aleskx at yahoo.com Fri Feb 6 17:38:00 2004 From: aleskx at yahoo.com (Aleksandar Fabijanic) Date: Fri, 6 Feb 2004 08:38:00 -0800 (PST) Subject: [C++-sig] Boost.Python and reportlab Message-ID: <20040206163800.38453.qmail@web12907.mail.yahoo.com> Hi, Anyone has any experience or can point me to some resources on running reportlab from c++ using boost.python? Thanks, Alex __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html From s_sourceforge at nedprod.com Fri Feb 6 19:58:36 2004 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Fri, 06 Feb 2004 18:58:36 -0000 Subject: [C++-sig] Problem with different return types. In-Reply-To: Message-ID: <4023E3DC.6972.4449BBBB@localhost> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 6 Feb 2004 at 11:22, Hanz Meizer wrote: > virtual const C& getC(void ) const = 0; > virtual C& getC(void) = 0; > > Is it possible to export both functions? Is it possible to export one > of them, and ignore the other? I've tried several ways to include it, > but both did not work out. Currently I'm using pythe to generate the > interface class. So my other question is: If it's possible, how can I > integrate the solution in pyste? :) delete the def("getC", (const C& (*)(void) const) &getC) version. Python never calls from within a const context anyway. Cheers, Niall -----BEGIN PGP SIGNATURE----- Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 iQA/AwUBQCPj3MEcvDLFGKbPEQLAkgCeLLu7oAalXtkOQb/rYwJdqQPianQAoPcs /jS5MUAH5YcfiKwW5wE3n/Ce =AzGw -----END PGP SIGNATURE----- From rwgk at yahoo.com Fri Feb 6 20:30:04 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Fri, 6 Feb 2004 11:30:04 -0800 (PST) Subject: [C++-sig] Re: MSVC6 problems upgrading to Version_1_31_0 tag In-Reply-To: <414912611045360@webmail.iastate.edu> Message-ID: <20040206193004.91535.qmail@web20206.mail.yahoo.com> Unfortunately I have to confirm that Boost.Python from the 1.31.0 release fails to compile with Visual C++ 6. :( :( :( I am extremely frustrated because I spent days and days recompiling the RC_1_31_0 branch over and over again with many different compilers. I guess I got exhausted because the release was pushed back all the time and VC6 dropped off my radar at some point. However, I am having NO problems compiling with Visual C++ 7.0 (.NET 2002) and 7.1 (.NET 2003) using our SCons-based build system. This includes compiling all tests in boost/libs/python/test. I.e. any problems with these compilers must be due to the compilation flags used. To see that flags that I am using look here: http://cci.lbl.gov/cctbx_build/results/2004_01_20_2338/win2000_py23_build_log I should mention that our VC7 is the poor-man's version without the optimizer. But our VC7.1 is the full-blown version. I don't know what to do about the VC6 failure. David? Two comments: - First of all a plea: please, please, please try the release candidates if you want to be sure a release works on your platform. For a volunteer driven development like Boost it is very difficult to ensure everything is healthy on all platforms at all times. Especially if antiquated compilers are involved we really depend on timely feedback. - Maybe it is a wink from god: VC6 is a very sick compiler anyway. A much better alternative is readily available (VC71). I personally believe that any effort spent on supporting VC6 is a huge financial damage in the bigger picture. Ralf --- Aashish Chaudhary wrote: > I had some sort of same probelm with the MSVC7.0 !! compiling the cvs version > of > Boost.Python... > > ~aashish > > > > > "Willem de Jonge" writes: > > > "Raoul Gough" wrote in message > > > news:usmhpz8to.fsf at yahoo.co.uk... > > > > [reformatting...] > > >> I'm now having trouble compiling python/src/object/inheritance.cpp > > >> on MSVC6 - errors are reported in > > >> boost/graph/detail/adjacency_list.hpp and boost/mem_fn.hpp (full > > >> details below). > > > > > > I'm having the same problem. I used a "clean" 1.31.0 version (.zip > > > downloaded from sourceforge). I also did a new checkout from the CVS > > > today, which also doesn't compile. I did a CVS checkout on 21-1-2004 > > > which compiled fine (and still does). Any help appreciated. > > > > That's bad - it's starting to look like Boost.Python may be broken on > > MSVC6 in the 1.31.0 release... I can't imagine it was a conscious > > decision to drop support for this compiler, but it could be that the > > Windows regression tests don't include Boost.Python [see below]. > > Maybe Ralf knows more about the situation? > > > > [snip] > > >> I don't see any Python test results at > > >> http://boost.sourceforge.net/regression-logs/cs-win32.html but MSVC6 > > >> has a bunch of fails in the graph and function libraries. Any insight > > >> into this? > > >> > > >> ----- build output (I'm pretty sure I'm using v1 of the build tools) - > > >> > > >> "C:\Program Files\Microsoft Visual Studio\VC98\bin\cl" /Zm800 > > >> -nologo -GX -c -DBOOST_PYTHON_DYNAMIC_LIB -DBOOST_PYTHON_SOURCE /Z7 > > >> /Od /Ob0 /GX /GR /MDd > > >> -I"c:\home\rgough\build\bin\boost\libs\python\build" > > >> -I"C:\home\rgough\boost" -I"c:\Python23\include" > > >> -I"c:\home\rgough\msvc" > > >> > -Fo"c:\home\rgough\build\bin\boost\libs\python\build\boost_python.dll\msvc > > > \debug\inheritance.obj" > > >> > -Tp"C:\home\rgough\boost\libs\python\build\../src/object\inheritance.cpp" > > >> > > >> inheritance.cpp > > >> C:\home\rgough\boost\boost/graph/detail/adjacency_list.hpp(1055) : error > > > C2244: 'bidirectional_graph_helper_with_property::remove_edge' : > > > unable to resolve function overload > > >> C:\home\rgough\boost\boost/graph/detail/adjacency_list.hpp(1057) : error > > > C2954: template definitions cannot nest > > >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2039: 'dm' : is not > a > > > member of '_mfi' > > >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2143: syntax error : > > > missing ';' before '<' > > >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2501: 'dm' : missing > > > storage-class or type specifiers > > >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2059: syntax error : > > > ';' > > >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2059: syntax error : > > > '<' > > >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2653: 'T' : is not a > > > class or namespace name > > >> C:\home\rgough\boost\boost/mem_fn.hpp(315) : error C2645: no qualified > > > name for > > >> pointer to member (found ':: *') > > >> C:\home\rgough\boost\boost/mem_fn.hpp(320) : error C2143: syntax error : > > > missing ';' before '}' > > >> C:\home\rgough\boost\boost/mem_fn.hpp(320) : fatal error C1506: > > > unrecoverable block scoping error > > >> ...failed vc-C++ > > > > c:\home\rgough\build\bin\boost\libs\python\build\boost_python.dll\msvc\debug > > > \inheritance.obj... > > > > -- > > Raoul Gough. > > export LESS='-X' > > > > > > _______________________________________________ > > C++-sig mailing list > > C++-sig at python.org > > http://mail.python.org/mailman/listinfo/c++-sig __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html From rwgk at yahoo.com Fri Feb 6 20:37:27 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Fri, 6 Feb 2004 11:37:27 -0800 (PST) Subject: [C++-sig] Problems to compile Boost 1.31.0 In-Reply-To: <40236EAC.9070606@der.edfgdf.fr> Message-ID: <20040206193727.93114.qmail@web20206.mail.yahoo.com> --- "Xavier WARIN(Compte LOCAL) - I23" wrote: > Has anybody seen this problem before ? I saw on boost web site that this > compiler has been tested. > Has anybody tried to compile with g++ 3.3.2 ? Well, some version was tested at some point. It is simply impossible for us to completely cover the many different combinations of OS releases, compilers, Python Versions and Boost Versions at all times. We need help and that's what the release candidates are for. See my previous posting. Ralf __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html From aashish at iastate.edu Fri Feb 6 20:47:20 2004 From: aashish at iastate.edu (Aashish Chaudhary) Date: Fri, 6 Feb 2004 13:47:20 -0600 (CST) Subject: [C++-sig] Problems to compile Boost 1.31.0 Message-ID: <204713611045360@webmail.iastate.edu> Hi Ralf, Is it possible or you to put the scons script to compile Boost.Python on MSVC7.0. Yeah I wont recommend someone to use VC6.0. ~aashish > --- "Xavier WARIN(Compte LOCAL) - I23" wrote: > > Has anybody seen this problem before ? I saw on boost web site that this > > compiler has been tested. > > Has anybody tried to compile with g++ 3.3.2 ? > > Well, some version was tested at some point. It is simply impossible for us to > completely cover the many different combinations of OS releases, compilers, > Python Versions and Boost Versions at all times. We need help and that's what > the release candidates are for. See my previous posting. > Ralf > > > __________________________________ > Do you Yahoo!? > Yahoo! Finance: Get your refund fast by filing online. > http://taxes.yahoo.com/filing.html > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > __________________________________________________________________________ Aashish Chaudhary Research Assistant Iowa State University E-Mail: aashish at iastate.edu Ames, Iowa Telephone: +1 515-441-1178 From rwgk at yahoo.com Fri Feb 6 21:00:44 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Fri, 6 Feb 2004 12:00:44 -0800 (PST) Subject: [C++-sig] type conversion In-Reply-To: Message-ID: <20040206200044.71136.qmail@web20205.mail.yahoo.com> --- Uwe Schmitt wrote: > how can I instruct boost to convert std::pair to a > Python tuple ??? I did not find anything in the archive... Converting to a Python tuple is easy: http://www.boost.org/libs/python/doc/v2/to_python_converter.html In anticipation of the next question, "how can I do it the other way around", you can do that with a "custom converter". It's a bit tricky but not actually hard. Here is the solution for a similar problem: http://www.boost.org/libs/python/doc/v2/faq.html#custom_string This technique is very powerful if you have may functions with std::pair as an argument. If you only have a few it is easier to write "thin wrappers" for your functions or member functions. E.g.: http://www.boost.org/libs/python/doc/v2/faq.html#voidptr This is not the best example but I hope you get the idea. It should be obvious after reading the tutorial. Ralf __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html From rwgk at yahoo.com Fri Feb 6 21:16:53 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Fri, 6 Feb 2004 12:16:53 -0800 (PST) Subject: [C++-sig] Problems to compile Boost 1.31.0 In-Reply-To: <204713611045360@webmail.iastate.edu> Message-ID: <20040206201653.9226.qmail@web20208.mail.yahoo.com> --- Aashish Chaudhary wrote: > Is it possible or you to put the scons script to compile Boost.Python on > MSVC7.0. It is not just one SConscript. I don't know what to recommend, but here is something you could try: Go to this page: http://cctbx.sourceforge.net/current_cvs/installation.html Only cvs checkout libtbx and boost_adaptbx (not the other stuff). Both modules are really tiny. Also get a copy of SCons. Rename your boost directory to be just "boost" (not e.g. "boost_1_31_0") and put everything in the same place: scons boost libtbx boost_adaptbx Then follow the rest of the instructions for Windows, but specify boost as the top-level module. E.g.: mkdir build cd build python ..\libtbx\configure.py boost setpaths.bat libtbx.scons . The result will be here: libtbx\boost_python.dll Hope this is useful. Ralf __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html From RaoulGough at yahoo.co.uk Fri Feb 6 21:29:19 2004 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Fri, 06 Feb 2004 20:29:19 +0000 Subject: [C++-sig] Re: MSVC6 problems upgrading to Version_1_31_0 tag References: <414912611045360@webmail.iastate.edu> <20040206193004.91535.qmail@web20206.mail.yahoo.com> Message-ID: "Ralf W. Grosse-Kunstleve" writes: > Unfortunately I have to confirm that Boost.Python from the 1.31.0 > release fails to compile with Visual C++ 6. :( :( :( I am extremely > frustrated because I spent days and days recompiling the RC_1_31_0 > branch over and over again with many different compilers. I guess I > got exhausted because the release was pushed back all the time and > VC6 dropped off my radar at some point. OK, the problem looks to be very simple - a member function in the bidirectional_graph_helper_with_property class template (from graph/detail/adjacency_list.hpp) is defined outside the class definition, which MSVC6++ can't handle. I tried moving the definition of remove_edge inline into the class definition, and the compile problems disappear (looks like the mem_fn.hpp problem was a consequential error). Amazingly, the declaration of remove_edge in the class definition immediately follows a comment that says "Placement of these overloaded remove_edge() functions inside the class avoids a VC++ bug". LOL! ROTFL! I'll report the patch on the main developers' list. -- Raoul Gough. export LESS='-X' From RaoulGough at yahoo.co.uk Sat Feb 7 00:25:32 2004 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Fri, 06 Feb 2004 23:25:32 +0000 Subject: [C++-sig] Re: MSVC6 problems upgrading to Version_1_31_0 tag References: <414912611045360@webmail.iastate.edu> <20040206193004.91535.qmail@web20206.mail.yahoo.com> Message-ID: Raoul Gough writes: > I'll report the patch on the main developers' list. FYI, Jeremy Siek has applied the fix in adjacency_list.hpp, so the CVS head should now work on MSVC++6. I haven't actually tried this, since I'm using the Version_1_31_0 tag and applied the patch locally, but I guess it should be OK. -- Raoul Gough. export LESS='-X' From steam at nurfuerspam.de Sat Feb 7 11:27:45 2004 From: steam at nurfuerspam.de (Hanz Meizer) Date: Sat, 07 Feb 2004 11:27:45 +0100 Subject: [C++-sig] Re: Problem with different return types. In-Reply-To: <4023E3DC.6972.4449BBBB@localhost> References: <4023E3DC.6972.4449BBBB@localhost> Message-ID: Niall Douglas wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On 6 Feb 2004 at 11:22, Hanz Meizer wrote: > > >>virtual const C& getC(void ) const = 0; >>virtual C& getC(void) = 0; >> >>Is it possible to export both functions? Is it possible to export one >>of them, and ignore the other? I've tried several ways to include it, >>but both did not work out. Currently I'm using pythe to generate the >>interface class. So my other question is: If it's possible, how can I >>integrate the solution in pyste? :) > > > delete the def("getC", (const C& (*)(void) const) &getC) version. > Python never calls from within a const context anyway. > > Cheers, > Niall Hi, Does anyone happen to know how to do this in pyste? I could write exclude(C.getC), but this removes both versions. Greetings, Hanz. From nicodemus at esss.com.br Sat Feb 7 17:58:35 2004 From: nicodemus at esss.com.br (Nicodemus) Date: Sat, 07 Feb 2004 13:58:35 -0300 Subject: [C++-sig] Re: Problem with different return types. In-Reply-To: References: <4023E3DC.6972.4449BBBB@localhost> Message-ID: <4025193B.6080901@esss.com.br> Hi Hanz, Hanz Meizer wrote: > Niall Douglas wrote: > >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> On 6 Feb 2004 at 11:22, Hanz Meizer wrote: >> >> >>> virtual const C& getC(void ) const = 0; >>> virtual C& getC(void) = 0; >>> >>> Is it possible to export both functions? Is it possible to export one >>> of them, and ignore the other? I've tried several ways to include it, >>> but both did not work out. Currently I'm using pythe to generate the >>> interface class. So my other question is: If it's possible, how can I >>> integrate the solution in pyste? :) >> >> >> >> delete the def("getC", (const C& (*)(void) const) &getC) version. >> Python never calls from within a const context anyway. >> >> Cheers, >> Niall > > > Hi, > > Does anyone happen to know how to do this in pyste? I could write > exclude(C.getC), but this removes both versions. Currently that's not supported... there's plan to include a mechanism to do that in the future thought. Regards, Nicodemus. From aashish at iastate.edu Sat Feb 7 19:47:04 2004 From: aashish at iastate.edu (Aashish Chaudhary) Date: Sat, 7 Feb 2004 12:47:04 -0600 (CST) Subject: [C++-sig] Re: Problem with different return types. Message-ID: <44712711046370@webmail.iastate.edu> Hi, I have compiled boost.python on Linux after unsuccessfull attempt to compile it on windows (I found VC7.0 can not compile it as shown the status of boost.python compilation for VC7.0 on boost.python web). Well then I tried to build some basic examples .. and it just worked fine ... I got into trouble when I tried to compile a example from register_ptr_to_python.hpp struct A { virtual int f() { return 0; } }; shared_ptr New() { return shared_ptr( new A() ); } int Ok( const shared_ptr& a ) { return a->f(); } int Fail( shared_ptr& a ) { return a->f(); } struct A_Wrapper: A { A_Wrapper(PyObject* self_): self(self_) {} int f() { return call_method(self, "f"); } int default_f() { return A::f(); } PyObject* self; }; BOOST_PYTHON_MODULE(register_ptr) { class_("A") .def("f", &A::f, &A_Wrapper::default_f) ; def("New", &New); def("Ok", &Call); def("Fail", &Fail); register_ptr_to_python< shared_ptr >(); } and when in the python file I did this: from register_ptr import * it throws me the error : Traceback (most recent call last): File "usr/src/bp_register_test.py", line 2, in ? from bp_register import * ImportError: dynamic module does not define init function (initbp_register) I am wondering why it would happened ??? Thanks for any help. ~aashish __________________________________________________________________________ Aashish Chaudhary Research Assistant Iowa State University E-Mail: aashish at iastate.edu Ames, Iowa Telephone: +1 515-441-1178 From RaoulGough at yahoo.co.uk Sat Feb 7 22:13:08 2004 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Sat, 07 Feb 2004 21:13:08 +0000 Subject: [C++-sig] Re: init function not found [was Re: Problem with different return types. ] References: <44712711046370@webmail.iastate.edu> Message-ID: Aashish Chaudhary writes: > Hi, > > I have compiled boost.python on Linux after unsuccessfull attempt to > compile it on windows (I found VC7.0 can not compile it as shown the > status of boost.python compilation for VC7.0 on boost.python web). I didn't know that VC7.0 support had been dropped - at least, not deliberately! > > Well then I tried to build some basic examples .. and it just worked > fine ... I got into trouble when I tried to compile a example from > register_ptr_to_python.hpp [snip] > BOOST_PYTHON_MODULE(register_ptr) > { > class_("A") > .def("f", &A::f, &A_Wrapper::default_f) > ; > > def("New", &New); > def("Ok", &Call); > def("Fail", &Fail); > > register_ptr_to_python< shared_ptr >(); > } > > and when in the python file I did this: > > from register_ptr import * > > it throws me the error : > > Traceback (most recent call last): > File "usr/src/bp_register_test.py", line 2, in ? > from bp_register import * > ImportError: dynamic module does not define init function (initbp_register) > > I am wondering why it would happened ??? This looks very confusing to me, because the error message doesn't seem to match up to what you "did" in Python. Maybe the problem is very simple though. If you create a shared object called register_ptr.so you can import it with "from register_ptr import ...". Python then looks for a Python module or shared object that matches that name, and in the case of a shared object loads it and looks for a function called something like initregister_ptr. The BOOST_PYTHON_MODULE(register_ptr) macro gives you this function, correctly named. However, if you want to do "from bp_register import .." (which is what the error message indicates) you would have to change the name in BOOST_PYTHON_MODULE as well as the shared object file name. -- Raoul Gough. export LESS='-X' From aashish at iastate.edu Sun Feb 8 01:36:09 2004 From: aashish at iastate.edu (Aashish Chaudhary) Date: Sat, 7 Feb 2004 18:36:09 -0600 (CST) Subject: [C++-sig] Re: init function not found [was Re: Problem with Message-ID: <93618711046370@webmail.iastate.edu> Thanks raul that was a silly mistake :( ... I should have noticed that .. > I didn't know that VC7.0 support had been dropped - at least, not > deliberately! Well that link that you sent in the some mail (on feb 03) (the status of the compilers) showed that there were couple of problems with the VC7.0 but nothing reported for 7.1.. I got the CVS version compiled on Linux .. :) > This looks very confusing to me, because the error message doesn't > seem to match up to what you "did" in Python. Maybe the problem is > very simple though. If you create a shared object called > register_ptr.so you can import it with "from register_ptr import > ....". Python then looks for a Python module or shared object that > matches that name, and in the case of a shared object loads it and > looks for a function called something like initregister_ptr. The > BOOST_PYTHON_MODULE(register_ptr) macro gives you this function, > correctly named. > > > ____________ Problem solved !! Thanks! regards, Aashish ___________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > __________________________________________________________________________ Aashish Chaudhary Research Assistant Iowa State University E-Mail: aashish at iastate.edu Ames, Iowa Telephone: +1 515-441-1178 From s_sourceforge at nedprod.com Sun Feb 8 08:12:23 2004 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Sun, 08 Feb 2004 07:12:23 -0000 Subject: [C++-sig] Re: Problem with different return types. In-Reply-To: References: <4023E3DC.6972.4449BBBB@localhost> Message-ID: <4025E157.5331.36BF368@localhost> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 7 Feb 2004 at 11:27, Hanz Meizer wrote: > > delete the def("getC", (const C& (*)(void) const) &getC) version. > > Python never calls from within a const context anyway. > > Does anyone happen to know how to do this in pyste? I could write > exclude(C.getC), but this removes both versions. I personally hacked pyste to stop it for this particular case (as well as casting off any throw() modifiers), but here I recommend you diff your fixed version agains the pyste output and simply reapply the patch after every regeneration. I do this a lot to munge in custom list converters. Cheers, Niall -----BEGIN PGP SIGNATURE----- Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 iQA/AwUBQCXhWMEcvDLFGKbPEQI54wCgz3u6N54RW7XJ8qSRY97rUzJcIeEAoM1G cG7OcEj25zgPbaGtqYUFivST =MQnu -----END PGP SIGNATURE----- From nitin.shukla at pw.utc.com Mon Feb 9 14:31:45 2004 From: nitin.shukla at pw.utc.com (Shukla, Nitin (Export)) Date: Mon, 9 Feb 2004 08:31:45 -0500 Subject: [C++-sig] How to export arrays from C(++) to python using boost Message-ID: <271266F9567FB84D8F887943C93FA1EB0209CD27@pusehe0o.eh.pweh.com> Hi, I am working on an application where an array of ints and floats are to exported from C++ to Python using boost::python. As I am newbie to boost python, I couldn't find any documentation or working example that satisfies the above requirement. Can someone help me out?? Nitin. From rwgk at yahoo.com Mon Feb 9 14:59:50 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Mon, 9 Feb 2004 05:59:50 -0800 (PST) Subject: [C++-sig] How to export arrays from C(++) to python using boost In-Reply-To: <271266F9567FB84D8F887943C93FA1EB0209CD27@pusehe0o.eh.pweh.com> Message-ID: <20040209135950.30777.qmail@web20207.mail.yahoo.com> --- "Shukla, Nitin (Export)" wrote: > I am working on an application where an array of ints and floats are to > exported from C++ to Python using boost::python. > > As I am newbie to boost python, I couldn't find any documentation or > working example that satisfies the above requirement. Can someone help > me out?? Wrapping arrays is possible in several different ways. There isn't "the one" universal solution. Here are some links to get you started: To learn about the choice of creating a new Python types for your arrays vs. converting to and from regular Python tuples: http://www.boost.org/libs/python/doc/v2/faq.html#question2 How to use the "indexing suite" that comes with Boost.Python (1.31.0 release): http://www.boost.org/libs/python/doc/v2/indexing.html Some nice general examples that predate the indexing suite: http://www.python.org/cgi-bin/moinmoin/boost_2epython_2fStlContainers Raoul Gough is working on a new implementation of the indexing suite. Look in the archieve of this list to learn more about his efforts. Ralf __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html From nikolai.kirsebom at siemens.no Mon Feb 9 15:16:06 2004 From: nikolai.kirsebom at siemens.no (Kirsebom Nikolai) Date: Mon, 9 Feb 2004 15:16:06 +0100 Subject: [C++-sig] =?iso-8859-1?q?RE=3A_=C6C++-sig=C5_How_to_export_array?= =?iso-8859-1?q?s_from_C=28++=29_to_python_using_boost?= Message-ID: <5B5544F322E5D211850F00A0C91DEF3B05E0C5B1@osll007a.siemens.no> > -----Original Message----- > From: Shukla, Nitin (Export) [mailto:nitin.shukla at pw.utc.com] > Hi, > > I am working on an application where an array of ints and > floats are to > exported from C++ to Python using boost::python. > > As I am newbie to boost python, I couldn't find any documentation or > working example that satisfies the above requirement. Can > someone help > me out?? > Had similar need some time ago (fetching / setting BLOB values in database). Ended up making conversion to/from file in C++ code (MFC) and using the python Array module to import. Hope info below (which is fragments of working code) is of any use. The class DLBlob is a class providing needed methods to set/get byte array. Python code would supply the filename to be used. Nikolai //C++ CODE int PyElement::Blob2File(CString fileName) { DLBlob blob = GetBlobValue(); if (!blob.IsEmpty()) { unsigned char * b = blob.GetBuffer(); CFile theFile(fileName, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary); theFile.Write(b, blob.Length()); theFile.Close(); return blob.Length(); } return 0; } int PyElement::File2Blob(CString fileName) { CFile theFile(fileName, CFile::modeRead | CFile::typeBinary); DWORD fileSize = theFile.GetLength(); void *s = ::malloc(fileSize+1); DWORD count = theFile.Read(s, fileSize); theFile.Close(); DLBlob blob(count); blob.InsertBytes(s, count, 0); SetBlobValue(blob); return (int)count; } int PyElement::BlobSize() { DLBlob blob = GetBlobValue(); if (!blob.IsEmpty()) { return blob.Length(); } return 0; } BOOST_PYTHON_MODULE(CElement) { class_("Element") .def("Blob2File", &PyElement::Blob2File) .def("File2Blob", &PyElement::File2Blob) .def("BlobSize", &PyElement::BlobSize) ; } From xavier.warin at der.edfgdf.fr Mon Feb 9 17:21:23 2004 From: xavier.warin at der.edfgdf.fr (Xavier WARIN(Compte LOCAL) - I23) Date: Mon, 09 Feb 2004 17:21:23 +0100 Subject: [C++-sig] How to export arrays from C(++) to python using boost In-Reply-To: <5B5544F322E5D211850F00A0C91DEF3B05E0C5B1@osll007a.siemens.no> References: <5B5544F322E5D211850F00A0C91DEF3B05E0C5B1@osll007a.siemens.no> Message-ID: <4027B383.1090601@der.edfgdf.fr> Hi, If your python array are Numerical Python array, you can use the Numeric Utility Interface http://www.eos.ubc.ca/research/clouds/software/pythonlibs/ Hope it helps. Xavier Kirsebom Nikolai wrote: >>-----Original Message----- >>From: Shukla, Nitin (Export) [mailto:nitin.shukla at pw.utc.com] >>Hi, >> >>I am working on an application where an array of ints and >>floats are to >>exported from C++ to Python using boost::python. >> >>As I am newbie to boost python, I couldn't find any documentation or >>working example that satisfies the above requirement. Can >>someone help >>me out?? >> > > > Had similar need some time ago (fetching / setting BLOB values in database). > Ended up making conversion to/from file in C++ code (MFC) and using the > python Array module to import. Hope info below (which is fragments of > working code) is of any use. The class DLBlob is a class providing needed > methods to set/get byte array. Python code would supply the filename to be > used. > > Nikolai > > //C++ CODE > int PyElement::Blob2File(CString fileName) > { > DLBlob blob = GetBlobValue(); > if (!blob.IsEmpty()) { > unsigned char * b = blob.GetBuffer(); > CFile theFile(fileName, CFile::modeCreate | CFile::modeWrite > | CFile::typeBinary); > theFile.Write(b, blob.Length()); > theFile.Close(); > return blob.Length(); > } > return 0; > } > > int PyElement::File2Blob(CString fileName) > { > CFile theFile(fileName, CFile::modeRead | CFile::typeBinary); > DWORD fileSize = theFile.GetLength(); > void *s = ::malloc(fileSize+1); > DWORD count = theFile.Read(s, fileSize); > theFile.Close(); > > DLBlob blob(count); > blob.InsertBytes(s, count, 0); > SetBlobValue(blob); > return (int)count; > } > > int PyElement::BlobSize() > { > DLBlob blob = GetBlobValue(); > if (!blob.IsEmpty()) { > return blob.Length(); > } > return 0; > } > > BOOST_PYTHON_MODULE(CElement) > { > class_("Element") > .def("Blob2File", &PyElement::Blob2File) > .def("File2Blob", &PyElement::File2Blob) > .def("BlobSize", &PyElement::BlobSize) > ; > } > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > > From schmitt at num.uni-sb.de Mon Feb 9 20:12:50 2004 From: schmitt at num.uni-sb.de (Uwe Schmitt) Date: Mon, 9 Feb 2004 20:12:50 +0100 Subject: AW: [mailinglist] Re: [C++-sig] type conversion In-Reply-To: <20040206200044.71136.qmail@web20205.mail.yahoo.com> Message-ID: > > > --- Uwe Schmitt wrote: > > how can I instruct boost to convert std::pair to a > > Python tuple ??? I did not find anything in the archive... > > Converting to a Python tuple is easy: > > http://www.boost.org/libs/python/doc/v2/to_python_converter.html > Hi, thanks for your answer, it works ;-) But I found a mistake on the page linked above: struct tag_to_noddy { static PyObject* convert(tag const& x) { return PyObject_New(noddy_NoddyObject, &noddy_NoddyType); } }; In the body of the convert method the variable x does not appear... Greetings, Uwe From dleary at ttlc.net Mon Feb 9 22:08:33 2004 From: dleary at ttlc.net (Dusty Leary) Date: Mon, 9 Feb 2004 16:08:33 -0500 Subject: [C++-sig] intel compiler failing References: <4023E3DC.6972.4449BBBB@localhost> <4025E157.5331.36BF368@localhost> Message-ID: <000b01c3ef50$e4880f10$4d00a8c0@eigensoft.net> with both the previous version of boost, and the new 1.31, I can't compile with the intel-win32 tools. I get lots of instances of internal compiler errors. example: D:\vs.net2003\VC7\include\xlocnum(1286): (col. 37)internal error: assertion failed at: "proton/edgglue/edg_main.c", line 593 compilation aborted for D:\dev\boost_1_31_0\libs\python\build\../src/object_operators.cpp (code 4) as far as I can tell, the errors are always this same assertion... maybe it's bottoming out on template nesting depth or something? Anyway, obviously this is not really the fault of the boost developers. But is a workaround known? From boost-users at johnmeinel.com Tue Feb 10 04:13:54 2004 From: boost-users at johnmeinel.com (John F Meinel Jr) Date: Mon, 09 Feb 2004 21:13:54 -0600 Subject: [C++-sig] Problems with def(self_ns::str(self)) and virtual functions Message-ID: I've been testing out boost::python for wrapping some C++ code that I've written, but I had some weird results trying to get the "__str__" functionality to work correctly. I have a base C++ class that has a virtual function in it (with a default value). I derive another C++ class from it and change the virtual function. I also create a std::ostream << operator so that I can print this class. Here is the code: struct Base { virtual ~Base() {} virtual int f() const { return 12345; } }; struct Derived : Base { virtual int f() const { return 54321; } }; inline int call_f(Base& b) { return b.f(); } inline std::ostream& operator<<(std::ostream& os, const Base& b) { return os << "A: " << b.f() << std::endl; } ///// Begin Python Wrapper #include using namespace boost::python; struct BaseWrap : Base { BaseWrap(PyObject* self_) : self(self_) { } BaseWrap(PyObject* self_, const Base& b) : self(self_) , Base(b) { } int f() const { return call_method(self, "f"); } int default_f() const { return Base::f(); } PyObject *self; }; BOOST_PYTHON_MODULE(test2) { class_("Base") .def("f", Base::f, BaseWrap::default_f) .def(self_ns::str(self)) ; class_ >("Derived") // Without this, it doesn't work .def(self_ns::str(self)) ; def("call_f", call_f); } ///// End Python Wrapper First, the Tutorial doesn't include the need for BaseWrap to have both constructors, but it wouldn't compile without both of them (I am using boost-1.31.0 with MSVC 2003 and python 2.3, though I am trying to get it all to work with GCC 3.2.2) First, I can test that without the python wrapper, in a simple C++ script I can do std::cout << Base() << std::endl; and std::cout << Derived() << std::endl; and I get the correct output. So I know that in C++ the << operator is calling the appropriate overloaded function. However, when I load this library in python, if I don't define .def(self_ns::str(self)) for the Derived class, it prints out the exact string for the Base(). Here is the exact python code that I type >>> import test2 >>> import test2 >>> b = test2.Base() >>> b.f() 12345 >>> test2.call_f(b) 12345 >>> print b A: 12345 >>> d = test2.Derived() >>> d.f() 54321 >>> test2.call_f(d) 54321 >>> print d A: 12345 With __str__ redefined for the Derived class I get >>> print d A: 54321 Which is what I want. What is really weird is that call_f() works correctly in python, even if I derive a class in python. >>> class MyClass(test2.Base): ... def f(self): ... return 9876 ... >>> m = MyClass() >>> m.f() 9876 >>> test2.call_f(m) 9876 >>> print m A: 12345 Does anyone know why the call_f() operator is using the correct overload, but the __str__ operator isn't? Thanks, John =:-> From nitin.shukla at pw.utc.com Tue Feb 10 15:52:36 2004 From: nitin.shukla at pw.utc.com (Shukla, Nitin (Export)) Date: Tue, 10 Feb 2004 09:52:36 -0500 Subject: [C++-sig] How to export arrays from C(++) to python using boo st Message-ID: <271266F9567FB84D8F887943C93FA1EB0209CD2A@pusehe0o.eh.pweh.com> I have still not figured out how to go about exporting arrays. Most of the examples I have seen so far shows export of STL like vectors etc. What I am looking is to do something simple like this : //C++ Code class myarrayclass { int iarr[20]; float farr[40]; }; Then from python I will do only the following: >>> from some_name import myarrayclass >>> obj = myarrayclass() >>> obj.iarr[3] 5 >>> obj.iarr[3] = 10 >>> obj.iarr[3] 10 >>> obj.farr[5] 23.126 >>> obj.farr[5] = 2.146 >>> obj.farr[5] 2.146 That's all I want to do from python. If somebody has worked out similar code (complete and working) and willing to guide me will be useful. Nevertheless, if the there are any tutorials on net which will suit the above requirement, will be pretty useful for me. If the above requirement can to be implemented only by "indexing_suite class", can someone list down how and what steps needs to be followed. Nitin. -----Original Message----- From: Ralf W. Grosse-Kunstleve [mailto:rwgk at yahoo.com] --- "Shukla, Nitin (Export)" wrote: > I am working on an application where an array of ints and floats are to > exported from C++ to Python using boost::python. > > As I am newbie to boost python, I couldn't find any documentation or > working example that satisfies the above requirement. Can someone help > me out?? Wrapping arrays is possible in several different ways. There isn't "the one" universal solution. Here are some links to get you started: To learn about the choice of creating a new Python types for your arrays vs. converting to and from regular Python tuples: http://www.boost.org/libs/python/doc/v2/faq.html#question2 How to use the "indexing suite" that comes with Boost.Python (1.31.0 release): http://www.boost.org/libs/python/doc/v2/indexing.html Some nice general examples that predate the indexing suite: http://www.python.org/cgi-bin/moinmoin/boost_2epython_2fStlContainers Raoul Gough is working on a new implementation of the indexing suite. Look in the archieve of this list to learn more about his efforts. Ralf __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html _______________________________________________ C++-sig mailing list C++-sig at python.org http://mail.python.org/mailman/listinfo/c++-sig From nitin.shukla at pw.utc.com Tue Feb 10 17:24:02 2004 From: nitin.shukla at pw.utc.com (Shukla, Nitin (Export)) Date: Tue, 10 Feb 2004 11:24:02 -0500 Subject: [C++-sig] How to export arrays from C(++) to python using boo st Message-ID: <271266F9567FB84D8F887943C93FA1EB0209CD2B@pusehe0o.eh.pweh.com> Hi, I have downloaded the Numeric Utility Interface but couldn't build and test the demonstration num_util on my Windows system. The readme document which came with the download says that it was only tested on Mandrake Linux v8.2, with gcc-3.2, boost-1.30.0, and Python-2.2.2 libraries. I have Windows 2000 system with MinGW gcc-3.2.3, boost-1_31_0 and Python-2.3.2 libraries. Will it work on the above system. Do I need something else to compile and build the demonstration program num_util. Nitin -----Original Message----- From: Xavier WARIN(Compte LOCAL) - I23 Hi, If your python array are Numerical Python array, you can use the Numeric Utility Interface http://www.eos.ubc.ca/research/clouds/software/pythonlibs/ Hope it helps. Xavier Kirsebom Nikolai wrote: >>-----Original Message----- >>From: Shukla, Nitin (Export) [mailto:nitin.shukla at pw.utc.com] >>Hi, >> >>I am working on an application where an array of ints and >>floats are to >>exported from C++ to Python using boost::python. >> >>As I am newbie to boost python, I couldn't find any documentation or >>working example that satisfies the above requirement. Can >>someone help >>me out?? >> > > > Had similar need some time ago (fetching / setting BLOB values in database). > Ended up making conversion to/from file in C++ code (MFC) and using the > python Array module to import. Hope info below (which is fragments of > working code) is of any use. The class DLBlob is a class providing needed > methods to set/get byte array. Python code would supply the filename to be > used. > > Nikolai > > //C++ CODE > int PyElement::Blob2File(CString fileName) > { > DLBlob blob = GetBlobValue(); > if (!blob.IsEmpty()) { > unsigned char * b = blob.GetBuffer(); > CFile theFile(fileName, CFile::modeCreate | CFile::modeWrite > | CFile::typeBinary); > theFile.Write(b, blob.Length()); > theFile.Close(); > return blob.Length(); > } > return 0; > } > > int PyElement::File2Blob(CString fileName) > { > CFile theFile(fileName, CFile::modeRead | CFile::typeBinary); > DWORD fileSize = theFile.GetLength(); > void *s = ::malloc(fileSize+1); > DWORD count = theFile.Read(s, fileSize); > theFile.Close(); > > DLBlob blob(count); > blob.InsertBytes(s, count, 0); > SetBlobValue(blob); > return (int)count; > } > > int PyElement::BlobSize() > { > DLBlob blob = GetBlobValue(); > if (!blob.IsEmpty()) { > return blob.Length(); > } > return 0; > } > > BOOST_PYTHON_MODULE(CElement) > { > class_("Element") > .def("Blob2File", &PyElement::Blob2File) > .def("File2Blob", &PyElement::File2Blob) > .def("BlobSize", &PyElement::BlobSize) > ; > } > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > > _______________________________________________ C++-sig mailing list C++-sig at python.org http://mail.python.org/mailman/listinfo/c++-sig From nitin.shukla at pw.utc.com Tue Feb 10 18:44:27 2004 From: nitin.shukla at pw.utc.com (Shukla, Nitin (Export)) Date: Tue, 10 Feb 2004 12:44:27 -0500 Subject: =?iso-8859-1?Q?RE=3A_=5BC++-sig=5D_RE=3A_=C6C++-sig=C5_How_to_?= =?iso-8859-1?Q?export_arrays_from_C=28++=29_to_python_using_boost?= Message-ID: <271266F9567FB84D8F887943C93FA1EB0209CD2C@pusehe0o.eh.pweh.com> Thanks Nikolai. Can you show me the declaration of your class PyElement. That will give me better understanding of your code and help me create my own class. Nitin -----Original Message----- From: Kirsebom Nikolai [mailto:nikolai.kirsebom at siemens.no] Sent: Monday, February 09, 2004 9:16 AM To: Development of Python/C++ integration Subject: [C++-sig] RE: ?C++-sig? How to export arrays from C(++) to python using boost > -----Original Message----- > From: Shukla, Nitin (Export) [mailto:nitin.shukla at pw.utc.com] > Hi, > > I am working on an application where an array of ints and > floats are to > exported from C++ to Python using boost::python. > > As I am newbie to boost python, I couldn't find any documentation or > working example that satisfies the above requirement. Can > someone help > me out?? > Had similar need some time ago (fetching / setting BLOB values in database). Ended up making conversion to/from file in C++ code (MFC) and using the python Array module to import. Hope info below (which is fragments of working code) is of any use. The class DLBlob is a class providing needed methods to set/get byte array. Python code would supply the filename to be used. Nikolai //C++ CODE int PyElement::Blob2File(CString fileName) { DLBlob blob = GetBlobValue(); if (!blob.IsEmpty()) { unsigned char * b = blob.GetBuffer(); CFile theFile(fileName, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary); theFile.Write(b, blob.Length()); theFile.Close(); return blob.Length(); } return 0; } int PyElement::File2Blob(CString fileName) { CFile theFile(fileName, CFile::modeRead | CFile::typeBinary); DWORD fileSize = theFile.GetLength(); void *s = ::malloc(fileSize+1); DWORD count = theFile.Read(s, fileSize); theFile.Close(); DLBlob blob(count); blob.InsertBytes(s, count, 0); SetBlobValue(blob); return (int)count; } int PyElement::BlobSize() { DLBlob blob = GetBlobValue(); if (!blob.IsEmpty()) { return blob.Length(); } return 0; } BOOST_PYTHON_MODULE(CElement) { class_("Element") .def("Blob2File", &PyElement::Blob2File) .def("File2Blob", &PyElement::File2Blob) .def("BlobSize", &PyElement::BlobSize) ; } _______________________________________________ C++-sig mailing list C++-sig at python.org http://mail.python.org/mailman/listinfo/c++-sig From nikolai.kirsebom at siemens.no Wed Feb 11 12:03:34 2004 From: nikolai.kirsebom at siemens.no (Kirsebom Nikolai) Date: Wed, 11 Feb 2004 12:03:34 +0100 Subject: =?iso-8859-1?Q?RE=3A_=5BC++-sig=5D_RE=3A_=C6C++-sig=C5_How_to_?= =?iso-8859-1?Q?export_arrays_from_C=28++=29_to_python_using_boost?= Message-ID: <5B5544F322E5D211850F00A0C91DEF3B05E0C6D1@osll007a.siemens.no> > -----Original Message----- > From: Shukla, Nitin (Export) [mailto:nitin.shukla at pw.utc.com] > Sent: 10. februar 2004 18:44 > To: 'Development of Python/C++ integration' > Subject: RE: [C++-sig] RE: ?C++-sig? How to export arrays > from C(++) to > python using boost > > > Thanks Nikolai. Can you show me the declaration of your class > PyElement. > That will give me better understanding of your code and help > me create my > own class. > > Nitin > > There is really not very much in PyElement: PyElement.h: #pragma once class PyElement : public Element { public: int File2Blob(CString fileName); int Blob2File(CString fileName); int BlobSize(); }; The class Element is a 'big' class - and I cannot share the complete content of it. However, some parts of the class definition is given below. class AFX_EXT_CLASS Element : public CObject { ... DLBlob GetBlobValue(){return BlobValue;} void SetBlobValue(DLBlob BlobValuep) {if (BlobValue == BlobValuep) return; BlobValue=BlobValuep; Modified= TRUE;} ... } The class DLBlob is in principle a class wrapping an array (unsigned char). Hope info is of any use Nikolai From nitin.shukla at pw.utc.com Wed Feb 11 14:54:03 2004 From: nitin.shukla at pw.utc.com (Shukla, Nitin (Export)) Date: Wed, 11 Feb 2004 08:54:03 -0500 Subject: =?iso-8859-1?Q?RE=3A_=5BC++-sig=5D_RE=3A_=C6C++-sig=C5_How_to_?= =?iso-8859-1?Q?export_arrays_from_C=28++=29_to_python_using_boost?= Message-ID: <271266F9567FB84D8F887943C93FA1EB0209CD32@pusehe0o.eh.pweh.com> I may need bit more clarification I guess. If I am not wrong (correct me if I am), your class DLBlob contains an array (unsigned char) but I couldn't see this class being exported to python module. Instead in "BOOST_PYTHON_MODULE" you have exported only "PyElement" class which exports the functions "Blob2File" and "File2Blob". You have finally made it by writing the array into a file and then reading it where it is required. This spared you from actually exporting an array to python, which is exactly what I want to do. Let me know if that's not the correct interpretation of your logic and I have missed out something here. Nitin > -----Original Message----- > From: Kirsebom Nikolai [mailto:nikolai.kirsebom at siemens.no] > Sent: Wednesday, February 11, 2004 6:04 AM > To: Development of Python/C++ integration > Subject: RE: [C++-sig] RE: ?C++-sig? How to export arrays > from C(++) to > python using boost > > > > > > -----Original Message----- > > From: Shukla, Nitin (Export) [mailto:nitin.shukla at pw.utc.com] > > Sent: 10. februar 2004 18:44 > > To: 'Development of Python/C++ integration' > > Subject: RE: [C++-sig] RE: ?C++-sig? How to export arrays > > from C(++) to > > python using boost > > > > > > Thanks Nikolai. Can you show me the declaration of your class > > PyElement. > > That will give me better understanding of your code and help > > me create my > > own class. > > > > Nitin > > > > > > There is really not very much in PyElement: > > PyElement.h: > #pragma once > > class PyElement : public Element > { > public: > int File2Blob(CString fileName); > int Blob2File(CString fileName); > int BlobSize(); > }; > > The class Element is a 'big' class - and I cannot share the > complete content > of it. However, some parts of the class definition is given below. > > class AFX_EXT_CLASS Element : public CObject > { > ... > DLBlob GetBlobValue(){return BlobValue;} > void SetBlobValue(DLBlob BlobValuep) > {if (BlobValue == BlobValuep) return; > BlobValue=BlobValuep; > Modified= TRUE;} > ... > } > > The class DLBlob is in principle a class wrapping an array > (unsigned char). > > Hope info is of any use > Nikolai > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From RaoulGough at yahoo.co.uk Wed Feb 11 15:26:51 2004 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Wed, 11 Feb 2004 14:26:51 +0000 Subject: [C++-sig] Re: intel compiler failing References: <4023E3DC.6972.4449BBBB@localhost> <4025E157.5331.36BF368@localhost> <000b01c3ef50$e4880f10$4d00a8c0@eigensoft.net> Message-ID: "Dusty Leary" writes: > with both the previous version of boost, and the new 1.31, I can't compile > with the intel-win32 tools. > > I get lots of instances of internal compiler errors. > example: > D:\vs.net2003\VC7\include\xlocnum(1286): (col. 37)internal error: assertion > failed at: "proton/edgglue/edg_main.c", line 593 > compilation aborted for > D:\dev\boost_1_31_0\libs\python\build\../src/object_operators.cpp (code 4) > > as far as I can tell, the errors are always this same assertion... maybe > it's bottoming out on template nesting depth or something? > > Anyway, obviously this is not really the fault of the boost developers. But > is a workaround known? I don't use this compiler, in fact I'm not even sure what compiler you mean - is this some kind of mixture of Intel's compiler and the Microsoft/Dinkumware library? The regression logs show an almost perfect build for boost 1.31.0 under Intel C++ 8.00 on Windows. see http://boost.sourceforge.net/regression-logs/ -- Raoul Gough. export LESS='-X' From RaoulGough at yahoo.co.uk Wed Feb 11 15:38:35 2004 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Wed, 11 Feb 2004 14:38:35 +0000 Subject: [C++-sig] Re: How to export arrays from C(++) to python using boo st References: <271266F9567FB84D8F887943C93FA1EB0209CD2A@pusehe0o.eh.pweh.com> Message-ID: "Shukla, Nitin (Export)" writes: > I have still not figured out how to go about exporting arrays. Most > of the examples I have seen so far shows export of STL like vectors > etc. What I am looking is to do something simple like this : > > //C++ Code > class myarrayclass { > int iarr[20]; > float farr[40]; > }; > > Then from python I will do only the following: > >>>> from some_name import myarrayclass >>>> obj = myarrayclass() >>>> obj.iarr[3] > 5 >>>> obj.iarr[3] = 10 >>>> obj.iarr[3] > 10 >>>> obj.farr[5] > 23.126 >>>> obj.farr[5] = 2.146 >>>> obj.farr[5] > 2.146 > > That's all I want to do from python. If somebody has worked out > similar code (complete and working) and willing to guide me will > be useful. Nevertheless, if the there are any tutorials on net > which will suit the above requirement, will be pretty useful for > me. > > If the above requirement can to be implemented only by "indexing_suite > class", can someone list down how and what steps needs to be followed. Well, given the *new* indexing suite (i.e. indexing_v2) you would have something along the lines of: using namespace boost::python; typedef indexing::iterator_range integer_array; typedef indexing::iterator_range float_array; class myarrayclass { int iarr[20]; float farr[40]; public: integer_array get_int_array () { return indexing::make_iterator_range (iarr); } float_array get_float_array () { return indexing::make_iterator_range (farr); } }; // ... class_ ("integer_array") .def (indexing::container_suite()); class_ ("float_array") .def (indexing::container_suite()); class_ ("myarrayclass") .def ("get_int_array", &myarrayclass::get_int_array) .def ("get_float_array", &myarrayclass::get_float_array) ; [untested, but should more or less work]. Minimal help on obtaining indexing_v2 is available from http://home.clara.net/raoulgough/boost/ Sorry it's not easier at the moment, I'm currently trying to get it ready for introduction to the CVS mainline... If you manage that, the file libs/python/test/test_array_ext.cpp has a simple working example. -- Raoul Gough. export LESS='-X' From sirbender at freenet.de Wed Feb 11 15:58:03 2004 From: sirbender at freenet.de (Billy Gnosis) Date: Wed, 11 Feb 2004 15:58:03 +0100 Subject: [C++-sig] The easiest way to evoke a python function from a C++ application...? Message-ID: <402A42FB.1030800@freenet.de> What is the easiest way to evoke a python function from a C++ application ? I just want it for testing reasons and perhaps use it as a new way to develop software. I am new into python, but admire the fast and easy way to write code. Actually I planned to set up most of the program in C++ in a more or less complete way - this should be quickly possible by using Python functions, that are later replaced by C code when the "design" of the program is ok. So I just want to call e.g. a python function string.split(...) and return an array of strings to the C-Program. How is this most easily done ? It can be very 'dirty' as it will be replaced later anyway. Does somebody has example code? Cheers, sb From stefan.seefeld at orthosoft.ca Wed Feb 11 16:33:34 2004 From: stefan.seefeld at orthosoft.ca (Stefan Seefeld) Date: Wed, 11 Feb 2004 10:33:34 -0500 Subject: [C++-sig] with_custodian_and_ward clarification Message-ID: <4210b4c7a4e138e2a1eb5a0023191641402a47e4@Orthosoft.ca> hi there, I want to call a function that connects one object ('slave') to another ('master'). Looking through the documentation for the possible call policies, my best guess is to use 'with_custodian_and_ward'. void connect(Slave *s, Master *m) { s->connect(m);} ... def("connect", make_function(connect, with_custodian_and_ward<1, 2>())); The docs say the lifetime of '2' is thus tied to the lifetime of '1'. I'm *guessing* it means that '2' will *at least* live as long as '1'. Is that correct ? (The docs could be a bit more explicit about that) Thanks, Stefan From nikolai.kirsebom at siemens.no Wed Feb 11 16:44:09 2004 From: nikolai.kirsebom at siemens.no (Kirsebom Nikolai) Date: Wed, 11 Feb 2004 16:44:09 +0100 Subject: =?iso-8859-1?Q?RE=3A_=5BC++-sig=5D_RE=3A_=C6C++-sig=C5_How_to_?= =?iso-8859-1?Q?export_arrays_from_C=28++=29_to_python_using_boost?= Message-ID: <5B5544F322E5D211850F00A0C91DEF3B05E0C719@osll007a.siemens.no> Yes, you have understood the principle of my construction. As you understand, I did not need to have an array exported as a python array. Instead I use the mentioned File<-->Blob methods and then in the python context I use the python module array. See the documentation of the python array module. In my context there is no need to expose the DLBlob class to python, so only the 3 needed methods (that is not available in the Element class) is exposed by the PyElement class, which again is the class exposed to python (through BOOST). Nikolai > -----Original Message----- > From: Shukla, Nitin (Export) [mailto:nitin.shukla at pw.utc.com] > Sent: 11. februar 2004 14:54 > To: 'Development of Python/C++ integration' > Subject: RE: [C++-sig] RE: ?C++-sig? How to export arrays > from C(++) to > python using boost > > > I may need bit more clarification I guess. If I am not wrong > (correct me if I am), your class DLBlob contains an array > (unsigned char) but I couldn't see this class being exported > to python module. > > Instead in "BOOST_PYTHON_MODULE" you have exported only > "PyElement" class which exports the functions "Blob2File" > and "File2Blob". You have finally made it by writing the > array into a file and then reading it where it is required. > This spared you from actually exporting an array to python, > which is exactly what I want to do. Let me know if that's > not the correct interpretation of your logic and I have missed > out something here. > > Nitin > > > > -----Original Message----- > > From: Kirsebom Nikolai [mailto:nikolai.kirsebom at siemens.no] > > Sent: Wednesday, February 11, 2004 6:04 AM > > To: Development of Python/C++ integration > > Subject: RE: [C++-sig] RE: ?C++-sig? How to export arrays > > from C(++) to > > python using boost > > > > > > > > > > > -----Original Message----- > > > From: Shukla, Nitin (Export) [mailto:nitin.shukla at pw.utc.com] > > > Sent: 10. februar 2004 18:44 > > > To: 'Development of Python/C++ integration' > > > Subject: RE: [C++-sig] RE: ?C++-sig? How to export arrays > > > from C(++) to > > > python using boost > > > > > > > > > Thanks Nikolai. Can you show me the declaration of your class > > > PyElement. > > > That will give me better understanding of your code and help > > > me create my > > > own class. > > > > > > Nitin > > > > > > > > > > There is really not very much in PyElement: > > > > PyElement.h: > > #pragma once > > > > class PyElement : public Element > > { > > public: > > int File2Blob(CString fileName); > > int Blob2File(CString fileName); > > int BlobSize(); > > }; > > > > The class Element is a 'big' class - and I cannot share the > > complete content > > of it. However, some parts of the class definition is given below. > > > > class AFX_EXT_CLASS Element : public CObject > > { > > ... > > DLBlob GetBlobValue(){return BlobValue;} > > void SetBlobValue(DLBlob BlobValuep) > > {if (BlobValue == BlobValuep) return; > > BlobValue=BlobValuep; > > Modified= TRUE;} > > ... > > } > > > > The class DLBlob is in principle a class wrapping an array > > (unsigned char). > > > > Hope info is of any use > > Nikolai > > > > _______________________________________________ > > C++-sig mailing list > > C++-sig at python.org > > http://mail.python.org/mailman/listinfo/c++-sig > > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From dave at boost-consulting.com Wed Feb 11 18:12:21 2004 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 11 Feb 2004 12:12:21 -0500 Subject: [C++-sig] Re: with_custodian_and_ward clarification References: <4210b4c7a4e138e2a1eb5a0023191641402a47e4@Orthosoft.ca> Message-ID: Stefan Seefeld writes: > hi there, > > I want to call a function that connects one object ('slave') > to another ('master'). Looking through the documentation for > the possible call policies, my best guess is to use > 'with_custodian_and_ward'. > > void connect(Slave *s, Master *m) { s->connect(m);} > > ... > > def("connect", > make_function(connect, with_custodian_and_ward<1, 2>())); > > > The docs say the lifetime of '2' is thus tied to the lifetime > of '1'. I'm *guessing* it means that '2' will *at least* live > as long as '1'. Is that correct ? (The docs could be a bit more > explicit about that) What docs are you looking at? http://www.boost.org/libs/python/doc/v2/with_custodian_and_ward.html#introduction This header provides faciliites for establishing a lifetime dependency between two of a function's Python argument or result objects. The ward object will not be destroyed until after the custodian as ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ long as the custodian object supports weak references -- Dave Abrahams Boost Consulting www.boost-consulting.com From seefeld at sympatico.ca Wed Feb 11 18:39:15 2004 From: seefeld at sympatico.ca (Stefan Seefeld) Date: Wed, 11 Feb 2004 12:39:15 -0500 Subject: [C++-sig] Re: with_custodian_and_ward clarification References: <4210b4c7a4e138e2a1eb5a0023191641402a47e4@Orthosoft.ca> Message-ID: David Abrahams wrote: > Stefan Seefeld writes: > > >>hi there, >> >>I want to call a function that connects one object ('slave') >>to another ('master'). Looking through the documentation for >>the possible call policies, my best guess is to use >>'with_custodian_and_ward'. >> >>void connect(Slave *s, Master *m) { s->connect(m);} >> >>... >> >>def("connect", >> make_function(connect, with_custodian_and_ward<1, 2>())); >> >> >>The docs say the lifetime of '2' is thus tied to the lifetime >>of '1'. I'm *guessing* it means that '2' will *at least* live >>as long as '1'. Is that correct ? (The docs could be a bit more >>explicit about that) > > > What docs are you looking at? http://www.boost.org/libs/python/doc/tutorial/doc/call_policies.html > http://www.boost.org/libs/python/doc/v2/with_custodian_and_ward.html#introduction > > This header provides faciliites for establishing a lifetime > dependency between two of a function's Python argument or result > objects. > The ward object will not be destroyed until after the custodian as > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > long as the custodian object supports weak references Ah, that's quite clear indeed. Thanks ! Stefan From dave at boost-consulting.com Wed Feb 11 19:24:24 2004 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 11 Feb 2004 13:24:24 -0500 Subject: [C++-sig] Re: with_custodian_and_ward clarification References: <4210b4c7a4e138e2a1eb5a0023191641402a47e4@Orthosoft.ca> Message-ID: Stefan Seefeld writes: > David Abrahams wrote: >> Stefan Seefeld writes: >> >>>hi there, >>> >>>I want to call a function that connects one object ('slave') >>>to another ('master'). Looking through the documentation for >>>the possible call policies, my best guess is to use >>>'with_custodian_and_ward'. >>> >>>void connect(Slave *s, Master *m) { s->connect(m);} >>> >>>... >>> >>>def("connect", >>> make_function(connect, with_custodian_and_ward<1, 2>())); >>> >>> >>>The docs say the lifetime of '2' is thus tied to the lifetime >>>of '1'. I'm *guessing* it means that '2' will *at least* live >>>as long as '1'. Is that correct ? (The docs could be a bit more >>>explicit about that) >> What docs are you looking at? > > http://www.boost.org/libs/python/doc/tutorial/doc/call_policies.html > >> http://www.boost.org/libs/python/doc/v2/with_custodian_and_ward.html#introduction >> This header provides faciliites for establishing a lifetime >> dependency between two of a function's Python argument or result >> objects. The ward object will not be destroyed until after the >> custodian as >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> long as the custodian object supports weak references > > Ah, that's quite clear indeed. Thanks ! The tutorial is really just intended to give you an idea of the types of capabilities provided by call policies. That's why the "link to a complete reference" is provided. -- Dave Abrahams Boost Consulting www.boost-consulting.com From Benjamin.Golinvaux at euresys.com Thu Feb 12 12:35:26 2004 From: Benjamin.Golinvaux at euresys.com (Benjamin Golinvaux) Date: Thu, 12 Feb 2004 12:35:26 +0100 Subject: [C++-sig] beginner : call_policies Message-ID: Dear list members, I need to wrap a C++ tree structure in Python, and I'm not sure of the correct call policies to use (i'm not even sure they can be applied to my particular case). An node of the tree holds pointers to : - its parent - its children (only pointers are involved) I have pasted the class def. and impl. at the end of this message. operations are provided to attach a tree node to a parent, and to detach it. note : usually the tree nodes do not own their children (they never delete them), but i might provide a way to tag SOME children as 'owned' by their parent. I will need to express this across the python/cpp boundary, too... I would like to create wrappers for this class, that correctly handle the various objects lifetimes. So basically i would like an item to hold a ref to its children, and maybe a weak ref to its parent (?) I have understood how to use "with_custodian_and_ward" to have the TreeNode::Attach(TreeNode* parent) function wrapped so that the node is guaranteed to live at least as long as its parent (== parent holding a ref ?), but i haven't understood how to perform the INVERSE operation, that is, "release" the item reference the parent holds when TreeNode::DetachFrom(TreeNode* parent) is called. Is this possible at all ? I have read the FAQ entry called "how to transfer ownership across a function boundary" but i must admit i don't see how it fits in my problem. I somehow feel uncomfortable being unable to control the way refcounts are inc'd and dec'd but i prefer trusting boost controlling that than myself ! in short, i would like my structure to work just like a python container wrt its items (if i understood things correctly). Thanks for taking the time to read my message. Benjamin Golinvaux Euresys s.a. www.euresys.com The code is as follows : struct TreeNode { typedef std::list::const_iterator ConstItor; TreeNode* _parent; std::list _children; TreeNode( ) : _parent(0) {}; void Attach(TreeNode* parent) { if(parent == _parent) return; if(_parent) Detach(_parent); _parent = parent; parent->_children.push_back(this); } bool HasChild(TreeNode* node) const { for(ConstItor itor = _children.begin(); itor != _children.end(); ++itor) { if(*itor == node) return true; } return false; } void Detach(TreeNode* parent) { if(!parent->HasChild(this)) throw Error_TreeNode_WrongParentSpecified(); parent->_children.remove(this); parent = 0; } private : // prevent generation of bad default code TreeNode(const TreeNode& treeNode); TreeNode& operator=(const TreeNode& treeNode); }; -------------------------------------------------------- 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 sirbender at freenet.de Fri Feb 13 16:08:38 2004 From: sirbender at freenet.de (Billy Gnosis) Date: Fri, 13 Feb 2004 16:08:38 +0100 Subject: [C++-sig] Protect your Python code ? Or do I have to write everything in C++ ? Message-ID: <402CE876.4000301@freenet.de> Can I protect my python code - meaning, that nobody can read the source code when I want to publish it ? Is it already enough if I use .pyc files instead of py ? Or is it like in Java, that you can revert the compilition process in order to get the source ? Cheers, sb From bob at redivi.com Fri Feb 13 17:02:28 2004 From: bob at redivi.com (Bob Ippolito) Date: Fri, 13 Feb 2004 11:02:28 -0500 Subject: [C++-sig] Protect your Python code ? Or do I have to write everything in C++ ? In-Reply-To: <402CE876.4000301@freenet.de> References: <402CE876.4000301@freenet.de> Message-ID: <05C3A842-5E3E-11D8-A4CE-000A95686CD8@redivi.com> On Feb 13, 2004, at 10:08 AM, Billy Gnosis wrote: > Can I protect my python code - meaning, that nobody can read the > source code when I want to publish it ? Is it already enough if I use > .pyc files instead of py ? Or is it like in Java, that you can revert > the compilition process in order to get the source ? I've never seen a polished tool to take Python bytecode and produce working source, though one would not be terribly hard to write. Python comes with the dis module, which can give you a human readable version of the bytecode, but it does not give you python source. You are completely mistaken if you think C++. You can run C++ code through a couple tools and step through it in a debugger if you care enough to know what it's doing. For example, I can read assembly language for a few different CPU architectures, so not having source wouldn't really stop me from reverse engineering an algorithm if I really wanted to. Chances are, your code will not be worth the effort regardless of which language you choose to write it in... and if it is worth the effort, it doesn't really matter which language you write it in because anything can be reverse-engineered. -bob From gameguy at eastlink.ca Fri Feb 13 16:46:01 2004 From: gameguy at eastlink.ca (GameGuy) Date: Fri, 13 Feb 2004 11:46:01 -0400 Subject: [C++-sig] Is it possible to expose functions with variable argument lists? Message-ID: Hello. I have been using PYSTE and Boost.Python to wrap a C++ library for use in Python. Very nice stuff. I have reached a stumbling block though: There are several methods in this library that have an ellipsis in their method declarations. Eg: class Foo { virtual void method(const char* bar, ... ) const = 0; }; Which I think can be wrapped with Boost.Python in the following way: struct Foo_Wrapper : Foo { // ... virtual void method(const char* p0, ... ) const { va_list args; va_start(args, p0); call_method< void >(self, "method", p0, args); } }; // ... class_< Foo, Foo_Wrapper >("Foo", init< >()) .def("method", &Foo::method) ; I saw it done this way in another library. I haven't verified that it works or not yet as I can't compile it yet (running into MSVC7 issues). Has anyone else had experience wrapping functions with variable argument lists? Will this work in Boost.Python? Is it worth extending PYSTE to handle these cases? (It doesn't currently) Thank you for any assistance, ~Shaun From dave at boost-consulting.com Fri Feb 13 18:36:44 2004 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 13 Feb 2004 12:36:44 -0500 Subject: [C++-sig] Re: Protect your Python code ? Or do I have to write everything in C++ ? References: <402CE876.4000301@freenet.de> Message-ID: Billy Gnosis writes: > Can I protect my python code - meaning, that nobody can read the > source code when I want to publish it ? Is it already enough if I use > .pyc files instead of py ? Or is it like in Java, that you can revert > the compilition process in order to get the source ? This is a pure Python question, not a Python/C++ question, so it doesn't belong here. Please take it to comp.lang.python. Thanks, -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Fri Feb 13 18:52:37 2004 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 13 Feb 2004 12:52:37 -0500 Subject: [C++-sig] Re: Is it possible to expose functions with variable argument lists? References: Message-ID: GameGuy writes: > Hello. > I have been using PYSTE and Boost.Python to wrap a C++ library for use in Python. Very nice stuff. > > I have reached a stumbling block though: There are several methods in > this library that have an ellipsis in their method declarations. Eg: > > class Foo > { > virtual void method(const char* bar, ... ) const = 0; > }; > > Which I think can be wrapped with Boost.Python in the following way: > > struct Foo_Wrapper : Foo > { > // ... > > virtual void method(const char* p0, ... ) const { > va_list args; > va_start(args, p0); > call_method< void >(self, "method", p0, args); > } > }; > > // ... > > class_< Foo, Foo_Wrapper >("Foo", init< >()) > .def("method", &Foo::method) > ; > > > I saw it done this way in another library. I haven't verified that it > works or not yet as I can't compile it yet (running into MSVC7 > issues). > > Has anyone else had experience wrapping functions with variable argument lists? > Will this work in Boost.Python? Short answer: no, this doesn't work. Longer answer: you can't really get this to work in Boost.Python because it relies on being able to deduce the expected C++ types of arguments. Longer answer still: you might be able use BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS to wrap this method for specific sequences of arguments. http://tinyurl.com/2wptk But now that I look I think it'll fail for the same reason. I think the need to use call_method internally might give you problems, too. I think your best bet might be to use the facilities of http://www.boost.org/libs/python/doc/v2/raw_function.html > Is it worth extending PYSTE to handle these cases? (It doesn't currently) > > > Thank you for any assistance, > ~Shaun -- Dave Abrahams Boost Consulting www.boost-consulting.com From ak at ixion.net Sat Feb 14 15:37:32 2004 From: ak at ixion.net (Andreas Kloeckner) Date: Sat, 14 Feb 2004 15:37:32 +0100 Subject: [C++-sig] self_ns:: necessary when exposing stringification? Message-ID: <20040214143732.GA2061@aramis.ath.cx> Hey everybody, when writing a wrapper recently, I wanted to expose stringification by writing 8<----------------------------------------------------------------------------- using namespace boost::pyton; BOOST_PYTHON_MODULE(...) { class_<...>(...) .def(str(self)); } 8<----------------------------------------------------------------------------- which resulted in the following error message: 8<----------------------------------------------------------------------------- ... instantiated from various points... (see below for complete error message) /home/ak/work/boost/boost/python/def_visitor.hpp:32: error: no matching function for call to `boost::python::api::object::visit( boost::python::class_, boost::python::bases, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_>, boost::python::detail::not_specified, boost::python::detail::not_specified>& ) const' 8<----------------------------------------------------------------------------- So, the compiler must have picked up the "str" function from the object API, and then class_ tries to apply its visitor magic and fails miserably. This theory is confirmed by the fact that 8<----------------------------------------------------------------------------- class_<...>(...) .def(self_ns::str(self)); 8<----------------------------------------------------------------------------- actually works. Same thing happens with the BPL test case "operators". This strikes me as odd since the unit test sheet published on boost.org says that this should work with 3.2.3. (which it doesn't, at least not with Debian's) Do you want me to try any other solutions besides adding self_ns? Is there a good reason for this behavior besides "gcc's function lookup is broken"? What can I do to help you provide a general solution? Andreas ------------------------------------------------------------------------------- My version dump: ------------------------------------------------------------------------------- Boost.Python 1.31.0, self-compiled with g++ below g++ (GCC) 3.3.3 20040125 (prerelease) (Debian) (also occurs with Debian-released g++ 3.2.3) Python 2.3.3 (#2, Jan 13 2004, 00:47:05) [GCC 3.3.3 20040110 (prerelease) (Debian)] on linux2 ------------------------------------------------------------------------------- Complete error message ------------------------------------------------------------------------------- /home/ak/work/boost/boost/python/def_visitor.hpp: In static member function ` static void boost::python::def_visitor_access::visit(const V&, classT&) [with V = boost::python::def_visitor, classT = boost::python::class_, boost::python::bases, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_>, boost::python::detail::not_specified, boost::python::detail::not_specified>] ': /home/ak/work/boost/boost/python/def_visitor.hpp:68: instantiated from `void boost::python::def_visitor::visit(classT&) const [with classT = boost::python::class_, boost::python::bases, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_>, boost::python::detail::not_specified, boost::python::detail::not_specified>, DerivedVisitor = boost::python::api::object]' /home/ak/work/boost/boost/python/class.hpp:294: instantiated from `boost::python::class_& boost::python::class_::def(const boost::python::def_visitor&) [with Derived = boost::python::api::object, T = LLMatWrapper, X1 = boost::python::bases, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_>, X2 = boost::python::detail::not_specified, X3 = boost::python::detail::not_specified]' py_matrices.cc:105: instantiated from here /home/ak/work/boost/boost/python/def_visitor.hpp:32: error: no matching function for call to `boost::python::api::object::visit( boost::python::class_, boost::python::bases, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_>, boost::python::detail::not_specified, boost::python::detail::not_specified>& ) const' From ak at ixion.net Sat Feb 14 15:58:26 2004 From: ak at ixion.net (Andreas Kloeckner) Date: Sat, 14 Feb 2004 15:58:26 +0100 Subject: [C++-sig] Wrapping an abstract interface Message-ID: <20040214145826.GB2061@aramis.ath.cx> Hey again, I have an abstract interface like this: 8< ---------------------------------------------------------------------------- class MatrixOperator { virtual void apply(const Vector &) const = 0; }; 8< ---------------------------------------------------------------------------- which I want to wrap. In Python, I want to pass this function a Numeric array. Vector is a class that could be initialized to share data with a Numeric array. How would I do such a thing? - Can I create a subclass of MatrixOperator that takes a Numeric array and use the class_ HeldType feature to force its use? - Can I write a custom value converter that would to this Numeric.array->Vector conversion for me? How? or - Do I need to do this the "easy way", by having a separate function applyOperator(const MatrixOperator &,NumericArray &)? This boils down to this: Can I make it appear from Python as if a class has a method for which no member function in C++ actually exists (but maybe just a regular function)? Andreas From dave at boost-consulting.com Sat Feb 14 18:06:36 2004 From: dave at boost-consulting.com (David Abrahams) Date: Sat, 14 Feb 2004 12:06:36 -0500 Subject: [C++-sig] Re: self_ns:: necessary when exposing stringification? References: <20040214143732.GA2061@aramis.ath.cx> Message-ID: Andreas Kloeckner writes: > Hey everybody, > > when writing a wrapper recently, I wanted to expose stringification by > writing > > 8<----------------------------------------------------------------------------- > using namespace boost::pyton; > > BOOST_PYTHON_MODULE(...) > { > class_<...>(...) > .def(str(self)); > } > 8<----------------------------------------------------------------------------- > > which resulted in the following error message: > > 8<----------------------------------------------------------------------------- > ... instantiated from various points... (see below for complete error > message) > /home/ak/work/boost/boost/python/def_visitor.hpp:32: error: no matching > function for call to `boost::python::api::object::visit( > boost::python::class_, > boost::python::bases, boost::mpl::void_, > boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, > boost::mpl::void_, boost::mpl::void_, boost::mpl::void_, boost::mpl::void_>, > boost::python::detail::not_specified, boost::python::detail::not_specified>& > ) const' > 8<----------------------------------------------------------------------------- > > So, the compiler must have picked up the "str" function from the object > API It's a class. > , and then class_ tries to apply its visitor magic and fails > miserably. > > This theory is confirmed by the fact that > > 8<----------------------------------------------------------------------------- > class_<...>(...) > .def(self_ns::str(self)); > 8<----------------------------------------------------------------------------- > > actually works. Same thing happens with the BPL test case > "operators". Not AFAICT, unless you explicitly add #include . > This strikes me as odd since the unit test sheet published on boost.org > says that this should work with 3.2.3. (which it doesn't, at least not > with Debian's) I don't believe you have an unmodified installation of Boost 1.31.0 > Do you want me to try any other solutions besides adding self_ns? > Is there a good reason for this behavior besides > "gcc's function lookup is broken"? Nothing broken about it, AFAICT. > What can I do to help you provide a general solution? The general solution is "don't use using-directives" That, however, is draconian in this case. We could make boost::python::str visitable, just for the sake of this ambiguity, but that also feels very wrong. I'm afraid none of my ideas at this point are very good. The one that I definitely like so far is changing str's templated constructor to: template explicit str( T const& other , typename disable_if >::type* = 0 ) : base(object(other)) { } That stops the erroneous construct in the right place, but I don't know how to get the compiler to stop preferring boost::python::str over boost::python::self_ns::str. Even nesting the class into an enclosing namespace doesn't seem to do much good. I suggest taking a good look at the C++ standard (with the technical corrigendum) and considering the rules that govern the choice of classes vs. functions in unqualified calls like this one. -- Dave Abrahams Boost Consulting www.boost-consulting.com From rwgk at yahoo.com Sat Feb 14 18:30:16 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Sat, 14 Feb 2004 09:30:16 -0800 (PST) Subject: [C++-sig] Wrapping an abstract interface In-Reply-To: <20040214145826.GB2061@aramis.ath.cx> Message-ID: <20040214173016.19975.qmail@web20209.mail.yahoo.com> --- Andreas Kloeckner wrote: > This boils down to this: Can I make it appear from Python as if a class > has a method for which no member function in C++ actually exists (but > maybe just a regular function)? Definitely yes. With 1.31.0 you can do this even with constructors. Methods: Your free function must take the wrapped type as the first argument: void addl_method(wrapped_t const& self); class_("wrapped_t") .def("addl_method", addl_method) ; Constructors: See boost/libs/python/test/injected.cpp Ralf __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html From pixellent at stodge.net Sun Feb 15 17:45:52 2004 From: pixellent at stodge.net (pixellent at stodge.net) Date: Sun, 15 Feb 2004 11:45:52 -0500 Subject: [C++-sig] 1.31.0 Python libs Visual Studio Workspace is "empty" Message-ID: <1076863552.402fa240901a3@webmail.stodge.net> I downloaded 1.31.0 and tried to compile the Python library but the workspace was empty when I loaded it into VC++ 6. It this a workspace for a later version of VC++ or is the workspace broken? Thanks Mike ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/ From Benjamin.Golinvaux at euresys.com Mon Feb 16 09:13:33 2004 From: Benjamin.Golinvaux at euresys.com (Benjamin Golinvaux) Date: Mon, 16 Feb 2004 09:13:33 +0100 Subject: [C++-sig] beginner : call_policies Message-ID: Dear list members, I would like to know if it's possible to write my own call policies, in order to be able to handle the reference counting of objets dynamically, based on some return values of my wrapped C++ functions. For example struct A {}; struct B { bool foo(A& someA); A _a; } where i would like B::foo(someA) to increment someA reference count if it returns "true", and don't do anything otherwise. (so basically i would like to tie someA's lifetime to the instance of B ONLY IF the function returns "true". is this possible with some precall/postcall magic ? Thank you. Benjamin Golinvaux Euresys s.a. www.euresys.com -----Original Message----- From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] On Behalf Of Benjamin Golinvaux Sent: jeudi 12 f?vrier 2004 12:35 To: Development of Python/C++ integration Cc: Pierre Joskin; Philippe Latour Subject: [C++-sig] beginner : call_policies Dear list members, I need to wrap a C++ tree structure in Python, and I'm not sure of the correct call policies to use (i'm not even sure they can be applied to my particular case). An node of the tree holds pointers to : - its parent - its children (only pointers are involved) I have pasted the class def. and impl. at the end of this message. operations are provided to attach a tree node to a parent, and to detach it. note : usually the tree nodes do not own their children (they never delete them), but i might provide a way to tag SOME children as 'owned' by their parent. I will need to express this across the python/cpp boundary, too... I would like to create wrappers for this class, that correctly handle the various objects lifetimes. So basically i would like an item to hold a ref to its children, and maybe a weak ref to its parent (?) I have understood how to use "with_custodian_and_ward" to have the TreeNode::Attach(TreeNode* parent) function wrapped so that the node is guaranteed to live at least as long as its parent (== parent holding a ref ?), but i haven't understood how to perform the INVERSE operation, that is, "release" the item reference the parent holds when TreeNode::DetachFrom(TreeNode* parent) is called. Is this possible at all ? I have read the FAQ entry called "how to transfer ownership across a function boundary" but i must admit i don't see how it fits in my problem. I somehow feel uncomfortable being unable to control the way refcounts are inc'd and dec'd but i prefer trusting boost controlling that than myself ! in short, i would like my structure to work just like a python container wrt its items (if i understood things correctly). Thanks for taking the time to read my message. Benjamin Golinvaux Euresys s.a. www.euresys.com The code is as follows : struct TreeNode { typedef std::list::const_iterator ConstItor; TreeNode* _parent; std::list _children; TreeNode( ) : _parent(0) {}; void Attach(TreeNode* parent) { if(parent == _parent) return; if(_parent) Detach(_parent); _parent = parent; parent->_children.push_back(this); } bool HasChild(TreeNode* node) const { for(ConstItor itor = _children.begin(); itor != _children.end(); ++itor) { if(*itor == node) return true; } return false; } void Detach(TreeNode* parent) { if(!parent->HasChild(this)) throw Error_TreeNode_WrongParentSpecified(); parent->_children.remove(this); parent = 0; } private : // prevent generation of bad default code TreeNode(const TreeNode& treeNode); TreeNode& operator=(const TreeNode& treeNode); }; -------------------------------------------------------- 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). -------------------------------------------------------- _______________________________________________ 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 gameguy at eastlink.ca Mon Feb 16 14:04:44 2004 From: gameguy at eastlink.ca (GameGuy) Date: Mon, 16 Feb 2004 09:04:44 -0400 Subject: [C++-sig] Re: Is it possible to expose functions with variable argument lists? In-Reply-To: References: Message-ID: It looks like raw_function is definitely the way to go here. It's not as painless as I was hoping for, but such is life. ;) Thanks a heap! ~Shaun David Abrahams wrote: > GameGuy writes: > > >>Hello. >>I have been using PYSTE and Boost.Python to wrap a C++ library for use in Python. Very nice stuff. >> >>I have reached a stumbling block though: There are several methods in >>this library that have an ellipsis in their method declarations. Eg: >> >>class Foo >>{ >> virtual void method(const char* bar, ... ) const = 0; >>}; >> >>Which I think can be wrapped with Boost.Python in the following way: >> >>struct Foo_Wrapper : Foo >>{ >> // ... >> >> virtual void method(const char* p0, ... ) const { >> va_list args; >> va_start(args, p0); >> call_method< void >(self, "method", p0, args); >> } >>}; >> >>// ... >> >> class_< Foo, Foo_Wrapper >("Foo", init< >()) >> .def("method", &Foo::method) >> ; >> >> >>I saw it done this way in another library. I haven't verified that it >>works or not yet as I can't compile it yet (running into MSVC7 >>issues). >> >>Has anyone else had experience wrapping functions with variable argument lists? >>Will this work in Boost.Python? > > > > Short answer: no, this doesn't work. > > Longer answer: you can't really get this to work in Boost.Python > because it relies on being able to deduce the expected C++ types of > arguments. > > Longer answer still: you might be able use > BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS to wrap this method for > specific sequences of arguments. > > http://tinyurl.com/2wptk > > But now that I look I think it'll fail for the same reason. I think > the need to use call_method internally might give you problems, too. > > I think your best bet might be to use the facilities of > http://www.boost.org/libs/python/doc/v2/raw_function.html > > >>Is it worth extending PYSTE to handle these cases? (It doesn't currently) >> >> >>Thank you for any assistance, >>~Shaun > > From dave at boost-consulting.com Mon Feb 16 14:09:16 2004 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 16 Feb 2004 08:09:16 -0500 Subject: [C++-sig] Re: Boost.Python proposed patch 1.31.0 In-Reply-To: <40306886.8040008@quakes.uq.edu.au> (John Gerschwitz's message of "Mon, 16 Feb 2004 16:51:50 +1000") References: <40298000.902@quakes.uq.edu.au> <402B225F.9070502@quakes.uq.edu.au> <40306886.8040008@quakes.uq.edu.au> Message-ID: John, Please ask Boost.Python questions on the C++-sig unless you want to hire Boost Consulting to help you. John Gerschwitz writes: > Hi Dave, I've had to continue with the patch to the numeric unit test > at home. The behaviour is not what I expected. Everything works fine > just as it is, ie the test comes back saying it has passed. Within > numpy.cpp making the calls to numeric::array nelements(), isaligned(), > iscontiguous(), itemsize() doesn't cause a failure prior to the > patch. This is not what I expected, I expected these calls to generate > an exception. Is there an easy way to run the tests through the > debugger? bjam numpy --debugger=whatever will put "whatever" at the beginning of the command line that runs the test. I use "--debugger=devenv /debugexe". > As you have probably guessed I'm trying to use the Boost.Python > library with numarray. I'm finding the documentation a little on the > light side. Yup. > Can you point me to more comprehensive documentation? All I know about is in the Boost.Python reference, but you might check the list (http://article.gmane.org/gmane.comp.python.c++/4070) or the wiki > I'm > particularly interested in copying data from a numarray into a C++ > data structure. I'm not sure what facilities Boost.Python provides to > make such a task easier. > > Thanks John > -- Dave Abrahams Boost Consulting www.boost-consulting.com From gameguy at eastlink.ca Mon Feb 16 14:51:29 2004 From: gameguy at eastlink.ca (GameGuy) Date: Mon, 16 Feb 2004 09:51:29 -0400 Subject: [C++-sig] Ellipsis parameter not handled in PYSTE Message-ID: FYI, Normally this really isn't a problem, but if the ellipsis is used in the definition of a pure virtual member function then we get compilation errors. PYSTE also tries to expose the member function in the class definition in the module. As discussed already, this can't be done automatically (thanks David!). I'm not exactly sure how PYSTE should wrap the pure virtual method so that it's portable (I'm kind of new to C++ so I may be professing ignorance here), but it definitely shouldn't be exposed in a .def in the class. ~Shaun Foo.cpp \Boost\include\boost-1_31\boost\python\object\value_holder.hpp(71) : error C2259: '`anonymous-namespace'::Foo_Wrapper' : cannot instantiate abstract class due to following members: 'void Foo::method(const char *,...) const' : pure virtual function was not defined Foo.h(3) : see declaration of 'Foo::method' \Boost\include\boost-1_31\boost\type_traits\alignment_of.hpp(37) : see reference to class template instantiation 'boost::python::objects::value_holder_back_reference' being compiled with [ Value=Foo, Held=boost::python::class_::held_type ] \Boost\include\boost-1_31\boost\type_traits\alignment_of.hpp(52) : see reference to class template instantiation 'boost::detail::alignment_of_hack' being compiled with [ T=holder ] \Boost\include\boost-1_31\boost\type_traits\alignment_of.hpp(61) : see reference to class template instantiation 'boost::detail::alignment_of_impl' being compiled with [ T=holder ] \Boost\include\boost-1_31\boost\python\object\instance.hpp(30) : see reference to class template instantiation 'boost::alignment_of' being compiled with [ T=holder ] \Boost\include\boost-1_31\boost\python\object\instance.hpp(45) : see reference to class template instantiation 'boost::python::objects::instance' being compiled with [ Data=holder ] \Boost\include\boost-1_31\boost\python\class.hpp(643) : see reference to class template instantiation 'boost::python::objects::additional_instance_size' being compiled with [ Data=holder ] \Boost\include\boost-1_31\boost\function\function_template.hpp(383) : while compiling class-template member function 'void boost::python::class_::register_holder(void)' with [ T=Foo, X1=boost::noncopyable, X2=`anonymous-namespace'::Foo_Wrapper ] Foo.cpp(37) : see reference to function template instantiation 'boost::python::class_::class_>(const char *,const boost::python::init_base &)' being compiled with [ T=Foo, X1=boost::noncopyable, X2=`anonymous-namespace'::Foo_Wrapper, DerivedT=boost::python::init<> ] -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Foo.h URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Foo.cpp URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Foo.pyste URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Foo.xml Type: text/xml Size: 1591 bytes Desc: not available URL: From dave at boost-consulting.com Mon Feb 16 15:23:15 2004 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 16 Feb 2004 09:23:15 -0500 Subject: [C++-sig] Re: beginner : call_policies References: Message-ID: "Benjamin Golinvaux" writes: > Dear list members, > > I would like to know if it's possible to write my own > call policies, in order to be able to handle the reference > counting of objets dynamically, based on some return values > of my wrapped C++ functions. For example > > struct A {}; > > struct B > { > bool foo(A& someA); > A _a; > } > > where i would like B::foo(someA) to increment someA reference count > if it returns "true", and don't do anything otherwise. > (so basically i would like to tie someA's lifetime to the instance > of B ONLY IF the function returns "true". > > is this possible with some precall/postcall magic ? Yes, it certainly is possible. -- Dave Abrahams Boost Consulting www.boost-consulting.com From gameguy at eastlink.ca Mon Feb 16 16:18:00 2004 From: gameguy at eastlink.ca (GameGuy) Date: Mon, 16 Feb 2004 11:18:00 -0400 Subject: [C++-sig] Re: Problem with current pyste and inheritance In-Reply-To: <4016F0A9.8050105@esss.com.br> References: <25582984.1075234165@localhost> <4016F0A9.8050105@esss.com.br> Message-ID: I'm not sure if this is related, but I found another inheritance problem: Attached are the files necessary to reproduce: 2 classes: A and B. B is derived from A. A defines a method, getA, to illustrate the point more clearly. The method is not necessary to reproduce the problem. If I only put B.pyste in the pyste command line specifying "--multiple", PYSTE won't output the proper bases in the class_ definition, and it redefines all of A's member definitions (as though it's ignoring the 'Import("A.pyste")' declaration in B.pyste). But if both A.pyste and B.pyste are specified in the same command line the proper output is achieved. % pyste --multiple B.pyste // outputs B.cpp erroneously: // Module ====================================================================== void Export_B() { class_< B >("B", init< >()) .def(init< const B& >()) .def("getA", &A::getA, return_value_policy< copy_const_reference >()) ; } % pyste --multiple A.pyste B.pyste // outputs B.cpp properly: // Module ====================================================================== void Export_B() { class_< B, bases< A > >("B", init< >()) .def(init< const B& >()) ; } BTW, is there an online PYSTE bug repository? Bugzilla? Or is this the proper forum for PYSTE bug reports? Cheers, ~Shaun Nicodemus wrote: > Gideon May wrote: > >> Hi, >> >> I've got a C++ class hierarchy which looks like this: >> >> Base >> ^ >> | >> Derived >> ^ >> | >> Sub >> >> and I want to use pyste to generate python bindings. >> I've got it working except for the fact that the bindings >> for Derived are being defined twice by pyste. >> I've attached the include files and pyste files. I generate >> the code with the following command: >> pyste --module=double Base.pyste Derived.pyste Sub.pyste >> >> Any suggestions ? > > > > Hi Gideon, > > I don't have time right now to look at this, but seems like a bug. I > will take a look ASAP. Thanks! > > Regards, > Nicodemus. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: A.h URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: A.pyste URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: B.h URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: B.pyste URL: From steam at nurfuerspam.de Mon Feb 16 16:51:28 2004 From: steam at nurfuerspam.de (Hanz Meizer) Date: Mon, 16 Feb 2004 16:51:28 +0100 Subject: [C++-sig] abstract templates and pyste question. Message-ID: Dear list, I've tried to wrap an abstract template using pyste. Unfortunately, I somehow do not get it to work properly. Maybe there's someone out there who can help? Using boot-1.31. The main problem seems that I have a hierarchy of templates where the base template is abstract. I get tons of error messages, I assume I'd have to tell pyste that the base template has to have a no_init keyword. Unfortunately, I haven't found out how to do this. example template: ---------------------------------------------------- template class PreProcessor { public: PreProcessor() {} virtual ~PreProcessor() {} virtual const int getSize(void) = 0; virtual T* getObject(int id) = 0; }; ---------------------------------------------------- Can anyone tell me how to export such constructs using pyste? If that is not possible, maybe there's a working method for boost.python? H. From nicodemus at esss.com.br Mon Feb 16 16:46:13 2004 From: nicodemus at esss.com.br (Nicodemus) Date: Mon, 16 Feb 2004 12:46:13 -0300 Subject: [C++-sig] Ellipsis parameter not handled in PYSTE In-Reply-To: References: Message-ID: <4030E5C5.6050704@esss.com.br> GameGuy wrote: > FYI, > > Normally this really isn't a problem, but if the ellipsis is used in > the definition of a pure virtual member function then we get > compilation errors. > > PYSTE also tries to expose the member function in the class definition > in the module. As discussed already, this can't be done automatically > (thanks David!). Right. You can just exclude the function using exclude(Foo.method) Regards, Nicodemus. From gameguy at eastlink.ca Mon Feb 16 17:33:54 2004 From: gameguy at eastlink.ca (GameGuy) Date: Mon, 16 Feb 2004 12:33:54 -0400 Subject: [C++-sig] Re: Ellipsis parameter not handled in PYSTE In-Reply-To: <4030E5C5.6050704@esss.com.br> References: <4030E5C5.6050704@esss.com.br> Message-ID: It runs a little deeper than that because excluding the function will remove its implementation from the Foo_Wrapper class, causing the same "pure virtual function was not defined" error message to appear when compiling. ~Shaun Nicodemus wrote: > GameGuy wrote: > >> FYI, >> >> Normally this really isn't a problem, but if the ellipsis is used in >> the definition of a pure virtual member function then we get >> compilation errors. >> >> PYSTE also tries to expose the member function in the class definition >> in the module. As discussed already, this can't be done automatically >> (thanks David!). > > > > Right. You can just exclude the function using > > exclude(Foo.method) > > Regards, > Nicodemus. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Foo.h URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Foo.cpp URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Foo.pyste URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Foo.xml Type: text/xml Size: 1591 bytes Desc: not available URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: compileError.txt URL: From nicodemus at esss.com.br Mon Feb 16 17:58:34 2004 From: nicodemus at esss.com.br (Nicodemus) Date: Mon, 16 Feb 2004 13:58:34 -0300 Subject: [C++-sig] abstract templates and pyste question. In-Reply-To: References: Message-ID: <4030F6BA.2010109@esss.com.br> Hanz Meizer wrote: > Dear list, > > I've tried to wrap an abstract template using pyste. Unfortunately, I > somehow do not get it to work properly. Maybe there's someone out > there who can help? Using boot-1.31. The main problem seems that I > have a hierarchy of templates where the base template is abstract. I > get tons of error messages, I assume I'd have to tell pyste that the > base template has to have a no_init keyword. Unfortunately, I haven't > found out how to do this. > > example template: > > ---------------------------------------------------- > template > class PreProcessor > { > public: > PreProcessor() {} > virtual ~PreProcessor() {} > > virtual const int getSize(void) = 0; > virtual T* getObject(int id) = 0; > }; > ---------------------------------------------------- > You have to create a Template, and the instantiate it for the types you want: PreProcessor = Template("PreProcessor", "preprocessor.hpp") # here no class is exported yet PreProcessor("float", "FPreProcessor") # instantiate PreProcessor with T=float, and rename the # instantiated class to FPreProcessor That should do it. Regards, Nicodemus. > Can anyone tell me how to export such constructs using pyste? If that > is not possible, maybe there's a working method for boost.python? > > H. > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From RaoulGough at yahoo.co.uk Mon Feb 16 20:47:43 2004 From: RaoulGough at yahoo.co.uk (Raoul Gough) Date: Mon, 16 Feb 2004 19:47:43 +0000 Subject: [C++-sig] Re: 1.31.0 Python libs Visual Studio Workspace is "empty" References: <1076863552.402fa240901a3@webmail.stodge.net> Message-ID: pixellent at stodge.net writes: > I downloaded 1.31.0 and tried to compile the Python library but the > workspace was empty when I loaded it into VC++ 6. It this a > workspace for a later version of VC++ or is the workspace broken? I can't answer this question, but just in case you don't already know, you can use bjam to build Python using the VC++ command line tools (this is the only way I've ever done it). Should all be documented... -- Raoul Gough. export LESS='-X' From nitin.shukla at pw.utc.com Mon Feb 16 23:31:53 2004 From: nitin.shukla at pw.utc.com (Shukla, Nitin (Export)) Date: Mon, 16 Feb 2004 17:31:53 -0500 Subject: [C++-sig] Redirecting the bjam output Message-ID: <271266F9567FB84D8F887943C93FA1EB0209CD3D@pusehe0o.eh.pweh.com> Hello, I am building a Boost.Python extension module outside the Boost.Python directory. While building bjam tool creates and outputs in the following directory structure: "bin/${Currentfolder_name}/${BOOST_PYTHON_MODULE}.pyd/${-sTOOLS}/${-sBUILD} e.g "/bin/ScriptEngineTool/scriptengine.pyd/mingw/release" I want to direct the bjam tool to output in the current working folder instead of creating the above directory structure. How can I do that? Thanks, Nitin From johng at quakes.uq.edu.au Tue Feb 17 00:53:07 2004 From: johng at quakes.uq.edu.au (John Gerschwitz) Date: Tue, 17 Feb 2004 09:53:07 +1000 Subject: [C++-sig] extracting data from numarray Message-ID: <403157E3.8080500@quakes.uq.edu.au> Does Boost.Python provide a mechanism for easily copying data from a numarray to a C++ data structure such as a STL vector? Thanks John From steam at nurfuerspam.de Tue Feb 17 11:05:21 2004 From: steam at nurfuerspam.de (Hanz Meizer) Date: Tue, 17 Feb 2004 11:05:21 +0100 Subject: [C++-sig] Re: abstract templates and pyste question. In-Reply-To: <4030F6BA.2010109@esss.com.br> References: <4030F6BA.2010109@esss.com.br> Message-ID: [...] >> ---------------------------------------------------- >> template >> class PreProcessor >> { >> public: >> PreProcessor() {} >> virtual ~PreProcessor() {} >> >> virtual const int getSize(void) = 0; >> virtual T* getObject(int id) = 0; >> }; >> ---------------------------------------------------- >> > You have to create a Template, and the instantiate it for the types you > want: > > PreProcessor = Template("PreProcessor", "preprocessor.hpp") # here no > class is exported yet > > PreProcessor("float", "FPreProcessor") # instantiate PreProcessor with > T=float, and rename the > # instantiated class to > FPreProcessor > > That should do it. > > Regards, > Nicodemus. [...] Unfortunately, this doesn't work. I've even excluded the virtual functions like this: -------------------------------------------------------------------- # PreProcessor.h PreProcessor=Template("PreProcessor", "TClass.h") exclude(PreProcessor.getSize) exclude(PreProcessor.getObject) PreProcessor_char=PreProcessor("char", "PreProcessor_char") -------------------------------------------------------------------- I get the following error output: -------------------------------------------------------------------- pyste.sh --module=pytest_p pytest_p.pyste Module pytest_p generated 5.73 seconds g++ -g -s -I. -I/home/thomast/work/pyste/boost.current -I/usr/include/python2.2 pytest_p.cpp -c -o pytest_p.o /home/thomast/work/pyste/boost.current/boost/python/object/value_holder.hpp: In instantiation of `boost::python::objects::value_holder_back_reference, ::PreProcessor_char_Wrapper>': /home/thomast/work/pyste/boost.current/boost/type_traits/alignment_of.hpp:56: instantiated from `boost::detail::alignment_of_impl, ::PreProcessor_char_Wrapper> >' /home/thomast/work/pyste/boost.current/boost/python/object/instance.hpp:31: instantiated from `boost::alignment_of, ::PreProcessor_char_Wrapper> >' /home/thomast/work/pyste/boost.current/boost/python/object/instance.hpp:31: instantiated from `boost::python::objects::instance, ::PreProcessor_char_Wrapper> >' /home/thomast/work/pyste/boost.current/boost/python/object/instance.hpp:47: instantiated from `boost::python::objects::additional_instance_size, ::PreProcessor_char_Wrapper> >' /home/thomast/work/pyste/boost.current/boost/python/class.hpp:642: instantiated from `void boost::python::class_::register_holder() [with T = PreProcessor, X1 = boost::noncopyable, X2 = ::PreProcessor_char_Wrapper, X3 = boost::python::detail::not_specified]' /home/thomast/work/pyste/boost.current/boost/python/class.hpp:275: instantiated from `boost::python::class_::class_(const char*, const boost::python::init_base&) [with DerivedT = boost::python::init, T = PreProcessor, X1 = boost::noncopyable, X2 = ::PreProcessor_char_Wrapper, X3 = boost::python::detail::not_specified]' pytest_p.cpp:41: instantiated from here /home/thomast/work/pyste/boost.current/boost/python/object/value_holder.hpp:59: error: cannot declare field ` boost::python::objects::value_holder_back_reference, ::PreProcessor_char_Wrapper>::m_held' to be of type ` ::PreProcessor_char_Wrapper' /home/thomast/work/pyste/boost.current/boost/python/object/value_holder.hpp:59: error: because the following virtual functions are abstract: TClass.h:72: error: const int PreProcessor::getSize() [with T = char] TClass.h:73: error: T* PreProcessor::getObject(int) [with T = char] make: *** [pytest_p.o] Error 1 -------------------------------------------------------------------- As far as I understand it, the compiler expects that the template can be instantiated. Looking into the pytes_p.cpp (which was generated with pyste): class_< PreProcessor, boost::noncopyable, PreProcessor_char_Wrapper >("PreProcessor_char", init< >()) Shouldn't this read no_init? I'm confused :( Greetings, H. From nicodemus at esss.com.br Tue Feb 17 11:31:19 2004 From: nicodemus at esss.com.br (Nicodemus) Date: Tue, 17 Feb 2004 07:31:19 -0300 Subject: [C++-sig] Re: abstract templates and pyste question. In-Reply-To: References: <4030F6BA.2010109@esss.com.br> Message-ID: <4031ED77.9000501@esss.com.br> Hanz Meizer wrote: > [...] > >>> ---------------------------------------------------- >>> template >>> class PreProcessor >>> { >>> public: >>> PreProcessor() {} >>> virtual ~PreProcessor() {} >>> >>> virtual const int getSize(void) = 0; >>> virtual T* getObject(int id) = 0; >>> }; >>> ---------------------------------------------------- >>> >> You have to create a Template, and the instantiate it for the types >> you want: >> >> PreProcessor = Template("PreProcessor", "preprocessor.hpp") # here no >> class is exported yet >> >> PreProcessor("float", "FPreProcessor") # instantiate PreProcessor >> with T=float, and rename the >> # instantiated class to >> FPreProcessor >> >> That should do it. >> >> Regards, >> Nicodemus. > > > [...] > > Unfortunately, this doesn't work. I've even excluded the virtual > functions like this: > -------------------------------------------------------------------- > # PreProcessor.h > PreProcessor=Template("PreProcessor", "TClass.h") > exclude(PreProcessor.getSize) > exclude(PreProcessor.getObject) > PreProcessor_char=PreProcessor("char", "PreProcessor_char") > -------------------------------------------------------------------- > > I get the following error output: > -------------------------------------------------------------------- > snip > error-------------------------------------------------------------------- > > As far as I understand it, the compiler expects that the template can > be instantiated. Looking into the pytes_p.cpp (which was generated > with pyste): > > class_< PreProcessor, boost::noncopyable, > PreProcessor_char_Wrapper >("PreProcessor_char", init< >()) > > Shouldn't this read no_init? I'm confused :( Under msvc 6.0 it works just fine... perhaps Dave can explain if the above should be valid or not? Meanwhile, this patch adds the no_init clausule for abstract classes: *** ClassExporter.old.py Tue Feb 17 07:26:57 2004 --- ClassExporter.py Tue Feb 17 07:27:07 2004 *************** *** 255,264 **** self.constructors = constructors[:] # don't export the copy constructor if the class is abstract if self.class_.abstract: ! for cons in constructors: ! if cons.IsCopy(): ! constructors.remove(cons) ! break if not constructors: # declare no_init self.Add('constructor', py_ns + 'no_init') --- 255,261 ---- self.constructors = constructors[:] # don't export the copy constructor if the class is abstract if self.class_.abstract: ! constructors = [] if not constructors: # declare no_init self.Add('constructor', py_ns + 'no_init') Regards, Nicodemus. From nicodemus at esss.com.br Tue Feb 17 13:05:12 2004 From: nicodemus at esss.com.br (Nicodemus) Date: Tue, 17 Feb 2004 09:05:12 -0300 Subject: [SPAM] [C++-sig] Re: Ellipsis parameter not handled in PYSTE In-Reply-To: References: <4030E5C5.6050704@esss.com.br> Message-ID: <40320378.3010901@esss.com.br> GameGuy wrote: > It runs a little deeper than that because excluding the function will > remove its implementation from the Foo_Wrapper class, causing the same > "pure virtual function was not defined" error message to appear when > compiling. I see... what do you suggest to solve this? Regards, Nicodemus. From roman.yakovenko at actimize.com Tue Feb 17 16:25:15 2004 From: roman.yakovenko at actimize.com (Roman Yakovenko) Date: Tue, 17 Feb 2004 17:25:15 +0200 Subject: [C++-sig] Pyste bug with unnamed enums Message-ID: <2CD84621099A814598AE3EFEFB5C142101E070@exchange.adrembi.com> Hi. I found bug in Pyste. Description: In your code you have 2 unnamed enum definitions enum { SOME_CONST_1 = 32 }; enum { SOME_CONST_2 = 46 }; after running pyste on this code you will get // Unique type for unnamed enums #ifndef PYSTE_UNIQUE_INT_DEFINED #define PYSTE_UNIQUE_INT_DEFINED template struct UniqueInt { int v; enum { value=num }; UniqueInt(int v_): v(v_) {} operator int() const { return v; } }; #endif // PYSTE_UNIQUE_INT_DEFINED generated twice ( if you generate your code to the same module ). The possible solution are: 1. To ask David Abrahams how we should export unnamed enums ( defined within class and within some namespace ). 2. To use unnamed enums as global constants for enums defined within namespace. To define new class attribute if enum defined within class. 3. To put definition of UniqueInt within BPL 4. To generate different name for UniqueInt or to generate it within different namespace As for me 1 - is preferred way 2 - I don't know whether it is possible to know where enum come from, and whether it is smart to divide in this way enums 3 - David Abrahams must agree to such solution 4 - patch, that could be written in 15 minutes, but it will be very, very ugly hint: to generate the struct definition in it's own namespace. ( namespace will be unique ) Also I will be glad to implement and to contribute a patch. Roman. From grafik.list at redshift-software.com Tue Feb 17 16:38:40 2004 From: grafik.list at redshift-software.com (Rene Rivera) Date: Tue, 17 Feb 2004 09:38:40 -0600 Subject: [C++-sig] Redirecting the bjam output In-Reply-To: <271266F9567FB84D8F887943C93FA1EB0209CD3D@pusehe0o.eh.pweh.com> References: <271266F9567FB84D8F887943C93FA1EB0209CD3D@pusehe0o.eh.pweh.com> Message-ID: <40323580.5030008@redshift-software.com> Shukla, Nitin (Export) wrote: > Hello, > > I am building a Boost.Python extension module outside the Boost.Python > directory. While building bjam tool creates and outputs in the following > directory structure: > > "bin/${Currentfolder_name}/${BOOST_PYTHON_MODULE}.pyd/${-sTOOLS}/${-sBUILD} > e.g "/bin/ScriptEngineTool/scriptengine.pyd/mingw/release" > > I want to direct the bjam tool to output in the current working folder > instead of creating the above directory structure. How can I do that? Unfortunately you can't. Actually it's fortunate in that the binaries don't collide with each other :-) The best you can do use the "stage" rule to copy the final products (libs, dlls, exes, pyds) to a top-level directory. -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com - 102708583/icq From dave at boost-consulting.com Tue Feb 17 17:38:18 2004 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 17 Feb 2004 11:38:18 -0500 Subject: [C++-sig] Re: Pyste bug with unnamed enums References: <2CD84621099A814598AE3EFEFB5C142101E070@exchange.adrembi.com> Message-ID: "Roman Yakovenko" writes: > Hi. I found bug in Pyste. > > Description: > In your code you have 2 unnamed enum definitions > > enum { SOME_CONST_1 = 32 }; > enum { SOME_CONST_2 = 46 }; > > after running pyste on this code you will get > > // Unique type for unnamed enums > #ifndef PYSTE_UNIQUE_INT_DEFINED > #define PYSTE_UNIQUE_INT_DEFINED > template > struct UniqueInt { > int v; > enum { value=num }; > UniqueInt(int v_): > v(v_) > {} > operator int() const > { return v; } > }; > #endif // PYSTE_UNIQUE_INT_DEFINED > > generated twice ( if you generate your code to the same module ). > > The possible solution are: > 1. To ask David Abrahams how we should export unnamed enums ( > defined within class and within some namespace ). Name them. If you can't name them, you can't export them. You can't even pass them through a function template: enum { x = 1 }; template int f(T); int y = f(x); // error Sorry. > 2. To use unnamed enums as global constants for enums defined within namespace. > To define new class attribute if enum defined within class. > 3. To put definition of UniqueInt within BPL :( I don't really know what UniqueInt is supposed to do, but I don't love it because it's not unique ;-) enum { x = 1 } enum { y = 1 } BOOST_STATIC_ASSERT((boost::is_same,UniqueInt >::value)); -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Tue Feb 17 17:33:31 2004 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 17 Feb 2004 11:33:31 -0500 Subject: [C++-sig] Re: abstract templates and pyste question. References: <4030F6BA.2010109@esss.com.br> <4031ED77.9000501@esss.com.br> Message-ID: Nicodemus writes: > Hanz Meizer wrote: > >> [...] >> >>>> ---------------------------------------------------- >>>> template >>>> class PreProcessor >>>> { >>>> public: >>>> PreProcessor() {} >>>> virtual ~PreProcessor() {} >>>> >>>> virtual const int getSize(void) = 0; >>>> virtual T* getObject(int id) = 0; >>>> }; >>>> ---------------------------------------------------- >>>> >> >> I get the following error output: >> -------------------------------------------------------------------- > pytest_p.cpp:41: instantiated from here > /home/thomast/work/pyste/boost.current/boost/python/object/value_holder.hpp:59: > error: cannot > declare field ` > boost::python::objects::value_holder_back_reference, > ::PreProcessor_char_Wrapper>::m_held' to be of type ` > ::PreProcessor_char_Wrapper' > /home/thomast/work/pyste/boost.current/boost/python/object/value_holder.hpp:59: > error: > because the following virtual functions are abstract: > TClass.h:72: error: const int PreProcessor::getSize() [with T = char] > TClass.h:73: error: T* PreProcessor::getObject(int) [with T = char] > make: *** [pytest_p.o] Error 1 > >> error-------------------------------------------------------------------- >> >> As far as I understand it, the compiler expects that the template >> can be instantiated. Looking into the pytes_p.cpp (which was >> generated with pyste): >> >> class_< PreProcessor, boost::noncopyable, >> PreProcessor_char_Wrapper >("PreProcessor_char", init< >()) >> >> Shouldn't this read no_init? I'm confused :( There are two choices: 1. It can be no_init 2. PreProcessor_char_Wrapper must define getSize() and getObject() Clearly, whatever was generated by pyste does neither of these. -- Dave Abrahams Boost Consulting www.boost-consulting.com From gameguy at eastlink.ca Tue Feb 17 19:41:23 2004 From: gameguy at eastlink.ca (GameGuy) Date: Tue, 17 Feb 2004 14:41:23 -0400 Subject: [C++-sig] Re: [SPAM] Re: Ellipsis parameter not handled in PYSTE In-Reply-To: <40320378.3010901@esss.com.br> References: <4030E5C5.6050704@esss.com.br> <40320378.3010901@esss.com.br> Message-ID: I'm not really sure. I guess it depends on your intentions for pyste. If, for example, pyste is to be used as a tool to help in the creation of C++ files (meaning that some editing is required after pyste is run), then flagging these cases with warning output and writing a meaningful member function stub in the .cpp file might be a good solution. That way programmers can pick up where pyste leaves off. Alternately, if pyste is to output C++ code that shouldn't be modified, than the guts of the wrapped member functions must be filled properly. That's difficult to do in a cross-platform way, I think. Regardless, I think the output of pyste should always compile. Below is a pretty quick hack, but I think it produces something that compiles in all ellipsis cases (it's not very careful with outputting proper warning messages and whatnot, nor is it the most elegant solution ever ;) ). It isn't complete either, because the variable argument list is untouched within the wrapped member functions. Attached are some test files I was using while producing this patch. I hope this helps, ~Shaun Index: ClassExporter.py =================================================================== RCS file: /boost/boost/libs/python/pyste/src/Pyste/ClassExporter.py,v retrieving revision 1.15 diff -u -r1.15 ClassExporter.py --- ClassExporter.py 23 Oct 2003 22:56:33 -0000 1.15 +++ ClassExporter.py 17 Feb 2004 18:24:50 -0000 @@ -345,7 +345,7 @@ def IsExportable(m): 'Returns true if the given method is exportable by this routine' ignore = (Constructor, ClassOperator, Destructor) - return isinstance(m, Function) and not isinstance(m, ignore) and not m.virtual + return isinstance(m, Function) and not isinstance(m, ignore) and not m.virtual and not m.has_ellipsis methods = [x for x in self.public_members if IsExportable(x)] methods.extend(self.GetAddedMethods()) @@ -645,12 +645,18 @@ if count is None: count = len(m.parameters) param_names = ['p%i' % i for i in range(count)] + has_ellipsis = False + if count > 0 and type(m.parameters[count-1]) == EllipsisType: + param_names[count-1] = '' + has_ellipsis = True param_types = [x.FullName() for x in m.parameters[:count]] params = ['%s %s' % (t, n) for t, n in zip(param_types, param_names)] #for i, p in enumerate(m.parameters[:count]): # if p.default is not None: # #params[i] += '=%s' % p.default # params[i] += '=%s' % (p.name + '()') + if has_ellipsis: + param_names = param_names[:-1] params = ', '.join(params) return params, param_names, param_types @@ -856,7 +862,7 @@ for method in self.virtual_methods: exclude = self.info[method.name].exclude # generate definitions only for public methods and non-abstract methods - if method.visibility == Scope.public and not exclude: + if method.visibility == Scope.public and not exclude and not method.has_ellipsis: defs.extend(self.MethodDefinition(method)) return defs Index: FunctionExporter.py =================================================================== RCS file: /boost/boost/libs/python/pyste/src/Pyste/FunctionExporter.py,v retrieving revision 1.7 diff -u -r1.7 FunctionExporter.py --- FunctionExporter.py 6 Oct 2003 19:10:50 -0000 1.7 +++ FunctionExporter.py 17 Feb 2004 18:24:50 -0000 @@ -33,6 +33,8 @@ def ExportDeclaration(self, decl, unique, codeunit): + if decl.has_ellipsis: + return name = self.info.rename or decl.name defs = namespaces.python + 'def("%s", ' % name wrapper = self.info.wrapper Index: GCCXMLParser.py =================================================================== RCS file: /boost/boost/libs/python/pyste/src/Pyste/GCCXMLParser.py,v retrieving revision 1.3 diff -u -r1.3 GCCXMLParser.py --- GCCXMLParser.py 6 Oct 2003 19:10:50 -0000 1.3 +++ GCCXMLParser.py 17 Feb 2004 18:24:50 -0000 @@ -190,12 +190,19 @@ def GetArguments(self, element): args = [] + has_ellipsis = False for child in element: if child.tag == 'Argument': type = self.GetType(child.get('type')) type.default = child.get('default') args.append(type) - return args + elif child.tag == 'Ellipsis': + args.append(EllipsisType()) + has_ellipsis = True + else: + print "Warning: Unhandled '"+child.tag+"' in", element.get('name'), + print "from", self.GetLocation(element.get('location')) + return args, has_ellipsis def GetExceptions(self, exception_list): @@ -216,10 +223,11 @@ returns = self.GetType(element.get('returns')) namespace = self.GetDecl(element.get('context')) location = self.GetLocation(element.get('location')) - params = self.GetArguments(element) + params, has_ellipsis = self.GetArguments(element) incomplete = bool(int(element.get('incomplete', 0))) throws = self.GetExceptions(element.get('throw', None)) function = functionType(name, namespace, returns, params, throws) + function.has_ellipsis = has_ellipsis function.location = location self.AddDecl(function) self.Update(id, function) @@ -354,16 +362,18 @@ def ParseFunctionType(self, id, element): result = self.GetType(element.get('returns')) - args = self.GetArguments(element) + args, has_ellipsis = self.GetArguments(element) func = FunctionType(result, args) + func.has_ellipsis = has_ellipsis self.Update(id, func) def ParseMethodType(self, id, element): class_ = self.GetDecl(element.get('basetype')).FullName() result = self.GetType(element.get('returns')) - args = self.GetArguments(element) + args, has_ellipsis = self.GetArguments(element) method = MethodType(result, args, class_) + method.has_ellipsis = has_ellipsis self.Update(id, method) @@ -390,9 +400,10 @@ const = bool(int(element.get('const', '0'))) location = self.GetLocation(element.get('location')) throws = self.GetExceptions(element.get('throw', None)) - params = self.GetArguments(element) + params, has_ellipsis = self.GetArguments(element) method = methodType( name, classname, result, params, visib, virtual, abstract, static, const, throws) + method.has_ellipsis = has_ellipsis method.location = location self.Update(id, method) @@ -406,8 +417,9 @@ visib = element.get('access', Scope.public) classname = self.GetDecl(element.get('context')).FullName() location = self.GetLocation(element.get('location')) - params = self.GetArguments(element) + params, has_ellipsis = self.GetArguments(element) ctor = Constructor(name, classname, params, visib) + ctor.has_ellipsis = has_ellipsis ctor.location = location self.Update(id, ctor) Index: declarations.py =================================================================== RCS file: /boost/boost/libs/python/pyste/src/Pyste/declarations.py,v retrieving revision 1.6 diff -u -r1.6 declarations.py --- declarations.py 6 Oct 2003 19:10:50 -0000 1.6 +++ declarations.py 17 Feb 2004 18:24:50 -0000 @@ -486,6 +486,17 @@ #============================================================================== +# EllipsisType +#============================================================================== +class EllipsisType(Type): + 'An ellipsis argument.' + + def __init__(self): + Type.__init__(self, "...", False, None) + + + +#============================================================================== # FunctionType #============================================================================== class FunctionType(Type): -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Foo.cpp URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Foo.pyste URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Foo.h URL: From nitin.shukla at pw.utc.com Tue Feb 17 20:48:53 2004 From: nitin.shukla at pw.utc.com (Shukla, Nitin (Export)) Date: Tue, 17 Feb 2004 14:48:53 -0500 Subject: [C++-sig] Redirecting the bjam output Message-ID: <271266F9567FB84D8F887943C93FA1EB0209CD40@pusehe0o.eh.pweh.com> Is it's really not possible? But whenever I build my project inside the Boost project tree, the outputs are generated in the following folder: ${BOOSTROOT}/bin/${Currentfolder_name}/${BOOST_PYTHON_MODULE}.pyd/${-sTOOLS} /${-sBUILD} rather than /bin/${Currentfolder_name}/... being created from my current working folder. I thought there would be some way of specifying the output to be generated in the current working folder rather than in such directory structure. May somewhere in Jamfile or Jamrules file, I don't know. Nitin > -----Original Message----- > From: Rene Rivera [mailto:grafik.list at redshift-software.com] > > > Shukla, Nitin (Export) wrote: > > > Hello, > > > > I am building a Boost.Python extension module outside the > Boost.Python > > directory. While building bjam tool creates and outputs in > the following > > directory structure: > > > > > "bin/${Currentfolder_name}/${BOOST_PYTHON_MODULE}.pyd/${-sTOOL > S}/${-sBUILD} > > e.g "/bin/ScriptEngineTool/scriptengine.pyd/mingw/release" > > > > I want to direct the bjam tool to output in the current > working folder > > instead of creating the above directory structure. How can > I do that? > > Unfortunately you can't. Actually it's fortunate in that the > binaries don't > collide with each other :-) > > The best you can do use the "stage" rule to copy the final > products (libs, > dlls, exes, pyds) to a top-level directory. > > > -- Grafik - Don't Assume Anything > -- Redshift Software, Inc. - http://redshift-software.com > -- rrivera/acm.org - grafik/redshift-software.com - 102708583/icq > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From gameguy at eastlink.ca Tue Feb 17 21:04:00 2004 From: gameguy at eastlink.ca (GameGuy) Date: Tue, 17 Feb 2004 16:04:00 -0400 Subject: [C++-sig] Re: Ellipsis parameter not handled in PYSTE In-Reply-To: <40320378.3010901@esss.com.br> References: <4030E5C5.6050704@esss.com.br> <40320378.3010901@esss.com.br> Message-ID: It looks like my last post didn't make it to the list. Just as well, the code had a couple problems anyway. I've play-tested this version a little more. ---- I'm not really sure what the best solution is. I guess it depends on your intentions for pyste. If, for example, pyste is to be used as a tool to help in the creation of C++ files (meaning that some editing is required after pyste is run), then flagging these cases with warning output and writing a meaningful member function stub in the .cpp file might be a good solution. That way programmers can pick up where pyste leaves off. Alternately, if pyste is to output C++ code that shouldn't be modified, than the guts of the wrapped member functions must be filled properly. That's difficult to do in a cross-platform way, I think. Regardless, I think the output of pyste should always compile. Below is a pretty quick hack, but I think it produces something that compiles in all ellipsis cases (it's not very careful with outputting proper warning messages and whatnot, nor is it the most elegant solution ever ). It isn't complete either, because the variable argument list is untouched within the wrapped member functions. Attached are some test files I was using while producing this patch. I hope this helps, ~Shaun Index: ClassExporter.py =================================================================== RCS file: /boost/boost/libs/python/pyste/src/Pyste/ClassExporter.py,v retrieving revision 1.15 diff -u -r1.15 ClassExporter.py --- ClassExporter.py 23 Oct 2003 22:56:33 -0000 1.15 +++ ClassExporter.py 17 Feb 2004 20:02:17 -0000 @@ -345,7 +345,7 @@ def IsExportable(m): 'Returns true if the given method is exportable by this routine' ignore = (Constructor, ClassOperator, Destructor) - return isinstance(m, Function) and not isinstance(m, ignore) and not m.virtual + return isinstance(m, Function) and not isinstance(m, ignore) and not m.virtual and not m.has_ellipsis methods = [x for x in self.public_members if IsExportable(x)] methods.extend(self.GetAddedMethods()) @@ -645,12 +645,18 @@ if count is None: count = len(m.parameters) param_names = ['p%i' % i for i in range(count)] + has_ellipsis = False + if count > 0 and type(m.parameters[count-1]) == EllipsisType: + param_names[count-1] = '' + has_ellipsis = True param_types = [x.FullName() for x in m.parameters[:count]] params = ['%s %s' % (t, n) for t, n in zip(param_types, param_names)] #for i, p in enumerate(m.parameters[:count]): # if p.default is not None: # #params[i] += '=%s' % p.default # params[i] += '=%s' % (p.name + '()') + if has_ellipsis: + param_names = param_names[:-1] params = ', '.join(params) return params, param_names, param_types @@ -856,7 +862,7 @@ for method in self.virtual_methods: exclude = self.info[method.name].exclude # generate definitions only for public methods and non-abstract methods - if method.visibility == Scope.public and not exclude: + if method.visibility == Scope.public and not exclude and not method.has_ellipsis: defs.extend(self.MethodDefinition(method)) return defs Index: FunctionExporter.py =================================================================== RCS file: /boost/boost/libs/python/pyste/src/Pyste/FunctionExporter.py,v retrieving revision 1.7 diff -u -r1.7 FunctionExporter.py --- FunctionExporter.py 6 Oct 2003 19:10:50 -0000 1.7 +++ FunctionExporter.py 17 Feb 2004 20:02:17 -0000 @@ -33,6 +33,8 @@ def ExportDeclaration(self, decl, unique, codeunit): + if decl.has_ellipsis: + return name = self.info.rename or decl.name defs = namespaces.python + 'def("%s", ' % name wrapper = self.info.wrapper Index: GCCXMLParser.py =================================================================== RCS file: /boost/boost/libs/python/pyste/src/Pyste/GCCXMLParser.py,v retrieving revision 1.3 diff -u -r1.3 GCCXMLParser.py --- GCCXMLParser.py 6 Oct 2003 19:10:50 -0000 1.3 +++ GCCXMLParser.py 17 Feb 2004 20:02:17 -0000 @@ -190,12 +190,19 @@ def GetArguments(self, element): args = [] + has_ellipsis = False for child in element: if child.tag == 'Argument': type = self.GetType(child.get('type')) type.default = child.get('default') args.append(type) - return args + elif child.tag == 'Ellipsis': + args.append(EllipsisType()) + has_ellipsis = True + else: + print "Warning: Unhandled '"+child.tag+"' in", element.get('name'), + print "from", self.GetLocation(element.get('location')) + return args, has_ellipsis def GetExceptions(self, exception_list): @@ -216,10 +223,11 @@ returns = self.GetType(element.get('returns')) namespace = self.GetDecl(element.get('context')) location = self.GetLocation(element.get('location')) - params = self.GetArguments(element) + params, has_ellipsis = self.GetArguments(element) incomplete = bool(int(element.get('incomplete', 0))) throws = self.GetExceptions(element.get('throw', None)) function = functionType(name, namespace, returns, params, throws) + function.has_ellipsis = has_ellipsis function.location = location self.AddDecl(function) self.Update(id, function) @@ -354,16 +362,18 @@ def ParseFunctionType(self, id, element): result = self.GetType(element.get('returns')) - args = self.GetArguments(element) + args, has_ellipsis = self.GetArguments(element) func = FunctionType(result, args) + func.has_ellipsis = has_ellipsis self.Update(id, func) def ParseMethodType(self, id, element): class_ = self.GetDecl(element.get('basetype')).FullName() result = self.GetType(element.get('returns')) - args = self.GetArguments(element) + args, has_ellipsis = self.GetArguments(element) method = MethodType(result, args, class_) + method.has_ellipsis = has_ellipsis self.Update(id, method) @@ -390,9 +400,10 @@ const = bool(int(element.get('const', '0'))) location = self.GetLocation(element.get('location')) throws = self.GetExceptions(element.get('throw', None)) - params = self.GetArguments(element) + params, has_ellipsis = self.GetArguments(element) method = methodType( name, classname, result, params, visib, virtual, abstract, static, const, throws) + method.has_ellipsis = has_ellipsis method.location = location self.Update(id, method) @@ -406,8 +417,9 @@ visib = element.get('access', Scope.public) classname = self.GetDecl(element.get('context')).FullName() location = self.GetLocation(element.get('location')) - params = self.GetArguments(element) + params, has_ellipsis = self.GetArguments(element) ctor = Constructor(name, classname, params, visib) + ctor.has_ellipsis = has_ellipsis ctor.location = location self.Update(id, ctor) Index: declarations.py =================================================================== RCS file: /boost/boost/libs/python/pyste/src/Pyste/declarations.py,v retrieving revision 1.6 diff -u -r1.6 declarations.py --- declarations.py 6 Oct 2003 19:10:50 -0000 1.6 +++ declarations.py 17 Feb 2004 20:02:17 -0000 @@ -22,6 +22,7 @@ @ivar namespace: The namespace of the declaration. ''' + has_ellipsis = False def __init__(self, name, namespace): ''' @type name: string @@ -482,6 +483,17 @@ def __init__(self, name, const=False, default=None): Type.__init__(self, name, const, default) + + + +#============================================================================== +# EllipsisType +#============================================================================== +class EllipsisType(Type): + 'An ellipsis argument.' + + def __init__(self): + Type.__init__(self, "...", False, None) -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Foo.h URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Foo.cpp URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Foo.pyste URL: From s_sourceforge at nedprod.com Tue Feb 17 23:55:44 2004 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Tue, 17 Feb 2004 22:55:44 -0000 Subject: [C++-sig] Pyste bug with unnamed enums In-Reply-To: <2CD84621099A814598AE3EFEFB5C142101E070@exchange.adrembi.com> Message-ID: <40329BF0.22709.3524D8A3@localhost> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 17 Feb 2004 at 17:25, Roman Yakovenko wrote: > 1. To ask David Abrahams how we should export unnamed enums ( defined > within class and within some namespace ). Believe it or not we have done our best on this - six months ago unnamed enums just didn't work at all. If you search the archives, all is explained there. Unfortunately pyste starts with a zero based index, so if it is called on two separate occasions it reuses the same index for two quite different enums in separate compilation units. This is a bug but Nicodemus knows about it. Cheers, Niall -----BEGIN PGP SIGNATURE----- Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 iQA/AwUBQDKb8MEcvDLFGKbPEQLGVQCfXESQvBBPPelYobm0cfMD6oyszc4AoMDt WXMbHghaT3UM1CryNYXI9Qpo =gA9f -----END PGP SIGNATURE----- From steam at nurfuerspam.de Wed Feb 18 16:08:34 2004 From: steam at nurfuerspam.de (Hanz Meizer) Date: Wed, 18 Feb 2004 16:08:34 +0100 Subject: [C++-sig] Re: abstract templates and pyste question. In-Reply-To: References: <4030F6BA.2010109@esss.com.br> <4031ED77.9000501@esss.com.br> Message-ID: Hi, While investigating, I found something strange: I've got two classes, both are abstract, the base class is a regular class, the derived class is a template. The base has a private copy constructor (which is empty). The derived one has no copy constructor declared. The whole construct didn't pythonize, since pyste declares a wrapper for the derived class that calls the base copy constructor (which is private). Obviously (?), C++ avoids calling the private base copy constructor from the implicitly generated derived copy constructor (that's my explanation, maybe this is not true. Who knows?). Maybe this only holds true for templates. Anyways, I solved this special issue by inserting a private copy constructor (that is defined empty) in the derived template. Is this a known thing? What if the include files were write only fo me and I couldn't modify them? After all, in C++ this kind of setup is working, just th generated wrapper seems to make false assumptions. H. From nicodemus at esss.com.br Wed Feb 18 16:36:12 2004 From: nicodemus at esss.com.br (Nicodemus) Date: Wed, 18 Feb 2004 12:36:12 -0300 Subject: [C++-sig] Re: abstract templates and pyste question. In-Reply-To: References: <4030F6BA.2010109@esss.com.br> <4031ED77.9000501@esss.com.br> Message-ID: <4033866C.1040401@esss.com.br> David Abrahams wrote: >Nicodemus writes: > > >>Hanz Meizer wrote: >> >> >>>[...] >>> >>> >>>>>---------------------------------------------------- >>>>>template >>>>>class PreProcessor >>>>>{ >>>>>public: >>>>> PreProcessor() {} >>>>> virtual ~PreProcessor() {} >>>>> >>>>> virtual const int getSize(void) = 0; >>>>> virtual T* getObject(int id) = 0; >>>>>}; >>>>>---------------------------------------------------- >>>>> >>>>> >>>I get the following error output: >>>-------------------------------------------------------------------- >>> >>pytest_p.cpp:41: instantiated from here >>/home/thomast/work/pyste/boost.current/boost/python/object/value_holder.hpp:59: >>error: cannot >> declare field ` >> boost::python::objects::value_holder_back_reference, >> ::PreProcessor_char_Wrapper>::m_held' to be of type ` >> ::PreProcessor_char_Wrapper' >>/home/thomast/work/pyste/boost.current/boost/python/object/value_holder.hpp:59: >>error: >> because the following virtual functions are abstract: >>TClass.h:72: error: const int PreProcessor::getSize() [with T = char] >>TClass.h:73: error: T* PreProcessor::getObject(int) [with T = char] >>make: *** [pytest_p.o] Error 1 >> >>>>error-------------------------------------------------------------------- >>>> >>>As far as I understand it, the compiler expects that the template >>>can be instantiated. Looking into the pytes_p.cpp (which was >>>generated with pyste): >>> >>> class_< PreProcessor, boost::noncopyable, >>>PreProcessor_char_Wrapper >("PreProcessor_char", init< >()) >>> >>>Shouldn't this read no_init? I'm confused :( >>> > >There are two choices: > > 1. It can be no_init > > 2. PreProcessor_char_Wrapper must define getSize() and getObject() > >Clearly, whatever was generated by pyste does neither of these. > The Wrapper defines getSize() and getObject(), but not no_init, and this compiles under msvc 6.0. But if we define no_init, then it's not possible to subclass PreProcessor from Python: >>> import temp >>> class C(temp.PreProcessor_float): ... def getSize(self): return 1 ... def getObject(self): return self ... >>> c = C() Traceback (most recent call last): File "", line 1, in ? RuntimeError: This class cannot be instantiated from Python >>> So what should we do in this case? From roman.yakovenko at actimize.com Wed Feb 18 16:50:02 2004 From: roman.yakovenko at actimize.com (Roman Yakovenko) Date: Wed, 18 Feb 2004 17:50:02 +0200 Subject: [C++-sig] Re: Pyste bug with unnamed enums Message-ID: <2CD84621099A814598AE3EFEFB5C142101E071@exchange.adrembi.com> Okay. I understand your answer. Than you. But I steel have to export unnamed enum. What do you think about declaring them as consts ( within scope of module / class ) ? It seems me that this is a way I should go. More over this is exactly their meaning in my code. Thanks you for help. Roman > -----Original Message----- > From: David Abrahams [mailto:dave at boost-consulting.com] > Sent: Tuesday, February 17, 2004 6:38 PM > To: c++-sig at python.org > Subject: [C++-sig] Re: Pyste bug with unnamed enums > > > "Roman Yakovenko" writes: > > > Hi. I found bug in Pyste. > > > > Description: > > In your code you have 2 unnamed enum definitions > > > > enum { SOME_CONST_1 = 32 }; > > enum { SOME_CONST_2 = 46 }; > > > > after running pyste on this code you will get > > > > // Unique type for unnamed enums > > #ifndef PYSTE_UNIQUE_INT_DEFINED > > #define PYSTE_UNIQUE_INT_DEFINED > > template > > struct UniqueInt { > > int v; > > enum { value=num }; > > UniqueInt(int v_): > > v(v_) > > {} > > operator int() const > > { return v; } > > }; > > #endif // PYSTE_UNIQUE_INT_DEFINED > > > > generated twice ( if you generate your code to the same module ). > > > > The possible solution are: > > 1. To ask David Abrahams how we should export unnamed enums ( > > defined within class and within some namespace ). > > Name them. If you can't name them, you can't export them. You can't > even pass them through a function template: > > enum { x = 1 }; > > template > int f(T); > > int y = f(x); // error > > Sorry. > > > 2. To use unnamed enums as global constants for enums > defined within namespace. > > To define new class attribute if enum defined within class. > > 3. To put definition of UniqueInt within BPL > > :( > > I don't really know what UniqueInt is supposed to do, but I don't > love it because it's not unique ;-) > > enum { x = 1 } > enum { y = 1 } > > > BOOST_STATIC_ASSERT((boost::is_same,UniqueInt > >::value)); > > > -- > Dave Abrahams > Boost Consulting > www.boost-consulting.com > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From grafik.list at redshift-software.com Wed Feb 18 18:08:39 2004 From: grafik.list at redshift-software.com (Rene Rivera) Date: Wed, 18 Feb 2004 11:08:39 -0600 Subject: [C++-sig] Redirecting the bjam output In-Reply-To: <271266F9567FB84D8F887943C93FA1EB0209CD40@pusehe0o.eh.pweh.com> References: <271266F9567FB84D8F887943C93FA1EB0209CD40@pusehe0o.eh.pweh.com> Message-ID: <40339C17.9090401@redshift-software.com> Shukla, Nitin (Export) wrote: > Is it's really not possible? But whenever I build my project inside the > Boost project tree, the outputs are generated in the following folder: > > ${BOOSTROOT}/bin/${Currentfolder_name}/${BOOST_PYTHON_MODULE}.pyd/${-sTOOLS} > /${-sBUILD} > > rather than /bin/${Currentfolder_name}/... being created from my current > working folder. I thought there would be some way of specifying the output > to be generated in the current working folder rather than in such directory > structure. May somewhere in Jamfile or Jamrules file, I don't know. You are confusing me :-( Could you be more explicit? ... * How do you want the files to end up? * Is it just the root "bin" directory that you want to change? * Or is it each *.pyd that you want to locate someplace else? -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com - 102708583/icq From dave at boost-consulting.com Wed Feb 18 21:29:09 2004 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 18 Feb 2004 15:29:09 -0500 Subject: [C++-sig] Re: abstract templates and pyste question. References: <4030F6BA.2010109@esss.com.br> <4031ED77.9000501@esss.com.br> <4033866C.1040401@esss.com.br> Message-ID: Nicodemus writes: >>There are two choices: >> >> 1. It can be no_init >> >> 2. PreProcessor_char_Wrapper must define getSize() and getObject() >> >>Clearly, whatever was generated by pyste does neither of these. >> > > The Wrapper defines getSize() and getObject(), but not no_init, and > this compiles under msvc 6.0. I don't see what vc6 has to do with this. The OP has a compilation error indicating that getSize and getObject are not defined in the wrapper. ?? -- Dave Abrahams Boost Consulting www.boost-consulting.com From s_sourceforge at nedprod.com Wed Feb 18 19:32:22 2004 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Wed, 18 Feb 2004 18:32:22 -0000 Subject: [C++-sig] Re: Pyste bug with unnamed enums In-Reply-To: Message-ID: <4033AFB6.10074.395A15C5@localhost> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 17 Feb 2004 at 11:38, David Abrahams wrote: > Name them. If you can't name them, you can't export them. You can't > even pass them through a function template: Actually you can. > I don't really know what UniqueInt is supposed to do, but I don't love > it because it's not unique ;-) > > enum { x = 1 } > enum { y = 1 } > > BOOST_STATIC_ASSERT((boost::is_same,UniqueInt > >::value)); No, pyste here produces: enum_< UniqueInt >("unnamed") .value("x", x) .value("y", y) ; At least, it would if AllFromHeader() were fixed. The UniqueInt merely converts a number to a unique strawman type to keep BPL happy. If you know of a way to always generate a random type with guaranteed no collisions, we'd be very interested. Cheers, Niall -----BEGIN PGP SIGNATURE----- Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 iQA/AwUBQDOvtsEcvDLFGKbPEQJKQQCfSy0DSdqWhXbXCycY1LW4JpG/WlYAn2pQ S5sxmWv3CmJXAtGrl15J3u63 =ojUI -----END PGP SIGNATURE----- From nitin.shukla at pw.utc.com Wed Feb 18 22:21:06 2004 From: nitin.shukla at pw.utc.com (Shukla, Nitin (Export)) Date: Wed, 18 Feb 2004 16:21:06 -0500 Subject: [C++-sig] Redirecting the bjam output Message-ID: <271266F9567FB84D8F887943C93FA1EB0209CD46@pusehe0o.eh.pweh.com> Sorry if I caused any confusion. What I am wondering is this? Whenever I build my module from inside the Boost project tree my build output i.e. *.pyd, *.lib etc. files are generated under following directory structure: ${BOOSTROOT}/bin/boost/libs/python/${Currentfolder_name}/${BOOST_PYTHON_MODU LE}.pyd/${-sTOOLS}/${-sBUILD} If I build say the 'example' or the 'tutorials' that comes with the boost directory the outputs go to the above path. But if I build a module outside the boost project directory, the bjam tool creates the following directory structure under the current working folder to output the *.pyd and other files. currentworkingdirectory/bin/${Currentfolder_name}/${BOOST_PYTHON_MODULE}.pyd /${-sTOOLS}/${-sBUILD} I want that the .pyd and other files to be generated under "currentworkingdirectory" rather the above directory structure. If redirection can happen for modules built from boost project tree, I feel I should be able to generate outputs in my current working folder. Nitin > -----Original Message----- > From: Rene Rivera [mailto:grafik.list at redshift-software.com] > > Shukla, Nitin (Export) wrote: > > > Is it's really not possible? But whenever I build my > project inside the > > Boost project tree, the outputs are generated in the > following folder: > > > > > ${BOOSTROOT}/bin/${Currentfolder_name}/${BOOST_PYTHON_MODULE}. > pyd/${-sTOOLS} > > /${-sBUILD} > > > > rather than /bin/${Currentfolder_name}/... being created > from my current > > working folder. I thought there would be some way of > specifying the output > > to be generated in the current working folder rather than > in such directory > > structure. May somewhere in Jamfile or Jamrules file, I don't know. > > You are confusing me :-( Could you be more explicit? ... > > * How do you want the files to end up? > > * Is it just the root "bin" directory that you want to change? > > * Or is it each *.pyd that you want to locate someplace else? > > > -- > -- Grafik - Don't Assume Anything > -- Redshift Software, Inc. - http://redshift-software.com > -- rrivera/acm.org - grafik/redshift-software.com - 102708583/icq > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From nicodemus at esss.com.br Wed Feb 18 23:11:36 2004 From: nicodemus at esss.com.br (Nicodemus) Date: Wed, 18 Feb 2004 19:11:36 -0300 Subject: [C++-sig] Re: abstract templates and pyste question. In-Reply-To: References: <4030F6BA.2010109@esss.com.br> <4031ED77.9000501@esss.com.br> <4033866C.1040401@esss.com.br> Message-ID: <4033E318.9010800@esss.com.br> David Abrahams wrote: >Nicodemus writes: > > >>>There are two choices: >>> >>> 1. It can be no_init >>> >>> 2. PreProcessor_char_Wrapper must define getSize() and getObject() >>> >>>Clearly, whatever was generated by pyste does neither of these. >>> >>> >>The Wrapper defines getSize() and getObject(), but not no_init, and >>this compiles under msvc 6.0. >> > >I don't see what vc6 has to do with this. The OP has a compilation >error indicating that getSize and getObject are not defined in the >wrapper. > >?? > You're right, I didn't read the error message carefully. But Pyste does generate the methods in the wrapper: struct PreProcessor_float_Wrapper: PreProcessor { PreProcessor_float_Wrapper(PyObject* self_, const PreProcessor& p0): PreProcessor(p0), self(self_) {} PreProcessor_float_Wrapper(PyObject* self_): PreProcessor(), self(self_) {} const int getSize() { return call_method< const int >(self, "getSize"); } float getObject(int p0) { return call_method< float >(self, "getObject", p0); } PyObject* self; }; // Module ====================================================================== BOOST_PYTHON_MODULE(temp) { class_< PreProcessor, boost::noncopyable, PreProcessor_float_Wrapper >("PreProcessor_float", init< >()) .def("getSize", pure_virtual(&PreProcessor::getSize)) .def("getObject", pure_virtual(&PreProcessor::getObject)) ; } And this compiles fine under msvc 6.0. Perhaps the generated code by the OP is different? From nicodemus at esss.com.br Wed Feb 18 23:19:07 2004 From: nicodemus at esss.com.br (Nicodemus) Date: Wed, 18 Feb 2004 19:19:07 -0300 Subject: [C++-sig] Re: abstract templates and pyste question. In-Reply-To: References: <4030F6BA.2010109@esss.com.br> <4031ED77.9000501@esss.com.br> Message-ID: <4033E4DB.2090809@esss.com.br> Hanz Meizer wrote: > Hi, > > While investigating, I found something strange: > > I've got two classes, both are abstract, the base class is a regular > class, the derived class is a template. The base has a private copy > constructor (which is empty). The derived one has no copy constructor > declared. The whole construct didn't pythonize, since pyste declares a > wrapper for the derived class that calls the base copy constructor > (which is private). Obviously (?), C++ avoids calling the private base > copy constructor from the implicitly generated derived copy > constructor (that's my explanation, maybe this is not true. Who > knows?). Maybe this only holds true for templates. Anyways, I solved > this special issue by inserting a private copy constructor (that is > defined empty) in the derived template. > > Is this a known thing? What if the include files were write only fo me > and I couldn't modify them? After all, in C++ this kind of setup is > working, just th generated wrapper seems to make false assumptions. > Hmm... I couldn't reproduce the error. I tried this: struct Abstract { private: Abstract(const Abstract&) {} public: virtual int getSize() = 0; }; struct Derived { virtual int getSize() = 0; }; But this generates a wrapper that compiles fine. Perhaps you can post a working example? Regards, Nicodemus. From nicodemus at esss.com.br Wed Feb 18 23:31:52 2004 From: nicodemus at esss.com.br (Nicodemus) Date: Wed, 18 Feb 2004 19:31:52 -0300 Subject: [C++-sig] Pyste bug with unnamed enums In-Reply-To: <40329BF0.22709.3524D8A3@localhost> References: <40329BF0.22709.3524D8A3@localhost> Message-ID: <4033E7D8.2060602@esss.com.br> Niall Douglas wrote: >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >On 17 Feb 2004 at 17:25, Roman Yakovenko wrote: > > > >> 1. To ask David Abrahams how we should export unnamed enums ( defined >> within class and within some namespace ). >> >> > >Believe it or not we have done our best on this - six months ago >unnamed enums just didn't work at all. If you search the archives, >all is explained there. > >Unfortunately pyste starts with a zero based index, so if it is >called on two separate occasions it reuses the same index for two >quite different enums in separate compilation units. This is a bug >but Nicodemus knows about it. > > Yeah, and I just thought about a fix: the name that GCCXML assigns to this enums is in the form $_0, $_1, etc..., so now this number is used to generate the UniqueInt. I guess this solves the problem. If that doesn't work, I have another idea that might. Regards, Nicodemus. From grafik.list at redshift-software.com Wed Feb 18 23:50:27 2004 From: grafik.list at redshift-software.com (Rene Rivera) Date: Wed, 18 Feb 2004 16:50:27 -0600 Subject: [C++-sig] Redirecting the bjam output In-Reply-To: <271266F9567FB84D8F887943C93FA1EB0209CD46@pusehe0o.eh.pweh.com> References: <271266F9567FB84D8F887943C93FA1EB0209CD46@pusehe0o.eh.pweh.com> Message-ID: <4033EC33.3090406@redshift-software.com> Shukla, Nitin (Export) wrote: > Sorry if I caused any confusion. What I am wondering is this? > > Whenever I build my module from inside the Boost project tree my build > output i.e. *.pyd, *.lib etc. files are generated under following directory > structure: > > ${BOOSTROOT}/bin/boost/libs/python/${Currentfolder_name}/${BOOST_PYTHON_MODU > LE}.pyd/${-sTOOLS}/${-sBUILD} > > If I build say the 'example' or the 'tutorials' that comes with the boost > directory the outputs go to the above path. But if I build a module outside > the boost project directory, the bjam tool creates the following directory > structure under the current working folder to output the *.pyd and other > files. > > currentworkingdirectory/bin/${Currentfolder_name}/${BOOST_PYTHON_MODULE}.pyd > /${-sTOOLS}/${-sBUILD} > > I want that the .pyd and other files to be generated under > "currentworkingdirectory" rather the above directory structure. If > redirection can happen for modules built from boost project tree, I feel I > should be able to generate outputs in my current working folder. OK now I understand... Yes it's possible to put the generated file anywhere, but it's a design issue with the build system. We can't assume that you are only using one compiler. And for Boost most developers use many compilers at once. Changing this would require modifying the build system itself, as the subdirectories are hard-wired into the way it builds. That only leaves copying the generated final products to the location of you liking. You can make that choice because only you know that when you copy them there are no collisions from separate compilers (this also includes debug/release/profile/etc differences). To copy them the easiest is to use the "stage" rule. For example in the Jamfile of your external project you could add something like this: stage ../ : ${BOOST_PYTHON_MODULE} ; "stage . :"... might also work, but I don't remember if it does :-) -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com - 102708583/icq From gameguy at eastlink.ca Thu Feb 19 01:01:46 2004 From: gameguy at eastlink.ca (GameGuy) Date: Wed, 18 Feb 2004 20:01:46 -0400 Subject: [C++-sig] Re: abstract templates and pyste question. In-Reply-To: <4033E4DB.2090809@esss.com.br> References: <4030F6BA.2010109@esss.com.br> <4031ED77.9000501@esss.com.br> <4033E4DB.2090809@esss.com.br> Message-ID: Nicodemus wrote: > Hanz Meizer wrote: > >> Hi, >> >> While investigating, I found something strange: >> >> I've got two classes, both are abstract, the base class is a regular >> class, the derived class is a template. The base has a private copy >> constructor (which is empty). The derived one has no copy constructor >> declared. The whole construct didn't pythonize, since pyste declares a >> wrapper for the derived class that calls the base copy constructor >> (which is private). Obviously (?), C++ avoids calling the private base >> copy constructor from the implicitly generated derived copy >> constructor (that's my explanation, maybe this is not true. Who >> knows?). Maybe this only holds true for templates. Anyways, I solved >> this special issue by inserting a private copy constructor (that is >> defined empty) in the derived template. >> >> Is this a known thing? What if the include files were write only fo me >> and I couldn't modify them? After all, in C++ this kind of setup is >> working, just th generated wrapper seems to make false assumptions. >> > > Hmm... I couldn't reproduce the error. I tried this: > > struct Abstract > { > private: > Abstract(const Abstract&) {} > public: virtual int getSize() = 0; > }; > > > struct Derived > { > virtual int getSize() = 0; > }; > But this generates a wrapper that compiles fine. Perhaps you can post a > working example? > > Regards, > Nicodemus. Oddly enough I was just drafting a post a related issue I ran into. struct Abstract { virtual void pure_virtual() = 0; }; struct Derived : public Abstract { //virtual void uncomment_to_make_it_work(); }; The above code should create a Derived_Wrapper class defining a wrapper for pure_virtual. But it doesn't. If you add a virtual method to Derived, then the wrapper function for pure_virtual is created. From s_sourceforge at nedprod.com Thu Feb 19 05:36:37 2004 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Thu, 19 Feb 2004 04:36:37 -0000 Subject: [C++-sig] Pyste bug with unnamed enums In-Reply-To: <4033E7D8.2060602@esss.com.br> References: <40329BF0.22709.3524D8A3@localhost> Message-ID: <40343D55.18625.3B834BC7@localhost> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 18 Feb 2004 at 19:31, Nicodemus wrote: > >Unfortunately pyste starts with a zero based index, so if it is > >called on two separate occasions it reuses the same index for two > >quite different enums in separate compilation units. This is a bug > >but Nicodemus knows about it. > > Yeah, and I just thought about a fix: the name that GCCXML assigns to > this enums is in the form $_0, $_1, etc..., so now this number is used > to generate the UniqueInt. I guess this solves the problem. If that > doesn't work, I have another idea that might. No I thought of that too, but the GCC tag is unique per compilation unit only a bit like unnamed namespaces. Unfortunately we need a unique type across the whole python module. I used a solution of taking a hash() of the input file name and incrementing from there but this is hackish. Ideally I think you're going to have to store persistent value across invocations. Hmm - why can't pyste use the system clock? You can't use the millisecond one as it wraps every 22 days. But if you did a gettime() and pulled the nanoseconds plus seconds into a 64 bit integer, that'd have to be pretty unique for all time. Pyste couldn't possibly generate wrappings for something in less than a millisecond (though this said, I do have a utility that runs two copies of pyste in parallel). Ok suggestion: put the file name and system time in at least milliseconds into a tuple and hash() it. Cheers, Niall -----BEGIN PGP SIGNATURE----- Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 iQA/AwUBQDQ9VsEcvDLFGKbPEQJDIwCeO/CftCI5y/1N6/ikBbLl2ZkNyXkAnRz5 Be8/kotlGRVX8YkhnzFZSnTS =CuPz -----END PGP SIGNATURE----- From roman.yakovenko at actimize.com Thu Feb 19 08:17:56 2004 From: roman.yakovenko at actimize.com (Roman Yakovenko) Date: Thu, 19 Feb 2004 09:17:56 +0200 Subject: [C++-sig] Re: Pyste bug with unnamed enums Message-ID: <2CD84621099A814598AE3EFEFB5C1421046D83@exchange.adrembi.com> > -----Original Message----- > From: Niall Douglas [mailto:s_sourceforge at nedprod.com] > Sent: Wednesday, February 18, 2004 8:32 PM > To: David Abrahams > Cc: c++-sig at python.org > Subject: Re: [C++-sig] Re: Pyste bug with unnamed enums > > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On 17 Feb 2004 at 11:38, David Abrahams wrote: > > > Name them. If you can't name them, you can't export them. > You can't > > even pass them through a function template: > > Actually you can. > > > I don't really know what UniqueInt is supposed to do, but I > don't love > > it because it's not unique ;-) > > > > enum { x = 1 } > > enum { y = 1 } > > > > BOOST_STATIC_ASSERT((boost::is_same,UniqueInt > > >::value)); > > No, pyste here produces: > > enum_< UniqueInt >("unnamed") > .value("x", x) > .value("y", y) > ; > > At least, it would if AllFromHeader() were fixed. The UniqueInt > merely converts a number to a unique strawman type to keep BPL happy. > If you know of a way to always generate a random type with guaranteed > no collisions, we'd be very interested. The one possible solution is generating UniqueInt + GUID I think > Cheers, > Niall > > > > > > -----BEGIN PGP SIGNATURE----- > Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 > > iQA/AwUBQDOvtsEcvDLFGKbPEQJKQQCfSy0DSdqWhXbXCycY1LW4JpG/WlYAn2pQ > S5sxmWv3CmJXAtGrl15J3u63 > =ojUI > -----END PGP SIGNATURE----- > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From steam at nurfuerspam.de Thu Feb 19 10:48:17 2004 From: steam at nurfuerspam.de (Hanz Meizer) Date: Thu, 19 Feb 2004 10:48:17 +0100 Subject: [C++-sig] Re: abstract templates and pyste question. In-Reply-To: References: <4030F6BA.2010109@esss.com.br> <4031ED77.9000501@esss.com.br> <4033E4DB.2090809@esss.com.br> Message-ID: Hi, Example: -------------------------------------------------- class Base { public: Base() {} virtual ~Base() {} virtual int getSize() = 0; private: Base(const Base&) {} }; class Derived: public Base { public: Derived() {} virtual ~Derived() {} virtual int getSizeD() = 0; }; class Derived2: public Derived { public: Derived2() {} virtual ~Derived2() {} virtual int getSize() { return 0; } virtual int getSizeD() { return 0; } }; -------------------------------------------------- Output (with your earlier patch): -------------------------------------------------- // Boost Includes ============================================================== #include #include // Includes ==================================================================== #include // Using ======================================================================= using namespace boost::python; // Declarations ================================================================ namespace { struct Base_Wrapper: Base { Base_Wrapper(PyObject* self_): Base(), self(self_) {} int getSize() { return call_method< int >(self, "getSize"); } PyObject* self; }; struct Derived_Wrapper: Derived { Derived_Wrapper(PyObject* self_, const Derived& p0): Derived(p0), self(self_) {} Derived_Wrapper(PyObject* self_): Derived(), self(self_) {} int getSizeD() { return call_method< int >(self, "getSizeD"); } int getSize() { return call_method< int >(self, "getSize"); } PyObject* self; }; struct Derived2_Wrapper: Derived2 { Derived2_Wrapper(PyObject* self_, const Derived2& p0): Derived2(p0), self(self_) {} Derived2_Wrapper(PyObject* self_): Derived2(), self(self_) {} int getSize() { return call_method< int >(self, "getSize"); } int default_getSize() { return Derived2::getSize(); } int getSizeD() { return call_method< int >(self, "getSizeD"); } int default_getSizeD() { return Derived2::getSizeD(); } PyObject* self; }; }// namespace // Module ====================================================================== BOOST_PYTHON_MODULE(pytest) { class_< Base, boost::noncopyable, Base_Wrapper >("Base", no_init) .def("getSize", pure_virtual(&Base::getSize)) ; class_< Derived, bases< Base > , boost::noncopyable, Derived_Wrapper >("Derived", no_init) .def("getSizeD", pure_virtual(&Derived::getSizeD)) .def("getSize", pure_virtual(&Base::getSize)) ; class_< Derived2, bases< Derived > , Derived2_Wrapper >("Derived2", init< >()) .def(init< const Derived2& >()) .def("getSize", (int (Derived2::*)() )&Derived2::getSize, (int (Derived2_Wrapper::*)())&Derived2_Wrapper::default_getSize) .def("getSizeD", (int (Derived2::*)() )&Derived2::getSizeD, (int (Derived2_Wrapper::*)())&Derived2_Wrapper::default_getSizeD) ; } -------------------------------------------------- Compiler: -------------------------------------------------- ../pyste.sh --module=pytest pytest.pyste Module pytest generated 0.04 seconds g++ -g -s -I. -Wall -ftemplate-depth-100 -DBOOST_PYTHON_DYNAMIC_LIB -fno-inline -fPIC -Iwork/pyste/boost.current -I/usr/include/python2.2 pytest.cpp -c -o pytest.o Test.h: In copy constructor `Derived::Derived(const Derived&)': Test.h:9: error: `Base::Base(const Base&)' is private pytest.cpp:30: error: within this context make: *** [pytest.o] Error 1 -------------------------------------------------- H. From steam at nurfuerspam.de Thu Feb 19 10:56:40 2004 From: steam at nurfuerspam.de (Hanz Meizer) Date: Thu, 19 Feb 2004 10:56:40 +0100 Subject: [C++-sig] Re: abstract templates and pyste question. In-Reply-To: References: <4030F6BA.2010109@esss.com.br> <4031ED77.9000501@esss.com.br> <4033E4DB.2090809@esss.com.br> Message-ID: I should add: The whole construct works in an g++-3.3 example program: ------------------------------------------------------------------------------- #include #include "Test.h" int main(int argc, char** argv) { //Base a; //Derived b; Derived2 c; std::cout << c.getSize() << " " << c.getSizeD() << std::endl; return 0; } ------------------------------------------------------------------------------- H. From steam at nurfuerspam.de Thu Feb 19 17:33:58 2004 From: steam at nurfuerspam.de (Hanz Meizer) Date: Thu, 19 Feb 2004 17:33:58 +0100 Subject: [C++-sig] member function template question. Message-ID: Hi, Sorry to post so many questions, but I've run into something I couldn't decduce from looking through the documentation. Is it possible to wrap member function templates? Example class: ----------------------------------------------------------------------- class A { public: A() {} virtual ~A() {} template void* makeVoidPointer(T* tp) { return static_cast(tp); } }; ----------------------------------------------------------------------- Let's say I weant to have it exported for int* and char*. How can I achieve this? Thanks for your efforts :) !!! H. From rwgk at yahoo.com Thu Feb 19 20:49:31 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 19 Feb 2004 11:49:31 -0800 (PST) Subject: [C++-sig] member function template question. In-Reply-To: Message-ID: <20040219194931.28978.qmail@web20207.mail.yahoo.com> Your example has several layers of complexity. I believe the main trick you need to know is how to use a cast to tell the compiler what you want. E.g.: template bool is_positive_definite( vec3 const& eigenvalues, FloatType const& tolerance); def("is_positive_definite", (bool(*)(vec3 const&, double const&)) is_positive_definite); This is a bit cumbersome but somehow you have to define which FloatType you want to use since you are crossing the boundary between compile-time polymorphism and runtime polymorphism. If you don't like the casts you can also define thin wrappers. This works for both "normal" functions and member functions. I don't know how this is handled by Pyste. Maybe someone else can help? I am also not an expert on dealing with raw pointers, in particular void* needs special attention. I think there is something about void* in the FAQ that you might want to read. Ralf --- Hanz Meizer wrote: > Sorry to post so many questions, but I've run into something I couldn't > decduce from looking through the documentation. Is it possible to wrap > member function templates? Example class: __________________________________ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools From jbrandmeyer at earthlink.net Thu Feb 19 21:05:25 2004 From: jbrandmeyer at earthlink.net (Jonathan Brandmeyer) Date: Thu, 19 Feb 2004 15:05:25 -0500 Subject: [C++-sig] member function template question. In-Reply-To: <20040219194931.28978.qmail@web20207.mail.yahoo.com> References: <20040219194931.28978.qmail@web20207.mail.yahoo.com> Message-ID: <1077221125.20838.3.camel@illuvatar> On Thu, 2004-02-19 at 14:49, Ralf W. Grosse-Kunstleve wrote: > Your example has several layers of complexity. I believe the main trick you > need to know is how to use a cast to tell the compiler what you want. E.g.: > > template > bool > is_positive_definite( > vec3 const& eigenvalues, > FloatType const& tolerance); > > def("is_positive_definite", > (bool(*)(vec3 const&, double const&)) is_positive_definite); I've had good results with statements like this: def("is_positive_definite", &is_positive_definite); Far simpler than casting the function, IMO. > This is a bit cumbersome but somehow you have to define which FloatType you > want to use since you are crossing the boundary between compile-time > polymorphism and runtime polymorphism. > > If you don't like the casts you can also define thin wrappers. This works for > both "normal" functions and member functions. > > I don't know how this is handled by Pyste. Maybe someone else can help? > > I am also not an expert on dealing with raw pointers, in particular void* needs > special attention. I think there is something about void* in the FAQ that you > might want to read. > > Ralf > > --- Hanz Meizer wrote: > > Sorry to post so many questions, but I've run into something I couldn't > > decduce from looking through the documentation. Is it possible to wrap > > member function templates? Example class: > -Jonathan Brandmeyer From dave at boost-consulting.com Thu Feb 19 21:31:25 2004 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 19 Feb 2004 15:31:25 -0500 Subject: [C++-sig] Re: member function template question. References: <20040219194931.28978.qmail@web20207.mail.yahoo.com> Message-ID: "Ralf W. Grosse-Kunstleve" writes: > Your example has several layers of complexity. I believe the main trick you > need to know is how to use a cast to tell the compiler what you want. E.g.: > > template > bool > is_positive_definite( > vec3 const& eigenvalues, > FloatType const& tolerance); > > def("is_positive_definite", > (bool(*)(vec3 const&, double const&)) is_positive_definite); > > This is a bit cumbersome but somehow you have to define which FloatType you > want to use since you are crossing the boundary between compile-time > polymorphism and runtime polymorphism. That won't work because is_positive_definite is a template, not a function. You can't cast templates. You can only wrap a particular *instantiation* of a function template. I suggest picking a FloatType (probably double), and wrapping is_positive_definite. Cheers, -- Dave Abrahams Boost Consulting www.boost-consulting.com From rwgk at yahoo.com Thu Feb 19 22:51:17 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 19 Feb 2004 13:51:17 -0800 (PST) Subject: [C++-sig] member function template question. In-Reply-To: <1077221125.20838.3.camel@illuvatar> Message-ID: <20040219215117.85726.qmail@web20204.mail.yahoo.com> --- Jonathan Brandmeyer wrote: > On Thu, 2004-02-19 at 14:49, Ralf W. Grosse-Kunstleve wrote: > > Your example has several layers of complexity. I believe the main trick you > > need to know is how to use a cast to tell the compiler what you want. E.g.: > > > > template > > bool > > is_positive_definite( > > vec3 const& eigenvalues, > > FloatType const& tolerance); > > > > def( __________________________________ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools From rwgk at yahoo.com Thu Feb 19 23:01:22 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 19 Feb 2004 14:01:22 -0800 (PST) Subject: [C++-sig] Re: member function template question. In-Reply-To: Message-ID: <20040219220122.4656.qmail@web20208.mail.yahoo.com> --- David Abrahams wrote: > "Ralf W. Grosse-Kunstleve" writes: > > > Your example has several layers of complexity. I believe the main trick you > > need to know is how to use a cast to tell the compiler what you want. E.g.: > > > > template > > bool > > is_positive_definite( > > vec3 const& eigenvalues, > > FloatType const& tolerance); > > > > def("is_positive_definite", > > (bool(*)(vec3 const&, double const&)) is_positive_definite); > > > > This is a bit cumbersome but somehow you have to define which FloatType you > > want to use since you are crossing the boundary between compile-time > > polymorphism and runtime polymorphism. > > That won't work because is_positive_definite is a template, not a > function. You can't cast templates. I agree that the other solution is better, but the code above does in fact work with all compilers that we are using! http://cvs.sourceforge.net/viewcvs.py/cctbx/cctbx/include/cctbx/adptbx.h?rev=1.24&view=auto http://cvs.sourceforge.net/viewcvs.py/cctbx/cctbx/adptbx/boost_python/adptbx_ext.cpp?rev=1.9&view=auto http://cci.lbl.gov/cctbx_build/ Are they all wrong? Ralf __________________________________ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools From nicodemus at esss.com.br Thu Feb 19 23:20:31 2004 From: nicodemus at esss.com.br (Nicodemus) Date: Thu, 19 Feb 2004 19:20:31 -0300 Subject: [C++-sig] Pyste bug with unnamed enums In-Reply-To: <40343D55.21460.3B8349E3@localhost> References: <40329BF0.22709.3524D8A3@localhost> <40343D55.21460.3B8349E3@localhost> Message-ID: <403536AF.90600@esss.com.br> Niall Douglas wrote: >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >On 18 Feb 2004 at 19:31, Nicodemus wrote: > > >>Yeah, and I just thought about a fix: the name that GCCXML assigns to >>this enums is in the form $_0, $_1, etc..., so now this number is used >>to generate the UniqueInt. I guess this solves the problem. If that >>doesn't work, I have another idea that might. >> >> > >No I thought of that too, but the GCC tag is unique per compilation >unit only a bit like unnamed namespaces. Unfortunately we need a >unique type across the whole python module. > > Bummer. 8( >I used a solution of taking a hash() of the input file name and >incrementing from there but this is hackish. Ideally I think you're >going to have to store persistent value across invocations. > > Yeah, that's the "another idea" that I mentioned earlier. While it certainly is a hack, we're using it to support a workaround anyway (UniqueInt), so I think that's ok. >Hmm - why can't pyste use the system clock? You can't use the >millisecond one as it wraps every 22 days. But if you did a gettime() >and pulled the nanoseconds plus seconds into a 64 bit integer, that'd >have to be pretty unique for all time. Pyste couldn't possibly >generate wrappings for something in less than a millisecond (though >this said, I do have a utility that runs two copies of pyste in >parallel). Ok suggestion: put the file name and system time in at >least milliseconds into a tuple and hash() it. > > I was going to use a hash of the filename (actually, I thought of a md5, where the chance for a clash is much smaller), but your idea to use also the system time is good. I will implement it today and commit it. Hmm... thinking again, adding the system time to the hash would have an undesirable effect: generating the bindings again would always cause a recompilation, even if nothing else in the binding has really changed... that said, I guess an md5 of the filename is good enough for our case. Thanks once again Niall for the feedback and help. 8) Regards, Nicodemus. From dave at boost-consulting.com Fri Feb 20 01:51:38 2004 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 19 Feb 2004 19:51:38 -0500 Subject: [C++-sig] Re: member function template question. References: <20040219220122.4656.qmail@web20208.mail.yahoo.com> Message-ID: "Ralf W. Grosse-Kunstleve" writes: > I agree that the other solution is better, but the code above does in fact work > with all compilers that we are using! > > http://cvs.sourceforge.net/viewcvs.py/cctbx/cctbx/include/cctbx/adptbx.h?rev=1.24&view=auto > > http://cvs.sourceforge.net/viewcvs.py/cctbx/cctbx/adptbx/boost_python/adptbx_ext.cpp?rev=1.9&view=auto > > http://cci.lbl.gov/cctbx_build/ > > Are they all wrong? Probably not. I guess it's a C++ feature I didn't know about. -- Dave Abrahams Boost Consulting www.boost-consulting.com From baas at ira.uka.de Fri Feb 20 10:46:45 2004 From: baas at ira.uka.de (Matthias Baas) Date: Fri, 20 Feb 2004 10:46:45 +0100 Subject: [C++-sig] How to turn output parameters to return values? Message-ID: Hi, suppose I have a function or method that takes references as arguments in order to return values like this: void getImageSize(int& width, int& height); How do I wrap that function? Ideally, I want the corresponding Python function/method to take no input parameter and return a tuple (width, height). I've experimented with the return_arg call policy but didn't get far. I was only able to return one single value but only if it was *not* a reference (in which case it's useless for my purpose). So is there an example somewhere how to wrap a function like the above? Cheers, - Matthias - From pierre.barbier at cirad.fr Fri Feb 20 11:20:53 2004 From: pierre.barbier at cirad.fr (Pierre Barbier de Reuille) Date: Fri, 20 Feb 2004 11:20:53 +0100 Subject: [C++-sig] How to turn output parameters to return values? In-Reply-To: References: Message-ID: <1077272441.1940.5.camel@pbarbier> I think you should write a thin wrapper like : boost::python::tuple getImageSize() { int width, height; getImageSize(width, height); return boost::python::make_tuple(width, height); } But I don't understand why you need to return a reference ! However, you can't return a reference on an integral type, because Python doesn't allow that. Pierre Le ven 20/02/2004 ? 10:46, Matthias Baas a ?crit : > Hi, > > suppose I have a function or method that takes references as arguments > in order to return values like this: > > void getImageSize(int& width, int& height); > > How do I wrap that function? Ideally, I want the corresponding Python > function/method to take no input parameter and return a tuple (width, > height). > I've experimented with the return_arg call policy but didn't get far. I > was only able to return one single value but only if it was *not* a > reference (in which case it's useless for my purpose). So is there an > example somewhere how to wrap a function like the above? > > Cheers, > > - Matthias - > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig -- 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 -- 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 nikolai.kirsebom at siemens.no Fri Feb 20 11:35:59 2004 From: nikolai.kirsebom at siemens.no (Kirsebom Nikolai) Date: Fri, 20 Feb 2004 11:35:59 +0100 Subject: [C++-sig] =?windows-1252?q?RE=3A_=C6C++-sig=C5_How_to_turn_outpu?= =?windows-1252?q?t_parameters_to_return_values=3F?= Message-ID: <5B5544F322E5D211850F00A0C91DEF3B05E0CB9C@osll007a.siemens.no> Hi See example - hope it helps: //// C++ class CDbHandler { public: boost::python::tuple GetCurUserInfo(); }; tuple CDbHandler::GetCurUserInfo() { int userId; CString userName; m_Dbh->GetCurUserInfo(userId, userName); char buf[200]; strcpy(buf, userName.GetBuffer(1000)); tuple x = make_tuple(userId, buf); return x; } BOOST_PYTHON_MODULE(CDbHandler) { class_(..some init stmt..) .def("GetCurUserInfo", &CDbHandler::GetCurUserInfo) ; } //// PYTHON: import CDbHandler ..... usi = dbh.GetCurUserInfo() # usi[0] contains userId # usi[1] contains userName Nikolai > -----Original Message----- > From: Matthias Baas [mailto:baas at ira.uka.de] > Sent: 20. februar 2004 10:47 > To: c++-sig at python.org > Subject: ?C++-sig? How to turn output parameters to return values? > > > Hi, > > suppose I have a function or method that takes references as > arguments > in order to return values like this: > > void getImageSize(int& width, int& height); > > How do I wrap that function? Ideally, I want the corresponding Python > function/method to take no input parameter and return a tuple (width, > height). > I've experimented with the return_arg call policy but didn't > get far. I > was only able to return one single value but only if it was *not* a > reference (in which case it's useless for my purpose). So is there an > example somewhere how to wrap a function like the above? > > Cheers, > > - Matthias - > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From Robert.Bielik at gyros.com Fri Feb 20 14:11:22 2004 From: Robert.Bielik at gyros.com (Bielik, Robert) Date: Fri, 20 Feb 2004 14:11:22 +0100 Subject: [C++-sig] import from an .exe Message-ID: <4D1D834CF718FF43A04E60599A2845350434C4@seuppms01.ad-gyrosmicro.com> Hi all, In the need to have a scripting language and C++ binding, I'm looking at Boost.Python. I've gotten the examples to work and see that I can accomplish what I need. Really cool! :) However, I have a question about imports: It seems that the import in Python implicitly loads a dynamic link library, but my application is an executable. Can I make an embedded Python interpreter aware of "internal" Python Modules without having to load any DLLs ?? TIA /Rob From aleskx at yahoo.com Fri Feb 20 14:27:57 2004 From: aleskx at yahoo.com (Aleksandar Fabijanic) Date: Fri, 20 Feb 2004 05:27:57 -0800 (PST) Subject: [C++-sig] The easiest way to evoke a python function from a C++ application...? In-Reply-To: <402A42FB.1030800@freenet.de> Message-ID: <20040220132757.58379.qmail@web12908.mail.yahoo.com> http://www.python.org/doc/current/ext/callingPython.html Alex --- Billy Gnosis wrote: > What is the easiest way to evoke a python function > from a C++ application ? > > I just want it for testing reasons and perhaps use > it as a new way to > develop software. > > I am new into python, but admire the fast and easy > way to write code. > > Actually I planned to set up most of the program in > C++ in a more or > less complete way - this should be quickly possible > by using Python > functions, that are later replaced by C code when > the "design" of the > program is ok. > > So I just want to call e.g. a python function > string.split(...) and > return an array of strings to the C-Program. How is > this most easily > done ? It can be very 'dirty' as it will be replaced > later anyway. Does > somebody has example code? > > Cheers, > > sb > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig __________________________________ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools From pierre.barbier at cirad.fr Fri Feb 20 14:34:36 2004 From: pierre.barbier at cirad.fr (Pierre Barbier de Reuille) Date: Fri, 20 Feb 2004 14:34:36 +0100 Subject: [C++-sig] import from an .exe In-Reply-To: <4D1D834CF718FF43A04E60599A2845350434C4@seuppms01.ad-gyrosmicro.com> References: <4D1D834CF718FF43A04E60599A2845350434C4@seuppms01.ad-gyrosmicro.com> Message-ID: <1077284063.1940.11.camel@pbarbier> Yes, you can ! Before importing your module, you have to call the 'initmodule' function (replace 'module' by the name of your module). Then, if you do a "import module" from python, as the module is already registred, it will not try to find an external module and will import the module inside your executable instead. Pierre Le ven 20/02/2004 ? 14:11, Bielik, Robert a ?crit : > Hi all, > > In the need to have a scripting language and C++ binding, I'm looking at Boost.Python. I've gotten the > examples to work and see that I can accomplish what I need. Really cool! :) > > However, I have a question about imports: > > It seems that the import in Python implicitly loads a dynamic link library, but my application is an executable. Can I make an embedded Python interpreter aware of "internal" Python Modules without having to load any DLLs ?? > > TIA > /Rob > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig -- 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 -- 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 Robert.Bielik at gyros.com Fri Feb 20 14:49:11 2004 From: Robert.Bielik at gyros.com (Bielik, Robert) Date: Fri, 20 Feb 2004 14:49:11 +0100 Subject: [C++-sig] import from an .exe Message-ID: <4D1D834CF718FF43A04E60599A28453506BAE7@seuppms01.ad-gyrosmicro.com> Thanks Pierre! I suspected it would be possible! :) Regards, /Robert > -----Original Message----- > From: Pierre Barbier de Reuille [mailto:pierre.barbier at cirad.fr] > Sent: Friday, February 20, 2004 14:35 > To: Development of Python/C++ integration > Subject: Re: [C++-sig] import from an .exe > > > Yes, you can ! > > Before importing your module, you have to call the > 'initmodule' function > (replace 'module' by the name of your module). Then, if you > do a "import > module" from python, as the module is already registred, it > will not try > to find an external module and will import the module inside your > executable instead. > > Pierre > > Le ven 20/02/2004 ? 14:11, Bielik, Robert a ?crit : > > Hi all, > > > > In the need to have a scripting language and C++ binding, > I'm looking at Boost.Python. I've gotten the > > examples to work and see that I can accomplish what I need. > Really cool! :) > > > > However, I have a question about imports: > > > > It seems that the import in Python implicitly loads a > dynamic link library, but my application is an executable. > Can I make an embedded Python interpreter aware of "internal" > Python Modules without having to load any DLLs ?? > > > > TIA > > /Rob > > > > _______________________________________________ > > C++-sig mailing list > > C++-sig at python.org > > http://mail.python.org/mailman/listinfo/c++-sig > -- > 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 > -- > 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 > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From baas at ira.uka.de Fri Feb 20 16:35:12 2004 From: baas at ira.uka.de (Matthias Baas) Date: Fri, 20 Feb 2004 16:35:12 +0100 Subject: [C++-sig] Re: How to turn output parameters to return values? In-Reply-To: <1077272441.1940.5.camel@pbarbier> References: <1077272441.1940.5.camel@pbarbier> Message-ID: Pierre Barbier de Reuille wrote: > I think you should write a thin wrapper like : Ah, ok, thanks! I thought there might be a mechanism to do that automatically. > But I don't understand why you need to return a reference ! However, you > can't return a reference on an integral type, because Python doesn't > allow that. Sorry, I didn't want to return a reference.... what I meant is this: If I have a function like this: void foo(int x); I could write a wrapper using return_arg<>() that actually returned the value of x. But of course, in such a case foo() can't return a value through this variable. What I wanted was this: void foo(int& x); But then the return_arg<>() didn't work anymore (I still only want the value of x, not a reference to x. But I suppose the wrapper still expected the x as input...). - Matthias - From pixellent at stodge.net Fri Feb 20 17:57:37 2004 From: pixellent at stodge.net (pixellent at stodge.net) Date: Fri, 20 Feb 2004 11:57:37 -0500 Subject: [C++-sig] Re: 1.31.0 Python libs Visual Studio Workspace is "empty" In-Reply-To: References: <1076863552.402fa240901a3@webmail.stodge.net> Message-ID: <1077296257.40363c81c2c9e@webmail.stodge.net> Ok, maybe I'll try that. Thanks Mike Quoting Raoul Gough : > pixellent at stodge.net writes: > > > I downloaded 1.31.0 and tried to compile the Python library but the > > workspace was empty when I loaded it into VC++ 6. It this a > > workspace for a later version of VC++ or is the workspace broken? > > I can't answer this question, but just in case you don't already know, > you can use bjam to build Python using the VC++ command line tools > (this is the only way I've ever done it). Should all be documented... > > -- > Raoul Gough. > export LESS='-X' > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/ From nitin.shukla at pw.utc.com Fri Feb 20 22:33:07 2004 From: nitin.shukla at pw.utc.com (Shukla, Nitin (Export)) Date: Fri, 20 Feb 2004 16:33:07 -0500 Subject: [C++-sig] How to specify include file path in Jamfile for bjam tool Message-ID: <271266F9567FB84D8F887943C93FA1EB0209CD4E@pusehe0o.eh.pweh.com> Hello I know how to specify library dependencies in the jamfile : # requirements "/path/to/lib/dir" libraryname but how can I specify the include path for my C/++ source files in the jamfile. Is there any documentation on writing Jamfiles for "bjam" tool. Nitin From dave at boost-consulting.com Fri Feb 20 23:13:35 2004 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 20 Feb 2004 17:13:35 -0500 Subject: [C++-sig] Re: How to specify include file path in Jamfile for bjam tool References: <271266F9567FB84D8F887943C93FA1EB0209CD4E@pusehe0o.eh.pweh.com> Message-ID: "Shukla, Nitin (Export)" writes: > Hello > > I know how to specify library dependencies in the jamfile > > : # requirements > "/path/to/lib/dir" > libraryname whatever # quoted #includes "..." whatever # angle #includes <...> > but how can I specify the include path for my C/++ source files in the > jamfile. > > Is there any documentation on writing Jamfiles for "bjam" tool. Not enough :( -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Fri Feb 20 23:16:30 2004 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 20 Feb 2004 17:16:30 -0500 Subject: [C++-sig] Re: The easiest way to evoke a python function from a C++ application...? References: <402A42FB.1030800@freenet.de> Message-ID: Billy Gnosis writes: > What is the easiest way to evoke a python function from a C++ application ? > > I just want it for testing reasons and perhaps use it as a new way to > develop software. > > I am new into python, but admire the fast and easy way to write code. > > Actually I planned to set up most of the program in C++ in a more or > less complete way - this should be quickly possible by using Python > functions, that are later replaced by C code when the "design" of the > program is ok. > > So I just want to call e.g. a python function string.split(...) and > return an array of strings to the C-Program. How is this most easily > done ? It can be very 'dirty' as it will be replaced later > anyway. Does somebody has example code? #include #include namespace py = boost::python; py::list split_strings = py::str('whatever').split(whatver-else) HTH, -- Dave Abrahams Boost Consulting www.boost-consulting.com From aashish at vrac.iastate.edu Sun Feb 22 01:07:48 2004 From: aashish at vrac.iastate.edu (aashish) Date: Sat, 21 Feb 2004 18:07:48 -0600 Subject: [C++-sig] Re: fatal error C1002: compiler is out of heap space in pass 2 In-Reply-To: Message-ID: <200402220009.i1M09H3N10304103@vracs001.vrac.iastate.edu> Hi, I am using boost.python for my project and I am using boost version 1.31.0. When I compiled against boost.python library I got this error: boost\tuple\detail\tuple_basic.hpp(496): fatal error C1002: compiler is out of heap space in pass 2 But I can compile the boost.python alone and I never got this error with the previous version. I am using VisualStudio.Net 2003 version for compilation. Any help will be appreciated. Thanks, Aashish -------------- next part -------------- An HTML attachment was scrubbed... URL: From steam at nurfuerspam.de Mon Feb 23 10:06:31 2004 From: steam at nurfuerspam.de (Hanz Meizer) Date: Mon, 23 Feb 2004 10:06:31 +0100 Subject: [C++-sig] Re: member function template question. In-Reply-To: References: <20040219220122.4656.qmail@web20208.mail.yahoo.com> Message-ID: Hello! I somehow would like this to be solved with pyste, and not for function, but for member function templates (I figure this would work differently right?). Can someone boost.pystify my example classes, or if that is not possible, boost.pythonify them? That would help me a lot! Regards, H. From lutz_p at gmx.net Mon Feb 23 13:04:31 2004 From: lutz_p at gmx.net (lutz_p at gmx.net) Date: Mon, 23 Feb 2004 13:04:31 +0100 (MET) Subject: [C++-sig] Re: 1.31.0 Python libs Visual Studio Workspace is "empty" References: Message-ID: <13862.1077537871@www51.gmx.net> I noticed the same problem from time to time. I figured out that it is caused by unix text format, you can try to convert it to windows/dos format since the project and workspace files are just plain text. I think the command line cvs doesn't convert the different formats when checking out the files. I use the builtin function of ultraedit for this but you can use other tools of course... Hope this helps, Lutz > pixellent at stodge.net writes: > > > I downloaded 1.31.0 and tried to compile the Python library but the > > workspace was empty when I loaded it into VC++ 6. It this a > > workspace for a later version of VC++ or is the workspace broken? > > I can't answer this question, but just in case you don't already know, > you can use bjam to build Python using the VC++ command line tools > (this is the only way I've ever done it). Should all be documented... > > -- > Raoul Gough. > export LESS='-X' > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > -- GMX ProMail (250 MB Mailbox, 50 FreeSMS, Virenschutz, 2,99 EUR/Monat...) jetzt 3 Monate GRATIS + 3x DER SPIEGEL +++ http://www.gmx.net/derspiegel +++ From rwgk at yahoo.com Mon Feb 23 17:49:14 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Mon, 23 Feb 2004 08:49:14 -0800 (PST) Subject: [C++-sig] Re: member function template question. In-Reply-To: <20040223153627.GA28454@raschap> Message-ID: <20040223164914.76105.qmail@web20203.mail.yahoo.com> There is no big difference between a cast to a function and a cast to a member function. If you have a class bar with a member function foo the cast looks like this: .def("foo", (void(bar::*)(int)) &bar::foo) If you don't require compatibility with older compilers you can follow Jonathan's advice: .def("foo", &bar::foo) Again, I don't know how this works in Pyste. Ralf --- Thomas.Troeger at chemie.uni-erlangen.de wrote: > Hello, > > I've seen you've replied to my question. Unfortunately, the > whole thing is missing the point that I need it for member > function templates. Would you lookat the errors I get, maybe > you can see the problem. I'm a little stuck currently :-( > > mfG, > > --tst. __________________________________ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools From Marc-Alexis.Cote at ino.ca Mon Feb 23 21:08:25 2004 From: Marc-Alexis.Cote at ino.ca (=?iso-8859-1?Q?C=D4T=C9_Marc-Alexis?=) Date: Mon, 23 Feb 2004 15:08:25 -0500 Subject: [C++-sig] Creating an array in C++ Message-ID: <12EDAD956333D8118C830007E9086704493CDA@mozart.ino.ca> Hello, I am relatively new to the world of python, so please bear with me if you find this question rather basic. I am writting some python code that interfaces with an image processing library that I wrote in C++. Up until now, I have exchanged image data (between the c++ library and python) through bitmaps stored in files. I find this rather clumsy and I am trying to use boost.python and the numeric::array type to help me transfer images from the library in a more elegant manner. My first problem is in creating the numeric::array in the c++ code. Let's say that I want a 3 dimensional array of unsigned bytes, would this be a correct way to do it? unsigned char data[300]; boost::python::numeric::array anArray(&data[0], "UByte", boost::python::make_tuple(10,10,3)); This doesn't give an error when I compile it. However, it fails to run as I expect it: >>>TypeError: No to_python (by-value) converter found for C++ type: unsigned char What am I missing? Would you even use an array to return the data, or is there a better way? Thanks, Marc-Alexis Cote ************************************************************************************* Ce courrier ?lectronique s'adresse uniquement ? la personne d?sign?e ci-dessus, il est confidentiel et ne doit pas ?tre remis ? une autre personne, ni reproduit et son contenu ne peut ?tre autrement divulgu?. Si ce courrier ?lectronique vous est transmis par erreur, veuillez nous en avertir imm?diatement ? l'adresse securite at ino.ca. Nous vous remercions de votre collaboration. This email is directed in confidence solely to the person named above, and may not otherwise be distributed, copied or disclosed. If you have received this email by error, please notify us immediately by email to address security at ino.ca. Thank you for your cooperation. *********************************************************************************** From paustin at eos.ubc.ca Mon Feb 23 22:10:59 2004 From: paustin at eos.ubc.ca (Philip Austin) Date: Mon, 23 Feb 2004 13:10:59 -0800 Subject: [C++-sig] Creating an array in C++ In-Reply-To: <12EDAD956333D8118C830007E9086704493CDA@mozart.ino.ca> References: <12EDAD956333D8118C830007E9086704493CDA@mozart.ino.ca> Message-ID: <16442.27747.34670.491420@gull.eos.ubc.ca> C?T? Marc-Alexis writes: [snip] > > My first problem is in creating the numeric::array in the c++ code. [snip] > Would you even use an array to return the data, or is there a > better way? Note that numeric::array is still in alpha -- it's lacking the two Numeric functions (ones and zeros) that allocate arrays on the Python side. One alternative is to use the helper functions at http://www.eos.ubc.ca/research/clouds/num_util.html Regards, Phil Austin From dave at boost-consulting.com Wed Feb 25 01:54:51 2004 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 24 Feb 2004 19:54:51 -0500 Subject: [C++-sig] Re: Creating an array in C++ References: <12EDAD956333D8118C830007E9086704493CDA@mozart.ino.ca> <16442.27747.34670.491420@gull.eos.ubc.ca> Message-ID: Philip Austin writes: > C?T? Marc-Alexis writes: > > [snip] > > > > > My first problem is in creating the numeric::array in the c++ code. > > [snip] > > > Would you even use an array to return the data, or is there a > > better way? > > Note that numeric::array is still in alpha -- it's lacking the two > Numeric functions (ones and zeros) that allocate arrays on the Python > side. One alternative is to use the helper functions at > http://www.eos.ubc.ca/research/clouds/num_util.html Excuse me? Alpha?! It may be missing a couple of features, but it's hardly alpha software. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Wed Feb 25 02:00:04 2004 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 24 Feb 2004 20:00:04 -0500 Subject: [C++-sig] Re: 1.31.0 Python libs Visual Studio Workspace is "empty" References: <13862.1077537871@www51.gmx.net> Message-ID: lutz_p at gmx.net writes: > I noticed the same problem from time to time. > I figured out that it is caused by unix text format, you can try to convert > it to windows/dos > format since the project and workspace files are just plain text. > I think the command line cvs doesn't convert the different formats when > checking out the files. > I use the builtin function of ultraedit for this but you can use other tools > of course... It should work if the file was properly checked in. I'm not sure that it was. The OP says he *downloaded* Boost, so if he got the .tar.gz file (which has Unix line endings) that would explain it. Windows downloaders need to get the .zip file. -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Wed Feb 25 01:58:40 2004 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 24 Feb 2004 19:58:40 -0500 Subject: [C++-sig] Re: Creating an array in C++ References: <12EDAD956333D8118C830007E9086704493CDA@mozart.ino.ca> Message-ID: C?T? Marc-Alexis writes: > Hello, > > I am relatively new to the world of python, so please bear with me if you > find this question rather basic. > > I am writting some python code that interfaces with an image processing > library that I wrote in C++. Up until now, I have exchanged image data > (between the c++ library and python) through bitmaps stored in files. I find > this rather clumsy and I am trying to use boost.python and the > numeric::array type to help me transfer images from the library in a more > elegant manner. > > My first problem is in creating the numeric::array in the c++ code. Let's > say that I want a 3 dimensional array of unsigned bytes, would this be a > correct way to do it? > > unsigned char data[300]; > boost::python::numeric::array anArray(&data[0], "UByte", > boost::python::make_tuple(10,10,3)); > > This doesn't give an error when I compile it. However, it fails to run as I > expect it: > >>>>TypeError: No to_python (by-value) converter found for C++ type: unsigned > char > > What am I missing? The error is coming from boost::python::numeric::array anArray(&data[0], "UByte", here--------------------------------------^^^^^^^^ What python argument value do you expect to be passed to the python object's __init__ function? > Would you even use an array to return the data, or is there a better way? An array probably makes sense. I guess it depends what type you want Python users to see on the other side of this function. -- Dave Abrahams Boost Consulting www.boost-consulting.com From jjhuang at cm.nctu.edu.tw Wed Feb 25 05:39:59 2004 From: jjhuang at cm.nctu.edu.tw (Jiun-jie Huang) Date: Wed, 25 Feb 2004 12:39:59 +0800 Subject: [C++-sig] Embedding python in ns-2(tcl and c++) simulator? Message-ID: Dear all, I spent a lot of time searching solutions and answers to this question, but I can't find any solution. Maybe it's because no body did this before. In the simulation of my thesis, I need a network simulator. ns-2[1] is a flexible network simulation environment, which provides TCL for users to create and set C++ objects. There is no real main function entry point. So I don't know how to embed python under such environment. I tried to embed python in the C++ node class, but I can't even perform PyImport_ImportModule successfully. The initialization of python was done at the creation of the first node object. Any idea? Thanks in advance. Footnotes: [1] Network Simulator, http://www.isi.edu/nsnam/ns/ -- Jiun-jie Huang, aka Albert E-mail: jjhuang AT cm.nctu.edu.tw ??? Department of Computer Science National Tsing Hua University MIME/ASCII/PDF/PostScript are welcome! HsinChu, Taiwan NO MS WORD DOC FILE, PLEASE! From ak at ixion.net Wed Feb 25 12:33:14 2004 From: ak at ixion.net (Andreas Kloeckner) Date: Wed, 25 Feb 2004 12:33:14 +0100 Subject: [C++-sig] Must be CopyConstructible for stringification? Message-ID: <20040225113314.GA2444@aramis.ath.cx> Hi all, I've discovered that in order to have a __str__ method, i.e. to be able to use .def( self_ns::str(self)) on a class_, it has to be CopyConstructible, or rather, is copy constructed when passed to boost::lexical_cast. This strikes me as slightly odd, since a reference would have done just as well, and not everything that can be sensibly stringified is also copyconstructible (or cheaply so, thinking matrices and lists). In short: Wouldn't it make sense to pass lexical_cast a reference instead of a copy? Andreas -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From steam at nurfuerspam.de Wed Feb 25 14:55:05 2004 From: steam at nurfuerspam.de (Hanz Meizer) Date: Wed, 25 Feb 2004 14:55:05 +0100 Subject: [C++-sig] "print" member functions. Message-ID: Hi, I have classes that contain print member functions. If I try to call those from python, I get: print a.print() ^ SyntaxError: invalid syntax I can't rename them, either: ------------ test.pyste ------------ rename(test.print, "print_me") ------------------------------------ gives: ------------------------------------ execfile(interface, context) File "test.pyste", line 15 rename(test.print, "print_me") ^ SyntaxError: invalid syntax make: *** [test.cpp] Error 1 ------------------------------------ How can I get this print function wrapped and callable from python? (it returns void). H. From pierre.barbier at cirad.fr Wed Feb 25 15:21:07 2004 From: pierre.barbier at cirad.fr (Pierre Barbier de Reuille) Date: Wed, 25 Feb 2004 15:21:07 +0100 Subject: [C++-sig] "print" member functions. In-Reply-To: References: Message-ID: <1077718867.1233.3.camel@pbarbier> "print" being a reserved work, you cannot use it at all in python !!! As pyste is in python, you cannot use any object named "print" ... you'll have to change the C++ code or write a wrapper in C++ On Wed, 2004-02-25 at 14:55, Hanz Meizer wrote: > Hi, > > I have classes that contain print member functions. If I try to call > those from python, I get: > > print a.print() > ^ > SyntaxError: invalid syntax > > I can't rename them, either: > ------------ test.pyste ------------ > rename(test.print, "print_me") > ------------------------------------ > > gives: > ------------------------------------ > execfile(interface, context) > File "test.pyste", line 15 > rename(test.print, "print_me") > ^ > SyntaxError: invalid syntax > make: *** [test.cpp] Error 1 > ------------------------------------ > > How can I get this print function wrapped and callable from python? (it > returns void). > > H. > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig -- 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 steam at nurfuerspam.de Wed Feb 25 15:34:22 2004 From: steam at nurfuerspam.de (Hanz Meizer) Date: Wed, 25 Feb 2004 15:34:22 +0100 Subject: [C++-sig] Re: "print" member functions. In-Reply-To: <1077718867.1233.3.camel@pbarbier> References: <1077718867.1233.3.camel@pbarbier> Message-ID: Pierre Barbier de Reuille wrote: > "print" being a reserved work, you cannot use it at all in python !!! > As pyste is in python, you cannot use any object named "print" ... > you'll have to change the C++ code or write a wrapper in C++ > > On Wed, 2004-02-25 at 14:55, Hanz Meizer wrote: > [...] >> print a.print() >> ^ >>SyntaxError: invalid syntax Hmmm, I think the python interpreter should figure that in this case, print is a function name. But I already feared it wouldn't work out without a wrapper :| Thanks anyways :) H. From rwgk at yahoo.com Wed Feb 25 18:33:15 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Wed, 25 Feb 2004 09:33:15 -0800 (PST) Subject: [C++-sig] "print" member functions. In-Reply-To: <1077718867.1233.3.camel@pbarbier> Message-ID: <20040225173315.26658.qmail@web20205.mail.yahoo.com> I don't know how Pyste works so this me be silly, but consider this simple example: class test: def print_me(self): print "Hi" setattr(test, "print", test.print_me) getattr(test(), "print")() This suggests: rename(getattr(test,"print"), "print_me") Ralf --- Pierre Barbier de Reuille wrote: > "print" being a reserved work, you cannot use it at all in python !!! > As pyste is in python, you cannot use any object named "print" ... > you'll have to change the C++ code or write a wrapper in C++ > > On Wed, 2004-02-25 at 14:55, Hanz Meizer wrote: > > Hi, > > > > I have classes that contain print member functions. If I try to call > > those from python, I get: > > > > print a.print() > > ^ > > SyntaxError: invalid syntax > > > > I can't rename them, either: > > ------------ test.pyste ------------ > > rename(test.print, "print_me") > > ------------------------------------ > > > > gives: > > ------------------------------------ > > execfile(interface, context) > > File "test.pyste", line 15 > > rename(test.print, "print_me") > > ^ > > SyntaxError: invalid syntax > > make: *** [test.cpp] Error 1 > > ------------------------------------ > > > > How can I get this print function wrapped and callable from python? (it > > returns void). __________________________________ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools From mike at nospam.com Wed Feb 25 19:12:07 2004 From: mike at nospam.com (Mike Rovner) Date: Wed, 25 Feb 2004 10:12:07 -0800 Subject: [C++-sig] Re: Embedding python in ns-2(tcl and c++) simulator? References: Message-ID: Jiun-jie Huang wrote: > In the simulation of my thesis, I need a network simulator. ns-2[1] is You didn't explain the python role in this. There are existing tcl/python integration solutions, may be that will do (if transfering data through tcl is enough). > a flexible network simulation environment, which provides TCL for > users to create and set C++ objects. There is no real main function > entry point. So I don't know how to embed python under such > environment. Why not to do it in Simulator class? Also please note that I know nothing about ns. Regards, Mike From Marc.Kwiatkowski at veritas.com Wed Feb 25 19:25:59 2004 From: Marc.Kwiatkowski at veritas.com (Marc Kwiatkowski) Date: Wed, 25 Feb 2004 10:25:59 -0800 Subject: [C++-sig] Re: Embedding python in ns-2(tcl and c++) simulator? In-Reply-To: References: Message-ID: <16444.59575.699000.812872@gargle.gargle.HOWL> Another possibility is to use SSF, a very nice, semi-open, (API, and protocol models are open source, event engine is proprietary) event-based network simulator implemented in java and do whatever scripting you want in jython. See http://ssfnet.org. I've used SSF for peer-to-peer network simulations and in general find it a very nice tool. It's free for research and academic projects and, no, I'm not affiliated with anyone who might make a buck from it. Mike Rovner writes: > Jiun-jie Huang wrote: > > In the simulation of my thesis, I need a network simulator. ns-2[1] is > > You didn't explain the python role in this. There are existing tcl/python > integration solutions, may be that will do (if transfering data through tcl > is enough). > > > a flexible network simulation environment, which provides TCL for > > users to create and set C++ objects. There is no real main function > > entry point. So I don't know how to embed python under such > > environment. > > Why not to do it in Simulator class? > > Also please note that I know nothing about ns. > > Regards, > Mike > > > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig -- marc.kwiatkowski at veritas.com From paustin at eos.ubc.ca Wed Feb 25 21:06:41 2004 From: paustin at eos.ubc.ca (Philip Austin) Date: Wed, 25 Feb 2004 12:06:41 -0800 Subject: [C++-sig] Re: Creating an array in C++ In-Reply-To: References: <12EDAD956333D8118C830007E9086704493CDA@mozart.ino.ca> <16442.27747.34670.491420@gull.eos.ubc.ca> Message-ID: <16445.81.838306.531344@gull.eos.ubc.ca> David Abrahams writes: > > Excuse me? Alpha?! > > It may be missing a couple of features, but it's hardly alpha > software. Sorry, that was a careless choice of words. We use numeric::array daily without a hitch, but like Marc-Alexis I'm not sure how to create an empty array of arbitray shape and type using the boost python array constructor. > What python argument value do you expect to be passed to the python > object's __init__ function? Our most common requirement is to be able to do something like theArray=numarray.array(shape=(300,),type=numarray.UInt8) from the C++ side, and then fill it with values returned from C or Fortran. Regards, Phil From jbrandmeyer at earthlink.net Thu Feb 26 00:07:48 2004 From: jbrandmeyer at earthlink.net (Jonathan Brandmeyer) Date: Wed, 25 Feb 2004 18:07:48 -0500 Subject: [C++-sig] Re: Creating an array in C++ In-Reply-To: <16445.81.838306.531344@gull.eos.ubc.ca> References: <12EDAD956333D8118C830007E9086704493CDA@mozart.ino.ca> <16442.27747.34670.491420@gull.eos.ubc.ca> <16445.81.838306.531344@gull.eos.ubc.ca> Message-ID: <1077750467.10341.38.camel@illuvatar> On Wed, 2004-02-25 at 15:06, Philip Austin wrote: > David Abrahams writes: > > > > Excuse me? Alpha?! > > > > It may be missing a couple of features, but it's hardly alpha > > software. > > Sorry, that was a careless choice of words. We use numeric::array > daily without a hitch, but like Marc-Alexis I'm not sure how to create > an empty array of arbitray shape and type using the boost python > array constructor. > > > What python argument value do you expect to be passed to the python > > object's __init__ function? > > Our most common requirement is to be able to do something like > > theArray=numarray.array(shape=(300,),type=numarray.UInt8) > > from the C++ side, and then fill it with values returned > from C or Fortran. > num_util has that capability. You would create it with this: /** Creates a n-dimensional Numeric array with dimensions dimens and Numeric type t. The elements of the array are initialized to zero. @param dimens a vector of interger specifies the dimensions of the array. @param t elements' Numeric type. Default is double. @return a numeric array of shape dimens with elements initialized to zero. */ boost::python::numeric::array makeNum(std::vector dimens, PyArray_TYPES t = PyArray_DOUBLE); Num util also has some functions that let you directly manipulate the underlying data array and functions that create and initialize an array with preexisting data. One word of warning, though, you will have to ensure sure that any arrays passed from Python to C++ through the Numeric interface meet your requirements for shape, size, continuity, and data type. HTH, Jonathan Brandmeyer From paustin at eos.ubc.ca Thu Feb 26 00:26:20 2004 From: paustin at eos.ubc.ca (Philip Austin) Date: Wed, 25 Feb 2004 15:26:20 -0800 Subject: [C++-sig] Re: Creating an array in C++ In-Reply-To: <1077750467.10341.38.camel@illuvatar> References: <12EDAD956333D8118C830007E9086704493CDA@mozart.ino.ca> <16442.27747.34670.491420@gull.eos.ubc.ca> <16445.81.838306.531344@gull.eos.ubc.ca> <1077750467.10341.38.camel@illuvatar> Message-ID: <16445.12060.102741.769211@gull.eos.ubc.ca> Jonathan Brandmeyer writes: > > num_util has that capability. You would create it with this: Well, yes ;-) (I wrote num_util in collaboration with my coop students Rhys Goldstein and Charles Leung, but would love to ditch it, if I could figure out how to use numeric::array's constructor). > > /** > Creates a n-dimensional Numeric array with dimensions dimens and Numeric > type t. The elements of the array are initialized to zero. > @param dimens a vector of interger specifies the dimensions of the > array. > @param t elements' Numeric type. Default is double. > @return a numeric array of shape dimens with elements initialized to > zero. From jjhuang at cm.nctu.edu.tw Thu Feb 26 02:14:34 2004 From: jjhuang at cm.nctu.edu.tw (Jiun-jie Huang) Date: Thu, 26 Feb 2004 09:14:34 +0800 Subject: [C++-sig] Re: Embedding python in ns-2(tcl and c++) simulator? In-Reply-To: (Mike Rovner's message of "Wed, 25 Feb 2004 10:12:07 -0800") References: Message-ID: "Mike Rovner" writes: > You didn't explain the python role in this. There are existing tcl/python > integration solutions, may be that will do (if transfering data through tcl > is enough). > > Why not to do it in Simulator class? > > Also please note that I know nothing about ns. Sorry about not explain in details. ns-2 is a mixed tcl and c++ simulator, where all C++ objects are subclasses of TclObject. C++ objects can be created and binding variables by C++. Simulator is written in TCL. At the start of a simulator, TCL creates some necessary objects, and because all C++ objects are inherited from TclObject, they all have an interface in TCL. There is already a Bluetooth c++ module for ns-2 that can performe lower layer communication routines, not written by me. I need to implement my algorithm in higher layer, and I use python to do it. The python portion is already done. And it's not an easy task to re-implement those lower-layer communication routines in Python. So one Bluetooth node is composed of C++ and python code; C++ handles lower layer, and Python handles higher layer. I'm studying socket programming now. I plan to write a simple server for handling Python code. It seems stupid, but if I can't successfully embed python in ns-2's C++ object, it's worth to do when comparing to re-implement those lower layer communication routines in Python, or re-implement those higher layer algorithm in C++. -- Jiun-jie Huang, aka Albert E-mail: jjhuang AT cm.nctu.edu.tw ??? Department of Computer Science National Tsing Hua University MIME/ASCII/PDF/PostScript are welcome! HsinChu, Taiwan NO MS WORD DOC FILE, PLEASE! From dave at boost-consulting.com Thu Feb 26 01:13:52 2004 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 25 Feb 2004 19:13:52 -0500 Subject: [C++-sig] Re: Creating an array in C++ References: <12EDAD956333D8118C830007E9086704493CDA@mozart.ino.ca> <16442.27747.34670.491420@gull.eos.ubc.ca> <16445.81.838306.531344@gull.eos.ubc.ca> Message-ID: Philip Austin writes: > David Abrahams writes: > > > > Excuse me? Alpha?! > > > > It may be missing a couple of features, but it's hardly alpha > > software. > > Sorry, that was a careless choice of words. We use numeric::array > daily without a hitch, but like Marc-Alexis I'm not sure how to create > an empty array of arbitray shape and type using the boost python > array constructor. > >> What python argument value do you expect to be passed to the python >> object's __init__ function? > > Our most common requirement is to be able to do something like > > theArray=numarray.array(shape=(300,),type=numarray.UInt8) > > from the C++ side Does this work? handle<> m = ::PyImport_Import(str("numarray").ptr()) object numarray(m); numeric::array theArray(make_tuple(300), numarray.attr("UInt8")); Yeah, it's ugly. > and then fill it with values returned from C or Fortran. You have to take theArray.ptr() to get the python object back if you want access to its raw memory. -- Dave Abrahams Boost Consulting www.boost-consulting.com From paustin at eos.ubc.ca Thu Feb 26 04:41:48 2004 From: paustin at eos.ubc.ca (Philip Austin) Date: Wed, 25 Feb 2004 19:41:48 -0800 Subject: [C++-sig] Re: Creating an array in C++ In-Reply-To: References: <12EDAD956333D8118C830007E9086704493CDA@mozart.ino.ca> <16442.27747.34670.491420@gull.eos.ubc.ca> <16445.81.838306.531344@gull.eos.ubc.ca> Message-ID: <16445.27388.444037.222017@gull.eos.ubc.ca> David Abrahams writes: > Does this work? > > handle<> m = ::PyImport_Import(str("numarray").ptr()) > object numarray(m); > numeric::array theArray(make_tuple(300),numarray.attr("UInt8")); Unfortunately, without the keyword it interprets the shape array as data: >>> theArray=numarray.array((300,),numarray.UInt8) >>> theArray array([44], type=UInt8) > > You have to take theArray.ptr() to get the python object back if you > want access to its raw memory. Yes, that adds a dependency on PyArrayObject, but there's really no alternative to memcpy if you're moving big arrays back and fort. Phil From johng at quakes.uq.edu.au Thu Feb 26 07:41:55 2004 From: johng at quakes.uq.edu.au (John Gerschwitz) Date: Thu, 26 Feb 2004 16:41:55 +1000 Subject: [C++-sig] problem with embedded python Message-ID: <403D9533.3040907@quakes.uq.edu.au> Can anybody tell me why I am getting the following error. The problem C++ code looks like this . The problem occurs trying to import numarray. Py_Initialize(); handle<> numarrayModule(PyImport_ImportModule("numarray")); numeric::array pointData(make_tuple(1,2,3,4)); Thanks John Traceback (most recent call last): File "/usr/local/lib/python2.2/site-packages/numarray/__init__.py", line 1, in ? from numarrayall import * File "/usr/local/lib/python2.2/site-packages/numarray/numarrayall.py", line 1, in ? from numerictypes import * File "/usr/local/lib/python2.2/site-packages/numarray/numerictypes.py", line 33, in ? from typeconv import typeConverters as _typeConverters File "/usr/local/lib/python2.2/site-packages/numarray/typeconv.py", line 6, in ? import _conv ImportError: /usr/local/lib/python2.2/site-packages/numarray/_conv.so: undefined symbol: PyCObject_Type From pierre.barbier at cirad.fr Thu Feb 26 09:56:18 2004 From: pierre.barbier at cirad.fr (Pierre Barbier de Reuille) Date: Thu, 26 Feb 2004 09:56:18 +0100 Subject: [C++-sig] problem with embedded python In-Reply-To: <403D9533.3040907@quakes.uq.edu.au> References: <403D9533.3040907@quakes.uq.edu.au> Message-ID: <1077785778.1233.5.camel@pbarbier> The error is when linking ... to be able to help you, I would need the linking command. On Thu, 2004-02-26 at 07:41, John Gerschwitz wrote: > Can anybody tell me why I am getting the following error. The problem > C++ code > looks like this . The problem occurs trying to import numarray. > > Py_Initialize(); > handle<> numarrayModule(PyImport_ImportModule("numarray")); > numeric::array pointData(make_tuple(1,2,3,4)); > > Thanks John > > Traceback (most recent call last): > File "/usr/local/lib/python2.2/site-packages/numarray/__init__.py", > line 1, in ? > from numarrayall import * > File "/usr/local/lib/python2.2/site-packages/numarray/numarrayall.py", > line 1, in ? > from numerictypes import * > File > "/usr/local/lib/python2.2/site-packages/numarray/numerictypes.py", line > 33, in ? > from typeconv import typeConverters as _typeConverters > File "/usr/local/lib/python2.2/site-packages/numarray/typeconv.py", > line 6, in ? > import _conv > ImportError: /usr/local/lib/python2.2/site-packages/numarray/_conv.so: > undefined symbol: PyCObject_Type > > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig -- 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 steam at nurfuerspam.de Thu Feb 26 11:32:56 2004 From: steam at nurfuerspam.de (Hanz Meizer) Date: Thu, 26 Feb 2004 11:32:56 +0100 Subject: [C++-sig] Conversion of C++ return type. Message-ID: Hello, I've realized that one of the C++-classes of my project will be very hard to wrap. Basically, it's a generic container type that holds a pointer to some object (similar to auto_ptr<>). The class is called 'Any' because it can contain a pointer to anything (nice eh? :( ). What I want to do is avoid this class entirely from python, that means, I want to have the wrapped object returned directly without the Any class wrapper. Functions that take an Any as rgument should be callable as well, of course. My question: Is it possible to shado this Any class entirely, and if yes, has this been done or where can I get some hints as to how this could work? I've searched some and my guess is to_python_converter, but I currently don't see the way how to achive my goal. Regards, H. From steam at nurfuerspam.de Thu Feb 26 13:30:04 2004 From: steam at nurfuerspam.de (Hanz Meizer) Date: Thu, 26 Feb 2004 13:30:04 +0100 Subject: [C++-sig] Re: "print" member functions. In-Reply-To: <20040225173315.26658.qmail@web20205.mail.yahoo.com> References: <1077718867.1233.3.camel@pbarbier> <20040225173315.26658.qmail@web20205.mail.yahoo.com> Message-ID: Ralf W. Grosse-Kunstleve wrote: > I don't know how Pyste works so this me be silly, but consider this simple > example: [...] > rename(getattr(test,"print"), "print_me") > > Ralf Cool, it's working! Thank you for yor help :) H. From natsu_mizu_99 at yahoo.co.jp Thu Feb 26 15:07:40 2004 From: natsu_mizu_99 at yahoo.co.jp (Natsu) Date: Thu, 26 Feb 2004 23:07:40 +0900 Subject: [C++-sig] Help on Template Instantiation Message-ID: <42C3FC71E5651Fnatsu_mizu_99@yahoo.co.jp> Dear list members, I have a question on template instantiation, probably it's rather a C++ issue. My codes are organized as follows. - 'field.h', a header file. - 'field.cpp: c++ codes using templates. - 'myfield.cpp', boost interface. After making 'myfield.so' and imported from python module, I got undefined symbol error. I assume it is related to instantiation of the template, for the error dissappears when I add a dummy main() function and call the template class field and its member functions. Is my understanding correct? If it is correct, what is the best recommended way to instantiate those class using templates, or should I modify the code structure? I use gcc-2.95.3, Boost-1.31.0, Python-2.2.1, on Red Hat 7.2. Thanks in advance Natsu // field.h #include struct vect{ double x_ ; double y_ ; double z_ ; public: vect(); ~vect(){}; }; template class field { protected: T body_; unsigned int nx_; public: field(int nx); ~field(){}; unsigned int getsize(); }; // End of field.h // field.cpp #include #include "field.h" template field::field(int nx): body_(T()), nx_(nx){} template unsigned int field::getsize() {return nx_;} vect::vect() : x_(0.0), y_(0.0), z_(0.0) {} /* int main() { field f0(0); f0.getsize(); return 0; } */ // End of field.cpp // myfield.cpp #include #include #include #include using namespace boost::python; BOOST_PYTHON_MODULE(myfield) { class_< field >("field_vect", init< int >()) .def("getsize", &field::getsize) ; class_< vect >("vect", init< >()) ; } // End of myfield.cpp // Makefile INCLUDE = -I. -I/usr/include/python2.2 CFLAGS = -Wall -O -ftemplate-depth-100 CFLAG2 = -fPIC -shared LFLAGS = -L/usr/local/lib/boost -lboost_python-gcc CPP = /usr/local/gcc-2.95.3/bin/g++ TGT = myfield OBJ = field.o ${TGT}.so: ${TGT}.o ${OBJS} ${CPP} -o $@ ${TGT}.o ${OBJS} ${LFLAGS} .cpp.o: ${CPP} ${CFLAGS} ${CFLAG2} ${INCLUDE} -o $@ -c $< ${TGT}.o: field.h field.o: field.h // End of Makefile $ python2 Python 2.2.1 (#1, Jan 22 2003, 19:07:20) [GCC 2.95.3 20010315 (release)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import myfield Traceback (most recent call last): File "", line 1, in ? ImportError: ./myfield.so: undefined symbol: getsize__t5field1Z4vect >>> __________________________________________________ Do You Yahoo!? http://bb.yahoo.co.jp/ From rwgk at yahoo.com Thu Feb 26 18:56:46 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 26 Feb 2004 09:56:46 -0800 (PST) Subject: [C++-sig] Help on Template Instantiation In-Reply-To: <42C3FC71E5651Fnatsu_mizu_99@yahoo.co.jp> Message-ID: <20040226175646.19969.qmail@web20201.mail.yahoo.com> --- Natsu wrote: > I assume it is related to instantiation of the template, You are right. > template > field::field(int nx): body_(T()), nx_(nx){} > > template > unsigned int field::getsize() {return nx_;} All you have to do is to move this code (verbatim) to field.h. This confused me too when I started with C++. I guess there is really no excuse other than the history of C/C++. Ralf __________________________________ Do you Yahoo!? Get better spam protection with Yahoo! Mail. http://antispam.yahoo.com/tools From mike at nospam.com Thu Feb 26 19:34:27 2004 From: mike at nospam.com (Mike Rovner) Date: Thu, 26 Feb 2004 10:34:27 -0800 Subject: [C++-sig] Re: Re: Embedding python in ns-2(tcl and c++) simulator? References: Message-ID: "Jiun-jie Huang" wrote in message > one Bluetooth node is composed of C++ and python code; C++ handles > lower layer, and Python handles higher layer. Write another (high-level) bluetooth node in tcl and call your code from there. >...but if I can't successfully embed python in ns-2's C++ object... Then don't. You can do either one: 1) embed python in tcl (see elmer (http://www.python.org/cgi-bin/moinmoin/elmer) for example) and call it from tcl 2) embed python in a separate c++ object and call it from "tcl c++" object (see http://www.boost.org/libs/python/doc/tutorial/doc/embedding.html) Regards, Mike From dave at boost-consulting.com Fri Feb 27 01:34:32 2004 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 26 Feb 2004 19:34:32 -0500 Subject: [C++-sig] Re: Conversion of C++ return type. References: Message-ID: Hanz Meizer writes: > Hello, > > I've realized that one of the C++-classes of my project will be very > hard to wrap. Basically, it's a generic container type that holds a > pointer to some object (similar to auto_ptr<>). The class is called > Any' because it can contain a pointer to anything (nice eh? :( ). Err, like boost::any? > What I want to do is avoid this class entirely from python, that > means, I want to have the wrapped object returned directly without the > Any class wrapper. Functions that take an Any as rgument should be > callable as well, of course. > > My question: Is it possible to shado this Any class entirely, and if > yes, has this been done or where can I get some hints as to how this > could work? I've searched some and my guess is to_python_converter, > but I currently don't see the way how to achive my goal. Good guess. Unfortunately I can't track down the details for you, but here's the gist: you need to register a custom to_python_converter for Any. Then, inside its conversion function, you need to get the typeid of the type stored by the Any (if you can't get that you're out of luck), and invoke the registry's lookup function to get the to-python conversion chain for the stored type. Then you need to "manually" invoke that converter. Expect the resulting code to be fairly ugly and low-level. Sorry :( -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Fri Feb 27 01:37:19 2004 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 26 Feb 2004 19:37:19 -0500 Subject: [C++-sig] Re: Must be CopyConstructible for stringification? References: <20040225113314.GA2444@aramis.ath.cx> Message-ID: Andreas Kloeckner writes: > Hi all, > > I've discovered that in order to have a __str__ method, i.e. to be able to > use > > .def( self_ns::str(self)) > > on a class_, it has to be CopyConstructible, or rather, is copy > constructed when passed to boost::lexical_cast. This strikes me as > slightly odd, since a reference would have done just as well, and not > everything that can be sensibly stringified is also copyconstructible > (or cheaply so, thinking matrices and lists). > > In short: Wouldn't it make sense to pass lexical_cast a reference > instead of a copy? You don't get to choose whether you're pasing a reference or a copy; the signature of the called function does that. You need to take it up with the author of lexical_cast. Sorry, -- Dave Abrahams Boost Consulting www.boost-consulting.com From nicodemus at esss.com.br Fri Feb 27 19:15:02 2004 From: nicodemus at esss.com.br (Bruno da Silva de Oliveira) Date: Fri, 27 Feb 2004 15:15:02 -0300 Subject: [C++-sig] Code failing to compile in boost-1.31.0 Message-ID: <006d01c3fd5d$9e2ad960$2700000a@esss.com.br> Hi all, This code used to compile using boost from CVS (from 05.Aug.2003, IIRC): #include #include #include struct A { std::vector v; double foo() const throw(std::out_of_range) { return v.at(0); } }; using namespace boost::python; BOOST_PYTHON_MODULE(testit) { class_("A") .def("foo", &A::foo) ; } Removing the throw declaration from A::foo: double foo() const { Makes the code compile. Is this a bug, or am I doing something wrong? Thanks, Nicodemus. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ostiguy at fnal.gov Fri Feb 27 22:18:06 2004 From: ostiguy at fnal.gov (Francois Ostiguy) Date: Fri, 27 Feb 2004 15:18:06 -0600 (CST) Subject: [C++-sig] exposing a class with a member class object Message-ID: Hi - Using boost.python, I am trying to expose an object member from a class. As a simple example, consider : class A { A( double x, double y): s.h(0.0), s.v(0.0) {} struct S { double h, double v } s; }; I would like the C++ type A to be mapped into a corresponding Python type that once instantiated can be used with the obvious syntax a = A() a.s.h = 1.0 a.s.v = 2.0 a2 = A() a2.s.h = 3.0 a2.s.v = 4.0 As usual, I am grateful for any help or hints. -Francois ---------------------------------------------------------------------------- Dr. Jean-Francois OSTIGUY voice: (630) 840-2231 Beam Physics Dept MS220 FAX: (630) 840-6039 Fermi National Accelerator Laboratory email: ostiguy at fnal.gov Batavia IL 60510-0500 WWW:www-ap.fnal.gov/~ostiguy From nicodemus at esss.com.br Fri Feb 27 23:00:30 2004 From: nicodemus at esss.com.br (Nicodemus) Date: Fri, 27 Feb 2004 19:00:30 -0300 Subject: [C++-sig] exposing a class with a member class object In-Reply-To: References: Message-ID: <403FBDFE.9020703@esss.com.br> Hi, Francois Ostiguy wrote: >Hi - > >Using boost.python, I am trying to expose an object member from a class. >As a simple example, consider : > >class A { > > A( double x, double y): s.h(0.0), s.v(0.0) {} > > struct S { double h, double v } s; > >}; > >I would like the C++ type A to be mapped into a corresponding Python type >that once instantiated can be used with the obvious syntax > > Hope that helps (untested): { scope s ( class_("A", init()); ); class_("S")...; } Cheers, Nicodemus. From mike at nospam.com Sat Feb 28 00:56:25 2004 From: mike at nospam.com (Mike Rovner) Date: Fri, 27 Feb 2004 15:56:25 -0800 Subject: [C++-sig] Re: Code failing to compile in boost-1.31.0 References: <006d01c3fd5d$9e2ad960$2700000a@esss.com.br> Message-ID: "Bruno da Silva de Oliveira" wrote in message >This code used to compile using boost from CVS (from 05.Aug.2003, IIRC): > double foo() const throw(std::out_of_range) { >Removing the throw declaration from A::foo: > double foo() const { >Makes the code compile. Is this a bug, or am I doing something wrong? Earlier in this list was a message about that. AFAIR this is a compiler bug. For now you have to cast (untested): (double (*foo_cast)()) = &foo; ... def("foo", foo_cast); HTH, Mike From darylew at hotmail.com Sun Feb 29 14:19:20 2004 From: darylew at hotmail.com (Daryle Walker) Date: Sun, 29 Feb 2004 08:19:20 -0500 Subject: [C++-sig] Software development levels (was: Re: Creating an array in C++) In-Reply-To: Message-ID: On 2/24/04 7:54 PM, "David Abrahams" wrote: > Philip Austin writes: [SNIP] >> Note that numeric::array is still in alpha -- it's lacking the two >> Numeric functions (ones and zeros) that allocate arrays on the Python >> side. One alternative is to use the helper functions at >> http://www.eos.ubc.ca/research/clouds/num_util.html > > Excuse me? Alpha?! > > It may be missing a couple of features, but it's hardly alpha > software. If it's missing features, I would consider it alpha-level software. Recall that the alpha/beta/final scale relates to feature completeness, NOT code quality! The two usually go hand in hand, but not always. (There are programs that are awesome even in the alpha stage, and craptacular final stage programs. The latter leads to accusations of "rushing the SW out the door and forcing the beta-testing on [paying] users".) -- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com From dave at boost-consulting.com Sun Feb 29 19:01:59 2004 From: dave at boost-consulting.com (David Abrahams) Date: Sun, 29 Feb 2004 13:01:59 -0500 Subject: [C++-sig] Re: Software development levels References: Message-ID: Daryle Walker writes: > On 2/24/04 7:54 PM, "David Abrahams" wrote: > >> Philip Austin writes: > [SNIP] >>> Note that numeric::array is still in alpha -- it's lacking the two >>> Numeric functions (ones and zeros) that allocate arrays on the Python >>> side. One alternative is to use the helper functions at >>> http://www.eos.ubc.ca/research/clouds/num_util.html >> >> Excuse me? Alpha?! >> >> It may be missing a couple of features, but it's hardly alpha >> software. > > If it's missing features, I would consider it alpha-level software. Recall > that the alpha/beta/final scale relates to feature completeness, NOT code > quality! I don't "recall that", and it seems to contradict what you say below... > The two usually go hand in hand, but not always. (There are > programs that are awesome even in the alpha stage, and craptacular final > stage programs. The latter leads to accusations of "rushing the SW out the > door and forcing the beta-testing on [paying] users".) If it's all about features and not quality, what do the terms "alpha testing" and "beta testing" mean? -- Dave Abrahams Boost Consulting www.boost-consulting.com From cimca at ise.canberra.edu.au Sun Feb 29 13:01:56 2004 From: cimca at ise.canberra.edu.au (cimca) Date: Sun, 29 Feb 2004 23:01:56 +1100 Subject: [C++-sig] CFP: International Conference on Computational Intelligence for Modelling, Control and Automation Message-ID: <6.0.0.22.1.20040229225436.02442dc8@hera.ucstaff.win.canberra.edu.au> CALL FOR PAPERS International Conference on Computational Intelligence for Modelling, Control and Automation 12-14 July 2004 Gold Coast, Australia http://www.ise.canberra.edu.au/conferences/cimca04/index.htm Jointly with International Conference on Intelligent Agents, Web Technologies and Internet Commerce 12-14 July 2004 Gold Coast, Australia http://www.ise.canberra.edu.au/conferences/iawtic04/index.htm The international conference on computational intelligence for modelling, control and automation will be held in Gold Coast, Australia on 12-14 July 2004. The conference provides a medium for the exchange of ideas between theoreticians and practitioners to address the important issues in computational intelligence, modelling, control and automation. The conference will consist of both plenary sessions and contributory sessions, focusing on theory, implementation and applications of computational intelligence techniques to modelling, control and automation. For contributory sessions, papers (4 pages or more) are being solicited. Several well-known keynote speakers will address the conference. Topics of the conference include, but are not limited to, the following areas: Modern and Advanced Control Strategies: Neural Networks Control, Fuzzy Logic Control, Genetic Algorithms & Evolutionary Control, Model-Predictive Control, Adaptive and Optimal Control, Intelligent Control Systems, Robotics and Automation, Fault Diagnosis, Intelligent agents, Industrial Automations Hybrid Systems: Fuzzy Evolutionary Systems, Fuzzy Expert Systems, Fuzzy Neural Systems, Neural Genetic Systems, Neural-Fuzzy-Genetic Systems, Hybrid Systems for Optimisation Data Analysis, Prediction and Model Identification: Signal Processing, Prediction & Time Series Analysis, System Identification, Data Fusion and Mining, Knowledge Discovery, Intelligent Information Systems, Image Processing, Image Understanding, Parallel Computing applications in Identification & Control, Pattern Recognition, Clustering, Classification Decision Making and Information Retrieval: Case-Based Reasoning, Decision Analysis, Intelligent Databases & Information Retrieval, Dynamic Systems Modelling, Decision Support Systems, Multi-criteria Decision Making, Qualitative and Approximate-Reasoning Paper Submission Papers will be selected based on their originality, significance, correctness, and clarity of presentation. Papers (4 pages or more) should be submitted to the following e-mail or the following address: CIMCA'2004 Secretariat School of Computing University of Canberra Canberra, 2601, ACT, Australia E-mail: cimca at ise.canberra.edu.au E-mail submission is preferred. Papers should present original work, which has not been published or being reviewed for other conferences. Important Dates ? 14 March 2004 Submission of papers ? 30 April 2004 Notification of acceptance ? 21 May 2004 Deadline for camera-ready copies of accepted papers ? 12-14 July 2004 Conference sessions Special Sessions and Tutorials Special sessions and tutorials will be organised at the conference. The conference is calling for special sessions and tutorial proposals. All proposals should be sent to the conference chair on or before 27th February 2004. CIMCA'04 will also include a special poster session devoted to recent work and work-in-progress. Abstracts are solicited for this session. Abstracts (3 pages limit) may be submitted up to 30 days before the conference date. Invited Sessions Keynote speakers from academia and industry will be addressing the main issues of the conference. Visits and social events Sightseeing visits will be arranged for the delegates and guests. A separate program will be arranged for companions during the conference. Further Information For further information either contact cimca at ise.canberra.edu.au or see the conference homepage at: http://www.ise.canberra.edu.au/conferences/cimca04/index.htm