1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ci: fix some of v test-cleancode 1

This commit is contained in:
Delyan Angelov 2021-04-05 20:47:32 +03:00
parent 4822274d29
commit fec89c7efb
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
7 changed files with 18 additions and 12 deletions

View File

@ -66,7 +66,8 @@ fn test_write_struct() ? {
f.write_struct(another_point) ?
f.close()
x := os.read_file(tfile) ?
y := unsafe { byteptr(memdup(&another_point, size_of_point)).vstring_with_len(size_of_point) }
pcopy := unsafe { &byte(memdup(&another_point, size_of_point)) }
y := unsafe { pcopy.vstring_with_len(size_of_point) }
assert x == y
$if debug {
eprintln(x.bytes())
@ -120,7 +121,8 @@ fn test_write_raw() ? {
f.write_raw(another_point) ?
f.close()
x := os.read_file(tfile) ?
y := unsafe { byteptr(memdup(&another_point, size_of_point)).vstring_with_len(size_of_point) }
pcopy := unsafe { &byte(memdup(&another_point, size_of_point)) }
y := unsafe { pcopy.vstring_with_len(size_of_point) }
assert x == y
$if debug {
eprintln(x.bytes())

View File

@ -10,7 +10,7 @@ struct C.ANativeActivity {
assetManager voidptr
}
fn C.AAssetManager_open(&C.AAssetManager, charptr, int) &C.AAsset
fn C.AAssetManager_open(&C.AAssetManager, &char, int) &C.AAsset
fn C.AAsset_getLength(&C.AAsset) int

View File

@ -64,7 +64,7 @@ mut:
dw_flags u32
w_show_window u16
cb_reserved2 u16
lp_reserved2 byteptr
lp_reserved2 &byte
h_std_input voidptr
h_std_output voidptr
h_std_error voidptr
@ -77,7 +77,7 @@ mut:
b_inherit_handle bool
}
fn init_os_args_wide(argc int, argv &byteptr) []string {
fn init_os_args_wide(argc int, argv &&byte) []string {
mut args_ := []string{}
for i in 0 .. argc {
args_ << unsafe { string_from_wide(&u16(argv[i])) }
@ -258,6 +258,7 @@ pub fn execute(cmd string) Result {
}
proc_info := ProcessInformation{}
start_info := StartupInfo{
lp_reserved2: 0
lp_reserved: 0
lp_desktop: 0
lp_title: 0

View File

@ -3,13 +3,13 @@ module os
import strings
fn C.GenerateConsoleCtrlEvent(event u32, pgid u32) bool
fn C.GetModuleHandleA(name charptr) HMODULE
fn C.GetProcAddress(handle voidptr, procname byteptr) voidptr
fn C.GetModuleHandleA(name &char) HMODULE
fn C.GetProcAddress(handle voidptr, procname &byte) voidptr
fn C.TerminateProcess(process HANDLE, exit_code u32) bool
type FN_NTSuspendResume = fn (voidptr)
fn ntdll_fn(name charptr) FN_NTSuspendResume {
fn ntdll_fn(name &char) FN_NTSuspendResume {
ntdll := C.GetModuleHandleA(c'NTDLL')
if ntdll == 0 {
return FN_NTSuspendResume(0)
@ -66,6 +66,7 @@ fn (mut p Process) win_spawn_process() int {
}
p.wdata = voidptr(wdata)
mut start_info := StartupInfo{
lp_reserved2: 0
lp_reserved: 0
lp_desktop: 0
lp_title: 0

View File

@ -37,7 +37,8 @@ pub fn (mut b Builder) writeln(s string) {
}
pub fn (b Builder) str() string {
return unsafe { byteptr(b.buf.data).vstring_with_len(b.len) }
x := &byte(b.buf.data)
return unsafe { x.vstring_with_len(b.len) }
}
pub fn (mut b Builder) cut(n int) {

View File

@ -1605,7 +1605,8 @@ pub fn (node Node) position() token.Position {
StructField {
return node.pos.extend(node.type_pos)
}
MatchBranch, SelectBranch, EnumField, ConstField, StructInitField, GlobalField, CallArg {
MatchBranch, SelectBranch, EnumField, ConstField, StructInitField, GlobalField, CallArg
{
return node.pos
}
IfBranch {

View File

@ -1,7 +1,7 @@
[unsafe]
fn memcpy(mut dest voidptr, src voidptr, len u32) voidptr {
mut d := byteptr(dest)
s := byteptr(src)
mut d := unsafe { &byte(dest) }
s := unsafe { &byte(src) }
mut l := len
for l > 0 {
l--