@@ -128,8 +128,8 @@ size_t ffi_type_get_sz(ffi_type *type) {
128
128
}
129
129
130
130
static JSClassID js_ffi_type_classid ;
131
- static JSValue js_ffi_type_create_struct (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
132
- JSValueConst * types = argv ;
131
+ static JSValue js_ffi_type_create_struct (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
132
+ JSValue * types = argv ;
133
133
size_t typeCnt = argc ;
134
134
int arrSz = 0 ;
135
135
if (JS_IsNumber (argv [0 ])) {
@@ -254,7 +254,7 @@ static void js_ffi_type_finalizer(JSRuntime *rt, JSValue val) {
254
254
js_free_rt (rt , u );
255
255
}
256
256
}
257
- static void js_ffi_type_mark (JSRuntime * rt , JSValueConst val , JS_MarkFunc * mark_func ) {
257
+ static void js_ffi_type_mark (JSRuntime * rt , JSValue val , JS_MarkFunc * mark_func ) {
258
258
js_ffi_type * u = JS_GetOpaque (val , js_ffi_type_classid );
259
259
if (u ) {
260
260
for (unsigned i = 0 ; i < u -> elemCount ; i ++ ) {
@@ -264,7 +264,7 @@ static void js_ffi_type_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_
264
264
}
265
265
JSClassDef js_ffi_type_class = { "FfiType" , .finalizer = js_ffi_type_finalizer , .gc_mark = js_ffi_type_mark };
266
266
267
- static JSValue js_ffi_type_get_sz (JSContext * ctx , JSValueConst this_val ) {
267
+ static JSValue js_ffi_type_get_sz (JSContext * ctx , JSValue this_val ) {
268
268
js_ffi_type * type = JS_GetOpaque (this_val , js_ffi_type_classid );
269
269
if (type == NULL ) {
270
270
JS_ThrowTypeError (ctx , "expected this to be FfiType" );
@@ -273,7 +273,7 @@ static JSValue js_ffi_type_get_sz(JSContext *ctx, JSValueConst this_val) {
273
273
return JS_NEW_SIZE_T (ctx , ffi_type_get_sz (type -> ffi_type ));
274
274
}
275
275
276
- int ffi_type_to_buffer (JSContext * ctx , JSValueConst val , ffi_type * type , uint8_t * buf ) {
276
+ int ffi_type_to_buffer (JSContext * ctx , JSValue val , ffi_type * type , uint8_t * buf ) {
277
277
if (type -> type == FFI_TYPE_STRUCT ) {
278
278
if (!JS_IsArray (ctx , val )) {
279
279
JS_ThrowTypeError (ctx , "expected argument 1 to be array" );
@@ -392,7 +392,7 @@ int ffi_type_to_buffer(JSContext *ctx, JSValueConst val, ffi_type *type, uint8_t
392
392
}
393
393
}
394
394
395
- static JSValue js_ffi_type_to_buffer (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
395
+ static JSValue js_ffi_type_to_buffer (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
396
396
js_ffi_type * type = JS_GetOpaque (this_val , js_ffi_type_classid );
397
397
if (type == NULL ) {
398
398
JS_ThrowTypeError (ctx , "expected this to be FfiType" );
@@ -486,7 +486,7 @@ static int ffi_type_from_buffer(JSContext *ctx, ffi_type *type, uint8_t *buf, JS
486
486
}
487
487
}
488
488
489
- static JSValue js_ffi_type_from_buffer (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
489
+ static JSValue js_ffi_type_from_buffer (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
490
490
js_ffi_type * type = JS_GetOpaque (this_val , js_ffi_type_classid );
491
491
if (type == NULL ) {
492
492
JS_ThrowTypeError (ctx , "expected this to be FfiType" );
@@ -513,7 +513,7 @@ static JSValue js_ffi_type_from_buffer(JSContext *ctx, JSValueConst this_val, in
513
513
return val ;
514
514
}
515
515
516
- static JSValue js_ffi_type_name (JSContext * ctx , JSValueConst this_val ) {
516
+ static JSValue js_ffi_type_name (JSContext * ctx , JSValue this_val ) {
517
517
js_ffi_type * type = JS_GetOpaque (this_val , js_ffi_type_classid );
518
518
if (type == NULL ) {
519
519
JS_ThrowTypeError (ctx , "expected this to be FfiType" );
@@ -539,12 +539,12 @@ JSClassDef js_uv_dlsym_class = {
539
539
"UvDlSym" ,
540
540
};
541
541
542
- static JSValue js_uv_dlsym_create (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
542
+ static JSValue js_uv_dlsym_create (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
543
543
JS_ThrowReferenceError (ctx , "no constructor for UvDlSym available" );
544
544
return JS_EXCEPTION ;
545
545
}
546
546
547
- static JSValue js_uv_dlsym_get_addr (JSContext * ctx , JSValueConst this_val ) {
547
+ static JSValue js_uv_dlsym_get_addr (JSContext * ctx , JSValue this_val ) {
548
548
void * ptr = JS_GetOpaque (this_val , js_uv_dlsym_classid );
549
549
if (ptr == NULL ) {
550
550
JS_ThrowTypeError (ctx , "expected this to be UvDlSym" );
@@ -569,7 +569,7 @@ typedef struct {
569
569
JSValue * deps ;
570
570
} js_ffi_cif ;
571
571
572
- static JSValue js_ffi_cif_create (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
572
+ static JSValue js_ffi_cif_create (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
573
573
ssize_t nfixedargs = -1 ;
574
574
size_t ntotalargs = argc - 1 ;
575
575
if (JS_IsNumber (argv [argc - 1 ])) {
@@ -638,7 +638,7 @@ static JSValue js_ffi_cif_create(JSContext *ctx, JSValueConst this_val, int argc
638
638
return obj ;
639
639
}
640
640
641
- static void js_ffi_cif_mark (JSRuntime * rt , JSValueConst val , JS_MarkFunc * mark_func ) {
641
+ static void js_ffi_cif_mark (JSRuntime * rt , JSValue val , JS_MarkFunc * mark_func ) {
642
642
js_ffi_cif * u = JS_GetOpaque (val , js_ffi_cif_classid );
643
643
if (u ) {
644
644
for (unsigned i = 0 ; i < u -> depsCount ; i ++ ) {
@@ -663,7 +663,7 @@ static void js_ffi_cif_finalizer(JSRuntime *rt, JSValue val) {
663
663
664
664
JSClassDef js_ffi_cif_class = { "FfiCif" , .finalizer = js_ffi_cif_finalizer , .gc_mark = js_ffi_cif_mark };
665
665
666
- static JSValue js_ffi_cif_call (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
666
+ static JSValue js_ffi_cif_call (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
667
667
js_ffi_cif * cif = JS_GetOpaque (this_val , js_ffi_cif_classid );
668
668
if (!cif ) {
669
669
JS_ThrowTypeError (ctx , "this must be FfiCif" );
@@ -676,7 +676,7 @@ static JSValue js_ffi_cif_call(JSContext *ctx, JSValueConst this_val, int argc,
676
676
}
677
677
678
678
unsigned ffi_arg_cnt = argc - 1 ;
679
- JSValueConst * func_argv = & argv [1 ];
679
+ JSValue * func_argv = & argv [1 ];
680
680
if (ffi_arg_cnt != cif -> ffi_cif .nargs ) {
681
681
JS_ThrowRangeError (ctx , "expected %d arguments but got %d" , cif -> ffi_cif .nargs , ffi_arg_cnt );
682
682
return JS_EXCEPTION ;
@@ -721,7 +721,7 @@ static JSCFunctionListEntry js_ffi_cif_proto_funcs[] = {
721
721
// =====================================
722
722
723
723
static JSClassID js_uv_lib_classid ;
724
- static JSValue js_uv_lib_create (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
724
+ static JSValue js_uv_lib_create (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
725
725
TJS_CHECK_ARG_RET (ctx , JS_IsString (argv [0 ]), 0 , "string" );
726
726
JSValue obj = JS_NewObjectClass (ctx , js_uv_lib_classid );
727
727
if (JS_IsException (obj )) {
@@ -749,7 +749,7 @@ static void js_uv_lib_finalizer(JSRuntime *rt, JSValue val) {
749
749
}
750
750
}
751
751
752
- static JSValue js_uv_lib_dlsym (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
752
+ static JSValue js_uv_lib_dlsym (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
753
753
TJS_CHECK_ARG_RET (ctx , JS_IsString (argv [0 ]), 0 , "string" );
754
754
755
755
uv_lib_t * lib = JS_GetOpaque (this_val , js_uv_lib_classid );
@@ -789,15 +789,15 @@ static JSCFunctionListEntry js_uv_lib_proto_funcs[] = {
789
789
#pragma region "Libc helpers"
790
790
// ===========================
791
791
792
- static JSValue js_libc_errno (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
792
+ static JSValue js_libc_errno (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
793
793
if (argc != 0 ) {
794
794
JS_ThrowTypeError (ctx , "expected 0 arguments" );
795
795
return JS_EXCEPTION ;
796
796
}
797
797
return JS_NEW_INT (ctx , errno );
798
798
}
799
799
800
- static JSValue js_libc_strerror (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
800
+ static JSValue js_libc_strerror (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
801
801
TJS_CHECK_ARG_RET (ctx , JS_IsNumber (argv [0 ]), 0 , "number" );
802
802
int err ;
803
803
JS_TO_INT (ctx , & err , argv [0 ]);
@@ -808,7 +808,7 @@ static JSValue js_libc_strerror(JSContext *ctx, JSValueConst this_val, int argc,
808
808
#pragma region "other helpers"
809
809
// ============================
810
810
811
- static JSValue js_array_buffer_get_ptr (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
811
+ static JSValue js_array_buffer_get_ptr (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
812
812
if (argc <= 0 ) {
813
813
JS_ThrowTypeError (ctx , "expected argument 1 to be ArrayBuffer" );
814
814
return JS_EXCEPTION ;
@@ -820,7 +820,7 @@ static JSValue js_array_buffer_get_ptr(JSContext *ctx, JSValueConst this_val, in
820
820
return JS_NEW_UINTPTR_T (ctx , (uint64_t ) buf );
821
821
}
822
822
823
- static JSValue js_get_cstring (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
823
+ static JSValue js_get_cstring (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
824
824
if (argc == 0 || argc >= 2 ) {
825
825
TJS_CHECK_ARG_RET (ctx , JS_IS_PTR (ctx , argv [0 ]), 0 , "pointer" );
826
826
TJS_CHECK_ARG_RET (ctx , JS_IsNumber (argv [1 ]), 1 , "number" );
@@ -848,7 +848,7 @@ static JSValue TJS_NewUint8ArrayShared(JSContext *ctx, uint8_t *data, size_t siz
848
848
return JS_NewUint8Array (ctx , data , size , NULL , NULL , true);
849
849
}
850
850
851
- static JSValue js_ptr_to_buffer (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
851
+ static JSValue js_ptr_to_buffer (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
852
852
TJS_CHECK_ARG_RET (ctx , JS_IS_PTR (ctx , argv [0 ]), 0 , "pointer" );
853
853
TJS_CHECK_ARG_RET (ctx , JS_IsNumber (argv [1 ]), 1 , "number" );
854
854
uint8_t * ptr ;
@@ -858,7 +858,7 @@ static JSValue js_ptr_to_buffer(JSContext *ctx, JSValueConst this_val, int argc,
858
858
return TJS_NewUint8ArrayShared (ctx , ptr , sz );
859
859
}
860
860
861
- static JSValue js_deref_ptr (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
861
+ static JSValue js_deref_ptr (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
862
862
unsigned times = 1 ;
863
863
if (argc <= 0 || !JS_IS_PTR (ctx , argv [0 ])) {
864
864
JS_ThrowTypeError (ctx , "expected argument 1 to be pointer" );
@@ -913,7 +913,7 @@ typedef struct {
913
913
void js_ffi_closure_invoke (ffi_cif * cif , void * ret , void * * args , void * userptr ) {
914
914
js_ffi_closure * jscl = (js_ffi_closure * ) userptr ;
915
915
JSContext * ctx = jscl -> ctx ;
916
- JSValueConst * jsargs = js_malloc (ctx , sizeof (JSValue ) * cif -> nargs );
916
+ JSValue * jsargs = js_malloc (ctx , sizeof (JSValue ) * cif -> nargs );
917
917
918
918
for (unsigned i = 0 ; i < cif -> nargs ; i ++ ) {
919
919
jsargs [i ] = TJS_NewUint8ArrayShared (ctx , args [i ], ffi_type_get_sz (cif -> arg_types [i ]));
@@ -939,7 +939,7 @@ void js_ffi_closure_invoke(ffi_cif *cif, void *ret, void **args, void *userptr)
939
939
JS_FreeValue (ctx , jsret );
940
940
}
941
941
942
- static JSValue js_ffi_closure_create (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
942
+ static JSValue js_ffi_closure_create (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
943
943
TJS_CHECK_ARG_RET (ctx , JS_IsObject (argv [0 ]), 0 , "object" );
944
944
TJS_CHECK_ARG_RET (ctx , JS_IsFunction (ctx , argv [1 ]), 1 , "function" );
945
945
@@ -972,7 +972,7 @@ static JSValue js_ffi_closure_create(JSContext *ctx, JSValueConst this_val, int
972
972
return obj ;
973
973
}
974
974
975
- static void js_ffi_closure_mark (JSRuntime * rt , JSValueConst val , JS_MarkFunc * mark_func ) {
975
+ static void js_ffi_closure_mark (JSRuntime * rt , JSValue val , JS_MarkFunc * mark_func ) {
976
976
js_ffi_closure * u = JS_GetOpaque (val , js_ffi_closure_classid );
977
977
if (u ) {
978
978
JS_MarkValue (rt , u -> cif , mark_func );
@@ -993,7 +993,7 @@ JSClassDef js_ffi_closure_class = { "FfiClosure",
993
993
.finalizer = js_ffi_closure_finalizer ,
994
994
.gc_mark = js_ffi_closure_mark };
995
995
996
- static JSValue js_ffi_closure_get_addr (JSContext * ctx , JSValueConst this_val ) {
996
+ static JSValue js_ffi_closure_get_addr (JSContext * ctx , JSValue this_val ) {
997
997
js_ffi_closure * ptr = JS_GetOpaque (this_val , js_ffi_closure_classid );
998
998
if (ptr == NULL ) {
999
999
JS_ThrowTypeError (ctx , "expected this to be FfiClosure" );
@@ -1045,7 +1045,7 @@ static JSCFunctionListEntry funcs[] = {
1045
1045
JS_SetPropertyStr(ctx, obj, #name, name##_jsval)
1046
1046
#define ADD_ALIAS_TYPE (ctx , obj , alias , oldname ) JS_SetPropertyStr(ctx, obj, #alias, JS_DupValue(ctx, oldname##_jsval))
1047
1047
1048
- static JSValue tjs__mod_ffi_init_js (JSContext * ctx , JSValueConst this_val , int argc , JSValueConst * argv ) {
1048
+ static JSValue tjs__mod_ffi_init_js (JSContext * ctx , JSValue this_val , int argc , JSValue * argv ) {
1049
1049
JSValue ffiobj = JS_NewObject (ctx );
1050
1050
JS_SetPropertyFunctionList (ctx , ffiobj , funcs , countof (funcs ));
1051
1051
0 commit comments