fmt: `id []typ`

pull/846/head
Zaoqi 2019-06-30 11:06:46 +00:00 committed by Alexander Medvednikov
parent 8d13880cab
commit 437b32fe78
7 changed files with 17 additions and 18 deletions

View File

@ -696,7 +696,7 @@ fn (c &V) log(s string) {
println(s) println(s)
} }
fn new_v(args[]string) *V { fn new_v(args []string) *V {
mut dir := args.last() mut dir := args.last()
if args.contains('run') { if args.contains('run') {
dir = args[2] dir = args[2]

View File

@ -254,7 +254,7 @@ fn (t Token) is_assign() bool {
return t in AssignTokens return t in AssignTokens
} }
fn (t[]Token) contains(val Token) bool { fn (t []Token) contains(val Token) bool {
for tt in t { for tt in t {
if tt == val { if tt == val {
return true return true

View File

@ -1,6 +1,6 @@
import time import time
fn print_field(field[]array_int) { fn print_field(field []array_int) {
for line in field { for line in field {
mut s := ' ' mut s := ' '
for j, cell in line { for j, cell in line {

View File

@ -188,7 +188,7 @@ pub fn (arr mut array) _push_many(val voidptr, size int) {
arr.len += size arr.len += size
} }
pub fn (a[]int) str() string { pub fn (a []int) str() string {
mut res := '[' mut res := '['
for i := 0; i < a.len; i++ { for i := 0; i < a.len; i++ {
val := a[i] val := a[i]
@ -201,14 +201,13 @@ pub fn (a[]int) str() string {
return res return res
} }
pub fn (a[]int) free() { pub fn (a []int) free() {
// println('array free')
C.free(a.data) C.free(a.data)
} }
// TODO generic // TODO generic
// "[ 'a', 'b', 'c' ]" // "[ 'a', 'b', 'c' ]"
pub fn (a[]string) str() string { pub fn (a []string) str() string {
mut res := '[' mut res := '['
for i := 0; i < a.len; i++ { for i := 0; i < a.len; i++ {
val := a[i] val := a[i]

View File

@ -136,7 +136,7 @@ pub fn (n i64) hex() string {
return tos(hex, s.len + 3) 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 { for aa in a {
if aa == val { if aa == val {
return true return true

View File

@ -477,7 +477,7 @@ pub fn (s string) find_between(start, end string) string {
} }
// TODO generic // TODO generic
pub fn (ar[]string) contains(val string) bool { pub fn (ar []string) contains(val string) bool {
for s in ar { for s in ar {
if s == val { if s == val {
return true return true
@ -487,7 +487,7 @@ pub fn (ar[]string) contains(val string) bool {
} }
// TODO generic // TODO generic
pub fn (ar[]int) contains(val int) bool { pub fn (ar []int) contains(val int) bool {
for i, s in ar { for i, s in ar {
if s == val { if s == val {
return true 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); char ** res = malloc(sizeof(char*) * a.len);
for i := 0; i < a.len; i++ { for i := 0; i < a.len; i++ {
val := a[i] val := a[i]
@ -704,7 +704,7 @@ pub fn (s string) free() {
C.free(s.str) C.free(s.str)
} }
fn (arr[]string) free() { fn (arr []string) free() {
for s in arr { for s in arr {
s.free() s.free()
} }
@ -739,7 +739,7 @@ pub fn (s string) all_after(dot string) string {
// fn (s []string) substr(a, b int) string { // fn (s []string) substr(a, b int) string {
// return join_strings(s.slice_fast(a, b)) // 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 { if a.len == 0 {
return '' return ''
} }
@ -772,7 +772,7 @@ pub fn (a[]string) join(del string) string {
return res return res
} }
pub fn (s[]string) join_lines() string { pub fn (s []string) join_lines() string {
return s.join('\n') return s.join('\n')
} }

View File

@ -129,22 +129,22 @@ pub fn buffer_data(typ, size int, arr voidptr, draw_typ int) {
C.glBufferData(typ, size, arr, draw_typ) 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 size := sizeof(int) * vertices.len
C.glBufferData(typ, size, vertices.data, draw_typ) 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 size := sizeof(f32) * vertices.len
C.glBufferData(typ, size, vertices.data, draw_typ) 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.bind_buffer(GL_ARRAY_BUFFER, vbo)
gl.buffer_data_f32(GL_ARRAY_BUFFER, vertices, draw_typ) 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.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)
gl.buffer_data_int(GL_ELEMENT_ARRAY_BUFFER, indices, draw_typ) gl.buffer_data_int(GL_ELEMENT_ARRAY_BUFFER, indices, draw_typ)