fix compilation errors on windows and linux
Some checks failed
Build and Deploy / build-macos (push) Failing after 4s
Build and Deploy / build-windows (CLANG64) (push) Has been cancelled
Build and Deploy / build-linux (push) Failing after 1m59s
Build and Deploy / package-dist (push) Has been skipped
Build and Deploy / deploy-itch (push) Has been skipped
Build and Deploy / deploy-gitea (push) Has been skipped

This commit is contained in:
2025-05-23 18:11:07 -05:00
parent 7246016b8b
commit f754d91e14
4 changed files with 38 additions and 33 deletions

View File

@@ -1,4 +1,3 @@
option('editor', type:'boolean', value:true)
option('chipmunk', type:'boolean', value:true)
option('enet', type:'boolean', value:true)
option('storefront', type:'combo', choices:['none','steam', 'gog', 'egs'], value:'none')

View File

@@ -9,7 +9,7 @@
#define JS_SetProperty(js, tar, str, val) JS_SetPropertyStr(js, tar, #str, val)
#define JS_GetProperty(js, tar, atom) JS_GetPropertyStr(js, tar, #atom)
SDL_Window *global_window;
extern SDL_Window *global_window;
// Core FFI functions
void ffi_load(JSContext *js);

View File

@@ -23,6 +23,7 @@
#include <sys/utsname.h>
#ifdef __linux__
#include <sys/sysinfo.h>
#include <sys/resource.h>
#endif
#endif
@@ -62,7 +63,8 @@ JSC_CCALL(os_power_state,
JSC_CCALL(os_totalmem, return number2js(js, SDL_GetSystemRAM()))
JSC_CCALL(os_platform, return JS_NewString(js,SDL_GetPlatform()))
JSC_CCALL(os_hostname,
static JSValue js_os_hostname(JSContext *js, JSValue self, int argc, JSValue *argv) {
JSValue ret = JS_UNDEFINED;
#ifdef _WIN32
TCHAR buffer[256] = TEXT("");
DWORD size = sizeof(buffer) / sizeof(TCHAR);
@@ -73,9 +75,11 @@ JSC_CCALL(os_hostname,
if (uname(&buffer) != 0) return JS_ThrowReferenceError(js,"Could not get hostname.");
return JS_NewString(js, buffer.nodename);
#endif
)
return ret;
}
JSC_CCALL(os_arch,
static JSValue js_os_arch(JSContext *js, JSValue self, int argc, JSValue *argv) {
JSValue ret = JS_UNDEFINED;
#if defined(__x86_64__) || defined(_M_X64)
return JS_NewString(js,"x64");
#elif defined(__aarch64__) || defined(_M_ARM64)
@@ -99,9 +103,11 @@ JSC_CCALL(os_arch,
#else
return JS_NewString(js,"unknown");
#endif
)
return ret;
}
JSC_CCALL(os_freemem,
static JSValue js_os_freemem(JSContext *js, JSValue self, int argc, JSValue *argv) {
JSValue ret = JS_UNDEFINED;
#ifdef _WIN32
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
@@ -124,9 +130,11 @@ JSC_CCALL(os_freemem,
// Fallback: unknown
return JS_NewInt64(js,0);
#endif
)
return ret;
}
JSC_CCALL(os_version,
static JSValue js_os_version(JSContext *js, JSValue self, int argc, JSValue *argv) {
JSValue ret = JS_UNDEFINED;
#ifdef _WIN32
typedef LONG (WINAPI *RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
HMODULE h = GetModuleHandleA("ntdll.dll");
@@ -165,7 +173,8 @@ JSC_CCALL(os_version,
if (!uname(&info)) return JS_NewString(js, info.release);
return JS_NewString(js, "");
#endif
)
return ret;
}
JSValue js_os_get_trace(JSContext *js, JSValue self)
{
@@ -205,7 +214,8 @@ JSC_CCALL(os_mallinfo,
JSJMEMRET(keepcost);*/
)
JSC_CCALL(os_rusage,
static JSValue js_os_rusage(JSContext *js, JSValue self, int argc, JSValue *argv) {
JSValue ret = JS_UNDEFINED;
ret = JS_NewObject(js);
#ifndef _WIN32
@@ -228,7 +238,7 @@ JSC_CCALL(os_rusage,
#endif
return ret;
)
}
static const JSCFunctionListEntry js_os_funcs[] = {
MIST_FUNC_DEF(os, platform, 0),

View File

@@ -158,25 +158,7 @@ static const JSCFunctionListEntry js_camera_funcs[] = {
MIST_FUNC_DEF(camera, position, 1),
};
static const JSCFunctionListEntry js_SDL_Camera_funcs[] =
{
// MIST_FUNC_DEF(camera, frame, 0),
// MIST_FUNC_DEF(camera, release_frame, 1),
};
JSValue js_camera_use(JSContext *js) {
JSValue mod = JS_NewObject(js);
JS_SetPropertyFunctionList(js,mod,js_camera_funcs,countof(js_camera_funcs));
// Initialize SDL camera class with functions
JSValue c_types = JS_GetPropertyStr(js, JS_GetGlobalObject(js), "c_types");
QJSCLASSPREP_FUNCS(SDL_Camera)
JS_FreeValue(js, c_types);
return mod;
}
JSC_CCALL(camera_frame,
JSC_CCALL(camera_capture,
/*
SDL_ClearError();
SDL_Camera *cam = js2SDL_Camera(js,self);
@@ -200,15 +182,29 @@ JSC_CCALL(camera_frame,
return SDL_Surface2js(js,newsurf);
*/
)
JSC_CCALL(camera_release_frame,
/* SDL_Camera *cam = js2SDL_Camera(js,self);
SDL_Surface *surf = js2SDL_Surface(js,argv[0]);
SDL_ReleaseCameraFrame(cam,surf);
*/
)
static const JSCFunctionListEntry js_SDL_Camera_funcs[] =
{
MIST_FUNC_DEF(camera, capture, 0),
};
JSValue js_camera_use(JSContext *js) {
JSValue mod = JS_NewObject(js);
JS_SetPropertyFunctionList(js,mod,js_camera_funcs,countof(js_camera_funcs));
// Initialize SDL camera class with functions
JSValue c_types = JS_GetPropertyStr(js, JS_GetGlobalObject(js), "c_types");
QJSCLASSPREP_FUNCS(SDL_Camera)
JS_FreeValue(js, c_types);
return mod;
}
// SDL AUDIO FUNCTIONS