Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make NQP nativecall tests robust on Win32.
At least, with MSVC. If we don't find standard C symbols, fall back to
explicitly looking in the C library.
  • Loading branch information
jnthn committed Mar 12, 2014
1 parent 3ebb27f commit 2d19f41
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions t/nativecall/01-basic.t
Expand Up @@ -47,15 +47,19 @@ BEGIN {
class Call is repr('NativeCall') { }
class CPointer is repr('CPointer') { }

#my $printf := nqp::create(Call);
my $printf := Call.new;
$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);
try {
nqp::buildnativecall($printf, '', 'printf', '', [$arg_hash], $return_hash);
CATCH {
nqp::buildnativecall($printf, 'msvcrt.dll', 'printf', '', [$arg_hash], $return_hash);
}
}
nqp::nativecall(nqp::null(), $printf, ["ok - printf\n"]);

my $strdup := nqp::create(Call);
Expand All @@ -68,7 +72,7 @@ $return_hash<type> := 'cpointer';
try {
nqp::buildnativecall($strdup, '', 'strdup', '', [$arg_hash], $return_hash);
CATCH {
nqp::buildnativecall($strdup, '', '_strdup', '', [$arg_hash], $return_hash);
nqp::buildnativecall($strdup, 'msvcrt.dll', '_strdup', '', [$arg_hash], $return_hash);
}
}
my $dupped := nqp::nativecall(CPointer, $strdup, ["ok - passing cpointer\n"]);
Expand All @@ -80,7 +84,12 @@ $arg_hash<type> := 'cpointer';
$return_hash := nqp::hash();
$return_hash<type> := 'void';

nqp::buildnativecall($printf, '', 'printf', '', [$arg_hash], $return_hash);
try {
nqp::buildnativecall($printf, '', 'printf', '', [$arg_hash], $return_hash);
CATCH {
nqp::buildnativecall($printf, 'msvcrt.dll', 'printf', '', [$arg_hash], $return_hash);
}
}
nqp::nativecall(nqp::null(), $printf, [$dupped]);

# vim: ft=perl6

0 comments on commit 2d19f41

Please sign in to comment.