mark gossage | 1 Sep 02:57 2006
Picon

Re: Problems with %extending template classes

Hello Nitro,

> > On a differnt matter to the rest of the SWIG maintainers, it seems that 
> > you can have to %extend the Vector<5>, it is not possible to %extend a  
> > %template parameter, nor is it possible to %extend Vector<T>. Is
> this a bug?
> 
> I am not a SWIG maintainer, but I have code like this in my interfaces and  
> it works without a hitch:
> 
> 		/** a simply array holding N values of type T
> 		  */
> 		template<typename T, uint N>
> 		struct DCVector
> 		{
> 			T data[N];			///< the components of the vector
> 
> 			DCVECTOROPS(T,N)
> 			
> 			%extend
> 			{
> 				char* __str__() const
> 				{
> 					static DCString tmp="(";
> 					
> 					for (int i=0;i<N;i++)
> 					{
> 						tmp+=toString(self->data[i]);
> 						if (i!=N-1) tmp+=", ";
> 					}
(Continue reading)

Nitro | 1 Sep 11:21 2006

Re: Problems with %extending template classes

Am 01.09.2006, 02:57 Uhr, schrieb mark gossage <" <mark <at> gossage.cjb.net>>:

> Yes I did it differently.
> When I split the declaration and the %extend, there seems to be problems  
> with SWIG spotting it.
>
> // given the template:
> template<int N>
> struct Vector
> {
>   double p[N];
> };
> %template(Point5) Vector<5>;
>
> I tried the following:
>
> %extend Vector{...}         doesnt add the extra methods, no warning  
> given
>
> %extend Vector<N>{...}       doesnt add the extra methods, no warning  
> given
>
> %extend Vector<5>{...}       works ok
>
> %extend Point5{...}     generates warning during SWIG'ing,
>                           "%extend for undeclared class Pont5"
>
> This doesn't look like a good behaviour

Hey Mark,
(Continue reading)

Tino Lange | 1 Sep 11:36 2006

SWIG&Python: Call a Method in a (Python-)derived Class from C++ - is that possible? How?

Hi!

I'm just doing my first SWIG project and need a bit of help...

I'm trying to wrap a given C++-Library that encapsulates communication
with a server. I can send requests to this server and somewhen I will
get answers back. Quite easy...

The dispatching of the answer is done via a Listener class one has to
derive from. A virtual 'onReceive' is called for every answer.

Imagine the following C++ -code:

> // we need our own listener
> class MyListener : public Listener {
> public:
>   void onReceive(Msg *message) {
>     cerr << "Got Message:" << *message << endl;
>   }
> };
> [...] 
> 
> // sending and receiving
> [...]
> MyListener lis; // see above
> [...]
> connection.request(query, &lis); // <- here I have to give the reference to a custom Listener
> [...]
> connection.receive(); // will dispatch to the correponding custom listener specified in 'request()'
> [...]
(Continue reading)

Paul Melis | 1 Sep 11:40 2006
Picon

Re: SWIG&Python: Call a Method in a (Python-)derived Class from C++ - is that possible? How?

Tino Lange wrote:

>Hi!
>
>I'm just doing my first SWIG project and need a bit of help...
>
>I'm trying to wrap a given C++-Library that encapsulates communication
>with a server. I can send requests to this server and somewhen I will
>get answers back. Quite easy...
>
>The dispatching of the answer is done via a Listener class one has to
>derive from. A virtual 'onReceive' is called for every answer.
>
>Imagine the following C++ -code:
>
>  
>
>>// we need our own listener
>>class MyListener : public Listener {
>>public:
>>  void onReceive(Msg *message) {
>>    cerr << "Got Message:" << *message << endl;
>>  }
>>};
>>[...] 
>>
>>// sending and receiving
>>[...]
>>MyListener lis; // see above
>>[...]
(Continue reading)

Tino Lange | 1 Sep 11:50 2006

Re: SWIG&Python: Call a Method in a (Python-)derived Class from C++ - is that possible? How?

Hi!

That's it! It's working now.
Wow, SWIG is great! Thanks a lot, Paul.

Cheers,

Tino

-------------------

Paul Melis wrote:

> Did you enable directors for the Listener class (see the SWIG docs on
> python support)?

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Josh Cherry | 1 Sep 19:39 2006
Picon

Re: Python : rename keywords arguments


On Thu, 31 Aug 2006, William S Fulton wrote:

> but you will probably be there forever doing this. Personally, I'd
> filter your header files by piping them through sed, deleting all 'a_'
> at the beginning of a word, before giving the header files to SWIG to parse.

There's a variation of this that I find convenient.  You can run the
preprocessor with -E, save the results to a file, and feed them back to
SWIG with -nopreprocess.  In between, you can manipulate the file in any
way you like, including running it through sed.  You don't (at least not
easily) get to apply fitlering selectively to individual headers, but it's
easier than dealing separately with all the headers.

Josh

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Nitro | 2 Sep 01:29 2006

Re: Python : rename keywords arguments

Am 01.09.2006, 19:39 Uhr, schrieb Josh Cherry <jcherry <at> ncbi.nlm.nih.gov>:

>
> On Thu, 31 Aug 2006, William S Fulton wrote:
>
>> but you will probably be there forever doing this. Personally, I'd
>> filter your header files by piping them through sed, deleting all 'a_'
>> at the beginning of a word, before giving the header files to SWIG to  
>> parse.
>
> There's a variation of this that I find convenient.  You can run the
> preprocessor with -E, save the results to a file, and feed them back to
> SWIG with -nopreprocess.  In between, you can manipulate the file in any
> way you like, including running it through sed.  You don't (at least not
> easily) get to apply fitlering selectively to individual headers, but  
> it's
> easier than dealing separately with all the headers.
>
> Josh

A similar way that I use to rename classes and functions is to parse  
everything with swig -xml and then run an xml parser on this to extract  
the necessary symbols. You could use this to generate the proper #defines  
into another file.
My script is basically a customized version of this one here (credits to  
Robin Dunn from wxPython): 

http://cvs.wxwidgets.org/viewcvs.cgi/*checkout*/wxWidgets/wxPython/config.py?rev=1.71.2.19&content-type=text/plain

. Just search for "processXML" (at the very bottom) in there to get the  
(Continue reading)

John Lenz | 2 Sep 02:36 2006
Picon

Re: Python : rename keywords arguments

On 09/01/06 18:29, Nitro wrote:
> A similar way that I use to rename classes and functions is to parse  
> everything with swig -xml and then run an xml parser on this to extract  
> the necessary symbols. You could use this to generate the proper #defines  
> into another file.
> My script is basically a customized version of this one here (credits to  
> Robin Dunn from wxPython):  
>
http://cvs.wxwidgets.org/viewcvs.cgi/*checkout*/wxWidgets/wxPython/config.py?rev=1.71.2.19&content-type=text/plain

> . Just search for "processXML" (at the very bottom) in there to get the  
> function which extracts the proper xml data.
> 
> -Matthias

Since a bunch of people ask about this feature, it might be nice to add
that script in as an example in the Example directory.  Then people can
copy it from SWIG and customize it themselves.

If anyone wants to make a simple example, of using a script to rename
variables, I will gladly add it to CVS.

John

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
(Continue reading)

Nitro | 2 Sep 14:59 2006

Re: Python : rename keywords arguments

Am 02.09.2006, 02:36 Uhr, schrieb John Lenz <lenz <at> cs.wisc.edu>:

> On 09/01/06 18:29, Nitro wrote:
>> A similar way that I use to rename classes and functions is to parse
>> everything with swig -xml and then run an xml parser on this to extract
>> the necessary symbols. You could use this to generate the proper  
>> #defines
>> into another file.
>> My script is basically a customized version of this one here (credits to
>> Robin Dunn from wxPython):
>> http://cvs.wxwidgets.org/viewcvs.cgi/*checkout*/wxWidgets/wxPython/config.py?rev=1.71.2.19&content-type=text/plain
>> . Just search for "processXML" (at the very bottom) in there to get the
>> function which extracts the proper xml data.
>>
>> -Matthias
>
>
> Since a bunch of people ask about this feature, it might be nice to add
> that script in as an example in the Example directory.  Then people can
> copy it from SWIG and customize it themselves.
>
> If anyone wants to make a simple example, of using a script to rename
> variables, I will gladly add it to CVS.
>
> John

A shortcut to using this script is to use %rename with the regular  
expression things. I've never tried that way though. In bigger projects  
the xml building + parsing step takes up a considerable amount of time, so  
the %rename way might be preferred in that case for simple operations.
(Continue reading)

LIN | 3 Sep 05:12 2006
Picon

What's problem i compilered SWIG error


example_wrap.c:112:20: error:Python.h:No serach the file or directory
example_wrap.c:719: error:expected 「=」, 「,」, 「;」, 「asm」 or 「__attribute__」
before 「*」 token
example_wrap.c:774: error:expected 「=」, 「,」, 「;」, 「asm」 or 「__attribute__」
before 「*」 token
example_wrap.c:787: error:expected 「=」, 「,」, 「;」, 「asm」 or 「__attribute__」
before 「*」 token
example_wrap.c: in this "SWIG_Python_AddErrorMsg"'s function
example_wrap.c:834: error:「PyObject」 No defined (The function is begin used)
example_wrap.c:834: error:(即使在一個函式內多次出現,每個No defined的識別碼在其
example_wrap.c:834: error:所在的函式內只報告一次。)
example_wrap.c:834: error:「type」 No defined (The function is begin used)
example_wrap.c:835: error:「value」 No defined (The function is begin used)
example_wrap.c:836: error:「traceback」 No defined (The function is begin
used)
example_wrap.c:840: error:「old_str」 No defined (The function is begin used)
example_wrap.c:847: error:「PyExc_RuntimeError」 No defined (The function is
begin used)
example_wrap.c: 在頂層:
example_wrap.c:1015: error:expected 「)」 before 「*」 token
example_wrap.c:1023: error:expected 「)」 before 「*」 token
example_wrap.c:1034: error:expected 「)」 before 「*」 token
example_wrap.c:1041: error:expected 「=」, 「,」, 「;」, 「asm」 or 「__attribute__」
before 「*」 token
example_wrap.c:1087: error:expected 「)」 before 「*」 token
example_wrap.c:1189: error:expected 「=」, 「,」, 「;」, 「asm」 or 「__attribute__」
before 「*」 token
example_wrap.c:1200: error:expected specifier-qualifier-list before
「PyObject」example_wrap.c: 在函式 「SWIG_Python_CheckImplicit」 中:
(Continue reading)


Gmane