Created
November 22, 2011 23:18
-
-
Save jnthn/1387382 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
__declspec(dllexport) /* comment this line out if not on Windows */ | |
int GotValues(int a, float b) | |
{ | |
printf("Got %d\nGot %f\n", a, b); | |
return 69; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pir::nqp_native_call_setup__v(); | |
my $nc_type := pir::get_knowhow__P().new_type(:name('NQPNativeCall'), :repr('NativeCall')); | |
$nc_type.HOW.compose($nc_type); | |
say("Created test type"); | |
my $call := pir::nqp_native_call_build__PPsssPP($nc_type, | |
'foo.dll', 'GotValues', '', | |
nqp::list( | |
nqp::hash('type', 'int'), | |
nqp::hash('type', 'float') | |
), | |
nqp::hash('type', 'int')); | |
say("Created call...and now for invoking it..."); | |
my $i := pir::nqp_native_call__PPPP(int, $call, | |
nqp::list( | |
nqp::box_i(42, int), | |
nqp::box_n(10.12, num) | |
)); | |
say("And lived beyond call!"); | |
say("Got back " ~ nqp::unbox_i($i)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment