83 lines
3.1 KiB
C
83 lines
3.1 KiB
C
// 19 april 2019
|
|
#include <errno.h>
|
|
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "ui.h"
|
|
#ifdef uiprivOSHeader
|
|
#include uiprivOSHeader
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// TODO figure out why this is needed despite what https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/b0084kay(v=vs.120) says
|
|
#ifdef _MSC_VER
|
|
#define uiprivFunc __FUNCTION__
|
|
#else
|
|
#define uiprivFunc __func__
|
|
#endif
|
|
|
|
// TODO {
|
|
// WHY IS THIS NEEDED?!?!?!?!!?!??!Q https://stackoverflow.com/questions/15610053/correct-printf-format-specifier-for-size-t-zu-or-iu SAYS THAT VS2013 DOES SUPPORT %zu
|
|
// AND WHY IS MINGW AFFECTED?!?!?!?!
|
|
// Oh and even better: the -Wno-pedantic-ms-printf stuff doesn't result in a warning about this either...
|
|
// }
|
|
#ifdef _WIN32
|
|
#define uiprivSizetPrintf "Iu"
|
|
#else
|
|
#define uiprivSizetPrintf "zu"
|
|
#endif
|
|
|
|
#include "../sharedbits/printfwarn_header.h"
|
|
#define uiprivPrintfFunc(decl, fmtpos, appos) sharedbitsPrintfFunc(decl, fmtpos, appos)
|
|
|
|
// main.c
|
|
extern bool uiprivSysInit(void *options, uiInitError *err);
|
|
uiprivPrintfFunc(
|
|
extern bool uiprivInitReturnErrorf(uiInitError *err, const char *fmt, ...),
|
|
2, 3);
|
|
extern void uiprivSysQueueMain(void (*f)(void *data), void *data);
|
|
extern bool uiprivCheckInitializedAndThreadImpl(const char *func);
|
|
#define uiprivCheckInitializedAndThread() uiprivCheckInitializedAndThreadImpl(uiprivFunc)
|
|
extern bool uiprivSysCheckThread(void);
|
|
|
|
// alloc.c
|
|
#define sharedbitsPrefix uipriv
|
|
// TODO determine if we need the ../ or not, and if not, figure out if we should use it everywhere (including ui.h) or not
|
|
#include "../sharedbits/alloc_header.h"
|
|
#include "../sharedbits/array_header.h"
|
|
#define uiprivArrayStaticInit(T, grow, whatstr) { NULL, 0, 0, sizeof (T), grow, whatstr }
|
|
#define uiprivArrayInit(arr, T, nGrow, what) uiprivArrayInitFull(&(arr), sizeof (T), nGrow, what)
|
|
#define uiprivArrayFree(arr) uiprivArrayFreeFull(&(arr))
|
|
#define uiprivArrayAt(arr, T, n) (((T *) (arr.buf)) + (n))
|
|
#include "../sharedbits/strsafe_header.h"
|
|
#undef sharedbitsPrefix
|
|
|
|
// errors.c
|
|
uiprivPrintfFunc(
|
|
extern void uiprivInternalError(const char *fmt, ...),
|
|
1, 2);
|
|
enum {
|
|
uiprivProgrammerErrorNotInitialized, // arguments: uiprivFunc
|
|
uiprivProgrammerErrorWrongThread, // arguments: uiprivFunc
|
|
uiprivProgrammerErrorWrongStructSize, // arguments: size_t badSize, const char *structName
|
|
uiprivProgrammerErrorIndexOutOfRange, // arguments: int badIndex, uiprivFunc
|
|
uiprivProgrammerErrorNullPointer, // arguments: const char *paramDesc, uiprivFunc
|
|
uiprivProgrammerErrorIntIDNotFound, // arguments: const char *idDesc, int badID, uiprivFunc
|
|
// TODO type mismatch
|
|
uiprivProgrammerErrorBadSenderForEvent, // arguments: const char *senderDesc, const char *eventDesc, uiprivFunc
|
|
uiprivProgrammerErrorChangingEventDuringFire, // arguments: uiprivFunc
|
|
uiprivProgrammerErrorRecursiveEventFire, // no arguments
|
|
uiprivNumProgrammerErrors,
|
|
};
|
|
// TODO drop the enum and make the above all format strings
|
|
extern void uiprivProgrammerError(unsigned int which, ...);
|
|
extern void uiprivReportError(const char *prefix, const char *msg, const char *suffix, bool internal);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|