Skip to content
Permalink
Browse files

Make some NativeCall data structures compile time

  • Loading branch information...
lizmat committed Jan 11, 2019
1 parent e463518 commit 50e1ec33b413a720a7a5948dbacaaf1b957faa2f
Showing with 7 additions and 7 deletions.
  1. +7 −7 lib/NativeCall.pm6
@@ -5,7 +5,7 @@ use NativeCall::Types;
use NativeCall::Compiler::GNU;
use NativeCall::Compiler::MSVC;

my $repr_map := nqp::hash(
my constant $repr_map = nqp::hash(
"CArray", "carray",
"CPPStruct", "cppstruct",
"CPointer", "cpointer",
@@ -123,11 +123,15 @@ sub return_hash_for(Signature $s, &r?, :$with-typeobj, :$entry-point) {
$result
}

my $signed_ints_by_size :=
sub nativesizeof($obj) is export(:DEFAULT) {
nqp::nativecallsizeof($obj)
}

my constant $signed_ints_by_size =
nqp::list_s( "", "char", "short", "", "int", "", "", "", "longlong" );

# Gets the NCI type code to use based on a given Perl 6 type.
my $type_map := nqp::hash(
my constant $type_map = nqp::hash(
"Bool", nqp::atpos_s($signed_ints_by_size,nativesizeof(bool)),
"bool", nqp::atpos_s($signed_ints_by_size,nativesizeof(bool)),
"Callable", "callback",
@@ -683,10 +687,6 @@ multi sub nativecast($target-type, $source) is export(:DEFAULT) {
nqp::decont($target-type), nqp::decont($source));
}

sub nativesizeof($obj) is export(:DEFAULT) {
nqp::nativecallsizeof($obj)
}

sub cglobal($libname, $symbol, $target-type) is export is rw {
Proxy.new(
FETCH => -> $ {

0 comments on commit 50e1ec3

Please sign in to comment.
You can’t perform that action at this time.