From 437b32fe7851551b6b271720685f6a73052d4cc2 Mon Sep 17 00:00:00 2001 From: Zaoqi Date: Sun, 30 Jun 2019 11:06:46 +0000 Subject: [PATCH] fmt: `id []typ` --- compiler/main.v | 2 +- compiler/token.v | 2 +- examples/game_of_life/life.v | 2 +- vlib/builtin/array.v | 7 +++---- vlib/builtin/int.v | 2 +- vlib/builtin/string.v | 12 ++++++------ vlib/gl/gl.v | 8 ++++---- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/compiler/main.v b/compiler/main.v index d7f1786988..fa798c3bcd 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -696,7 +696,7 @@ fn (c &V) log(s string) { println(s) } -fn new_v(args[]string) *V { +fn new_v(args []string) *V { mut dir := args.last() if args.contains('run') { dir = args[2] diff --git a/compiler/token.v b/compiler/token.v index 4c1bbcf059..894bc815e4 100644 --- a/compiler/token.v +++ b/compiler/token.v @@ -254,7 +254,7 @@ fn (t Token) is_assign() bool { return t in AssignTokens } -fn (t[]Token) contains(val Token) bool { +fn (t []Token) contains(val Token) bool { for tt in t { if tt == val { return true diff --git a/examples/game_of_life/life.v b/examples/game_of_life/life.v index 7796a69883..ce5a4ad14b 100644 --- a/examples/game_of_life/life.v +++ b/examples/game_of_life/life.v @@ -1,6 +1,6 @@ import time -fn print_field(field[]array_int) { +fn print_field(field []array_int) { for line in field { mut s := ' ' for j, cell in line { diff --git a/vlib/builtin/array.v b/vlib/builtin/array.v index dfbbfb8645..4936480d3e 100644 --- a/vlib/builtin/array.v +++ b/vlib/builtin/array.v @@ -188,7 +188,7 @@ pub fn (arr mut array) _push_many(val voidptr, size int) { arr.len += size } -pub fn (a[]int) str() string { +pub fn (a []int) str() string { mut res := '[' for i := 0; i < a.len; i++ { val := a[i] @@ -201,14 +201,13 @@ pub fn (a[]int) str() string { return res } -pub fn (a[]int) free() { - // println('array free') +pub fn (a []int) free() { C.free(a.data) } // TODO generic // "[ 'a', 'b', 'c' ]" -pub fn (a[]string) str() string { +pub fn (a []string) str() string { mut res := '[' for i := 0; i < a.len; i++ { val := a[i] diff --git a/vlib/builtin/int.v b/vlib/builtin/int.v index b2da49921e..24a98c54c5 100644 --- a/vlib/builtin/int.v +++ b/vlib/builtin/int.v @@ -136,7 +136,7 @@ pub fn (n i64) hex() string { return tos(hex, s.len + 3) } -pub fn (a[]byte) contains(val byte) bool { +pub fn (a []byte) contains(val byte) bool { for aa in a { if aa == val { return true diff --git a/vlib/builtin/string.v b/vlib/builtin/string.v index 9aaeeea287..1e8dfe1b0f 100644 --- a/vlib/builtin/string.v +++ b/vlib/builtin/string.v @@ -477,7 +477,7 @@ pub fn (s string) find_between(start, end string) string { } // TODO generic -pub fn (ar[]string) contains(val string) bool { +pub fn (ar []string) contains(val string) bool { for s in ar { if s == val { return true @@ -487,7 +487,7 @@ pub fn (ar[]string) contains(val string) bool { } // TODO generic -pub fn (ar[]int) contains(val int) bool { +pub fn (ar []int) contains(val int) bool { for i, s in ar { if s == val { return true @@ -497,7 +497,7 @@ pub fn (ar[]int) contains(val int) bool { } /* -pub fn (a[]string) to_c() voidptr { +pub fn (a []string) to_c() voidptr { char ** res = malloc(sizeof(char*) * a.len); for i := 0; i < a.len; i++ { val := a[i] @@ -704,7 +704,7 @@ pub fn (s string) free() { C.free(s.str) } -fn (arr[]string) free() { +fn (arr []string) free() { for s in arr { s.free() } @@ -739,7 +739,7 @@ pub fn (s string) all_after(dot string) string { // fn (s []string) substr(a, b int) string { // return join_strings(s.slice_fast(a, b)) // } -pub fn (a[]string) join(del string) string { +pub fn (a []string) join(del string) string { if a.len == 0 { return '' } @@ -772,7 +772,7 @@ pub fn (a[]string) join(del string) string { return res } -pub fn (s[]string) join_lines() string { +pub fn (s []string) join_lines() string { return s.join('\n') } diff --git a/vlib/gl/gl.v b/vlib/gl/gl.v index 9c0d06009e..f31f897c9d 100644 --- a/vlib/gl/gl.v +++ b/vlib/gl/gl.v @@ -129,22 +129,22 @@ pub fn buffer_data(typ, size int, arr voidptr, draw_typ int) { C.glBufferData(typ, size, arr, draw_typ) } -pub fn buffer_data_int(typ int, vertices[]int, draw_typ int) { +pub fn buffer_data_int(typ int, vertices []int, draw_typ int) { size := sizeof(int) * vertices.len C.glBufferData(typ, size, vertices.data, draw_typ) } -pub fn buffer_data_f32(typ int, vertices[]f32, draw_typ int) { +pub fn buffer_data_f32(typ int, vertices []f32, draw_typ int) { size := sizeof(f32) * vertices.len C.glBufferData(typ, size, vertices.data, draw_typ) } -pub fn set_vbo(vbo u32, vertices[]f32, draw_typ int) { +pub fn set_vbo(vbo u32, vertices []f32, draw_typ int) { gl.bind_buffer(GL_ARRAY_BUFFER, vbo) gl.buffer_data_f32(GL_ARRAY_BUFFER, vertices, draw_typ) } -pub fn set_ebo(ebo u32, indices[]int, draw_typ int) { +pub fn set_ebo(ebo u32, indices []int, draw_typ int) { gl.bind_buffer(GL_ELEMENT_ARRAY_BUFFER, ebo) // gl.buffer_data_int(GL_ELEMENT_ARRAY_BUFFER, indices, draw_typ) gl.buffer_data_int(GL_ELEMENT_ARRAY_BUFFER, indices, draw_typ)