2019-04-19 11:32:13 -05:00
// 19 april 2019
2019-04-21 14:08:09 -05:00
# ifdef __cplusplus
extern " C " {
# endif
2019-05-27 10:02:23 -05:00
// 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
2019-05-27 10:18:05 -05:00
// 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
2019-05-27 10:36:59 -05:00
// TODO AND WHY IS MINGW AFFECTED?!?!?!?!
# ifdef _WIN32
2019-05-27 10:18:05 -05:00
# define uiprivSizetPrintf "Iu"
# else
# define uiprivSizetPrintf "zu"
# endif
2019-04-19 11:32:13 -05:00
// init.c
2019-05-09 11:07:28 -05:00
extern const char * * uiprivSysInitErrors ( void ) ;
extern int uiprivSysInit ( void * options , uiInitError * err ) ;
2019-04-19 11:32:13 -05:00
extern int uiprivInitReturnError ( uiInitError * err , const char * msg ) ;
2019-04-21 13:49:16 -05:00
extern int uiprivInitReturnErrorf ( uiInitError * err , const char * msg , . . . ) ;
2019-05-28 20:54:13 -05:00
extern bool uiprivCheckInitializedAndThreadImpl ( const char * func ) ;
# define uiprivCheckInitializedAndThread() uiprivCheckInitializedAndThreadImpl(uiprivFunc)
extern bool uiprivSysCheckThread ( void ) ;
2019-04-21 14:08:09 -05:00
2019-05-16 22:02:03 -05:00
// alloc.c
extern void * uiprivAlloc ( size_t n , const char * what ) ;
2019-05-27 10:02:23 -05:00
extern void * uiprivRealloc ( void * p , size_t nOld , size_t nNew , const char * what ) ;
2019-05-16 22:02:03 -05:00
extern void uiprivFree ( void * p ) ;
2019-05-19 11:52:06 -05:00
typedef struct uiprivArray uiprivArray ;
struct uiprivArray {
void * buf ;
size_t len ;
size_t cap ;
size_t elemsize ;
size_t nGrow ;
const char * what ;
} ;
2019-05-19 17:06:58 -05:00
# define uiprivArrayStaticInit(T, grow, whatstr) { NULL, 0, 0, sizeof (T), grow, whatstr }
2019-05-19 13:37:32 -05:00
# define uiprivArrayInit(arr, T, grow, whatstr) \
memset ( & ( arr ) , 0 , sizeof ( uiprivArray ) ) ; \
2019-05-19 11:52:06 -05:00
arr . elemsize = sizeof ( T ) ; \
arr . nGrow = grow ; \
2019-05-19 13:37:32 -05:00
arr . what = whatstr ;
# define uiprivArrayFree(arr) \
2019-05-19 11:52:06 -05:00
uiprivFree ( arr . buf ) ; \
2019-05-19 22:15:35 -05:00
memset ( & arr , 0 , sizeof ( uiprivArray ) ) ;
2019-05-19 11:52:06 -05:00
# define uiprivArrayAt(arr, T, n) (((T *) (arr.buf)) + (n))
extern void * uiprivArrayAppend ( uiprivArray * arr , size_t n ) ;
extern void * uiprivArrayInsertAt ( uiprivArray * arr , size_t pos , size_t n ) ;
extern void uiprivArrayDelete ( uiprivArray * arr , size_t pos , size_t n ) ;
extern void uiprivArrayDeleteItem ( uiprivArray * arr , void * p , size_t n ) ;
2019-05-19 13:37:32 -05:00
extern void * uiprivArrayBsearch ( const uiprivArray * arr , const void * key , int ( * compare ) ( const void * , const void * ) ) ;
2019-05-19 11:52:06 -05:00
extern void uiprivArrayQsort ( uiprivArray * arr , int ( * compare ) ( const void * , const void * ) ) ;
2019-05-16 22:02:03 -05:00
2019-05-13 09:46:42 -05:00
// errors.c
2019-05-13 20:30:18 -05:00
extern void uiprivInternalError ( const char * fmt , . . . ) ;
2019-05-12 21:17:24 -05:00
enum {
2019-05-28 20:54:13 -05:00
uiprivProgrammerErrorNotInitialized , // arguments: uiprivFunc
uiprivProgrammerErrorWrongThread , // arguments: uiprivFunc
2019-05-12 21:17:24 -05:00
uiprivProgrammerErrorWrongStructSize , // arguments: size_t badSize, const char *structName
2019-05-27 10:02:23 -05:00
uiprivProgrammerErrorIndexOutOfRange , // arguments: int badIndex, uiprivFunc
uiprivProgrammerErrorNullPointer , // arguments: const char *paramDesc, uiprivFunc
uiprivProgrammerErrorIntIDNotFound , // arguments: const char *idDesc, int badID, uiprivFunc
2019-05-13 05:37:19 -05:00
// TODO type mismatch
2019-05-27 10:02:23 -05:00
uiprivProgrammerErrorBadSenderForEvent , // arguments: const char *senderDesc, const char *eventDesc, uiprivFunc
uiprivProgrammerErrorChangingEventDuringFire , // arguments: uiprivFunc
2019-05-14 10:02:23 -05:00
uiprivProgrammerErrorRecursiveEventFire , // no arguments
2019-05-12 21:17:24 -05:00
uiprivNumProgrammerErrors ,
} ;
extern void uiprivProgrammerError ( unsigned int which , . . . ) ;
2019-05-13 20:30:18 -05:00
extern void uiprivReportError ( const char * prefix , const char * msg , const char * suffix , bool internal ) ;
2019-05-12 21:17:24 -05:00
2019-04-21 14:08:09 -05:00
# ifdef __cplusplus
}
# endif