The simplest approach, which one gets by default, is just to pass a
void* as a number.

   use Inline;

   Inline->bind(C => <<END);
   static int foo(a) { return a + 3; }
   void* address_of_foo () { return (void*)&foo; }
   int invoke (void* p, int n) { int (*f)(int) = p;  return f(n); }
   END

   print address_of_foo(),"\n";
   print invoke(address_of_foo(),39),"\n";

   $ perl  -w foo.pl
   1075895008
   42
   $

To get a more opaque object, like swig -perl gives you, requires a bit
more work.

Mitchell Charity

Reply via email to