Front page | perl.perl6.users |
Postings from May 2020
Re: NativeCall questions
Thread Previous
|
Thread Next
From:
David Santiago
Date:
May 8, 2020 12:49
Subject:
Re: NativeCall questions
Message ID:
CAO5X0j54P19DebLybW0QGn=U1e0rzZ+_JfvZGcXTV-CwLyN58w@mail.gmail.com
Thanks for the help.
> EncodedData *encode(unsigned char* data, size_t data_size)
> and return &ed.
> Also your struct and CStruct are defining the contents in the reverse
> order. They must
> match up exactly.
>
I did those two changes:
"""
EncodedData* ed = malloc(sizeof(EncodedData));
ed->data = encbuffer;
ed->crc32 = crc32;
return ed;
"""
And i also changed the CStruct [1] to:
class EncodedData is repr('CStruct') {
has CArray[uint8] $.data;
has uint32 $.crc32;
}
I'm not getting a SIGSEGV anymore, however i'm now getting the
following error when trying to "say $_ for $ed.data.list":
Don't know how many elements a C array returned from a library
in method elems at
/usr/share/perl6/core/sources/8660F65A7B3492675BB3B2058DB30E411A4C4E54
(NativeCall::Types) line 223
in method list at
/usr/share/perl6/core/sources/8660F65A7B3492675BB3B2058DB30E411A4C4E54
(NativeCall::Types) line 226
in sub MAIN at bin/uints.p6 line 15
in block <unit> at bin/uints.p6 line 3
I can access without problems $ed.crc32
[1] - if i change the data type to str i get the error: "String
corruption detected: bad storage type"
Best regards,
David Santiago
Thread Previous
|
Thread Next