Skip to content

Instantly share code, notes, and snippets.

@gerdr

gerdr/test.nqp Secret

Last active December 24, 2015 01:59
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/c59d0365251bdec34fa6 to your computer and use it in GitHub Desktop.
Save gerdr/c59d0365251bdec34fa6 to your computer and use it in GitHub Desktop.
my $UInt32 := nqp::newtype(NQPMu, 'CScalar');
nqp::composetype($UInt32, 'CUInt32');
my $UInt16 := nqp::newtype(NQPMu, 'CScalar');
nqp::composetype($UInt16, 'CUInt16');
#my $Ptr := nqp::newtype(NQPMu, 'CPtr');
my $Collectable := nqp::newtype(NQPMu, 'CStruct');
nqp::composetype($Collectable, [
$UInt32, 'owner',
$UInt16, 'flags',
$UInt16, 'size',
# $Ptr, 'forwarder',
# $Ptr, 'sc'
]);
my $ptrtype := nqp::newtype(NQPMu, 'VMPtr');
# unsafe if $obj can move
my $obj := NQPMu;
my $ptr := nqp::box_i(nqp::where($obj), $ptrtype);
my $struct := nqp::ptrcast($ptr, $Collectable, 0);
say(nqp::getattr_i($struct, NQPMu, 'owner'));
say(nqp::getattr_i($struct, NQPMu, 'flags'));
say(nqp::getattr_i($struct, NQPMu, 'size'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment