Turned testVtable into a function that returned the pointer to use, made the OSVtable equivalent likewise, and renamed darwin/control.m to darwin/controls.m.

This commit is contained in:
Pietro Gagliardi 2019-06-15 21:33:53 -04:00
parent c1d8c0f5ec
commit 0550e4bc00
7 changed files with 17 additions and 16 deletions

View File

@ -1,7 +1,7 @@
# 23 march 2019 # 23 march 2019
libui_sources += [ libui_sources += [
'darwin/control.m', 'darwin/controls.m',
'darwin/main.m', 'darwin/main.m',
] ]

View File

@ -17,8 +17,13 @@ static void testVtableFree(uiControl *c, void *implData)
// do nothing // do nothing
} }
const uiControlVtable testVtable = { static const uiControlVtable vtable = {
.Size = sizeof (uiControlVtable), .Size = sizeof (uiControlVtable),
.Init = testVtableInit, .Init = testVtableInit,
.Free = testVtableFree, .Free = testVtableFree,
}; };
const uiControlVtable *testVtable(void)
{
return &vtable;
}

View File

@ -1,14 +1,11 @@
// 10 june 2019 // 10 june 2019
#import "test_darwin.h" #import "test_darwin.h"
uiControlOSVtable *allocOSVtableFull(testingT *t, const char *file, long line) static const uiControlOSVtable vtable = {
{ .Size = sizeof (uiControlOSVtable),
uiControlOSVtable *v; };
v = (uiControlOSVtable *) malloc(sizeof (uiControlOSVtable)); const uiControlOSVtable *testOSVtable(void)
if (v == NULL) {
testingTFatalfFull(t, file, line, "memory exhausted allocating uiControlOSVtable"); return &vtable;
memset(v, 0, sizeof (uiControlOSVtable));
v->Size = sizeof (uiControlOSVtable);
return v;
} }

View File

@ -31,7 +31,7 @@ static const struct checkErrorCase cases[] = {
{ {
"uiRegisterControlType() with NULL OS vtable", "uiRegisterControlType() with NULL OS vtable",
[](void) { [](void) {
uiRegisterControlType("name", &testVtable, NULL, 0); uiRegisterControlType("name", testVtable(), NULL, 0);
}, },
"uiRegisterControlType(): invalid null pointer for uiControlOSVtable", "uiRegisterControlType(): invalid null pointer for uiControlOSVtable",
}, },

View File

@ -17,7 +17,7 @@ if libui_OS == 'windows'
] ]
elif libui_OS == 'darwin' elif libui_OS == 'darwin'
libui_test_sources += [ libui_test_sources += [
# 'controls_darwin.m', 'controls_darwin.m',
] ]
else else
libui_test_sources += [ libui_test_sources += [

View File

@ -50,9 +50,8 @@ extern void checkProgrammerErrorsFull(testingT *t, const char *file, long line,
#define checkProgrammerErrorsInThread(t, cases) checkProgrammerErrorsFull(t, __FILE__, __LINE__, cases, true) #define checkProgrammerErrorsInThread(t, cases) checkProgrammerErrorsFull(t, __FILE__, __LINE__, cases, true)
// controls.c // controls.c
extern const uiControlVtable testVtable; extern const uiControlVtable *testVtable(void);
extern uiControlOSVtable *allocOSVtableFull(testingT *t, const char *file, long line); extern const uiControlOSVtable *testOSVtable(void);
#define allocOSVtable(t) allocOSVtableFull(t, __FILE__, __LINE__)
#ifdef __cplusplus #ifdef __cplusplus
} }