Skip to content

Instantly share code, notes, and snippets.

@gerdr

gerdr/test.nqp Secret

Last active December 24, 2015 00:19
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 gerdr/627e5508d69920e6e3aa to your computer and use it in GitHub Desktop.
Save gerdr/627e5508d69920e6e3aa to your computer and use it in GitHub Desktop.
my $ldtype := nqp::newtype(NQPMu, 'CScalar');
nqp::composetype($ldtype, 'CLDouble');
my $coltype := nqp::newtype(NQPMu, 'CArray');
nqp::composetype($coltype, [$ldtype, 4]);
my $mattype := nqp::newtype(NQPMu, 'CArray');
nqp::composetype($mattype, [$coltype, 4]);
say(nqp::csizeof($mattype));
my $ptr := nqp::bloballoc(nqp::csizeof($mattype));
my $arr := nqp::ptrcast($ptr, $mattype, 0);
my $i := 0;
while $i < 4 {
my $j := 0;
my $col := $arr[$i];
while $j < 4 {
nqp::bindpos_n($col, $j, ($i + 1) * 10 + ($j + 1) + 0.5);
$j := $j + 1;
}
$i := $i + 1;
}
$i := 0;
while $i < 4 {
my $j := 0;
my $col := $arr[$i];
while $j < 4 {
print(nqp::atpos_n($col, $j) ~ ' ');
$j := $j + 1;
}
print("\n");
$i := $i + 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment