Is there any way to declare an array of objects inside a CStruct?
struct my_struct {
int foo;
int bar;
char somestring[80];
};
class My::Struct is repr('CStruct') {
has int32 $.foo;
has int32 $.bar;
???
}
A CArray[uint8]
would be a char *
pointer, not actually reserving space inside the struct.
Instead of My::Struct.new
, I could probably make the memory myself (instead of My::Struct.new()
, I use a buf8.allocate(xxx)
and keep a handle so the GC doesn't reap it, nativecast
it to My::Struct), then I have to use pointer math to find the string inside the struct, etc. but it seems like there should be an easier way.
Even if it wasn't fully implemented, a simple way to say "Put 80 bytes here and here's a Pointer to it" would be very nice.
Here is my ugly work-around: