> Would some kind soul please explain to me what is going on line by line with > the "class" statement. > cupsGetDests definition can be found at: https://www.cups.org/doc/cupspm.html
The point of the class is to create a "template" in raku matching the C structure of the cups stuct. That way, when passed to "nativecall" https://docs.raku.org/routine/nativecast it can use that template to understand what the pointer is pointing to (i.e. the cups cstruct). my $dest = nativecast(CupsDest, Pointer.new($ptr + $i * nativesizeof(CupsDest))); The "nativesizeof" gives the size of the struct, so the $ptr + $i * nativesizeof(CupsDest) moves the new Pointer down the list one struct at a time. ________________________________ From: ToddAndMargo via perl6-users <perl6-us...@perl.org> Sent: Monday, December 7, 2020 10:36 PM To: perl6-users <perl6-us...@perl.org> Subject: Need help understand "class" CAUTION - EXTERNAL: Hi All, In the following piece of code: use NativeCall; class CupsDest is repr('CStruct') { has Str $.name; has Str $.instance; has int32 $.is-default; has Pointer $.options; } sub cupsGetDests(Pointer is rw --> int32) is native('cups', v2) {} Would some kind soul please explain to me what is going on line by line with the "class" statement. cupsGetDests definition can be found at: https://www.cups.org/doc/cupspm.html I am confused. Yes, again. -T CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise caution when opening attachments or clicking on links.