Brian's note about not using the Inline macro's was correct, although you
can continue to use some of them, if you'd like. The main culprit is that
Inline_Stack_Reset is NOT the same as PUSHMARK(SP). If you change the
Inline_Stack_Reset's to PUSHMARK(SP), everything now works (so the moral
of the story - you still need PUSHMARK(SP) and SPAGAIN, but otherwise the
Inline_Stack_* arsenal is complete).
-Aaron
On Wed, 10 Jul 2002, Aaron J Mackey wrote:
> test.pl:
> #!/usr/bin/perl -w
> use strict; use Foo;
> my $one = new Foo; my $two = new Foo;
> $one->bar($two, 'a', 'b', 'c');
>
> Foo.pm:
> package Foo;
>
> use strict;
> use Inline C => 'DATA';
>
> sub new { return bless {}, shift; }
> sub bar {
> my ($self, $other, $a, $b, $c) = @_;
> print "In bar: $a $b $c\n";
> $self->call_C($other, $b, $c, 'd');
> }
> sub call_Perl {
> my ($self, $c, $d, $e) = @_;
> print "In call_Perl: $c $d $e\n";
> }
> 1;
> __DATA__
> __C__
> void call_C(SV* self, SV* other, char b, char c, char d) {
> Inline_Stack_Vars;
>
> PerlIO_stdoutf("In call_C: %c %c %c\n", b, c, d);
>
> ENTER; SAVETMPS;
> Inline_Stack_Reset;
> Inline_Stack_Push(other);
> Inline_Stack_Push(sv_2mortal(newSVpvf("%c1", c)));
> Inline_Stack_Push(sv_2mortal(newSVpvf("%c1", d)));
> Inline_Stack_Push(sv_2mortal(newSVpvf("e1")));
> Inline_Stack_Done;
> call_method("call_Perl", G_SCALAR); SPAGAIN; Inline_Stack_Done;
> FREETMPS; LEAVE;
>
> ENTER; SAVETMPS;
> Inline_Stack_Reset;
> Inline_Stack_Push(other);
> Inline_Stack_Push(sv_2mortal(newSVpvf("%c2", c)));
> Inline_Stack_Push(sv_2mortal(newSVpvf("%c2", d)));
> Inline_Stack_Push(sv_2mortal(newSVpvf("e2")));
> Inline_Stack_Done;
> call_method("call_Perl", G_SCALAR); SPAGAIN; Inline_Stack_Done;
> FREETMPS; LEAVE;
> }
>
>
> On Tue, 9 Jul 2002, Aaron J Mackey wrote:
>
> >
> > Ok, in the middle of a C function I have this:
> >
> > /* $n = $seq->length() */
> > Inline_Stack_Reset; Inline_Stack_Push(seq); Inline_Stack_Done;
> > call_method("length", G_SCALAR);
> > if (SvIOK(Inline_Stack_Item(0))) {
> > n = SvIV(Inline_Stack_Item(0));
> > }
> >
> > This works fine. But then a few lines later:
> >
> > /* read.base = $seq->seq() */
> > Inline_Stack_Reset; Inline_Stack_Push(seq); Inline_Stack_Done;
> > call_method("seq", G_SCALAR);
> > if (SvPOK(Inline_Stack_Item(0))) {
> > strncpy(read->base, SvPV_nolen(Inline_Stack_Item(0)), n + 1);
> > }
> >
> > And I get:
> > Can't locate object method "seq" via package "pln" (perhaps you forgot to
> > load "pln"?) at blib/lib/Bio/SeqIO/staden/read.pm line 132
> >
> > Now my blessed ref "seq" is not the scalar string "pln", it's a real live
> > blessed object (sv_isa(seq, "The::Right::Package") is true). This smells
> > more like the Inline_Stack_Reset and friends not really repositioning the
> > stack correctly (translated as: how do I get these to correctly reposition
> > the stack for multiple call_method()'s). Or maybe it's something else?
> > Do I need to use ENTER; LEAVE; stuff?
> >
> > Thanks for any help, or "gotchyas".
> >
> > -Aaron
> >
> >
>
>
--
Aaron J Mackey
Pearson Laboratory
University of Virginia
(434) 924-2821
[EMAIL PROTECTED]