fix syntax

This commit is contained in:
2026-02-17 09:15:15 -06:00
parent f310c18b84
commit 4e1b63fd0e
52 changed files with 2169 additions and 1754 deletions

View File

@@ -38,8 +38,8 @@ static inline ImVec2 js2imvec2(JSContext *js, JSValue v)
{
ImVec2 c;
double dx, dy;
JSValue x = JS_GetPropertyUint32(js, v, 0);
JSValue y = JS_GetPropertyUint32(js, v, 1);
JSValue x = JS_GetPropertyNumber(js, v, 0);
JSValue y = JS_GetPropertyNumber(js, v, 1);
JS_ToFloat64(js, &dx, x);
JS_ToFloat64(js, &dy, y);
JS_FreeValue(js, x);
@@ -53,10 +53,10 @@ static inline ImVec4 js2imvec4(JSContext *js, JSValue v)
{
ImVec4 c;
double dx, dy, dz, dw;
JSValue x = JS_GetPropertyUint32(js, v, 0);
JSValue y = JS_GetPropertyUint32(js, v, 1);
JSValue z = JS_GetPropertyUint32(js, v, 2);
JSValue w = JS_GetPropertyUint32(js, v, 3);
JSValue x = JS_GetPropertyNumber(js, v, 0);
JSValue y = JS_GetPropertyNumber(js, v, 1);
JSValue z = JS_GetPropertyNumber(js, v, 2);
JSValue w = JS_GetPropertyNumber(js, v, 3);
JS_ToFloat64(js, &dx, x);
JS_ToFloat64(js, &dy, y);
JS_ToFloat64(js, &dz, z);
@@ -75,8 +75,8 @@ static inline ImVec4 js2imvec4(JSContext *js, JSValue v)
static inline JSValue imvec22js(JSContext *js, ImVec2 vec)
{
JSValue v = JS_NewObject(js);
JS_SetPropertyUint32(js, v, 0, JS_NewFloat64(js, vec.x));
JS_SetPropertyUint32(js, v, 1, JS_NewFloat64(js, vec.y));
JS_SetPropertyNumber(js, v, 0, JS_NewFloat64(js, vec.x));
JS_SetPropertyNumber(js, v, 1, JS_NewFloat64(js, vec.y));
return v;
}
@@ -169,17 +169,17 @@ JSC_SCALL(imgui_combo,
if (JS_IsNumber(argv[1])) {
current_item = js2number(js, argv[1]);
} else if (JS_IsString(argv[1])) {
} else if (JS_IsText(argv[1])) {
preview_str = JS_ToCString(js, argv[1]);
}
if (JS_IsArray(js, argv[2])) {
if (JS_IsArray(argv[2])) {
// Handle array of strings
int item_count = JS_ArrayLength(js, argv[2]);
const char **items = (const char**)malloc(sizeof(char*) * item_count);
for (int i = 0; i < item_count; i++) {
JSValue item = JS_GetPropertyUint32(js, argv[2], i);
JSValue item = JS_GetPropertyNumber(js, argv[2], i);
items[i] = JS_ToCString(js, item);
JS_FreeValue(js, item);
}
@@ -210,7 +210,7 @@ JSC_SCALL(imgui_combo,
}
free(items);
} else if (JS_IsString(argv[2])) {
} else if (JS_IsText(argv[2])) {
// Handle single string with \0 separators
const char *items_str = JS_ToCString(js, argv[2]);
@@ -248,13 +248,13 @@ JSC_SCALL(imgui_slider,
float low = JS_IsNull(argv[2]) ? 0.0 : js2number(js, argv[2]);
float high = JS_IsNull(argv[3]) ? 1.0 : js2number(js, argv[3]);
if (JS_IsArray(js, argv[1])) {
if (JS_IsArray(argv[1])) {
int n = JS_ArrayLength(js, argv[1]);
float a[4]; // Max 4 elements for SliderFloat4
// Read values from JS array
for (int i = 0; i < n && i < 4; i++) {
JSValue val = JS_GetPropertyUint32(js, argv[1], i);
JSValue val = JS_GetPropertyNumber(js, argv[1], i);
double d;
JS_ToFloat64(js, &d, val);
a[i] = (float)d;
@@ -276,7 +276,7 @@ JSC_SCALL(imgui_slider,
// Write values back to JS array
ret = JS_NewArray(js);
for (int i = 0; i < n && i < 4; i++) {
JS_SetPropertyUint32(js, ret, i, JS_NewFloat64(js, a[i]));
JS_SetPropertyNumber(js, ret, i, JS_NewFloat64(js, a[i]));
}
} else {
float val = js2number(js, argv[1]);
@@ -289,13 +289,13 @@ JSC_SCALL(imgui_intslider,
int low = JS_IsNull(argv[2]) ? 0 : js2number(js, argv[2]);
int high = JS_IsNull(argv[3]) ? 100 : js2number(js, argv[3]);
if (JS_IsArray(js, argv[1])) {
if (JS_IsArray(argv[1])) {
int n = JS_ArrayLength(js, argv[1]);
int a[4]; // Max 4 elements for SliderInt4
// Read values from JS array
for (int i = 0; i < n && i < 4; i++) {
JSValue val = JS_GetPropertyUint32(js, argv[1], i);
JSValue val = JS_GetPropertyNumber(js, argv[1], i);
double d;
JS_ToFloat64(js, &d, val);
a[i] = (int)d;
@@ -317,7 +317,7 @@ JSC_SCALL(imgui_intslider,
// Write values back to JS array
ret = JS_NewArray(js);
for (int i = 0; i < n && i < 4; i++) {
JS_SetPropertyUint32(js, ret, i, JS_NewInt32(js, a[i]));
JS_SetPropertyNumber(js, ret, i, JS_NewInt32(js, a[i]));
}
} else {
int val = js2number(js, argv[1]);