Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

force pointer's type name in target lang #102

Open
SwigAtSF opened this issue Jan 18, 2013 · 0 comments
Open

force pointer's type name in target lang #102

SwigAtSF opened this issue Jan 18, 2013 · 0 comments

Comments

@SwigAtSF
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant