roehrich@cray.com (Dean Roehrich)
Re: Passing a pointer to C function ?
Re: Passing a pointer to C function ?
Cray Research, Inc.
8 May 96 14:00:19 CDT
- Newsgroups:
- comp.lang.perl.misc
- References:
- <4mq340$jn7@thetimes.pixel.kodak.com>
In article <4mq340$jn7@thetimes.pixel.kodak.com>,
Tony Whyte wrote:
>
>
>I have created an extension to a C program one of whose parameters is a
>pointer to a particular type of data structure. I've created a typemap
>entry of T_PTROBJ for the data structure (not sure if I had to since Im
>not really passing the structure itself)
T_PTROBJ, and similar maps, are used to handle the _pointer_ for the data
structure. The basic form of these maps creates an SV and stores the value
of the pointer in that SV--a Perl object shadowing a C object.
> but Im not sure how I specify the
>pointer parameter when calling the function from perl. I've CookbookB'd,
>and perldoc'd around but cant find the trick.
You cannot fabricate a pointer out of nothing. Somehow you have to give
Perl the ability to allocate a copy of the structure and to get a pointer to
that structure. The "Struct1" and "Opaque" examples in CookBookB cover this
basic case.
[posted&mailed]
Dean
roehrich@cray.com