Skip to content

Instantly share code, notes, and snippets.

@jonathanstowe
Created June 25, 2015 11:00
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 jonathanstowe/27766738a215f42cbd4d to your computer and use it in GitHub Desktop.
Save jonathanstowe/27766738a215f42cbd4d to your computer and use it in GitHub Desktop.
use NativeCall;
class Foo is repr("CStruct") {
method foo(Mu:U $type, Int $a ) {
my @buff := CArray[$type].new;
my $ctype = $type ~~ Num ?? Num !! Int;
@buff[$_] = $ctype(0) for ^(10 * $a);
}
}
for ^10 {
say $_;
for (int16, int32,num64, num32 ) -> $type {
my $foo = Foo.new;
$foo.foo($type, 10.rand.Int);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment