Created
September 3, 2013 19:24
-
-
Save arnsholt/6428396 to your computer and use it in GitHub Desktop.
NativeCall weirdness
This file contains 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
plan(1); | |
my $arg_hash; | |
my $return_hash; | |
class Call is repr('NativeCall') { } | |
class CPointer is repr('CPointer') { } | |
my $printf := nqp::create(Call); | |
$arg_hash := nqp::hash(); | |
$arg_hash<type> := 'utf8str'; | |
$arg_hash<free_str> := 1; | |
$return_hash := nqp::hash(); | |
$return_hash<type> := 'void'; | |
nqp::buildnativecall($printf, '', 'printf', '', [$arg_hash], $return_hash); | |
nqp::nativecall(nqp::null(), $printf, ["ok 1 - printf\n"]); | |
my $strdup := nqp::create(Call); | |
$arg_hash := nqp::hash(); | |
$arg_hash<type> := 'utf8str'; | |
$arg_hash<free_str> := 1; | |
$return_hash := nqp::hash(); | |
$return_hash<type> := 'cpointer'; | |
nqp::buildnativecall($strdup, '', 'strdup', '', [$arg_hash], $return_hash); | |
my $dupped := nqp::nativecall(CPointer, $strdup, ["ok 3 - passing cpointer"]); | |
ok(1, "function returning cpointer"); | |
my $ptrprint := nqp::create(Call); | |
$arg_hash := nqp::hash(); | |
$arg_hash<type> := 'cpointer'; | |
$return_hash := nqp::hash(); | |
$return_hash<type> := 'void'; | |
nqp::buildnativecall($printf, '', 'printf', '', [$arg_hash], $return_hash); | |
nqp::nativecall(nqp::null(), $printf, [$dupped]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment