[m-users.] foreign_type confusion on how to do it across modules...
Julian Fondren
jfondren at minimaltype.com
Sun Jul 14 09:12:20 AEST 2019
On 2019-07-13 17:53, emacstheviking wrote:
> In my sdl2.m module I have this code
>
> % SDL_Rect
> :- type sdl_rect.
> :- pragma foreign_type("C", sdl_rect, "SDL_Rect",
> [can_pass_as_mercury_type]).
>
> The SDL_Rect structure is perfect enough and I don't want to define
> something like:
>
> :- TYPE SDL_RECT ---> SDL_RECT(X::INT, Y::INT, W::INT, H::INT).
>
> all over the place. The compiler seems to be happy with the fact that
> when I type "sdl_rect" I will get "SDL_Rect" but in my test module I
> just can't figure out how to create an instance of it to actually pass
> atound!
Since it's abstract to Mercury, Mercury can't make instances.
Mercury can still pass four ints to a foreign_proc function that
returns an sdl_rect however.
> SDL_RENDERFILLRECT(RND, SDL_RECT(0, 50, 200, 100), !IO),
>
> So...given I have declared an abstract type "sdl_rect" which is
> SDL_Rect under the hood....I can't believe I am even asking this as I
> have a horrible feeling the answer is so
> obvious......whataver....better to ask!
>
> Thanks.
> _______________________________________________
> users mailing list
> users at lists.mercurylang.org
> https://lists.mercurylang.org/listinfo/users
More information about the users
mailing list