mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
markused: add _result_ok (#14495)
This commit is contained in:
parent
3647fb4def
commit
d3ffd983c8
@ -113,14 +113,6 @@ struct Option {
|
||||
// derived Option_xxx types
|
||||
}
|
||||
|
||||
fn opt_ok(data voidptr, mut option Option, size int) {
|
||||
unsafe {
|
||||
*option = Option{}
|
||||
// use err to get the end of OptionBase and then memcpy into it
|
||||
vmemcpy(&u8(&option.err) + sizeof(IError), data, size)
|
||||
}
|
||||
}
|
||||
|
||||
// option is the base of V's internal optional return system.
|
||||
struct _option {
|
||||
state u8
|
||||
@ -130,6 +122,14 @@ struct _option {
|
||||
// derived _option_xxx types
|
||||
}
|
||||
|
||||
fn _option_ok(data voidptr, mut option _option, size int) {
|
||||
unsafe {
|
||||
*option = _option{}
|
||||
// use err to get the end of OptionBase and then memcpy into it
|
||||
vmemcpy(&u8(&option.err) + sizeof(IError), data, size)
|
||||
}
|
||||
}
|
||||
|
||||
fn opt_ok2(data voidptr, mut option _option, size int) {
|
||||
unsafe {
|
||||
*option = _option{}
|
||||
|
@ -5237,7 +5237,7 @@ fn (mut g Gen) or_block(var_name string, or_block ast.OrExpr, return_type ast.Ty
|
||||
styp := g.typ(g.fn_decl.return_type)
|
||||
err_obj := g.new_tmp_var()
|
||||
g.writeln('\t$styp $err_obj;')
|
||||
g.writeln('\tmemcpy(&$err_obj, &$cvar_name, sizeof(Option));')
|
||||
g.writeln('\tmemcpy(&$err_obj, &$cvar_name, sizeof(_option));')
|
||||
g.writeln('\treturn $err_obj;')
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,9 @@ pub fn mark_used(mut table ast.Table, pref &pref.Preferences, ast_files []&ast.F
|
||||
'tos2',
|
||||
'tos3',
|
||||
'isnil',
|
||||
'opt_ok',
|
||||
'opt_ok2',
|
||||
'_option_ok',
|
||||
'_result_ok',
|
||||
'error',
|
||||
// utf8_str_visible_length is used by c/str.v
|
||||
'utf8_str_visible_length',
|
||||
|
Loading…
Reference in New Issue
Block a user