Added uiOnShouldQuit() and its common code.

This commit is contained in:
Pietro Gagliardi 2015-05-09 09:50:23 -04:00
parent 3d714e03c1
commit c395cdd2fd
4 changed files with 28 additions and 0 deletions

View File

@ -25,6 +25,7 @@ baseHFILES = \
baseCFILES = \
box.c \
ptrarray.c \
shouldquit.c \
$(osCFILES)
baseMFILES = $(osMFILES)

22
shouldquit.c Normal file
View File

@ -0,0 +1,22 @@
// 9 may 2015
#include "ui.h"
#include "uipriv.h"
static int defaultOnShouldQuit(void *data)
{
return 0;
}
static int (*onShouldQuit)(void *) = defaultOnShouldQuit;
static void *onShouldQuitData;
void uiOnShouldQuit(int (*f)(void *), void *data)
{
onShouldQuit = f;
onShouldQuitData = data;
}
int shouldQuit(void)
{
return (*onShouldQuit)(onShouldQuitData);
}

2
ui.idl
View File

@ -24,6 +24,8 @@ func FreeInitError(err *const char);
func Main(void);
func Quit(void);
func OnShouldQuit(f *func(data *void) int, data *void);
func FreeText(text *char);
raw "typedef struct uiSizingSys uiSizingSys;";

View File

@ -27,3 +27,6 @@ void ptrArrayAppend(struct ptrArray *, void *);
void ptrArrayInsertBefore(struct ptrArray *, uintmax_t, void *);
void ptrArrayDelete(struct ptrArray *, uintmax_t);
#define ptrArrayIndex(p, T, i) ((T) ((p)->ptrs[(i)]))
// shouldquit.c
int shouldQuit(void);