Hello. The current grammar for ATTR in pmc2c allows declarations of the form: <type> * varname
In the perl6multisub pmc we have the attribute candidates_sorted whose intended type is candidate_info **, having two problems: The current grammar allows a single pointer, not a pointer to a pointer. This can be easily solved. candidate_info is a struct declared in the pmc file (as typedef struct candidate_info { ... } candidate_info), then his declaration is not viewable at the point of inclusion of the generated h file. This can be solved by declaring the ATTR with type struct candidate_info instead of candidate_info, but the grammar for ATTR does not allow it. I think that allowing struct in ATTR is the simpler solution to the second problem, because the intended usage is for struct used internally in the pmc, not for his documented interface. The attached patch changes the ATTR grammar and uses the changes to clean the workarounds currently used in perl6multsub pmc. It passes all coretest on my system, both building with C or with C++. -- Salu2
Index: lib/Parrot/Pmc2c/Parser.pm =================================================================== --- lib/Parrot/Pmc2c/Parser.pm (revisión: 30584) +++ lib/Parrot/Pmc2c/Parser.pm (copia de trabajo) @@ -105,7 +105,7 @@ # type \s+ - (INTVAL|FLOATVAL|STRING\s+\*|PMC\s+\*|\w+\s+\*|Parrot_\w*) + (INTVAL|FLOATVAL|STRING\s+\*|PMC\s+\*|(?:struct\s+)?\w+\s+\*+|Parrot_\w*) # name \s* Index: languages/perl6/src/pmc/perl6multisub.pmc =================================================================== --- languages/perl6/src/pmc/perl6multisub.pmc (revisión: 30584) +++ languages/perl6/src/pmc/perl6multisub.pmc (copia de trabajo) @@ -553,7 +553,7 @@ pmclass Perl6MultiSub extends MultiSub need_ext dynpmc group perl6_group { ATTR PMC *candidates; - ATTR void *candidates_sorted; + ATTR struct candidate_info **candidates_sorted; /* @@ -618,15 +618,7 @@ /* Make sure that we have a candidate list built. */ candidate_info **candidates = NULL; PMC *unsorted; - { - /* Use an aux var to get the attribute, because of - * current problems with the declaration of - * attributes. - */ - void *aux; - GETATTR_Perl6MultiSub_candidates_sorted(interp, SELF, aux); - candidates = (candidate_info **)aux; - } + GETATTR_Perl6MultiSub_candidates_sorted(interp, SELF, candidates); GETATTR_Perl6MultiSub_candidates(interp, SELF, unsorted); if (!candidates) { candidates = sort_candidiates(interp, unsorted);