Last active
March 4, 2019 02:43
-
-
Save salortiz/57239893265ec6d21e0527b20ed5df7a to your computer and use it in GitHub Desktop.
An example for serialize p6 CStructs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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