There could be a directive, feature etc. to force swig
assign (bless) a specified type (package) name in the
target language to pointers of given C type. I
understand this is not possible in all target
languages, but for example in perl it can be very handy.
Motivation:
I'm using swig to wrap my own library (written in C).
Example:
C function f(A *a) belongs to module MY_A.
All functions in MY_A take A pointer as first arg. (OO
think)
MY_A is wrapped to perl package MY::A.
When handling pointers to structs of type A in perl it
is very useful if the corresponding perl ref ($a for
example) is blessed to package MY::A. This allows
direct calling of functions in module MY_A like this,
$a->f();
This very efficient and it also allows me to forget
wheter $a is actually MY::A, MY::B or etc. when I just
wan't to call f. All access to struct A is done through
few functions in MY_A so shadow/proxy perl class seems
an overkill.
Currently I have implemented this as a hack that
modifies MY_A_wrap.c after it has been generated, but
it would be nice if I could tell swig to directly bless
the references to the package I choose.
There could be a directive, feature etc. to force swig assign (bless) a specified type (package) name in the target language to pointers of given C type. I understand this is not possible in all target languages, but for example in perl it can be very handy.
Motivation: I'm using swig to wrap my own library (written in C). Example: C function f(A *a) belongs to module MY_A. All functions in MY_A take A pointer as first arg. (OO think) MY_A is wrapped to perl package MY::A.
When handling pointers to structs of type A in perl it is very useful if the corresponding perl ref ($a for example) is blessed to package MY::A. This allows direct calling of functions in module MY_A like this, $a->f();
This very efficient and it also allows me to forget wheter $a is actually MY::A, MY::B or etc. when I just wan't to call f. All access to struct A is done through few functions in MY_A so shadow/proxy perl class seems an overkill.
Currently I have implemented this as a hack that modifies MY_A_wrap.c after it has been generated, but it would be nice if I could tell swig to directly bless the references to the package I choose.