mirror of
https://github.com/pevans/erc-c.git
synced 2024-10-03 22:54:42 +00:00
Make vm_area_set be an inline function.
Gets most of the benefits of being a macro, but also gains type safety (which macros do not have).
This commit is contained in:
parent
30223e0bca
commit
6a230341e1
@ -45,13 +45,8 @@ typedef struct {
|
||||
SDL_Rect name; \
|
||||
SET_SDL_RECT(name, a)
|
||||
|
||||
#define vm_area_set(a, x, y, w, h) \
|
||||
(a)->xoff = x; \
|
||||
(a)->yoff = y; \
|
||||
(a)->width = w; \
|
||||
(a)->height = h
|
||||
|
||||
extern bool vm_screen_active(vm_screen *);
|
||||
extern void vm_area_set(vm_area *, int, int, int, int);
|
||||
extern int vm_screen_add_window(vm_screen *, int, int);
|
||||
extern int vm_screen_init();
|
||||
extern int vm_screen_xcoords(vm_screen *);
|
||||
|
@ -211,3 +211,12 @@ vm_screen_draw_rect(vm_screen *screen, vm_area *area)
|
||||
|
||||
SDL_RenderFillRect(screen->render, &rect);
|
||||
}
|
||||
|
||||
inline void
|
||||
vm_area_set(vm_area *area, int xoff, int yoff, int width, int height)
|
||||
{
|
||||
area->xoff = xoff;
|
||||
area->yoff = yoff;
|
||||
area->width = width;
|
||||
area->height = height;
|
||||
}
|
||||
|
@ -52,3 +52,14 @@ Test(vm_screen, ycoords)
|
||||
screen->ycoords = 234;
|
||||
cr_assert_eq(screen->ycoords, 234);
|
||||
}
|
||||
|
||||
Test(vm_screen, area_set)
|
||||
{
|
||||
vm_area area;
|
||||
|
||||
vm_area_set(&area, 1, 2, 3, 4);
|
||||
cr_assert_eq(area.xoff, 1);
|
||||
cr_assert_eq(area.yoff, 2);
|
||||
cr_assert_eq(area.width, 3);
|
||||
cr_assert_eq(area.height, 4);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user