I'm having difficulty finding the right way to do this, and hope that
maybe someone here is familiar enough to regurgitate some code.

use Inline C => 'DATA';

sub my_test {
  return $a <=> $b;
}

print my_c( \&my_test, 1, 2 ), "\n";

__DATA__
__C__

int my_c ( SV* code, int left, int right ) {

  SV* rv;
  // Load $a and $b with 'left' and 'right' (I think)...
  GV *agv, *bgv;

  agv = gv_fetchpv( "a", GV_ADD, SVt_PV );
  bgv = gv_fetchpv( "b", GV_ADD, SVt_PV );
  SAVESPTR(GvSV(agv));
  SAVESPTR(GvSV(bgv));
  dSP;
  // .... I'm stuck ...
  // Now call "code" and get its return value.
  // *rv = ..... (Yes, I know this is a dismal start. ;) )

  PUTBACK;
  return SvIV(*rv); // Return the value.
}


I would sure appreciate some help on this.  I just keep staring at
examples from other modules, at perlguts, perlcall, and so on, and
each time I think I've got it right I end up getting partway into it
and thinking, "Nah, this can't be right either."  lol


-- 

David Oswald
daosw...@gmail.com

Reply via email to