Subversion Repositories eduke32

Rev

Rev 8116 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8094 hendricks2 1
#ifndef VOIDWRAP_H_
2
#define VOIDWRAP_H_
3
 
4
#include <inttypes.h>
5
#include <stdbool.h>
6
 
7
#ifdef _WIN32
8
# include <windows.h>
9
# ifdef VOIDWRAP_ISEXPORTING
10
#  define VOIDWRAP_API __declspec(dllexport)
11
# else
12
#  define VOIDWRAP_API __declspec(dllimport)
13
# endif
14
typedef HINSTANCE VW_LIBHANDLE;
15
# define Voidwrap_LoadLibrary(lib) LoadLibrary((lib))
8116 terminx 16
# define Voidwrap_GetSymbol(lib_handle, symbol) ((void(*)())GetProcAddress((lib_handle), (symbol)))
8094 hendricks2 17
#else
18
# include <dlfcn.h>
8131 hendricks2 19
# ifdef VOIDWRAP_ISEXPORTING
20
#  define VOIDWRAP_API __attribute__ ((visibility("default"))) 
21
# else
22
#  define VOIDWRAP_API
23
# endif
8094 hendricks2 24
typedef void * VW_LIBHANDLE;
25
# define Voidwrap_LoadLibrary(lib) dlopen((lib), RTLD_NOW|RTLD_GLOBAL)
26
# define Voidwrap_GetSymbol(lib_handle, symbol) dlsym((lib_handle), (symbol))
27
#endif
28
 
29
// #define VWDEBUG
30
 
31
// Function types
8096 hendricks2 32
typedef void (*VW_VOID)(void);
33
typedef void (*VW_VOID_INT32)(int32_t);
34
typedef void (*VW_VOID_CONSTCHARPTR)(char const *);
35
typedef void (*VW_VOID_CONSTCHARPTR_INT32)(char const *, int32_t);
8094 hendricks2 36
typedef bool (*VW_BOOL)(void);
37
#ifdef VWSCREENSHOT
38
typedef bool (*VW_BOOL_SCREENSHOT)(char * filepath, int32_t width, int32_t height);
39
#endif
40
typedef int32_t (*VW_INT32)(void);
41
 
8096 hendricks2 42
// Callback setup function types
43
typedef void (*VW_SETCALLBACK_VOID)(VW_VOID);
44
typedef void (*VW_SETCALLBACK_VOID_INT32)(VW_VOID_INT32);
45
typedef void (*VW_SETCALLBACK_VOID_CONSTCHARPTR)(VW_VOID_CONSTCHARPTR);
46
 
8094 hendricks2 47
#endif