Skip to content

Instantly share code, notes, and snippets.

@salortiz
Last active March 4, 2019 02:43
Show Gist options
  • Save salortiz/57239893265ec6d21e0527b20ed5df7a to your computer and use it in GitHub Desktop.
Save salortiz/57239893265ec6d21e0527b20ed5df7a to your computer and use it in GitHub Desktop.
An example for serialize p6 CStructs
use NativeHelpers::CStruct;
use NativeHelpers::Blob;
use NativeCall;
class Msg is repr<CStruct> { has uint16 $.bla is rw};
my $la = LinearArray[Msg].new(3);
$la[0].bla = 179;
$la[1] = Msg.new(:73bla);
$la[2].bla = 105;
say utf8-from-pointer($la.Pointer, $la.nativesizeof);
my $m = Msg.new(:10bla);
say utf8-from-pointer(pointer-to($m), nativesizeof($m));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment