This commit is contained in:
Felipe Pena 2025-09-08 09:12:07 -03:00
parent 0b785a1642
commit a6ced5dcba
2 changed files with 18 additions and 22 deletions

View file

@ -159,8 +159,12 @@ fn (mut g Gen) comptime_call(mut node ast.ComptimeCall) {
expand_strs := if node.args.len > 0 && m.params.len - 1 >= node.args.len {
arg := node.args.last()
param := m.params[node.args.len]
sym_arg := g.table.final_sym(arg.typ)
mut is_arr_interface := sym_arg.info is ast.Array
&& g.table.final_sym(sym_arg.info.elem_type).kind == .interface
arg.expr in [ast.IndexExpr, ast.Ident] && g.table.type_to_str(arg.typ) == '[]string'
arg.expr in [ast.IndexExpr, ast.Ident]
&& (g.table.type_to_str(arg.typ) == '[]string' || is_arr_interface)
&& g.table.type_to_str(param.typ) != '[]string'
} else {
false
@ -242,7 +246,8 @@ fn (mut g Gen) comptime_call(mut node ast.ComptimeCall) {
type_name := g.table.type_symbols[int(m.params[i].typ)].str()
g.write('string_${type_name}(((string*)${last_arg}.data) [${idx}])')
} else {
g.write('((string*)${last_arg}.data) [${idx}] ')
sym_name := g.table.sym(m.params[i].typ).cname
g.write('((${sym_name}*)${last_arg}.data) [${idx}] ')
}
if i < m.params.len - 1 {
g.write(', ')

View file

@ -733,7 +733,7 @@ fn handle_route[A, X](mut app A, mut user_context X, url urllib.URL, host string
if method.args.len > 1 && can_have_data_args {
// Populate method args with form or query values
mut args := []AnyParam{}
mut args := []AnyParam{cap: method.args.len + 1}
data := if user_context.Context.req.method == .get {
user_context.Context.query
} else {
@ -745,14 +745,11 @@ fn handle_route[A, X](mut app A, mut user_context X, url urllib.URL, host string
}
// println('m1')
if args.len > 0 {
print(1)
app.$method(mut user_context, ...args)
return
}
}
app.$method(mut user_context, args)
} else {
// println('m2')
app.$method(mut user_context)
}
return
}
@ -767,7 +764,7 @@ fn handle_route[A, X](mut app A, mut user_context X, url urllib.URL, host string
if method.args.len > 1 && can_have_data_args {
// Populate method args with form or query values
mut args := []AnyParam{}
mut args := []AnyParam{cap: method.args.len + 1}
data := if user_context.Context.req.method == .get {
user_context.Context.query
@ -780,13 +777,11 @@ fn handle_route[A, X](mut app A, mut user_context X, url urllib.URL, host string
}
// println('m3')
if args.len > 0 {
app.$method(mut user_context, ...args)
return
}
}
app.$method(mut user_context, args)
} else {
// println('m4')
app.$method(mut user_context)
}
return
}
@ -803,11 +798,7 @@ fn handle_route[A, X](mut app A, mut user_context X, url urllib.URL, host string
eprintln('[veb] warning: uneven parameters count (${method.args.len}) in `${method.name}`, compared to the veb route `${method.attrs}` (${method_args.len})')
}
// println('m5')
if method.args.len > 1 {
app.$method(mut user_context, ...method_args)
} else {
app.$method(mut user_context)
}
app.$method(mut user_context, method_args)
return
}
}