From 68fb97127c04063ddccbda224567216690c4864b Mon Sep 17 00:00:00 2001 From: "Alexander Klingenbeck (SHS DI SY R&D DEV4)" Date: Tue, 9 May 2023 18:24:54 +0200 Subject: [PATCH] Fix bindings --- bindings/src/quickjs.ts | 10 +++++++--- generate-bindings.js | 8 +++++--- src/bindings/js_raylib_core.h | 24 ++++++++++++------------ thirdparty/raylib | 2 +- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/bindings/src/quickjs.ts b/bindings/src/quickjs.ts index eff9e43..4424c5a 100644 --- a/bindings/src/quickjs.ts +++ b/bindings/src/quickjs.ts @@ -87,9 +87,9 @@ export abstract class GenericQuickJsGenerator extend this.statement(`JS_ToInt32(ctx, &${name}, ${src})`) break; case "unsigned char": - this.statement(`int _tmp`) - this.statement(`JS_ToInt32(ctx, &_tmp, ${src})`) - this.statement(`${type} ${name} = (${type})_tmp`) + this.statement("int _int_"+name) + this.statement(`JS_ToInt32(ctx, &_int_${name}, ${src})`) + this.statement(`${type} ${name} = (${type})_int_${name}`) break; default: throw new Error("Cannot handle parameter type: " + type) @@ -108,6 +108,10 @@ export abstract class GenericQuickJsGenerator extend this.jsStructToOpq(type, name, src, classId) } } + + jsConstructStruct(structName: string){ + + } jsStructToOpq(structType: string, jsVar: string, srcVar: string, classId: string){ this.declare("ptr", structType+"*", false, `(${structType}*)js_malloc(ctx, sizeof(${structType}))`) diff --git a/generate-bindings.js b/generate-bindings.js index 773203d..336a571 100644 --- a/generate-bindings.js +++ b/generate-bindings.js @@ -347,9 +347,9 @@ class GenericQuickJsGenerator extends generation_1.GenericCodeGenerator { this.statement(`JS_ToInt32(ctx, &${name}, ${src})`); break; case "unsigned char": - this.statement(`int _tmp`); - this.statement(`JS_ToInt32(ctx, &_tmp, ${src})`); - this.statement(`${type} ${name} = (${type})_tmp`); + this.statement("int _int_" + name); + this.statement(`JS_ToInt32(ctx, &_int_${name}, ${src})`); + this.statement(`${type} ${name} = (${type})_int_${name}`); break; default: throw new Error("Cannot handle parameter type: " + type); @@ -368,6 +368,8 @@ class GenericQuickJsGenerator extends generation_1.GenericCodeGenerator { this.jsStructToOpq(type, name, src, classId); } } + jsConstructStruct(structName) { + } jsStructToOpq(structType, jsVar, srcVar, classId) { this.declare("ptr", structType + "*", false, `(${structType}*)js_malloc(ctx, sizeof(${structType}))`); this.statement("*ptr = " + srcVar); diff --git a/src/bindings/js_raylib_core.h b/src/bindings/js_raylib_core.h index 1b9933c..2376f5e 100644 --- a/src/bindings/js_raylib_core.h +++ b/src/bindings/js_raylib_core.h @@ -37,9 +37,9 @@ static JSValue js_Color_set_r(JSContext* ctx, JSValueConst this_val, JSValueCons if(!ptr) { return JS_EXCEPTION; } - int _tmp; - JS_ToInt32(ctx, &_tmp, v); - unsigned char value = (unsigned char)_tmp; + int _int_value; + JS_ToInt32(ctx, &_int_value, v); + unsigned char value = (unsigned char)_int_value; ptr->r = value; return JS_UNDEFINED; } @@ -59,9 +59,9 @@ static JSValue js_Color_set_g(JSContext* ctx, JSValueConst this_val, JSValueCons if(!ptr) { return JS_EXCEPTION; } - int _tmp; - JS_ToInt32(ctx, &_tmp, v); - unsigned char value = (unsigned char)_tmp; + int _int_value; + JS_ToInt32(ctx, &_int_value, v); + unsigned char value = (unsigned char)_int_value; ptr->g = value; return JS_UNDEFINED; } @@ -81,9 +81,9 @@ static JSValue js_Color_set_b(JSContext* ctx, JSValueConst this_val, JSValueCons if(!ptr) { return JS_EXCEPTION; } - int _tmp; - JS_ToInt32(ctx, &_tmp, v); - unsigned char value = (unsigned char)_tmp; + int _int_value; + JS_ToInt32(ctx, &_int_value, v); + unsigned char value = (unsigned char)_int_value; ptr->b = value; return JS_UNDEFINED; } @@ -103,9 +103,9 @@ static JSValue js_Color_set_a(JSContext* ctx, JSValueConst this_val, JSValueCons if(!ptr) { return JS_EXCEPTION; } - int _tmp; - JS_ToInt32(ctx, &_tmp, v); - unsigned char value = (unsigned char)_tmp; + int _int_value; + JS_ToInt32(ctx, &_int_value, v); + unsigned char value = (unsigned char)_int_value; ptr->a = value; return JS_UNDEFINED; } diff --git a/thirdparty/raylib b/thirdparty/raylib index a48bb6e..5573f0f 160000 --- a/thirdparty/raylib +++ b/thirdparty/raylib @@ -1 +1 @@ -Subproject commit a48bb6e1ed7b33190e486ba65b7875f0dff73701 +Subproject commit 5573f0f1c7b29bfe46d0b70487e4adb4d01cba62