|
From: <Das...@co...> - 2011-09-20 13:37:06
|
Hi Please send me one example for %array_functions in carrays.i. With regards, Dasari Srinivas Electronic Brake Systems Continental Technical Center (India) Ozone Manay Tech Park, 4th Floor 56/18, 55/9 G.B. Palya Hosur Main Road, Bomanahalli Bangalore - 560068, INDIA Phone: +91 - (0)80 - 3918 - 6204 Email:das...@co... http://www.continental-corporation.com From: swi...@li... To: swi...@li... Date: 09/20/2011 09:56 AM Subject: Swig-user Digest, Vol 64, Issue 12 Send Swig-user mailing list submissions to swi...@li... To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/swig-user or, via email, send a message with subject or body 'help' to swi...@li... You can reach the person managing the list at swi...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of Swig-user digest..." Today's Topics: 1. Re: Call signature difference between SWIG 1.3 and 2.0 (William S Fulton) 2. Re: Question about wrapping C++ classes to be returned to Python as Python objects (Stefan Zager) 3. Re: problems with swig/distutils/numpy (Stefan Zager) 4. Re: problems with swig/distutils/numpy (cthulhum) 5. Re: Question about wrapping C++ classes to be returned to Python as Python objects (Anil Gurnani) 6. Re: Question about wrapping C++ classes to be returned to Python as Python objects (Stefan Zager) ---------------------------------------------------------------------- Message: 1 Date: Mon, 19 Sep 2011 22:23:58 +0100 From: William S Fulton <ws...@fu...> Subject: Re: [Swig-user] Call signature difference between SWIG 1.3 and 2.0 To: Teemu Ikonen <tpi...@gm...> Cc: swi...@li... Message-ID: <4E7...@fu...> Content-Type: text/plain; charset=ISO-8859-1; format=flowed On 19/09/11 14:55, Teemu Ikonen wrote: > Hello all, > > I'm trying to compile a Python SWIG interface to to Coin3D > (coin3d.org) called pivy (see > http://hg.sim.no/Pivy/default/file/8eab90908f2a/interfaces for the > interface code). The interface generation used to work perfectly with > the swig 1.3 series, but with swig 2.0.4 compilation of the generated > wrapper code fails. > > It turns out that the problem appears when a call to a function with a > function pointer reference argument is made. The function causing the > problem has this signature: > > static SbBool getHeaderData(const SbString& headerstring, > SbBool& isbinary, > float& ivversion, > SoDBHeaderCB *& precallback, > SoDBHeaderCB *& postcallback, > void *& userdata, > SbBool substringok = FALSE); > > where SoDBHeaderCB is > > typedef void SoDBHeaderCB(void * data, SoInput * input); > > Version 1.3 produces this call in the generated Python extension code: > > result = (SbBool)SoDB::getHeaderData((SbString const > &)*arg1,*arg2,*arg3,*arg4,*arg5,*arg6,arg7); > > and version 2.0.4: > > result = (SbBool)SoDB::getHeaderData((SbString const > &)*arg1,*arg2,*arg3,arg4,arg5,*arg6,arg7); > > i.e. args 4 and 5 are not dereferenced, although rest of the argument > unpacking code in the Python extension is identical between the two > swig versions. When compiling, a matching getHeaderData function is > not found, causing this error with swig 2.0.4: > > pivy/coin_wrap.cpp: In function 'PyObject* > _wrap_SoDB_getHeaderData__SWIG_0(PyObject*, PyObject*)': > pivy/coin_wrap.cpp:35402:96: error: no matching function for call to > 'SoDB::getHeaderData(const SbString&, SbBool&, float&, void > (**&)(void*, SoInput*), void (**&)(void*, SoInput*), void*&, SbBool&)' > pivy/coin_wrap.cpp:35402:96: note: candidate is: > /usr/include/Inventor/SoDB.h:65:17: note: static SbBool > SoDB::getHeaderData(const SbString&, SbBool&, float&, void (*&)(void*, > SoInput*), void (*&)(void*, SoInput*), void*&, SbBool) > /usr/include/Inventor/SoDB.h:65:17: note: no known conversion for > argument 4 from 'void (**)(void*, SoInput*)' to 'void (*&)(void*, > SoInput*)' > > See here http://people.debian.org/~lucas/logs/2011/08/22/pivy_0.5.0~svn765-2_lsid64.buildlog > for a full Debian build log. > > There are no typemaps affecting function pointers in the interface > code that I can find, so this looks to me like a genuine regression in > swig. Any hints on how to get this interface working? > It is now fixed for swig-2.0.5, see http://swig.svn.sourceforge.net/swig/?rev=12814&view=rev Until it is released, you could use %exception as a workaround to replace the call to the wrapped function. William ------------------------------ Message: 2 Date: Mon, 19 Sep 2011 16:27:59 -0700 From: Stefan Zager <sz...@gm...> Subject: Re: [Swig-user] Question about wrapping C++ classes to be returned to Python as Python objects To: Anil Gurnani <ani...@gm...> Cc: swi...@li... Message-ID: <CAN...@ma...> Content-Type: text/plain; charset="windows-1252" On Sun, Sep 18, 2011 at 7:32 AM, Anil Gurnani <ani...@gm...>wrote: > The C++ class that I want to return back to Python is contained as an > instance variable in the CPPClass (actually it?s like a linked list ? where > a node has a pointer to another node). > Can you explain why sometimes you return a wrapped object, and other times you return a float? That's the part that makes me think this should be a pure-python method. Stefan -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ Message: 3 Date: Mon, 19 Sep 2011 16:34:33 -0700 From: Stefan Zager <sz...@gm...> Subject: Re: [Swig-user] problems with swig/distutils/numpy To: cthulhum <dav...@bu...> Cc: swi...@li... Message-ID: <CAN...@ma...> Content-Type: text/plain; charset=ISO-8859-1 On Sun, Sep 18, 2011 at 1:12 PM, cthulhum <dav...@bu...> wrote: > > I'm currently trying to wrap a small C++ library with SWIG (though I only > need to access methods from one class), with the goal of accessing one class > and a few of its methods from python+numpy. ?My Extension setup looks like > this ... SWIG typically doesn't mix too well with distutils and/or scons. If you showed me the g++ linker command you're running, I'm pretty sure I could debug this. Stefan ------------------------------ Message: 4 Date: Mon, 19 Sep 2011 19:27:15 -0700 (PDT) From: cthulhum <dav...@bu...> Subject: Re: [Swig-user] problems with swig/distutils/numpy To: swi...@li... Message-ID: <324...@ta...> Content-Type: text/plain; charset=us-ascii Yeah, I came to that same conclusion myself and just started running the swig and g++ commands manually instead, and that seems to be working. I think the problem may have been the missing "-shared" argument in the linker command distutils was issuing (it's the one at the top of the error-log I posted). Stefan Zager-2 wrote: > > SWIG typically doesn't mix too well with distutils and/or scons. If > you showed me the g++ linker command you're running, I'm pretty sure I > could debug this. > > Stefan > > -- View this message in context: http://old.nabble.com/problems-with-swig-distutils-numpy-tp32482736p32499873.html Sent from the swig-user mailing list archive at Nabble.com. ------------------------------ Message: 5 Date: Mon, 19 Sep 2011 22:46:07 -0400 From: "Anil Gurnani" <ani...@gm...> Subject: Re: [Swig-user] Question about wrapping C++ classes to be returned to Python as Python objects To: "'Stefan Zager'" <sz...@gm...> Cc: swi...@li... Message-ID: <4e7...@mx...> Content-Type: text/plain; charset="us-ascii" We have a library similar to AVRO (or Protocol Buffers) to pack data structures for transmission using TCP/IP or Message Queues or plain old files on disk. The container can have any type of element. We want to offer Python like interface for our Python users like below: MyContainer[0] = 3.4 MyContainer[1] = 'abc' MyContainer[2] = nestedContainer; And so on.. In fact I want to go a step further and be able to give MyContainer['myfloat'] = 3.3 MyContainer['mystring'] = 'abc' Print MyContainer['myfloat'] Print MyContainer[1] And ideally, I would also like MyContainer['nestedContainer']['myint'] = 4 This last one is very tricky as I want to use the same memory space. I did actually manage to figure out how to combine boost and shared_ptr and have a working version for some of it - but the last usage is really tricky and I am still trying to figure that one out. Any suggestions/ideas or any pointers on what I should read up/refer to will be greatly appreciated. Thanks and Regards, Anil From: Stefan Zager [mailto:sz...@gm...] Sent: Monday, September 19, 2011 7:28 PM To: Anil Gurnani Cc: swi...@li... Subject: Re: [Swig-user] Question about wrapping C++ classes to be returned to Python as Python objects On Sun, Sep 18, 2011 at 7:32 AM, Anil Gurnani <ani...@gm...> wrote: The C++ class that I want to return back to Python is contained as an instance variable in the CPPClass (actually it's like a linked list - where a node has a pointer to another node). Can you explain why sometimes you return a wrapped object, and other times you return a float? That's the part that makes me think this should be a pure-python method. Stefan -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ Message: 6 Date: Mon, 19 Sep 2011 21:24:08 -0700 From: Stefan Zager <sz...@gm...> Subject: Re: [Swig-user] Question about wrapping C++ classes to be returned to Python as Python objects To: Anil Gurnani <ani...@gm...> Cc: swi...@li... Message-ID: <CAN...@ma...> Content-Type: text/plain; charset=windows-1252 OK, that makes sense. Next question: how do you deal with the type polymorphism in the C++ interface? What are the C++ method declarations for getting, setting, or checking the type of a value stored in your container class? Stefan On Mon, Sep 19, 2011 at 7:46 PM, Anil Gurnani <ani...@gm...> wrote: > We have a library similar to AVRO (or Protocol Buffers) to pack data > structures for transmission using TCP/IP or Message Queues or plain old > files on disk. The container can have any type of element. We want to offer > Python like interface for our Python users like below: > > > > MyContainer[0] = 3.4 > > MyContainer[1] = ?abc? > > MyContainer[2] = nestedContainer; > > > > And so on?. > > > > In fact I want to go a step further and be able to give > > MyContainer[?myfloat?] = 3.3 > > MyContainer[?mystring?] = ?abc? > > > > Print MyContainer[?myfloat?] > > Print MyContainer[1] > > > > And ideally, I would also like > > MyContainer[?nestedContainer?][?myint?] = 4 > > > > This last one is very tricky as I want to use the same memory space. I did > actually manage to figure out how to combine boost and shared_ptr and have a > working version for some of it ? but the last usage is really tricky and I > am still trying to figure that one out. Any suggestions/ideas or any > pointers on what I should read up/refer to will be greatly appreciated. > > > > Thanks and Regards, > > Anil > > > > > > From: Stefan Zager [mailto:sz...@gm...] > Sent: Monday, September 19, 2011 7:28 PM > > To: Anil Gurnani > Cc: swi...@li... > Subject: Re: [Swig-user] Question about wrapping C++ classes to be returned > to Python as Python objects > > > > On Sun, Sep 18, 2011 at 7:32 AM, Anil Gurnani <ani...@gm...> > wrote: > > > > The C++ class that I want to return back to Python is contained as an > instance variable in the CPPClass (actually it?s like a linked list ? where > a node has a pointer to another node). > > > > Can you explain why sometimes you return a wrapped object, and other times > you return a float? ?That's the part that makes me think this should be a > pure-python method. > > > > Stefan > > ------------------------------ ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 ------------------------------ _______________________________________________ Swig-user mailing list Swi...@li... https://lists.sourceforge.net/lists/listinfo/swig-user End of Swig-user Digest, Vol 64, Issue 12 ***************************************** |