removed sdl3_stdinc.c3i functions
This commit is contained in:
parent
2db2f2f0af
commit
cb2e8306f4
@ -1,288 +1,7 @@
|
||||
module sdl3::sdl;
|
||||
|
||||
// #include <SDL3/SDL_platform_defines.h>
|
||||
|
||||
//#define SDL_FOURCC(A, B, C, D) \
|
||||
// ((SDL_static_cast(uint, SDL_static_cast(Uint8, (A))) << 0) | \
|
||||
// (SDL_static_cast(uint, SDL_static_cast(Uint8, (B))) << 8) | \
|
||||
// (SDL_static_cast(uint, SDL_static_cast(Uint8, (C))) << 16) | \
|
||||
// (SDL_static_cast(uint, SDL_static_cast(Uint8, (D))) << 24))
|
||||
|
||||
|
||||
const float FLT_EPSILON = 1.1920928955078125e-07;
|
||||
|
||||
|
||||
//#define SDL_INIT_INTERFACE(iface) \
|
||||
// do { \
|
||||
// SDL_zerop(iface); \
|
||||
// (iface)->version = sizeof(*(iface)); \
|
||||
// } while (0)
|
||||
|
||||
alias FunctionPointer = fn void();
|
||||
|
||||
extern fn void* malloc(isz size) @extern("SDL_malloc");
|
||||
extern fn void* calloc(isz nmemb, isz size) @extern("SDL_calloc");
|
||||
extern fn void* realloc(void* mem, isz size) @extern("SDL_realloc");
|
||||
extern fn void free(void* mem) @extern("SDL_free");
|
||||
|
||||
alias Malloc_func = fn void*(isz size);
|
||||
alias Calloc_func = fn void*(isz nmemb, isz size);
|
||||
alias Realloc_func = fn void*(void* mem, isz size);
|
||||
alias Free_func = fn void(void* mem);
|
||||
|
||||
extern fn void get_original_memory_functions(Malloc_func* malloc_func, Calloc_func* calloc_func, Realloc_func* realloc_func, Free_func* free_func) @extern("SDL_GetOriginalMemoryFunctions");
|
||||
extern fn void get_memory_functions(Malloc_func* malloc_func, Calloc_func* calloc_func, Realloc_func* realloc_func, Free_func* free_func) @extern("SDL_GetMemoryFunctions");
|
||||
extern fn bool set_memory_functions(Malloc_func malloc_func, Calloc_func calloc_func, Realloc_func realloc_func, Free_func free_func) @extern("SDL_SetMemoryFunctions");
|
||||
|
||||
extern fn void* aligned_alloc(isz alignment, isz size) @extern("SDL_aligned_alloc");
|
||||
extern fn void aligned_free(void* mem) @extern("SDL_aligned_free");
|
||||
extern fn int get_num_allocations() @extern("SDL_GetNumAllocations");
|
||||
|
||||
typedef Environment = void;
|
||||
|
||||
extern fn Environment* get_environment() @extern("SDL_GetEnvironment");
|
||||
extern fn Environment* create_environment(bool populated) @extern("SDL_CreateEnvironment");
|
||||
extern fn ZString get_environment_variable(Environment* env, ZString name) @extern("SDL_GetEnvironmentVariable");
|
||||
extern fn ZString* get_environment_variables(Environment* env) @extern("SDL_GetEnvironmentVariables");
|
||||
extern fn bool set_environment_variable(Environment* env, ZString name, ZString value, bool overwrite) @extern("SDL_SetEnvironmentVariable");
|
||||
extern fn bool unset_environment_variable(Environment* env, ZString name) @extern("SDL_UnsetEnvironmentVariable");
|
||||
extern fn void destroy_environment(Environment* env) @extern("SDL_DestroyEnvironment");
|
||||
extern fn ZString getenv(ZString name) @extern("SDL_getenv");
|
||||
extern fn ZString getenv_unsafe(ZString name) @extern("SDL_getenv_unsafe");
|
||||
extern fn int setenv_unsafe(ZString name, ZString value, int overwrite) @extern("SDL_setenv_unsafe");
|
||||
extern fn int unsetenv_unsafe(ZString name) @extern("SDL_unsetenv_unsafe");
|
||||
|
||||
alias CompareCallback = fn int(void* a, void* b);
|
||||
|
||||
extern fn void qsort(void* base, isz nmemb, isz size, CompareCallback compare) @extern("SDL_qsort");
|
||||
extern fn void* bsearch(void* key, void* base, isz nmemb, isz size, CompareCallback compare) @extern("SDL_bsearch");
|
||||
|
||||
alias CompareCallback_r = fn int(void* userdata, void* a, void* b);
|
||||
|
||||
extern fn void qsort_r(void* base, isz nmemb, isz size, CompareCallback_r compare, void* userdata) @extern("SDL_qsort_r");
|
||||
extern fn void* bsearch_r(void* key, void* base, isz nmemb, isz size, CompareCallback_r compare, void* userdata) @extern("SDL_bsearch_r");
|
||||
extern fn int abs(int x) @extern("SDL_abs");
|
||||
|
||||
macro min(x, y) => x < y ? x : y;
|
||||
macro max(x, y) => x > y ? x : y;
|
||||
macro clamp(x, a, b) => x < a ? a : (x > b ? b : x);
|
||||
|
||||
extern fn int isalpha(int x) @extern("SDL_isalpha");
|
||||
extern fn int isalnum(int x) @extern("SDL_isalnum");
|
||||
extern fn int isblank(int x) @extern("SDL_isblank");
|
||||
extern fn int iscntrl(int x) @extern("SDL_iscntrl");
|
||||
extern fn int isdigit(int x) @extern("SDL_isdigit");
|
||||
extern fn int isxdigit(int x) @extern("SDL_isxdigit");
|
||||
extern fn int ispunct(int x) @extern("SDL_ispunct");
|
||||
extern fn int isspace(int x) @extern("SDL_isspace");
|
||||
extern fn int isupper(int x) @extern("SDL_isupper");
|
||||
extern fn int islower(int x) @extern("SDL_islower");
|
||||
extern fn int isprint(int x) @extern("SDL_isprint");
|
||||
extern fn int isgraph(int x) @extern("SDL_isgraph");
|
||||
extern fn int toupper(int x) @extern("SDL_toupper");
|
||||
extern fn int tolower(int x) @extern("SDL_tolower");
|
||||
extern fn ushort crc16(ushort crc, void* data, isz len) @extern("SDL_crc16");
|
||||
extern fn uint crc32(uint crc, void* data, isz len) @extern("SDL_crc32");
|
||||
extern fn uint murmur3_32(void* data, isz len, uint seed) @extern("SDL_murmur3_32");
|
||||
extern fn void* memcpy(void* dst, void* src, isz len) @extern("SDL_memcpy");
|
||||
|
||||
macro copyp(dst, src) => memcpy(dst, src, sizeof(*(src)));
|
||||
|
||||
extern fn void* memmove(void* dst,void* src, isz len) @extern("SDL_memmove");
|
||||
extern fn void* memset(void* dst, int c, isz len) @extern("SDL_memset");
|
||||
extern fn void* memset4(void* dst, uint val, isz dwords) @extern("SDL_memset4");
|
||||
extern fn int memcmp(void* s1, void* s2, isz len) @extern("SDL_memcmp");
|
||||
extern fn isz wcslen(WString wstr) @extern("SDL_wcslen");
|
||||
extern fn isz wcsnlen(WString wstr, isz maxlen) @extern("SDL_wcsnlen");
|
||||
extern fn isz wcslcpy(WString dst, WString src, isz maxlen) @extern("SDL_wcslcpy");
|
||||
extern fn isz wcslcat(WString dst, WString src, isz maxlen) @extern("SDL_wcslcat");
|
||||
extern fn WString wcsdup(WString wstr) @extern("SDL_wcsdup");
|
||||
extern fn WString wcsstr(WString haystack, WString needle) @extern("SDL_wcsstr");
|
||||
extern fn WString wcsnstr(WString haystack, WString needle, isz maxlen) @extern("SDL_wcsnstr");
|
||||
extern fn int wcscmp(WString str1, WString str2) @extern("SDL_wcscmp");
|
||||
extern fn int wcsncmp(WString str1, WString str2, isz maxlen) @extern("SDL_wcsncmp");
|
||||
extern fn int wcscasecmp(WString str1, WString str2) @extern("SDL_wcscasecmp");
|
||||
extern fn int wcsncasecmp(WString str1, WString str2, isz maxlen) @extern("SDL_wcsncasecmp");
|
||||
extern fn long wcstol(WString str, WString *endp, int base) @extern("SDL_wcstol");
|
||||
extern fn isz strlen(ZString str) @extern("SDL_strlen");
|
||||
extern fn isz strnlen(ZString str, isz maxlen) @extern("SDL_strnlen");
|
||||
extern fn isz strlcpy(ZString dst, ZString src, isz maxlen) @extern("SDL_strlcpy");
|
||||
extern fn isz utf8strlcpy(ZString dst, ZString src, isz dst_bytes) @extern("SDL_utf8strlcpy");
|
||||
extern fn isz strlcat(ZString dst, ZString src, isz maxlen) @extern("SDL_strlcat");
|
||||
extern fn ZString strdup(ZString str) @extern("SDL_strdup");
|
||||
extern fn ZString strndup(ZString str, isz maxlen) @extern("SDL_strndup");
|
||||
extern fn ZString strrev(ZString str) @extern("SDL_strrev");
|
||||
extern fn ZString strupr(ZString str) @extern("SDL_strupr");
|
||||
extern fn ZString strlwr(ZString str) @extern("SDL_strlwr");
|
||||
extern fn ZString strchr(ZString str, int c) @extern("SDL_strchr");
|
||||
extern fn ZString strrchr(ZString str, int c) @extern("SDL_strrchr");
|
||||
extern fn ZString strstr(ZString haystack, ZString needle) @extern("SDL_strstr");
|
||||
extern fn ZString strnstr(ZString haystack, ZString needle, isz maxlen) @extern("SDL_strnstr");
|
||||
extern fn ZString strcasestr(ZString haystack, ZString needle) @extern("SDL_strcasestr");
|
||||
extern fn ZString strtok_r(ZString str, ZString delim, ZString* saveptr) @extern("SDL_strtok_r");
|
||||
extern fn isz utf8strlen(ZString str) @extern("SDL_utf8strlen");
|
||||
extern fn isz utf8strnlen(ZString str, isz bytes) @extern("SDL_utf8strnlen");
|
||||
extern fn ZString itoa(int value, ZString str, int radix) @extern("SDL_itoa");
|
||||
extern fn ZString uitoa(uint value, ZString str, int radix) @extern("SDL_uitoa");
|
||||
extern fn ZString ltoa(long value, ZString str, int radix) @extern("SDL_ltoa");
|
||||
extern fn ZString ultoa(ulong value, ZString str, int radix) @extern("SDL_ultoa");
|
||||
extern fn int atoi(ZString str) @extern("SDL_atoi");
|
||||
extern fn double atof(ZString str) @extern("SDL_atof");
|
||||
extern fn long strtol(ZString str, ZString* endp, int base) @extern("SDL_strtol");
|
||||
extern fn ulong strtoul(ZString str, ZString* endp, int base) @extern("SDL_strtoul");
|
||||
extern fn double strtod(ZString str, ZString* endp) @extern("SDL_strtod");
|
||||
extern fn int strcmp(ZString str1, ZString str2) @extern("SDL_strcmp");
|
||||
extern fn int strncmp(ZString str1, ZString str2, isz maxlen) @extern("SDL_strncmp");
|
||||
extern fn int strcasecmp(ZString str1, ZString str2) @extern("SDL_strcasecmp");
|
||||
extern fn int strncasecmp(ZString str1, ZString str2, isz maxlen) @extern("SDL_strncasecmp");
|
||||
extern fn ZString strpbrk(ZString str, ZString breakset) @extern("SDL_strpbrk");
|
||||
|
||||
const ushort INVALID_UNICODE_CODEPOINT = 0xFFFD;
|
||||
|
||||
extern fn uint step_utf8(ZString *pstr, isz *pslen) @extern("SDL_StepUTF8");
|
||||
extern fn uint step_back_utf8(ZString start, ZString *pstr) @extern("SDL_StepBackUTF8");
|
||||
extern fn ZString ucs4_to_utf8(uint codepoint, ZString dst) @extern("SDL_UCS4ToUTF8");
|
||||
extern fn int sscanf(ZString text, ZString fmt, ...) @extern("SDL_sscanf");
|
||||
// extern fn int SDLCALL SDL_vsscanf(ZString text, ZString fmt, va_list ap) SDL_SCANF_VARARG_FUNCV(2);
|
||||
extern fn int snprintf(ZString text, isz maxlen, ZString fmt, ...) @extern("SDL_snprintf");
|
||||
extern fn int swprintf(WString text, isz maxlen, WString fmt, ...) @extern("SDL_swprintf");
|
||||
// extern fn int vsnprintf(ZString text, isz maxlen, ZString fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3) @extern("SDL_vsnprintf");
|
||||
// extern fn int vswprintf(WString text, isz maxlen, WString fmt, va_list ap) SDL_WPRINTF_VARARG_FUNCV(3) @extern("SDL_vswprintf");
|
||||
extern fn int asprintf(ZString* strp, ZString fmt, ...) @extern("SDL_asprintf");
|
||||
// extern fn int vasprintf(ZString* strp, ZString fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2) @extern("SDL_vasprintf");
|
||||
extern fn void srand(ulong seed) @extern("SDL_srand");
|
||||
extern fn int rand(int n) @extern("SDL_rand");
|
||||
extern fn float randf() @extern("SDL_randf");
|
||||
extern fn uint rand_bits() @extern("SDL_rand_bits");
|
||||
extern fn int rand_r(ulong *state, int n) @extern("SDL_rand_r");
|
||||
extern fn float randf_r(ulong *state) @extern("SDL_randf_r");
|
||||
extern fn uint rand_bits_r(ulong *state) @extern("SDL_rand_bits_r");
|
||||
|
||||
const double PI_D = 3.141592653589793238462643383279502884;
|
||||
const float PI_F = 3.141592653589793238462643383279502884;
|
||||
|
||||
extern fn double acos(double x) @extern("SDL_acos");
|
||||
extern fn float acosf(float x) @extern("SDL_acosf");
|
||||
extern fn double asin(double x) @extern("SDL_asin");
|
||||
extern fn float asinf(float x) @extern("SDL_asinf");
|
||||
extern fn double atan(double x) @extern("SDL_atan");
|
||||
extern fn float atanf(float x) @extern("SDL_atanf");
|
||||
extern fn double atan2(double y, double x) @extern("SDL_atan2");
|
||||
extern fn float atan2f(float y, float x) @extern("SDL_atan2f");
|
||||
extern fn double ceil(double x) @extern("SDL_ceil");
|
||||
extern fn float ceilf(float x) @extern("SDL_ceilf");
|
||||
extern fn double copysign(double x, double y) @extern("SDL_copysign");
|
||||
extern fn float copysignf(float x, float y) @extern("SDL_copysignf");
|
||||
extern fn double cos(double x) @extern("SDL_cos");
|
||||
extern fn float cosf(float x) @extern("SDL_cosf");
|
||||
extern fn double exp(double x) @extern("SDL_exp");
|
||||
extern fn float expf(float x) @extern("SDL_expf");
|
||||
extern fn double fabs(double x) @extern("SDL_fabs");
|
||||
extern fn float fabsf(float x) @extern("SDL_fabsf");
|
||||
extern fn double floor(double x) @extern("SDL_floor");
|
||||
extern fn float floorf(float x) @extern("SDL_floorf");
|
||||
extern fn double trunc(double x) @extern("SDL_trunc");
|
||||
extern fn float truncf(float x) @extern("SDL_truncf");
|
||||
extern fn double fmod(double x, double y) @extern("SDL_fmod");
|
||||
extern fn float fmodf(float x, float y) @extern("SDL_fmodf");
|
||||
extern fn int isinf(double x) @extern("SDL_isinf");
|
||||
extern fn int isinff(float x) @extern("SDL_isinff");
|
||||
extern fn int isnan(double x) @extern("SDL_isnan");
|
||||
extern fn int isnanf(float x) @extern("SDL_isnanf");
|
||||
extern fn double log(double x) @extern("SDL_log");
|
||||
extern fn float logf(float x) @extern("SDL_logf");
|
||||
extern fn double log10(double x) @extern("SDL_log10");
|
||||
extern fn float log10f(float x) @extern("SDL_log10f");
|
||||
extern fn double modf(double x, double *y) @extern("SDL_modf");
|
||||
extern fn float modff(float x, float *y) @extern("SDL_modff");
|
||||
extern fn double pow(double x, double y) @extern("SDL_pow");
|
||||
extern fn float powf(float x, float y) @extern("SDL_powf");
|
||||
extern fn double round(double x) @extern("SDL_round");
|
||||
extern fn float roundf(float x) @extern("SDL_roundf");
|
||||
extern fn long lround(double x) @extern("SDL_lround");
|
||||
extern fn long lroundf(float x) @extern("SDL_lroundf");
|
||||
extern fn double scalbn(double x, int n) @extern("SDL_scalbn");
|
||||
extern fn float scalbnf(float x, int n) @extern("SDL_scalbnf");
|
||||
extern fn double sin(double x) @extern("SDL_sin");
|
||||
extern fn float sinf(float x) @extern("SDL_sinf");
|
||||
extern fn double sqrt(double x) @extern("SDL_sqrt");
|
||||
extern fn float sqrtf(float x) @extern("SDL_sqrtf");
|
||||
extern fn double tan(double x) @extern("SDL_tan");
|
||||
extern fn float tanf(float x) @extern("SDL_tanf");
|
||||
|
||||
typedef Iconv = void*;
|
||||
|
||||
extern fn Iconv iconv_open(ZString tocode, ZString fromcode) @extern("SDL_iconv_open");
|
||||
extern fn int iconv_close(Iconv cd) @extern("SDL_iconv_close");
|
||||
extern fn isz iconv(Iconv cd, ZString *inbuf, isz *inbytesleft, ZString* outbuf, isz *outbytesleft) @extern("SDL_iconv");
|
||||
|
||||
const isz ICONV_ERROR = (isz)-1;
|
||||
const isz ICONV_E2BIG = (isz)-2;
|
||||
const isz ICONV_EILSEQ = (isz)-3;
|
||||
const isz ICONV_EINVAL = (isz)-4;
|
||||
|
||||
extern fn ZString iconv_string(ZString tocode, ZString fromcode, ZString inbuf, isz inbytesleft) @extern("SDL_iconv_string");
|
||||
|
||||
macro iconv_utf8_locale(s) => iconv_string("", "UTF-8", s, strlen(s)+1);
|
||||
macro iconv_utf8_ucs2(s) => (ushort *)iconv_string("UCS-2", "UTF-8", s, strlen(s)+1);
|
||||
macro iconv_utf8_ucs4(s) => (uint *)iconv_string("UCS-4", "UTF-8", s, strlen(s)+1);
|
||||
macro iconv_wchar_utf8(s) => iconv_string("UTF-8", "WCHAR_T", (ZString)s, (wcslen(s)+1)*sizeof(short));
|
||||
|
||||
// TODO: remove these from the pool
|
||||
// #define SDL_malloc malloc
|
||||
// #define SDL_calloc calloc
|
||||
// #define SDL_realloc realloc
|
||||
// #define SDL_free free
|
||||
// #ifndef SDL_memcpy
|
||||
// #define SDL_memcpy memcpy
|
||||
// #endif
|
||||
// #ifndef SDL_memmove
|
||||
// #define SDL_memmove memmove
|
||||
// #endif
|
||||
// #ifndef SDL_memset
|
||||
// #define SDL_memset memset
|
||||
// #endif
|
||||
// #define SDL_memcmp memcmp
|
||||
// #define SDL_strlcpy strlcpy
|
||||
// #define SDL_strlcat strlcat
|
||||
// #define SDL_strlen strlen
|
||||
// #define SDL_wcslen wcslen
|
||||
// #define SDL_wcslcpy wcslcpy
|
||||
// #define SDL_wcslcat wcslcat
|
||||
// #define SDL_strdup strdup
|
||||
// #define SDL_wcsdup wcsdup
|
||||
// #define SDL_strchr strchr
|
||||
// #define SDL_strrchr strrchr
|
||||
// #define SDL_strstr strstr
|
||||
// #define SDL_wcsstr wcsstr
|
||||
// #define SDL_strtok_r strtok_r
|
||||
// #define SDL_strcmp strcmp
|
||||
// #define SDL_wcscmp wcscmp
|
||||
// #define SDL_strncmp strncmp
|
||||
// #define SDL_wcsncmp wcsncmp
|
||||
// #define SDL_strcasecmp strcasecmp
|
||||
// #define SDL_strncasecmp strncasecmp
|
||||
// #define SDL_strpbrk strpbrk
|
||||
// #define SDL_sscanf sscanf
|
||||
// #define SDL_vsscanf vsscanf
|
||||
// #define SDL_snprintf snprintf
|
||||
// #define SDL_vsnprintf vsnprintf
|
||||
// #endif
|
||||
|
||||
macro bool size_mul_check_overflow(isz a, isz b, isz *ret)
|
||||
{
|
||||
if (a != 0 && b > isz.max / a) {
|
||||
return false;
|
||||
}
|
||||
*ret = a * b;
|
||||
return true;
|
||||
}
|
||||
|
||||
macro bool size_add_check_overflow(isz a, isz b, isz *ret)
|
||||
{
|
||||
if (b > isz.max - a) {
|
||||
return false;
|
||||
}
|
||||
*ret = a + b;
|
||||
return true;
|
||||
}
|
||||
|
@ -49,10 +49,10 @@ fn GPUShader* load_shader(GPUDevice* device, ZString filename, GPUShaderStage st
|
||||
|
||||
if (shader == null) {
|
||||
io::eprintf("ERROR: SDL_CreateGPUShader failed: %s\n", sdl::get_error());
|
||||
sdl::free(code);
|
||||
mem::free(code);
|
||||
return null;
|
||||
}
|
||||
sdl::free(code);
|
||||
mem::free(code);
|
||||
return shader;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user