On Tue, Dec 8, 2020 at 7:05 PM ToddAndMargo via perl6-users
<perl6-us...@perl.org> wrote:
> I guess what I am missing is how
>
> int cupsEnumDests(unsigned flags, int msec, int *cancel, cups_ptype_t
> type, cups_ptype_t mask, cups_dest_cb_t cb, void *user_data);
>
> matches up with
>
>   class CupsDest is repr('CStruct') {
>         has Str $.name;
>         has Str $.instance;
>         has int32 $.is-default;
>         has Pointer $.options;
>   }
>
>
> I also do not understand what the dot is doing in "$.name".

class CupsDest in Raku matches up with C's cups_dest_t
(see cups.h for its definition)

See https://docs.raku.org/language/nativecall#Structs
(or today's Raku Advent article:
https://raku-advent.blog/2020/12/09/day-11-getting-windows-memory-usage-with-nativecall/)

Also see https://docs.raku.org/language/classtut to understand "$.name"

(Although as I look at it again, it looks wrong -- there should be an
additional "has int32 $.num-options" between the $.is-default line and
the $.options line".  I think the only reason it works is padding
leaving an extra four bytes after the first int32 which just happens
to work.  I'll go correct that on stack overflow and suggest you take
a look at it and do the same to your entry.)

Curt

Reply via email to