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
libui_sources += [
'darwin/control.m',
'darwin/controls.m',
'darwin/main.m',
]

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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",
},

View File

@ -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 += [

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)
// 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
}