Skip to content

Instantly share code, notes, and snippets.

@FROGGS
Created March 16, 2015 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FROGGS/e3ec8bf0baf70458f6f3 to your computer and use it in GitHub Desktop.
Save FROGGS/e3ec8bf0baf70458f6f3 to your computer and use it in GitHub Desktop.
diff --git a/lib/NativeCall.pm b/lib/NativeCall.pm
index 24912ad..99a610e 100644
--- a/lib/NativeCall.pm
+++ b/lib/NativeCall.pm
@@ -183,7 +183,17 @@ my role Native[Routine $r, Str $libname] {
$!setup = 1;
$!rettype := nqp::decont(map_return_type($r.returns));
}
- nqp::nativecall($!rettype, self, nqp::getattr(nqp::decont(args), Capture, '$!list'))
+
+ my Mu $args := nqp::getattr(nqp::decont(args), Capture, '$!list');
+ if nqp::elems($args) != $r.signature.arity {
+ X::TypeCheck::Argument.new(
+ :objname($.name),
+ :arguments(nqp::p6list($args, Array, Mu).map(*.^name))
+ :signature(" Expected: " ~ try $r.signature.perl),
+ ).throw
+ }
+
+ nqp::nativecall($!rettype, self, $args)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment