sanko / Affix.pm

A Foreign Function Interface eXtension for Perl
https://metacpan.org/dist/Affix
Artistic License 2.0
1 stars 0 forks source link

:Native subs defined as wrappers #12

Closed sanko closed 1 week ago

sanko commented 1 year ago

Currently, any preexisting sub tagged with a :Native attribute is clobbered but we could save the CV * and use it as a wrapper of the affixed code.

sub myfunc :Native('lib.dll') : Signature ([Int, Str, Maybe[Str, Str, Any]]=>Void) {
    my ($code, $alpha, $beta) = @_;
    $code->($alpha, $beta . ' to Jurassic Park!', 'Extra parameters');
}
myfunc( 1993, 'Welcome' );

In this example, some values could be filled in by the wrapper. This might not be useful but we're just tossing the old code away now so...