~sircmpwn/hare-users

2 2

Re: question how to create and interact with C's array of pointers

Details
Message ID
<CADa827HDmS1iGevuDoa594AfyNhZaesd9XDUxWHH5rxMUzoCLg@mail.gmail.com>
DKIM signature
pass
Download raw message
The function was `LoadWEBPAnimation_RW` from sdl2_image. I need to
iterate through the `frames` field in the `IMG_Animation` struct,
which is `**SDL_Surface` and convert it to texture for later on to be
rendered.
I think the problem is solved. C's `**opaque` (array of pointers)
translates to `*[*]*opaque` instead of `[*]opaque`. Although I haven't
try my actual code.
B

Re: question how to create and interact with C's array of pointers

Details
Message ID
<ZggjQkiLYRvSFUzS@fluorine>
In-Reply-To
<CADa827HDmS1iGevuDoa594AfyNhZaesd9XDUxWHH5rxMUzoCLg@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
Quoth Abdul Wahab:
>The function was `LoadWEBPAnimation_RW` from sdl2_image. I need to
>iterate through the `frames` field in the `IMG_Animation` struct,
>which is `**SDL_Surface` and convert it to texture for later on to be
>rendered.
>I think the problem is solved. C's `**opaque` (array of pointers)
>translates to `*[*]*opaque` instead of `[*]opaque`. Although I haven't
>try my actual code.
>B

Note that in C, a pointer to void is incompatible with a pointer 
to SDL_Surface.  For example, a pointer to void may be larger than 
a pointer to SDL_Surface.  For you, that means that it’d be better 
to represent a C SDL_Surface** not as *[*]*opaque in Hare, but as 
*[*]*SDL_Surface with a definition of SDL_Surface that is 
compatible to C’s SDL_Surface.

Re: question how to create and interact with C's array of pointers

Details
Message ID
<096abd93-ad61-489a-9911-8cb107e0ce90@spxtr.net>
In-Reply-To
<ZggjQkiLYRvSFUzS@fluorine> (view parent)
DKIM signature
pass
Download raw message
IMG_Animations have a count along with the **SDL_Surface, so if you want 
you can make a types::slice with data set to the **SDL_Surface and 
length and cap set to the count, then cast to []*SDL_Surface. Then you 
get bounds checking.
Reply to thread Export thread (mbox)