如何在Perl6 NativeCall结构中定义固定长度的字符串?

Dig*_*rat 7 perl6 nativecall

我有一个第三方C库,它定义了一个类似于的结构:

struct myStruct {
  int a;
  int b;
  char str1[32];
  char str2[32];
};
Run Code Online (Sandbox Code Playgroud)

还有一个函数,它接受一个指向这个结构的指针并填充它.我需要我的Perl6本机调用来提供该结构,然后读取结果.

到目前为止,我已经在Perl6中定义了结构:

class myStruct is repr('CStruct') {
  has int32 $.a;
  has int32 $.b;
  has Str $.str1; # Option A: This won't work as Perl won't know what length to allocate
  has CArray[uint8] $.str2; # Option B: This makes more sense, but again how to define length?  
                     # Also, would this allocate the array in place, or 
                     #    reference an array that is separately allocated (and therefore not valid)?
}
Run Code Online (Sandbox Code Playgroud)

和本地电话一样:

sub fillStruct(myStruct) is native('test_lib') { ... }
my $struct = myStruct.new();
fillStruct($struct); # Gives a seg fault with any variation I've tried so far

我怎样才能做到这一点?

Yve*_*reY 1

在撰写本文时,这似乎尚未得到处理。
作为解决方法,我的做法是让宏生成 32 int8,充分放置字段名称。