raku-community-modules / GD

Raku interface to the Gd graphics library.
Artistic License 2.0
2 stars 6 forks source link

Type check failing in GD_add_point #4

Closed Von-Cheam closed 4 years ago

Von-Cheam commented 8 years ago

Pasted from terminal:

$ perl6 polygon.p6 Type check failed in binding $points; expected NativeCall::Types::CArray[int32] but got NativeCall::Types::Pointer (NativeCall::Types::Po...) in sub GD_add_point at /home/voncheam/.rakudobrew/moar-nom/install/share/perl6/site/sources/894D6853DEA03D7571570DE5657C77B44849BD2E (GD) line 29 in method polygon at /home/voncheam/.rakudobrew/moar-nom/install/share/perl6/site/sources/894D6853DEA03D7571570DE5657C77B44849BD2E (GD) line 198 in block <unit> at polygon.p6 line 30

Looks as though sub GD_add_point gets $points created by sub GD_new_set_of_points, which creates $points by calling sub malloc, which returns an OpaquePointer rather than a CArray.

I've tried tinkering a little bit with the typing and so on, but I can't seem to make it work. (I'm not much of a programmer, to be honest, and most of the code is over my head!)

Happy to give any further information or do anything as necessary, if directed, though.

jonathanstowe commented 4 years ago

4 YEARS LATER.

I've fixed this but I think that in reality it might be better to sort it out once and for all in #8 and avoid the use of OpaquePointer at all where some suitable more specific type is available, it's not actually necessary to use malloc to create a block of memory of known size (and I can't remember if it was when this was raised.)