Fix bindings

This commit is contained in:
Alexander Klingenbeck (SHS DI SY R&D DEV4) 2023-05-09 18:24:54 +02:00
parent bdba35dda4
commit 68fb97127c
4 changed files with 25 additions and 19 deletions

View File

@ -87,9 +87,9 @@ export abstract class GenericQuickJsGenerator<T extends QuickJsGenerator> 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)
@ -109,6 +109,10 @@ export abstract class GenericQuickJsGenerator<T extends QuickJsGenerator> extend
}
}
jsConstructStruct(structName: string){
}
jsStructToOpq(structType: string, jsVar: string, srcVar: string, classId: string){
this.declare("ptr", structType+"*", false, `(${structType}*)js_malloc(ctx, sizeof(${structType}))`)
this.statement("*ptr = " + srcVar)

View File

@ -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);

View File

@ -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;
}

2
thirdparty/raylib vendored

@ -1 +1 @@
Subproject commit a48bb6e1ed7b33190e486ba65b7875f0dff73701
Subproject commit 5573f0f1c7b29bfe46d0b70487e4adb4d01cba62