fix gc error

This commit is contained in:
2026-02-21 03:07:38 -06:00
parent 5975298ec4
commit 6bdd375dbb
10 changed files with 259 additions and 131 deletions

15
touch.c
View File

@@ -10,7 +10,8 @@ JSC_CCALL(touch_get_devices,
JS_FRAME(js);
JS_LOCAL(arr, JS_NewArray(js));
for (int i = 0; i < count; i++) {
JS_SetPropertyNumber(js, arr, i, JS_NewInt64(js, devices[i]));
JSValue _v = JS_NewInt64(js, devices[i]);
JS_SetPropertyNumber(js, arr, i, _v);
}
SDL_free(devices);
JS_RETURN(arr);
@@ -58,10 +59,14 @@ JSC_CCALL(touch_get_fingers,
for (int i = 0; i < count; i++) {
SDL_Finger *f = fingers[i];
finger = JS_NewObject(js);
JS_SetPropertyStr(js, finger, "id", JS_NewInt64(js, f->id));
JS_SetPropertyStr(js, finger, "x", JS_NewFloat64(js, f->x));
JS_SetPropertyStr(js, finger, "y", JS_NewFloat64(js, f->y));
JS_SetPropertyStr(js, finger, "pressure", JS_NewFloat64(js, f->pressure));
JSValue _id = JS_NewInt64(js, f->id);
JS_SetPropertyStr(js, finger, "id", _id);
JSValue _x = JS_NewFloat64(js, f->x);
JS_SetPropertyStr(js, finger, "x", _x);
JSValue _y = JS_NewFloat64(js, f->y);
JS_SetPropertyStr(js, finger, "y", _y);
JSValue _p = JS_NewFloat64(js, f->pressure);
JS_SetPropertyStr(js, finger, "pressure", _p);
JS_SetPropertyNumber(js, arr, i, finger);
}
SDL_free(fingers);