Front page | perl.perl6.users |
Postings from May 2020
Re: NativeCall questions
Thread Previous
|
Thread Next
From:
David Santiago
Date:
May 8, 2020 15:15
Subject:
Re: NativeCall questions
Message ID:
CAO5X0j6xYX-VCLVbqm_rKpQGUXjdsbzJRev9dh49FzAoff_txg@mail.gmail.com
I also noticed that although my data string is defined as
CArray[uint8], when i loop through the array, the values are signed
ints:
say $_ for $ed.data[0..10];
output:
-98
-110
-109
-99
74
-109
-99
74
-105
-93
74
Is it possible to not "sign" them?
Regards,
David Santiago
Curt Tilmes <curt@tilmes.org> escreveu no dia sexta, 8/05/2020 à(s) 12:56:
>
> On Fri, May 8, 2020 at 8:49 AM David Santiago <demanuel@gmail.com> wrote:
>
> > EncodedData* ed = malloc(sizeof(EncodedData));
> > ed->data = encbuffer;
> > ed->crc32 = crc32;
> > return ed;
>
> You're returning a pointer to encbuffer -- make sure the storage for
> that is kept around
> somewhere. If it is passed in from Raku, you'll be fine as long as
> you hold on to the
> object on that side. Otherwise you might need to allocate/copy it to make sure.
>
> > class EncodedData is repr('CStruct') {
> > has CArray[uint8] $.data;
> > has uint32 $.crc32;
> > }
>
> That's fine, but CArray[uint8] is just a pointer -- it doesn't know
> how long the array
> it is pointing to is. It either needs a sentinel at the end (like the
> Nul at the end of a
> C string), or a separate field with a size to figure that out.
>
> > Don't know how many elements a C array returned from a library
>
> yep
>
> Curt
Thread Previous
|
Thread Next