@@ -153,7 +153,7 @@ fn getNativeArg(
153
153
154
154
// JS object
155
155
const ptr = try getNativeObject (nat_ctx , T_refl , js_value .castTo (v8 .Object ));
156
- if (arg_T .underPtr () != null ) {
156
+ if (comptime arg_T .underPtr () != null ) {
157
157
value = ptr ;
158
158
} else {
159
159
value = ptr .* ;
@@ -373,13 +373,14 @@ fn getArgs(
373
373
374
374
fn freeArgs (alloc : std.mem.Allocator , comptime func : refl.Func , obj : anytype ) ! void {
375
375
inline for (func .args ) | arg_T | {
376
+ const underT = comptime arg_T .underT ();
376
377
377
378
// free char slices
378
379
// the API functions will be responsible of copying the slice
379
380
// in their implementations if they want to keep it afterwards
380
- if (arg_T . underT () == []u8 or arg_T . underT () == []const u8 ) {
381
+ if (underT == []u8 or underT == []const u8 ) {
381
382
const val = @field (obj , arg_T .name .? );
382
- if (arg_T .underOpt () != null ) {
383
+ if (comptime arg_T .underOpt () != null ) {
383
384
// free only if val is non-null
384
385
if (val ) | v | {
385
386
alloc .free (v );
@@ -390,7 +391,7 @@ fn freeArgs(alloc: std.mem.Allocator, comptime func: refl.Func, obj: anytype) !v
390
391
}
391
392
392
393
// free varidadic slices
393
- if (try refl .Type .variadic (arg_T . underT () , null ) != null ) {
394
+ if (try refl .Type .variadic (underT , null ) != null ) {
394
395
const val = @field (obj , arg_T .name .? ).? ;
395
396
// NOTE: variadic are optional by design
396
397
alloc .free (@field (val , "slice" ));
@@ -885,7 +886,7 @@ fn callFunc(
885
886
886
887
// call native func
887
888
const function = @field (T_refl .T , func .name );
888
- const res_T = func .return_type .underErr () orelse func .return_type .T ;
889
+ const res_T = comptime func .return_type .underErr () orelse func .return_type .T ;
889
890
var res : res_T = undefined ;
890
891
if (comptime @typeInfo (func .return_type .T ) == .ErrorUnion ) {
891
892
res = @call (.auto , function , args ) catch | err | {
@@ -912,7 +913,7 @@ fn callFunc(
912
913
nat_ctx .alloc ,
913
914
nat_ctx ,
914
915
T_refl ,
915
- func .return_type .underT (),
916
+ comptime func .return_type .underT (),
916
917
res ,
917
918
cbk_info .getThis (),
918
919
isolate ,
0 commit comments