module main const ( CommonCHeaders = ' #include // TODO remove all these includes, define all function signatures and types manually #include #include #include // for va_list #include // int64_t etc #include // memcpy #ifndef _WIN32 #include #include // tolower #include #include // sleep #endif #ifdef __APPLE__ #include // proc_pidpath #include // backtrace and backtrace_symbols_fd #endif #ifdef __linux__ #ifndef __BIONIC__ #include // backtrace and backtrace_symbols_fd #endif #pragma weak backtrace #pragma weak backtrace_symbols_fd #endif #ifdef __linux__ #include #include // os__wait uses wait on nix #endif #define EMPTY_STRUCT_DECLARATION #ifdef _MSC_VER #define EMPTY_STRUCT_DECLARATION int:0 #endif #define OPTION_CAST(x) (x) #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include // must be included after #ifndef __TINYC__ #include #endif #include // _waccess #include // _O_U8TEXT #include // _wgetcwd //#include #ifdef _MSC_VER // On MSVC these are the same (as long as /volatile:ms is passed) #define _Atomic volatile // MSVC cannot parse some things properly #undef EMPTY_STRUCT_DECLARATION #define EMPTY_STRUCT_DECLARATION void *____dummy_variable #undef OPTION_CAST #define OPTION_CAST(x) #endif void pthread_mutex_lock(HANDLE *m) { WaitForSingleObject(*m, INFINITE); } void pthread_mutex_unlock(HANDLE *m) { ReleaseMutex(*m); } #else #include #endif //================================== TYPEDEFS ================================*/ typedef int64_t i64; typedef int16_t i16; typedef int8_t i8; typedef uint64_t u64; typedef uint32_t u32; typedef uint16_t u16; typedef uint8_t byte; typedef uint32_t rune; typedef float f32; typedef double f64; typedef unsigned char* byteptr; typedef int* intptr; typedef void* voidptr; typedef struct array array; typedef struct map map; typedef array array_string; typedef array array_int; typedef array array_byte; typedef array array_f32; typedef array array_f64; typedef map map_int; typedef map map_string; #ifndef bool typedef int bool; #define true 1 #define false 0 #endif //============================== HELPER C MACROS =============================*/ #define _PUSH(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); array__push(arr, &tmp);} #define _PUSH_MANY(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); array__push_many(arr, tmp.data, tmp.len);} #define _IN(typ, val, arr) array_##typ##_contains(arr, val) #define _IN_MAP(val, m) map__exists(m, val) //#define ALLOC_INIT(type, ...) (type *)memdup((type[]){ __VA_ARGS__ }, sizeof(type)) //================================== GLOBALS =================================*/ byteptr g_str_buf; int load_so(byteptr); void reload_so(); void init_consts(); ' js_headers = ' class array_string {} class array_byte {} class array_int {} class byte {} class double {} class int {} class f64 {} class f32 {} class i64 {} class i32 {} class i16 {} class u64 {} class u32 {} class u16 {} class i8 {} class u8 {} class bool {} class rune {} class map_string {} class map_int {} function init_consts() { } ' )