diff --git a/darwin/control.m b/darwin/controls.m similarity index 100% rename from darwin/control.m rename to darwin/controls.m diff --git a/darwin/meson.build b/darwin/meson.build index 3114c536..a4a18d42 100644 --- a/darwin/meson.build +++ b/darwin/meson.build @@ -1,7 +1,7 @@ # 23 march 2019 libui_sources += [ - 'darwin/control.m', + 'darwin/controls.m', 'darwin/main.m', ] diff --git a/test/controls.c b/test/controls.c index 9d359887..1c11a613 100644 --- a/test/controls.c +++ b/test/controls.c @@ -17,8 +17,13 @@ static void testVtableFree(uiControl *c, void *implData) // do nothing } -const uiControlVtable testVtable = { +static const uiControlVtable vtable = { .Size = sizeof (uiControlVtable), .Init = testVtableInit, .Free = testVtableFree, }; + +const uiControlVtable *testVtable(void) +{ + return &vtable; +} diff --git a/test/controls_darwin.m b/test/controls_darwin.m index 69fc91a0..3027082e 100644 --- a/test/controls_darwin.m +++ b/test/controls_darwin.m @@ -1,14 +1,11 @@ // 10 june 2019 #import "test_darwin.h" -uiControlOSVtable *allocOSVtableFull(testingT *t, const char *file, long line) -{ - uiControlOSVtable *v; +static const uiControlOSVtable vtable = { + .Size = sizeof (uiControlOSVtable), +}; - v = (uiControlOSVtable *) malloc(sizeof (uiControlOSVtable)); - if (v == NULL) - testingTFatalfFull(t, file, line, "memory exhausted allocating uiControlOSVtable"); - memset(v, 0, sizeof (uiControlOSVtable)); - v->Size = sizeof (uiControlOSVtable); - return v; +const uiControlOSVtable *testOSVtable(void) +{ + return &vtable; } diff --git a/test/controls_errors.cpp b/test/controls_errors.cpp index 41e866f6..9923a0dc 100644 --- a/test/controls_errors.cpp +++ b/test/controls_errors.cpp @@ -31,7 +31,7 @@ static const struct checkErrorCase cases[] = { { "uiRegisterControlType() with NULL OS vtable", [](void) { - uiRegisterControlType("name", &testVtable, NULL, 0); + uiRegisterControlType("name", testVtable(), NULL, 0); }, "uiRegisterControlType(): invalid null pointer for uiControlOSVtable", }, diff --git a/test/meson.build b/test/meson.build index a96978af..5b5e2fa9 100644 --- a/test/meson.build +++ b/test/meson.build @@ -17,7 +17,7 @@ if libui_OS == 'windows' ] elif libui_OS == 'darwin' libui_test_sources += [ -# 'controls_darwin.m', + 'controls_darwin.m', ] else libui_test_sources += [ diff --git a/test/test.h b/test/test.h index 7a30687d..69ebe1ed 100644 --- a/test/test.h +++ b/test/test.h @@ -50,9 +50,8 @@ extern void checkProgrammerErrorsFull(testingT *t, const char *file, long line, #define checkProgrammerErrorsInThread(t, cases) checkProgrammerErrorsFull(t, __FILE__, __LINE__, cases, true) // controls.c -extern const uiControlVtable testVtable; -extern uiControlOSVtable *allocOSVtableFull(testingT *t, const char *file, long line); -#define allocOSVtable(t) allocOSVtableFull(t, __FILE__, __LINE__) +extern const uiControlVtable *testVtable(void); +extern const uiControlOSVtable *testOSVtable(void); #ifdef __cplusplus }