mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: voidptr(0) => unsafe { nil } (p.2)
This commit is contained in:
parent
1f25811786
commit
dc79f1392b
@ -112,7 +112,7 @@ mut:
|
||||
// Index of the rotation (0-3)
|
||||
rotation_idx int
|
||||
// gg context for drawing
|
||||
gg &gg.Context = voidptr(0)
|
||||
gg &gg.Context = unsafe { nil }
|
||||
font_loaded bool
|
||||
show_ghost bool = true
|
||||
// frame/time counters:
|
||||
|
@ -113,7 +113,7 @@ mut:
|
||||
// Index of the rotation (0-3)
|
||||
rotation_idx int
|
||||
// gg context for drawing
|
||||
gg &gg.Context = voidptr(0)
|
||||
gg &gg.Context = unsafe { nil }
|
||||
font_loaded bool
|
||||
show_ghost bool = true
|
||||
// frame/time counters:
|
||||
|
@ -139,7 +139,7 @@ fn (mut a array) ensure_cap(required int) {
|
||||
}
|
||||
new_size := u64(cap) * u64(a.element_size)
|
||||
new_data := unsafe { malloc(new_size) }
|
||||
if a.data != voidptr(0) {
|
||||
if a.data != unsafe { nil } {
|
||||
unsafe { vmemcpy(new_data, a.data, u64(a.len) * u64(a.element_size)) }
|
||||
// TODO: the old data may be leaked when no GC is used (ref-counting?)
|
||||
if a.flags.has(.noslices) {
|
||||
|
@ -31,7 +31,7 @@ fn (mut a array_buffer) make_copy() {
|
||||
#array_buffer.prototype.make_copy = function() { return array_buffer_make_copy(this) }
|
||||
// TODO(playX): Should this be implemented fully in JS, use generics or just voidptr?
|
||||
fn (a array_buffer) get(ix int) voidptr {
|
||||
mut res := voidptr(0)
|
||||
mut res := unsafe { nil }
|
||||
#res = a.arr[a.index_start.val + ix.val];
|
||||
|
||||
return res
|
||||
@ -128,14 +128,14 @@ pub fn (a array) repeat_to_depth(count int, depth int) array {
|
||||
|
||||
// last returns the last element of the array.
|
||||
pub fn (a array) last() voidptr {
|
||||
mut res := voidptr(0)
|
||||
mut res := unsafe { nil }
|
||||
#res = a.arr.get(new int(a.len-1));
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
fn (a array) get(ix int) voidptr {
|
||||
mut result := voidptr(0)
|
||||
mut result := unsafe { nil }
|
||||
#result = a.arr.get(ix)
|
||||
|
||||
return result
|
||||
@ -335,7 +335,7 @@ pub fn (a array) reduce(iter fn (int, int) int, accum_start int) int {
|
||||
}
|
||||
|
||||
pub fn (mut a array) pop() voidptr {
|
||||
mut res := voidptr(0)
|
||||
mut res := unsafe { nil }
|
||||
#a.val.arr.make_copy()
|
||||
#res = a.val.arr.arr.pop()
|
||||
#a.val.arr.len.val -= 1
|
||||
@ -344,7 +344,7 @@ pub fn (mut a array) pop() voidptr {
|
||||
}
|
||||
|
||||
pub fn (a array) first() voidptr {
|
||||
mut res := voidptr(0)
|
||||
mut res := unsafe { nil }
|
||||
#res = a.arr.get(new int(0))
|
||||
|
||||
return res
|
||||
|
@ -212,26 +212,26 @@ pub:
|
||||
borderless_window bool
|
||||
always_on_top bool
|
||||
bg_color gx.Color
|
||||
init_fn FNCb = voidptr(0)
|
||||
frame_fn FNCb = voidptr(0)
|
||||
native_frame_fn FNCb = voidptr(0)
|
||||
cleanup_fn FNCb = voidptr(0)
|
||||
fail_fn FNFail = voidptr(0)
|
||||
init_fn FNCb = unsafe { nil }
|
||||
frame_fn FNCb = unsafe { nil }
|
||||
native_frame_fn FNCb = unsafe { nil }
|
||||
cleanup_fn FNCb = unsafe { nil }
|
||||
fail_fn FNFail = unsafe { nil }
|
||||
//
|
||||
event_fn FNEvent = voidptr(0)
|
||||
quit_fn FNEvent = voidptr(0)
|
||||
event_fn FNEvent = unsafe { nil }
|
||||
quit_fn FNEvent = unsafe { nil }
|
||||
//
|
||||
keydown_fn FNKeyDown = voidptr(0)
|
||||
keyup_fn FNKeyUp = voidptr(0)
|
||||
char_fn FNChar = voidptr(0)
|
||||
keydown_fn FNKeyDown = unsafe { nil }
|
||||
keyup_fn FNKeyUp = unsafe { nil }
|
||||
char_fn FNChar = unsafe { nil }
|
||||
//
|
||||
move_fn FNMove = voidptr(0)
|
||||
click_fn FNClick = voidptr(0)
|
||||
unclick_fn FNUnClick = voidptr(0)
|
||||
leave_fn FNEvent = voidptr(0)
|
||||
enter_fn FNEvent = voidptr(0)
|
||||
resized_fn FNEvent = voidptr(0)
|
||||
scroll_fn FNEvent = voidptr(0)
|
||||
move_fn FNMove = unsafe { nil }
|
||||
click_fn FNClick = unsafe { nil }
|
||||
unclick_fn FNUnClick = unsafe { nil }
|
||||
leave_fn FNEvent = unsafe { nil }
|
||||
enter_fn FNEvent = unsafe { nil }
|
||||
resized_fn FNEvent = unsafe { nil }
|
||||
scroll_fn FNEvent = unsafe { nil }
|
||||
// wait_events bool // set this to true for UIs, to save power
|
||||
fullscreen bool
|
||||
scale f32 = 1.0
|
||||
|
@ -69,7 +69,7 @@ pub mut:
|
||||
expected_or_type ast.Type // fn() or { 'this type' } eg. string. expected or block type
|
||||
expected_expr_type ast.Type // if/match is_expr: expected_type
|
||||
mod string // current module name
|
||||
const_var &ast.ConstField = voidptr(0) // the current constant, when checking const declarations
|
||||
const_var &ast.ConstField = unsafe { nil } // the current constant, when checking const declarations
|
||||
const_deps []string
|
||||
const_names []string
|
||||
global_names []string
|
||||
@ -112,7 +112,7 @@ mut:
|
||||
timers &util.Timers = util.get_timers()
|
||||
comptime_fields_default_type ast.Type
|
||||
comptime_fields_type map[string]ast.Type
|
||||
fn_scope &ast.Scope = voidptr(0)
|
||||
fn_scope &ast.Scope = unsafe { nil }
|
||||
main_fn_decl_node ast.FnDecl
|
||||
match_exhaustive_cutoff_limit int = 10
|
||||
is_last_stmt bool
|
||||
@ -143,7 +143,7 @@ pub fn new_checker(table &ast.Table, pref &pref.Preferences) &Checker {
|
||||
fn (mut c Checker) reset_checker_state_at_start_of_new_file() {
|
||||
c.expected_type = ast.void_type
|
||||
c.expected_or_type = ast.void_type
|
||||
c.const_var = voidptr(0)
|
||||
c.const_var = unsafe { nil }
|
||||
c.in_for_count = 0
|
||||
c.returns = false
|
||||
c.scope_returns = false
|
||||
@ -3162,7 +3162,7 @@ pub fn (mut c Checker) mark_as_referenced(mut node ast.Expr, as_interface bool)
|
||||
ast.Ident {
|
||||
if mut node.obj is ast.Var {
|
||||
mut obj := unsafe { &node.obj }
|
||||
if c.fn_scope != voidptr(0) {
|
||||
if c.fn_scope != unsafe { nil } {
|
||||
obj = c.fn_scope.find_var(node.obj.name) or { obj }
|
||||
}
|
||||
if obj.typ == 0 {
|
||||
|
@ -5796,7 +5796,7 @@ static inline __shared__$interface_name ${shared_fn_name}(__shared__$cctype* x)
|
||||
...params[0]
|
||||
typ: st.set_nr_muls(1)
|
||||
}
|
||||
fargs, _, _ := g.fn_decl_params(params, voidptr(0), false)
|
||||
fargs, _, _ := g.fn_decl_params(params, unsafe { nil }, false)
|
||||
mut parameter_name := g.out.cut_last(g.out.len - params_start_pos)
|
||||
|
||||
if st.is_ptr() {
|
||||
|
@ -527,14 +527,14 @@ fn (mut g Gen) fn_decl_params(params []ast.Param, scope &ast.Scope, is_variadic
|
||||
func := info.func
|
||||
g.write('${g.typ(func.return_type)} (*$caname)(')
|
||||
g.definitions.write_string('${g.typ(func.return_type)} (*$caname)(')
|
||||
g.fn_decl_params(func.params, voidptr(0), func.is_variadic)
|
||||
g.fn_decl_params(func.params, unsafe { nil }, func.is_variadic)
|
||||
g.write(')')
|
||||
g.definitions.write_string(')')
|
||||
fparams << caname
|
||||
fparamtypes << param_type_name
|
||||
} else {
|
||||
mut heap_prom := false
|
||||
if scope != voidptr(0) {
|
||||
if scope != unsafe { nil } {
|
||||
if param.name != '_' {
|
||||
if v := scope.find_var(param.name) {
|
||||
if !v.is_stack_obj && v.is_auto_heap {
|
||||
|
Loading…
Reference in New Issue
Block a user