pushs in xs
---559023410-1804928587-1302225499=:2245
Content-Type: TEXT/PLAIN; charset=UTF-8; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE
Hello,
I created my interface in c by using xs.
This work fine:
transition_HF*
init___ ()
PREINIT:
transition_HF *trans ;
CODE:
trans =3D (transition_HF*) malloc (sizeof (transition_HF)) ;
RETVAL =3D trans ;
OUTPUT:
RETVAL
but if I make a push:
like:
XPUSHs (sv_2mortal (newRV ((SV*) (trans)))) ;
or:
XPUSHs (sv_2mortal (newRV (trans))) ;
I always get an error like:
is not of type transition_HFPtr
when I try to access to this structure (in the first case, it works
fine).
I set typemap like:
TYPEMAP
transition_HF *=09=09T_PTROBJ
What am I doing wrong ?
Thank.
--
---
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D
Patrick DUPR=C3=89 | |
Department of Chemistry | | Phone: (44)-(0)-1904-434384
The University of York | | Fax: (44)-(0)-1904-432516
Heslington | |
York YO10 5DD United Kingdom | | email: patrick.dupre [at] york.ac.uk
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D
---559023410-1804928587-1302225499=:2245
Content-Type: text/plain; charset=us-ascii
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
---559023410-1804928587-1302225499=:2245--
Re: pushs in xs
by definition, xs is NOT a beginner perl issue. please find another
forum for your question.
uri
--
Uri Guttman ------ uri [at] stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: pushs in xs
On Fri, Apr 08, 2011 at 02:18:19AM +0100, Patrick Dupre wrote:
> Hello,
>
> I created my interface in c by using xs.
>
> This work fine:
>
> transition_HF*
> init___ ()
> PREINIT:
> transition_HF *trans ;
> CODE:
> trans = (transition_HF*) malloc (sizeof (transition_HF)) ;
> RETVAL = trans ;
> OUTPUT:
> RETVAL
>
> but if I make a push:
> like:
>
> XPUSHs (sv_2mortal (newRV ((SV*) (trans)))) ;
> or:
> XPUSHs (sv_2mortal (newRV (trans))) ;
>
> I always get an error like:
>
> is not of type transition_HFPtr
This message comes from the typemap for T_PTROBJ:
T_PTROBJ
if (sv_derived_from($arg, \"${ntype}\")) {
IV tmp = SvIV((SV*)SvRV($arg));
$var = INT2PTR($type,tmp);
}
else
Perl_croak(aTHX_ \"%s: %s is not of type %s\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\", \"$ntype\")
This definition is found in .../ExtUtils/typemap in the directory tree where
perl is installed.
> when I try to access to this structure (in the first case, it works
> fine).
>
> I set typemap like:
> TYPEMAP
> transition_HF * T_PTROBJ
>
> What am I doing wrong ?
From perldoc perlxs:
When dealing with C structures one should select either T_PTROBJ or T_PTRREF
for the XS type. Both types are designed to handle pointers to complex
objects. The T_PTRREF type will allow the Perl object to be unblessed while
the T_PTROBJ type requires that the object be blessed. By using T_PTROBJ
one can achieve a form of type-checking because the XSUB will attempt to
verify that the Perl object is of the expected type.
I suspect that you want to be using T_PTRREF rather than T_PTROBJ. You can read
more about the different types in Typemap.xs:
http://search.cpan.org/~rjbs/perl-5.12.3/ext/XS-Typemap/Type map.xs
> Thank.
Welc.
I see no problem with asking beginner XS questions on a Perl beginners group.
but you might not find a large number or people who are able and willing to
help. Fortunately, there is a mailing list for XS. Details can be found at
http://lists.perl.org/list/perl-xs.html
Although the list is quite low in volume, you'll find people there who can
help further.
Good luck.
--
Paul Johnson - paul [at] pjcj.net
http://www.pjcj.net
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: pushs in xs
On 08/04/2011 10:43, Uri Guttman wrote:
>
> by definition, xs is NOT a beginner perl issue. please find another
> forum for your question.
This is rather churlish of you Uri. If he gets no answer here, what
harm has he done? At the very least you could suggest such an
alternative forum.
And "by definition"? So the definition of XS is "Not a beginner Perl
issue?"
Rob
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: pushs in xs
>>>>> "RD" == Rob Dixon <rob.dixon [at] gmx.com> writes:
RD> On 08/04/2011 10:43, Uri Guttman wrote:
>>
>> by definition, xs is NOT a beginner perl issue. please find another
>> forum for your question.
RD> This is rather churlish of you Uri. If he gets no answer here, what
RD> harm has he done? At the very least you could suggest such an
RD> alternative forum.
not churlish. xs is way beyond beginning perl. it isn't covered most
books.
ok, i should have mentioned other places. so could you. but still, we
can't start to get deep guts and xs issues here. then it will turn away
the beginners who come here. you need to have some boundaries or it
becomes a free for all. that has happened to too many other forums in
many places.
RD> And "by definition"? So the definition of XS is "Not a beginner Perl
RD> issue?"
yep. perl guts, c, crazy xs macros, etc are all way beyond beginner
stuff. if you can't see that, i can't help you. we get newbies here who
are just learning to code at all. tossing xs questions around will scare
them to ruby or worse, python!
as for other places, google helps. there is usenet (still alive),
perlmonks, lists.perl.org to find an appropriate mailing list. local pm
groups are great too.
uri
--
Uri Guttman ------ uri [at] stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: pushs in xs
--0016e6d7e99abaeaaa04a08d3a35
Content-Type: text/plain; charset=ISO-8859-1
On Apr 8, 2011 4:42 PM, "Uri Guttman" <uri [at] stemsystems.com> wrote:
While I don't agree with uri's reaction to the post, xs ain't beginner (but
something this 'beginner' has been thinking of getting into recently).
>
> as for other places, google helps. there is usenet (still alive),
> perlmonks, lists.perl.org to find an appropriate mailing list. local pm
> groups are great too.
>
What are 'local pm groups'?
Btw, irc is real good too - generally gets quicker solutions than any other
medium too.
--0016e6d7e99abaeaaa04a08d3a35--
Re: pushs in xs
shawn wilson wrote:
> On Apr 8, 2011 4:42 PM, "Uri Guttman"<uri [at] stemsystems.com> wrote:
>
> While I don't agree with uri's reaction to the post, xs ain't beginner (but
> something this 'beginner' has been thinking of getting into recently).
>
>>
>> as for other places, google helps. there is usenet (still alive),
>> perlmonks, lists.perl.org to find an appropriate mailing list. local pm
>> groups are great too.
>>
>
> What are 'local pm groups'?
Local Perl Mongers groups: www.pm.org
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/