Mathieu Malaterre | 2 Jan 2009 15:54
Picon

Re: Automatically generated callbacks using directors (python)

Carlos,

  Those macros look awesome. I was looking on how to deal with c++
callback and python and could not find any documentation.

Un-usable, you need to define you callback in the .i file (could
someone give me a practical example!):
http://www.swig.org/Doc1.3/SWIG.html#SWIG_nn30

Looks completely outdated:
http://www.swig.org/Doc1.1/HTML/Python.html#n11

swig comes with an example, but with a funky syntax (thisown=0 /
.disown() and you still need to explicitely delete the callback),
clearly not user oriented.

2008/8/31 Carlos Pita <carlosjosepita <at> gmail.com>:
> Hi all,
>
> I've hacked up a couple of macros for automatically generating
> callbacks that I'd like to share with you because I know it's a
> recurrent subject here.
>
> The idea behind the macros is simple: implement the callback as a
> virtual method of a class, implement this method in python, and let c
> call it through its director. Actually, the callback is implemented as
> a python callable and then wrapped into a virtual method for you, so
> you don't need to mess with a mere implementation concern. The macros
> that implement all this are not that complex at all, they just hide
> the details.
(Continue reading)


Gmane