Re: NativeCall questions

2020-05-08 Thread David Santiago
Thanks for the information! Have a great weekend! Best regards, David Santiago Tobias Boege escreveu no dia sexta, 8/05/2020 à(s) 15:52: > > On Fri, 08 May 2020, David Santiago wrote: > > I also noticed that although my data string is defined as > > CArray[uint8], when i loop through the

Re: NativeCall questions

2020-05-08 Thread Tobias Boege
On Fri, 08 May 2020, David Santiago wrote: > 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 There is an old open bug report about this:

Re: NativeCall questions

2020-05-08 Thread David Santiago
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

Re: NativeCall questions

2020-05-08 Thread Curt Tilmes
On Fri, May 8, 2020 at 8:49 AM David Santiago 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,

Re: NativeCall questions

2020-05-08 Thread David Santiago
Thanks for the help. > EncodedData *encode(unsigned char* data, size_t data_size) > and return > 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

Re: NativeCall questions

2020-05-08 Thread Curt Tilmes
On Fri, May 8, 2020 at 6:44 AM David Santiago wrote: > > I'm porting some personal perl5 scripts to Raku, and one of those > scripts is using Inline::C. > [...] > Why? How do i fix it? I haven't tried all of this, but the first thing that leaps out is that repr('CStruct') is not a struct -- it

Re: NativeCall questions

2020-05-08 Thread Timo Paulssen
Hi David, the first thing that catches my eye is that your struct and the class have the members switched around, so you're already almost guaranteed to read a bogus pointer when trying to get the data. Also, please note that returning structs directly, or passing structs directly, as arguments

NativeCall questions

2020-05-08 Thread David Santiago
Hello, I'm porting some personal perl5 scripts to Raku, and one of those scripts is using Inline::C. The inline::c code would contain a function with the signature: AV* encode(unsigned char* data, size_t data_size) Description of the parameters on the original perl script: data -> binary