@@ -168,7 +168,7 @@ fn getNativeArg(
168
168
169
169
// JS object
170
170
const ptr = try getNativeObject (nat_ctx , T_refl , js_value .castTo (v8 .Object ));
171
- if (arg_T .underPtr () != null ) {
171
+ if (comptime arg_T .underPtr () != null ) {
172
172
value = ptr ;
173
173
} else {
174
174
value = ptr .* ;
@@ -389,13 +389,14 @@ fn getArgs(
389
389
390
390
fn freeArgs (alloc : std.mem.Allocator , comptime func : refl.Func , obj : anytype ) ! void {
391
391
inline for (func .args ) | arg_T | {
392
+ const underT = comptime arg_T .underT ();
392
393
393
394
// free char slices
394
395
// the API functions will be responsible of copying the slice
395
396
// in their implementations if they want to keep it afterwards
396
- if (arg_T . underT () == []u8 or arg_T . underT () == []const u8 ) {
397
+ if (underT == []u8 or underT == []const u8 ) {
397
398
const val = @field (obj , arg_T .name .? );
398
- if (arg_T .underOpt () != null ) {
399
+ if (comptime arg_T .underOpt () != null ) {
399
400
// free only if val is non-null
400
401
if (val ) | v | {
401
402
alloc .free (v );
@@ -406,7 +407,7 @@ fn freeArgs(alloc: std.mem.Allocator, comptime func: refl.Func, obj: anytype) !v
406
407
}
407
408
408
409
// free varidadic slices
409
- if (try refl .Type .variadic (arg_T . underT () , null ) != null ) {
410
+ if (try refl .Type .variadic (underT , null ) != null ) {
410
411
const val = @field (obj , arg_T .name .? ).? ;
411
412
// NOTE: variadic are optional by design
412
413
alloc .free (@field (val , "slice" ));
@@ -913,7 +914,7 @@ fn callFunc(
913
914
914
915
// call native func
915
916
const function = @field (T_refl .T , func .name );
916
- const res_T = func .return_type .underErr () orelse func .return_type .T ;
917
+ const res_T = comptime func .return_type .underErr () orelse func .return_type .T ;
917
918
var res : res_T = undefined ;
918
919
if (comptime @typeInfo (func .return_type .T ) == .ErrorUnion ) {
919
920
res = @call (.auto , function , args ) catch | err | {
@@ -940,7 +941,7 @@ fn callFunc(
940
941
nat_ctx .alloc ,
941
942
nat_ctx ,
942
943
T_refl ,
943
- func .return_type .underT (),
944
+ comptime func .return_type .underT (),
944
945
res ,
945
946
cbk_info .getThis (),
946
947
isolate ,
0 commit comments