fmt: align each contiguous field of struct. not the whole. (#7981)

pull/8056/head
zakuro 2021-01-12 12:38:43 +09:00 committed by GitHub
parent 82a5300044
commit 33694665f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 533 additions and 497 deletions

View File

@ -29,7 +29,7 @@ enum OutputType {
}
struct VDoc {
cfg Config [required]
cfg Config [required]
mut:
docs []doc.Doc
assets map[string]string

View File

@ -11,7 +11,7 @@ import v.table
import v.token
struct Vet {
opt Options
opt Options
mut:
errors []vet.Error
file string

View File

@ -2426,10 +2426,10 @@ struct Foo {
}
struct User {
name string
age int
name string
age int
// Use the `skip` attribute to skip certain fields
foo Foo [skip]
foo Foo [skip]
// If the field name is different in JSON, it can be specified
last_name string [json: lastName]
}

View File

@ -14,7 +14,7 @@ provides API (functions and methods) for accessing and modifying bit arrays.
*/
pub struct BitField {
mut:
size int
size int
// field *u32
field []u32
}

View File

@ -10,9 +10,9 @@ pub struct array {
pub:
element_size int // size in bytes of one element in the array.
pub mut:
data voidptr
len int // length of the array.
cap int // capacity of the array.
data voidptr
len int // length of the array.
cap int // capacity of the array.
}
// array.data uses a void pointer, which allows implementing arrays without generics and without generating

View File

@ -97,9 +97,9 @@ struct DenseArray {
value_bytes int
slot_bytes int // sum of 2 fields above
mut:
cap int
len int
deletes u32 // count
cap int
len int
deletes u32 // count
// array allocated (with `cap` bytes) on first deletion
// has non-zero element when key deleted
all_deleted &byte
@ -200,22 +200,22 @@ type MapFreeFn = fn (voidptr)
pub struct map {
// Number of bytes of a key
key_bytes int
key_bytes int
// Number of bytes of a value
value_bytes int
value_bytes int
mut:
// Highest even index in the hashtable
even_index u32
even_index u32
// Number of cached hashbits left for rehasing
cached_hashbits byte
// Used for right-shifting out used hashbits
shift byte
shift byte
// Array storing key-values (ordered)
key_values DenseArray
key_values DenseArray
// Pointer to meta-data:
// - Odd indices store kv_index.
// - Even indices store probe_count and hashbits.
metas &u32
metas &u32
// Extra metas that allows for no ranging when incrementing
// index in the hashmap
extra_metas u32
@ -226,7 +226,7 @@ mut:
free_fn MapFreeFn
pub mut:
// Number of key-values currently in the hashmap
len int
len int
}
fn map_hash_string(pkey voidptr) u64 {

View File

@ -17,7 +17,7 @@ pub mut:
required bool
value string
mut:
found bool
found bool
}
pub fn (flags []Flag) get_all_found() []Flag {

View File

@ -25,36 +25,36 @@ pub type FNChar = fn (c u32, x voidptr)
pub struct Config {
pub:
width int
height int
use_ortho bool
retina bool
resizable bool
user_data voidptr
font_size int
create_window bool
width int
height int
use_ortho bool
retina bool
resizable bool
user_data voidptr
font_size int
create_window bool
// window_user_ptr voidptr
window_title string
borderless_window bool
always_on_top bool
bg_color gx.Color
init_fn FNCb = voidptr(0)
frame_fn FNCb = voidptr(0)
cleanup_fn FNCb = voidptr(0)
fail_fn FNFail = voidptr(0)
event_fn FNEvent = voidptr(0)
keydown_fn FNKeyDown = voidptr(0)
window_title string
borderless_window bool
always_on_top bool
bg_color gx.Color
init_fn FNCb = voidptr(0)
frame_fn FNCb = voidptr(0)
cleanup_fn FNCb = voidptr(0)
fail_fn FNFail = voidptr(0)
event_fn FNEvent = voidptr(0)
keydown_fn FNKeyDown = voidptr(0)
// special case of event_fn
char_fn FNChar = voidptr(0)
char_fn FNChar = voidptr(0)
// special case of event_fn
move_fn FNMove = voidptr(0)
move_fn FNMove = voidptr(0)
// special case of event_fn
click_fn FNMove = voidptr(0)
click_fn FNMove = voidptr(0)
// special case of event_fn
// wait_events bool // set this to true for UIs, to save power
fullscreen bool
scale f32 = 1.0
sample_count int
fullscreen bool
scale f32 = 1.0
sample_count int
// vid needs this
// init_text bool
font_path string
@ -63,7 +63,7 @@ pub:
}
pub struct Context {
render_text bool
render_text bool
mut:
// a cache with all images created by the user. used for sokol image init and to save space
// (so that the user can store image ids, not entire Image objects)
@ -71,17 +71,17 @@ mut:
needs_refresh bool = true
ticks int
pub mut:
scale f32 = 1.0
scale f32 = 1.0
// will get set to 2.0 for retina, will remain 1.0 for normal
width int
height int
clear_pass C.sg_pass_action
window C.sapp_desc
timage_pip C.sgl_pipeline
config Config
ft &FT
font_inited bool
ui_mode bool // do not redraw everything 60 times/second, but only when the user requests
width int
height int
clear_pass C.sg_pass_action
window C.sapp_desc
timage_pip C.sgl_pipeline
config Config
ft &FT
font_inited bool
ui_mode bool // do not redraw everything 60 times/second, but only when the user requests
}
pub struct Size {

View File

@ -1,9 +1,9 @@
module os
pub struct File {
cfile voidptr // Using void* instead of FILE*
cfile voidptr // Using void* instead of FILE*
pub:
fd int
fd int
pub mut:
is_opened bool
}

View File

@ -179,9 +179,9 @@ pub fn exec(cmd string) ?Result {
pub struct Command {
mut:
f voidptr
f voidptr
pub mut:
eof bool
eof bool
pub:
path string
redirect_stdout bool

View File

@ -16,12 +16,12 @@ pub enum ProcessState {
[ref_only]
pub struct Process {
pub:
filename string // the process's command file path
filename string // the process's command file path
pub mut:
pid int // the PID of the process
code int = -1
pid int // the PID of the process
code int = -1
// the exit code of the process, != -1 *only* when status is .exited *and* the process was not aborted
status ProcessState = .not_started
status ProcessState = .not_started
// the current status of the process
err string // if the process fails, contains the reason why
args []string // the arguments that the command takes

View File

@ -5,7 +5,7 @@ struct RawVersion {
prerelease string
metadata string
mut:
raw_ints []string
raw_ints []string
}
const (

View File

@ -5,7 +5,7 @@ module strings
pub struct Builder {
mut:
buf []byte
buf []byte
pub mut:
len int
initial_size int = 1

View File

@ -11,8 +11,8 @@ pub struct StopWatch {
mut:
elapsed u64
pub mut:
start u64
end u64
start u64
end u64
}
pub fn new_stopwatch(opts StopWatchOptions) StopWatch {

View File

@ -52,7 +52,7 @@ pub:
comments []Comment
is_expr bool
pub mut:
typ table.Type
typ table.Type
}
pub struct IntegerLiteral {
@ -107,12 +107,12 @@ pub:
// `foo.bar`
pub struct SelectorExpr {
pub:
pos token.Position
expr Expr // expr.field_name
field_name string
is_mut bool // is used for the case `if mut ident.selector is MyType {`, it indicates if the root ident is mutable
mut_pos token.Position
next_token token.Kind
pos token.Position
expr Expr // expr.field_name
field_name string
is_mut bool // is used for the case `if mut ident.selector is MyType {`, it indicates if the root ident is mutable
mut_pos token.Position
next_token token.Kind
pub mut:
expr_type table.Type // type of `Foo` in `Foo.bar`
typ table.Type // type of the entire thing (`Foo.bar`)
@ -152,8 +152,8 @@ pub:
attrs []table.Attr
is_public bool
pub mut:
name string
typ table.Type
name string
typ table.Type
}
pub struct Field {
@ -161,17 +161,17 @@ pub:
name string
pos token.Position
pub mut:
typ table.Type
typ table.Type
}
// const field in const declaration group
pub struct ConstField {
pub:
mod string
name string
expr Expr // the value expr of field; everything after `=`
is_pub bool
pos token.Position
mod string
name string
expr Expr // the value expr of field; everything after `=`
is_pub bool
pos token.Position
pub mut:
typ table.Type // the type of the const field, it can be any type in V
comments []Comment // comments before current const field
@ -180,8 +180,8 @@ pub mut:
// const declaration
pub struct ConstDecl {
pub:
is_pub bool
pos token.Position
is_pub bool
pos token.Position
pub mut:
fields []ConstField // all the const fields in the `const (...)` block
end_comments []Comment // comments that after last const field
@ -203,7 +203,7 @@ pub:
end_comments []Comment
embeds []Embed
pub mut:
fields []StructField
fields []StructField
}
pub struct Embed {
@ -255,8 +255,8 @@ pub mut:
pub struct StructInit {
pub:
pos token.Position
is_short bool
pos token.Position
is_short bool
pub mut:
pre_comments []Comment
typ table.Type
@ -277,7 +277,7 @@ pub:
mod_pos token.Position
alias_pos token.Position
pub mut:
syms []ImportSymbol // the list of symbols in `import {symbol1, symbol2}`
syms []ImportSymbol // the list of symbols in `import {symbol1, symbol2}`
}
// import symbol,for import {symbol} syntax
@ -292,7 +292,7 @@ pub struct AnonFn {
pub:
decl FnDecl
pub mut:
typ table.Type // the type of anonymous fn. Both .typ and .decl.name are auto generated
typ table.Type // the type of anonymous fn. Both .typ and .decl.name are auto generated
}
// function or method declaration
@ -323,12 +323,12 @@ pub:
is_direct_arr bool // direct array access
attrs []table.Attr
pub mut:
stmts []Stmt
return_type table.Type
comments []Comment // comments *after* the header, but *before* `{`; used for InterfaceDecl
next_comments []Comment // coments that are one line after the decl; used for InterfaceDecl
source_file &File = 0
scope &Scope
stmts []Stmt
return_type table.Type
comments []Comment // comments *after* the header, but *before* `{`; used for InterfaceDecl
next_comments []Comment // coments that are one line after the decl; used for InterfaceDecl
source_file &File = 0
scope &Scope
}
// break, continue
@ -342,9 +342,9 @@ pub:
// function or method call expr
pub struct CallExpr {
pub:
pos token.Position
left Expr // `user` in `user.register()`
mod string
pos token.Position
left Expr // `user` in `user.register()`
mod string
pub mut:
name string // left.name()
is_method bool
@ -374,10 +374,10 @@ pub struct AutofreeArgVar {
// function call argument: `f(callarg)`
pub struct CallArg {
pub:
is_mut bool
share table.ShareType
expr Expr
comments []Comment
is_mut bool
share table.ShareType
expr Expr
comments []Comment
pub mut:
typ table.Type
is_tmp_autofree bool // this tells cgen that a tmp variable has to be used for the arg expression in order to free it after the call
@ -392,7 +392,7 @@ pub:
exprs []Expr
comments []Comment
pub mut:
types []table.Type
types []table.Type
}
/*
@ -417,15 +417,15 @@ pub:
is_autofree_tmp bool
is_arg bool // fn args should not be autofreed
pub mut:
typ table.Type
sum_type_casts []table.Type // nested sum types require nested smart casting, for that a list of types is needed
pos token.Position
is_used bool
is_changed bool // to detect mutable vars that are never changed
typ table.Type
sum_type_casts []table.Type // nested sum types require nested smart casting, for that a list of types is needed
pos token.Position
is_used bool
is_changed bool // to detect mutable vars that are never changed
//
// (for setting the position after the or block for autofree)
is_or bool // `x := foo() or { ... }`
is_tmp bool // for tmp for loop vars, so that autofree can skip them
is_or bool // `x := foo() or { ... }`
is_tmp bool // for tmp for loop vars, so that autofree can skip them
}
// used for smartcasting only
@ -452,7 +452,7 @@ pub mut:
pub struct GlobalDecl {
pub:
pos token.Position
pos token.Position
pub mut:
fields []GlobalField
end_comments []Comment
@ -463,9 +463,9 @@ pub mut:
// That array is then passed to V's checker.
pub struct File {
pub:
path string // path of the source file
mod Module // the module of the source file (from `module xyz` at the top)
global_scope &Scope
path string // path of the source file
mod Module // the module of the source file (from `module xyz` at the top)
global_scope &Scope
pub mut:
scope &Scope
stmts []Stmt // all the statements in the source file
@ -512,13 +512,13 @@ pub:
pos token.Position
mut_pos token.Position
pub mut:
scope &Scope
obj ScopeObject
mod string
name string
kind IdentKind
info IdentInfo
is_mut bool
scope &Scope
obj ScopeObject
mod string
name string
kind IdentKind
info IdentInfo
is_mut bool
}
pub fn (i &Ident) var_info() IdentVar {
@ -537,8 +537,8 @@ pub fn (i &Ident) var_info() IdentVar {
// See: token.Kind.is_infix
pub struct InfixExpr {
pub:
op token.Kind
pos token.Position
op token.Kind
pos token.Position
pub mut:
left Expr
right Expr
@ -551,9 +551,9 @@ pub mut:
// ++, --
pub struct PostfixExpr {
pub:
op token.Kind
expr Expr
pos token.Position
op token.Kind
expr Expr
pos token.Position
pub mut:
auto_locked string
}
@ -561,9 +561,9 @@ pub mut:
// See: token.Kind.is_prefix
pub struct PrefixExpr {
pub:
op token.Kind
right Expr
pos token.Position
op token.Kind
right Expr
pos token.Position
pub mut:
right_type table.Type
or_block OrExpr
@ -571,10 +571,10 @@ pub mut:
pub struct IndexExpr {
pub:
pos token.Position
left Expr
index Expr // [0], RangeExpr [start..end] or map[key]
or_expr OrExpr
pos token.Position
left Expr
index Expr // [0], RangeExpr [start..end] or map[key]
or_expr OrExpr
pub mut:
left_type table.Type // array, map, fixed array
is_setter bool
@ -588,18 +588,18 @@ pub:
pos token.Position
post_comments []Comment
pub mut:
branches []IfBranch // includes all `else if` branches
is_expr bool
typ table.Type
has_else bool
branches []IfBranch // includes all `else if` branches
is_expr bool
typ table.Type
has_else bool
}
pub struct IfBranch {
pub:
cond Expr
pos token.Position
body_pos token.Position
comments []Comment
cond Expr
pos token.Position
body_pos token.Position
comments []Comment
pub mut:
stmts []Stmt
smartcast bool // true when cond is `x is SumType`, set in checker.if_expr // no longer needed with union sum types TODO: remove
@ -618,17 +618,17 @@ pub:
is_rlock bool
pos token.Position
pub mut:
lockeds []Ident // `x`, `y` in `lock x, y {`
is_expr bool
typ table.Type
lockeds []Ident // `x`, `y` in `lock x, y {`
is_expr bool
typ table.Type
}
pub struct MatchExpr {
pub:
tok_kind token.Kind
cond Expr
branches []MatchBranch
pos token.Position
tok_kind token.Kind
cond Expr
branches []MatchBranch
pos token.Position
pub mut:
is_expr bool // returns a value
return_type table.Type
@ -647,7 +647,7 @@ pub:
is_else bool
post_comments []Comment
pub mut:
scope &Scope
scope &Scope
}
pub struct SelectExpr {
@ -684,7 +684,7 @@ pub:
pos token.Position
pub mut:
// expr Expr
typ table.Type
typ table.Type
}
pub struct ForStmt {
@ -694,8 +694,8 @@ pub:
is_inf bool // `for {}`
pos token.Position
pub mut:
label string // `label: for {`
scope &Scope
label string // `label: for {`
scope &Scope
}
pub struct ForInStmt {
@ -710,12 +710,12 @@ pub:
val_is_mut bool // `for mut val in vals {` means that modifying `val` will modify the array
// and the array cannot be indexed inside the loop
pub mut:
key_type table.Type
val_type table.Type
cond_type table.Type
kind table.Kind // array/map/string
label string // `label: for {`
scope &Scope
key_type table.Type
val_type table.Type
cond_type table.Type
kind table.Kind // array/map/string
label string // `label: for {`
scope &Scope
}
pub struct ForCStmt {
@ -729,15 +729,15 @@ pub:
stmts []Stmt
pos token.Position
pub mut:
label string // `label: for {`
scope &Scope
label string // `label: for {`
scope &Scope
}
// #include etc
pub struct HashStmt {
pub:
mod string
pos token.Position
mod string
pos token.Position
pub mut:
val string // example: 'include <openssl/rand.h> # please install openssl // comment'
kind string // : 'include'
@ -755,11 +755,11 @@ pub:
// variable assign statement
pub struct AssignStmt {
pub:
right []Expr
op token.Kind // include: =,:=,+=,-=,*=,/= and so on; for a list of all the assign operators, see vlib/token/token.v
pos token.Position
comments []Comment
end_comments []Comment
right []Expr
op token.Kind // include: =,:=,+=,-=,*=,/= and so on; for a list of all the assign operators, see vlib/token/token.v
pos token.Position
comments []Comment
end_comments []Comment
pub mut:
left []Expr
left_types []table.Type
@ -771,9 +771,9 @@ pub mut:
pub struct AsCast {
pub:
expr Expr
typ table.Type
pos token.Position
expr Expr
typ table.Type
pos token.Position
pub mut:
expr_type table.Type
}
@ -786,7 +786,7 @@ pub:
mod string // for full path `mod_Enum_val`
pos token.Position
pub mut:
typ table.Type
typ table.Type
}
// enum field in enum declaration
@ -886,19 +886,19 @@ pub:
pub struct ArrayInit {
pub:
pos token.Position // `[]` in []Type{} position
elem_type_pos token.Position // `Type` in []Type{} position
exprs []Expr // `[expr, expr]` or `[expr]Type{}` for fixed array
ecmnts [][]Comment // optional iembed comments after each expr
is_fixed bool
has_val bool // fixed size literal `[expr, expr]!!`
mod string
len_expr Expr // len: expr
cap_expr Expr // cap: expr
default_expr Expr // init: expr
has_len bool
has_cap bool
has_default bool
pos token.Position // `[]` in []Type{} position
elem_type_pos token.Position // `Type` in []Type{} position
exprs []Expr // `[expr, expr]` or `[expr]Type{}` for fixed array
ecmnts [][]Comment // optional iembed comments after each expr
is_fixed bool
has_val bool // fixed size literal `[expr, expr]!!`
mod string
len_expr Expr // len: expr
cap_expr Expr // cap: expr
default_expr Expr // init: expr
has_len bool
has_cap bool
has_default bool
pub mut:
expr_types []table.Type // [Dog, Cat] // also used for interface_types
is_interface bool // array of interfaces e.g. `[]Animal` `[Dog{}, Cat{}]`
@ -909,8 +909,8 @@ pub mut:
pub struct ArrayDecompose {
pub:
expr Expr
pos token.Position
expr Expr
pos token.Position
pub mut:
expr_type table.Type
arg_type table.Type
@ -918,9 +918,9 @@ pub mut:
pub struct ChanInit {
pub:
pos token.Position
cap_expr Expr
has_cap bool
pos token.Position
cap_expr Expr
has_cap bool
pub mut:
typ table.Type
elem_type table.Type
@ -928,9 +928,9 @@ pub mut:
pub struct MapInit {
pub:
pos token.Position
keys []Expr
vals []Expr
pos token.Position
keys []Expr
vals []Expr
pub mut:
typ table.Type
key_type table.Type
@ -957,10 +957,10 @@ pub:
// `string(x,y)`, while skipping the real pointer casts like `&string(x)`.
pub struct CastExpr {
pub:
expr Expr // `buf` in `string(buf, n)`
arg Expr // `n` in `string(buf, n)`
typ table.Type // `string` TODO rename to `type_to_cast_to`
pos token.Position
expr Expr // `buf` in `string(buf, n)`
arg Expr // `n` in `string(buf, n)`
typ table.Type // `string` TODO rename to `type_to_cast_to`
pos token.Position
pub mut:
typname string // TypeSymbol.name
expr_type table.Type // `byteptr`
@ -970,7 +970,7 @@ pub mut:
pub struct AssertStmt {
pub:
pos token.Position
pos token.Position
pub mut:
expr Expr
}
@ -978,9 +978,9 @@ pub mut:
// `if [x := opt()] {`
pub struct IfGuardExpr {
pub:
var_name string
expr Expr
pos token.Position
var_name string
expr Expr
pos token.Position
pub mut:
expr_type table.Type
}
@ -1016,8 +1016,8 @@ pub:
exprs []Expr
pos token.Position
pub mut:
typ table.Type
scope &Scope
typ table.Type
scope &Scope
}
pub struct SizeOf {
@ -1038,8 +1038,8 @@ pub:
pub struct TypeOf {
pub:
expr Expr
pos token.Position
expr Expr
pos token.Position
pub mut:
expr_type table.Type
}
@ -1054,8 +1054,8 @@ pub:
pub struct ConcatExpr {
pub:
vals []Expr
pos token.Position
vals []Expr
pos token.Position
pub mut:
return_type table.Type
}
@ -1067,7 +1067,7 @@ pub:
pos token.Position
kind token.AtKind
pub mut:
val string
val string
}
pub struct ComptimeSelector {
@ -1076,8 +1076,8 @@ pub:
left Expr
field_expr Expr
pub mut:
left_type table.Type
typ table.Type
left_type table.Type
typ table.Type
}
pub struct ComptimeCall {
@ -1089,7 +1089,7 @@ pub:
vweb_tmpl File
args_var string
pub mut:
sym table.TypeSymbol
sym table.TypeSymbol
}
pub struct None {
@ -1122,8 +1122,8 @@ pub:
updated_columns []string // for `update set x=y`
update_exprs []Expr // for `update`
pub mut:
table_name string
fields []table.Field
table_name string
fields []table.Field
}
pub struct SqlExpr {
@ -1144,8 +1144,8 @@ pub:
has_limit bool
limit_expr Expr
pub mut:
table_name string
fields []table.Field
table_name string
fields []table.Field
}
[inline]

View File

@ -12,7 +12,7 @@ pub type InspectorFn = fn (node ast.Node, data voidptr) bool
struct Inspector {
inspector_callback InspectorFn
mut:
data voidptr
data voidptr
}
pub fn (i &Inspector) visit(node ast.Node) ? {

View File

@ -14,7 +14,7 @@ fn parse_text(text string) ast.File {
}
struct NodeByOffset {
pos int
pos int
mut:
node ast.Node
}

View File

@ -12,15 +12,15 @@ import v.depgraph
pub struct Builder {
pub:
compiled_dir string // contains os.real_path() of the dir of the final file beeing compiled, or the dir itself when doing `v .`
module_path string
compiled_dir string // contains os.real_path() of the dir of the final file beeing compiled, or the dir itself when doing `v .`
module_path string
mut:
pref &pref.Preferences
checker checker.Checker
global_scope &ast.Scope
out_name_c string
out_name_js string
max_nr_errors int = 100
pref &pref.Preferences
checker checker.Checker
global_scope &ast.Scope
out_name_c string
out_name_js string
max_nr_errors int = 100
pub mut:
module_search_paths []string
parsed_files []ast.File

View File

@ -163,20 +163,20 @@ mut:
shared_postfix string // .so, .dll
//
//
debug_mode bool
is_cc_tcc bool
is_cc_gcc bool
is_cc_msvc bool
is_cc_clang bool
debug_mode bool
is_cc_tcc bool
is_cc_gcc bool
is_cc_msvc bool
is_cc_clang bool
//
env_cflags string // prepended *before* everything else
env_ldflags string // appended *after* everything else
env_cflags string // prepended *before* everything else
env_ldflags string // appended *after* everything else
//
args []string // ordinary C options like `-O2`
wargs []string // for `-Wxyz` *exclusively*
o_args []string // for `-o target`
post_args []string // options that should go after .o_args
linker_flags []string // `-lm`
args []string // ordinary C options like `-O2`
wargs []string // for `-Wxyz` *exclusively*
o_args []string // for `-o target`
post_args []string // options that should go after .o_args
linker_flags []string // `-lm`
}
fn (mut v Builder) setup_ccompiler_options(ccompiler string) {

View File

@ -8,10 +8,10 @@ import os
// parsed cflag
pub struct CFlag {
pub:
mod string // the module in which the flag was given
os string // eg. windows | darwin | linux
name string // eg. -I
value string // eg. /path/to/include
mod string // the module in which the flag was given
os string // eg. windows | darwin | linux
name string // eg. -I
value string // eg. /path/to/include
pub mut:
cached string // eg. ~/.vmodules/cache/ea/ea9878886727367672163.o (for .o files)
}

View File

@ -31,34 +31,34 @@ const (
)
pub struct Checker {
pref &pref.Preferences // Preferences shared from V struct
pref &pref.Preferences // Preferences shared from V struct
pub mut:
table &table.Table
file &ast.File = 0
nr_errors int
nr_warnings int
errors []errors.Error
warnings []errors.Warning
error_lines []int // to avoid printing multiple errors for the same line
expected_type table.Type
expected_or_type table.Type // fn() or { 'this type' } eg. string. expected or block type
cur_fn &ast.FnDecl // current function
const_decl string
const_deps []string
const_names []string
global_names []string
locked_names []string // vars that are currently locked
rlocked_names []string // vars that are currently read-locked
in_for_count int // if checker is currently in a for loop
table &table.Table
file &ast.File = 0
nr_errors int
nr_warnings int
errors []errors.Error
warnings []errors.Warning
error_lines []int // to avoid printing multiple errors for the same line
expected_type table.Type
expected_or_type table.Type // fn() or { 'this type' } eg. string. expected or block type
cur_fn &ast.FnDecl // current function
const_decl string
const_deps []string
const_names []string
global_names []string
locked_names []string // vars that are currently locked
rlocked_names []string // vars that are currently read-locked
in_for_count int // if checker is currently in a for loop
// checked_ident string // to avoid infinite checker loops
returns bool
scope_returns bool
mod string // current module name
is_builtin_mod bool // are we in `builtin`?
inside_unsafe bool
inside_const bool
skip_flags bool // should `#flag` and `#include` be skipped
cur_generic_type table.Type
returns bool
scope_returns bool
mod string // current module name
is_builtin_mod bool // are we in `builtin`?
inside_unsafe bool
inside_const bool
skip_flags bool // should `#flag` and `#include` be skipped
cur_generic_type table.Type
mut:
expr_level int // to avoid infinite recursion segfaults due to compiler bugs
inside_sql bool // to handle sql table fields pseudo variables

View File

@ -41,11 +41,11 @@ pub fn (sk SymbolKind) str() string {
}
pub struct Doc {
prefs &pref.Preferences = new_vdoc_preferences()
prefs &pref.Preferences = new_vdoc_preferences()
pub mut:
base_path string
table &table.Table = &table.Table{}
checker checker.Checker = checker.Checker{
base_path string
table &table.Table = &table.Table{}
checker checker.Checker = checker.Checker{
table: 0
cur_fn: 0
pref: 0

View File

@ -589,10 +589,56 @@ pub fn (mut f Fmt) type_decl(node ast.TypeDecl) {
f.writeln('\n')
}
[inline]
fn abs(v int) int {
return if v >= 0 {
v
} else {
-v
}
}
const (
threshold_to_align_struct = 8
)
struct StructFieldAlignInfo {
mut:
first_line int
last_line int
max_type_len int
max_len int
}
fn (mut list []StructFieldAlignInfo) add_new_info(len int, type_len int, line int) {
list << StructFieldAlignInfo{
first_line: line
last_line: line
max_type_len: type_len
max_len: len
}
}
[direct_array_access]
fn (mut list []StructFieldAlignInfo) add_info(len int, type_len int, line int) {
if list.len == 0 {
list.add_new_info(len, type_len, line)
return
}
i := list.len - 1
if line - list[i].last_line > 1 {
list.add_new_info(len, type_len, line)
return
}
list[i].last_line = line
if len > list[i].max_len {
list[i].max_len = len
}
if type_len > list[i].max_type_len {
list[i].max_type_len = type_len
}
}
struct CommentAndExprAlignInfo {
mut:
max_attrs_len int
@ -610,15 +656,6 @@ fn (mut list []CommentAndExprAlignInfo) add_new_info(attrs_len int, type_len int
}
}
[inline]
fn abs(v int) int {
return if v >= 0 {
v
} else {
-v
}
}
fn (mut list []CommentAndExprAlignInfo) add_info(attrs_len int, type_len int, line int) {
if list.len == 0 {
list.add_new_info(attrs_len, type_len, line)
@ -667,8 +704,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) {
return
}
f.writeln(' {')
mut max := 0
mut max_type_len := 0
mut field_aligns := []StructFieldAlignInfo{}
mut comment_aligns := []CommentAndExprAlignInfo{}
mut default_expr_aligns := []CommentAndExprAlignInfo{}
mut field_types := []string{cap: node.fields.len}
@ -678,9 +714,6 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) {
ft = f.short_module(ft)
}
field_types << ft
if ft.len > max_type_len {
max_type_len = ft.len
}
attrs_len := inline_attrs_len(field.attrs)
end_pos := field.pos.pos + field.pos.len
mut comments_len := 0 // Length of comments between field name and type
@ -695,9 +728,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) {
comments_len += '/* $comment.text */ '.len
}
}
if comments_len + field.name.len > max {
max = comments_len + field.name.len
}
field_aligns.add_info(comments_len + field.name.len, ft.len, field.pos.line_nr)
if field.has_default_expr {
default_expr_aligns.add_info(attrs_len, field_types[i].len, field.pos.line_nr)
}
@ -706,6 +737,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) {
styp := f.table.type_to_str(embed.typ)
f.writeln('\t$styp')
}
mut field_align_i := 0
mut comment_align_i := 0
mut default_expr_align_i := 0
for i, field in node.fields {
@ -737,13 +769,17 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) {
f.write(comment_text)
comm_idx++
}
f.write(strings.repeat(` `, max - field.name.len - comments_len))
mut field_align := field_aligns[field_align_i]
if field_align.last_line < field.pos.line_nr {
field_align_i++
field_align = field_aligns[field_align_i]
}
f.write(strings.repeat(` `, field_align.max_len - field.name.len - comments_len))
f.write(field_types[i])
after_type_pad_len := max_type_len - field_types[i].len
attrs_len := inline_attrs_len(field.attrs)
has_attrs := field.attrs.len > 0
if has_attrs {
f.write(strings.repeat(` `, after_type_pad_len))
f.write(strings.repeat(` `, field_align.max_type_len - field_types[i].len))
f.inline_attrs(field.attrs)
}
if field.has_default_expr {

View File

@ -6,7 +6,7 @@ mut:
}
struct TileLine {
ypos int
ypos int
mut:
field [5]int
points int

View File

@ -9,7 +9,7 @@ enum Abc {
struct User {
name string // name
// middle comment
age int
age int
// last comment
// last comment2
}

View File

@ -10,7 +10,7 @@ fn (f Foo<int>) value() string {
type DB = string
struct Repo <T, U> {
db DB
db DB
pub mut:
model T
permission U

View File

@ -8,13 +8,13 @@ struct User {
}
struct Foo {
field1 int // f1
field2 string // f2
field1 int // f1
field2 string // f2
pub:
public_field1 int // f1
public_field2 f64 // f2
mut:
mut_field string
mut_field string
pub mut:
pub_mut_field string
}
@ -38,9 +38,9 @@ mut:
9
10
*/
somefield2 /* 11 */ int // 12
somefield2 /* 11 */ int // 12
pub:
somefield3 int
somefield3 int
/*
13
14

View File

@ -25,104 +25,104 @@ const (
)
struct Gen {
pref &pref.Preferences
module_built string
pref &pref.Preferences
module_built string
mut:
table &table.Table
out strings.Builder
cheaders strings.Builder
includes strings.Builder // all C #includes required by V modules
typedefs strings.Builder
typedefs2 strings.Builder
type_definitions strings.Builder // typedefs, defines etc (everything that goes to the top of the file)
definitions strings.Builder // typedefs, defines etc (everything that goes to the top of the file)
inits map[string]strings.Builder // contents of `void _vinit/2{}`
cleanups map[string]strings.Builder // contents of `void _vcleanup(){}`
gowrappers strings.Builder // all go callsite wrappers
stringliterals strings.Builder // all string literals (they depend on tos3() beeing defined
auto_str_funcs strings.Builder // function bodies of all auto generated _str funcs
comptime_defines strings.Builder // custom defines, given by -d/-define flags on the CLI
pcs_declarations strings.Builder // -prof profile counter declarations for each function
hotcode_definitions strings.Builder // -live declarations & functions
shared_types strings.Builder // shared/lock types
channel_definitions strings.Builder // channel related code
options_typedefs strings.Builder // Option typedefs
options strings.Builder // `Option_xxxx` types
json_forward_decls strings.Builder // json type forward decls
enum_typedefs strings.Builder // enum types
sql_buf strings.Builder // for writing exprs to args via `sqlite3_bind_int()` etc
file ast.File
fn_decl &ast.FnDecl // pointer to the FnDecl we are currently inside otherwise 0
last_fn_c_name string
tmp_count int // counter for unique tmp vars (_tmp1, tmp2 etc)
tmp_count2 int // a separate tmp var counter for autofree fn calls
is_c_call bool // e.g. `C.printf("v")`
is_assign_lhs bool // inside left part of assign expr (for array_set(), etc)
is_assign_rhs bool // inside right part of assign after `=` (val expr)
is_array_set bool
is_amp bool // for `&Foo{}` to merge PrefixExpr `&` and StructInit `Foo{}`; also for `&byte(0)` etc
is_sql bool // Inside `sql db{}` statement, generating sql instead of C (e.g. `and` instead of `&&` etc)
is_shared bool // for initialization of hidden mutex in `[rw]shared` literals
is_vlines_enabled bool // is it safe to generate #line directives when -g is passed
vlines_path string // set to the proper path for generating #line directives
optionals []string // to avoid duplicates TODO perf, use map
chan_pop_optionals []string // types for `x := <-ch or {...}`
chan_push_optionals []string // types for `ch <- x or {...}`
shareds []int // types with hidden mutex for which decl has been emitted
inside_ternary int // ?: comma separated statements on a single line
inside_map_postfix bool // inside map++/-- postfix expr
inside_map_infix bool // inside map<</+=/-= infix expr
table &table.Table
out strings.Builder
cheaders strings.Builder
includes strings.Builder // all C #includes required by V modules
typedefs strings.Builder
typedefs2 strings.Builder
type_definitions strings.Builder // typedefs, defines etc (everything that goes to the top of the file)
definitions strings.Builder // typedefs, defines etc (everything that goes to the top of the file)
inits map[string]strings.Builder // contents of `void _vinit/2{}`
cleanups map[string]strings.Builder // contents of `void _vcleanup(){}`
gowrappers strings.Builder // all go callsite wrappers
stringliterals strings.Builder // all string literals (they depend on tos3() beeing defined
auto_str_funcs strings.Builder // function bodies of all auto generated _str funcs
comptime_defines strings.Builder // custom defines, given by -d/-define flags on the CLI
pcs_declarations strings.Builder // -prof profile counter declarations for each function
hotcode_definitions strings.Builder // -live declarations & functions
shared_types strings.Builder // shared/lock types
channel_definitions strings.Builder // channel related code
options_typedefs strings.Builder // Option typedefs
options strings.Builder // `Option_xxxx` types
json_forward_decls strings.Builder // json type forward decls
enum_typedefs strings.Builder // enum types
sql_buf strings.Builder // for writing exprs to args via `sqlite3_bind_int()` etc
file ast.File
fn_decl &ast.FnDecl // pointer to the FnDecl we are currently inside otherwise 0
last_fn_c_name string
tmp_count int // counter for unique tmp vars (_tmp1, tmp2 etc)
tmp_count2 int // a separate tmp var counter for autofree fn calls
is_c_call bool // e.g. `C.printf("v")`
is_assign_lhs bool // inside left part of assign expr (for array_set(), etc)
is_assign_rhs bool // inside right part of assign after `=` (val expr)
is_array_set bool
is_amp bool // for `&Foo{}` to merge PrefixExpr `&` and StructInit `Foo{}`; also for `&byte(0)` etc
is_sql bool // Inside `sql db{}` statement, generating sql instead of C (e.g. `and` instead of `&&` etc)
is_shared bool // for initialization of hidden mutex in `[rw]shared` literals
is_vlines_enabled bool // is it safe to generate #line directives when -g is passed
vlines_path string // set to the proper path for generating #line directives
optionals []string // to avoid duplicates TODO perf, use map
chan_pop_optionals []string // types for `x := <-ch or {...}`
chan_push_optionals []string // types for `ch <- x or {...}`
shareds []int // types with hidden mutex for which decl has been emitted
inside_ternary int // ?: comma separated statements on a single line
inside_map_postfix bool // inside map++/-- postfix expr
inside_map_infix bool // inside map<</+=/-= infix expr
// inside_if_expr bool
ternary_names map[string]string
ternary_level_names map[string][]string
stmt_path_pos []int // positions of each statement start, for inserting C statements before the current statement
skip_stmt_pos bool // for handling if expressions + autofree (since both prepend C statements)
right_is_opt bool
is_autofree bool // false, inside the bodies of fns marked with [manualfree], otherwise === g.pref.autofree
indent int
empty_line bool
is_test bool
assign_op token.Kind // *=, =, etc (for array_set)
defer_stmts []ast.DeferStmt
defer_ifdef string
defer_profile_code string
str_types []string // types that need automatic str() generation
threaded_fns []string // for generating unique wrapper types and fns for `go xxx()`
array_fn_definitions []string // array equality functions that have been defined
map_fn_definitions []string // map equality functions that have been defined
struct_fn_definitions []string // struct equality functions that have been defined
auto_fn_definitions []string // auto generated functions defination list
is_json_fn bool // inside json.encode()
json_types []string // to avoid json gen duplicates
pcs []ProfileCounterMeta // -prof profile counter fn_names => fn counter name
is_builtin_mod bool
hotcode_fn_names []string
ternary_names map[string]string
ternary_level_names map[string][]string
stmt_path_pos []int // positions of each statement start, for inserting C statements before the current statement
skip_stmt_pos bool // for handling if expressions + autofree (since both prepend C statements)
right_is_opt bool
is_autofree bool // false, inside the bodies of fns marked with [manualfree], otherwise === g.pref.autofree
indent int
empty_line bool
is_test bool
assign_op token.Kind // *=, =, etc (for array_set)
defer_stmts []ast.DeferStmt
defer_ifdef string
defer_profile_code string
str_types []string // types that need automatic str() generation
threaded_fns []string // for generating unique wrapper types and fns for `go xxx()`
array_fn_definitions []string // array equality functions that have been defined
map_fn_definitions []string // map equality functions that have been defined
struct_fn_definitions []string // struct equality functions that have been defined
auto_fn_definitions []string // auto generated functions defination list
is_json_fn bool // inside json.encode()
json_types []string // to avoid json gen duplicates
pcs []ProfileCounterMeta // -prof profile counter fn_names => fn counter name
is_builtin_mod bool
hotcode_fn_names []string
// cur_fn ast.FnDecl
cur_generic_type table.Type // `int`, `string`, etc in `foo<T>()`
sql_i int
sql_stmt_name string
sql_side SqlExprSide // left or right, to distinguish idents in `name == name`
inside_vweb_tmpl bool
inside_return bool
inside_or_block bool
strs_to_free0 []string // strings.Builder
cur_generic_type table.Type // `int`, `string`, etc in `foo<T>()`
sql_i int
sql_stmt_name string
sql_side SqlExprSide // left or right, to distinguish idents in `name == name`
inside_vweb_tmpl bool
inside_return bool
inside_or_block bool
strs_to_free0 []string // strings.Builder
// strs_to_free []string // strings.Builder
inside_call bool
has_main bool
inside_const bool
comp_for_method string // $for method in T.methods {}
comp_for_field_var string // $for field in T.fields {}; the variable name
comp_for_field_value table.Field // value of the field variable
comp_for_field_type table.Type // type of the field variable inferred from `$if field.typ is T {}`
comptime_var_type_map map[string]table.Type
inside_call bool
has_main bool
inside_const bool
comp_for_method string // $for method in T.methods {}
comp_for_field_var string // $for field in T.fields {}; the variable name
comp_for_field_value table.Field // value of the field variable
comp_for_field_type table.Type // type of the field variable inferred from `$if field.typ is T {}`
comptime_var_type_map map[string]table.Type
// tmp_arg_vars_to_free []string
// autofree_pregen map[string]string
// autofree_pregen_buf strings.Builder
// autofree_tmp_vars []string // to avoid redefining the same tmp vars in a single function
called_fn_name string
cur_mod ast.Module
is_js_call bool // for handling a special type arg #1 `json.decode(User, ...)`
is_fn_index_call bool
called_fn_name string
cur_mod ast.Module
is_js_call bool // for handling a special type arg #1 `json.decode(User, ...)`
is_fn_index_call bool
// nr_vars_to_free int
// doing_autofree_tmp bool
inside_lambda bool
@ -131,11 +131,11 @@ mut:
// TypeOne, TypeTwo {}
// where an aggregate (at least two types) is generated
// sum type deref needs to know which index to deref because unions take care of the correct field
aggregate_type_idx int
returned_var_name string // to detect that a var doesn't need to be freed since it's being returned
branch_parent_pos int // used in BranchStmt (continue/break) for autofree stop position
timers &util.Timers = util.new_timers(false)
force_main_console bool // true when [console] used on fn main()
aggregate_type_idx int
returned_var_name string // to detect that a var doesn't need to be freed since it's being returned
branch_parent_pos int // used in BranchStmt (continue/break) for autofree stop position
timers &util.Timers = util.new_timers(false)
force_main_console bool // true when [console] used on fn main()
}
const (

View File

@ -13,8 +13,8 @@ import strings
import v.table
pub struct Gen {
out_name string
pref &pref.Preferences // Preferences shared from V struct
out_name string
pref &pref.Preferences // Preferences shared from V struct
mut:
table &table.Table
buf []byte

View File

@ -20,7 +20,7 @@ const (
)
pub struct Parser {
pref &pref.Preferences
pref &pref.Preferences
mut:
file_base string // "hello.v"
file_name string // "/home/user/hello.v"

View File

@ -49,71 +49,71 @@ const (
pub struct Preferences {
pub mut:
os OS // the OS to compile for
backend Backend
build_mode BuildMode
output_mode OutputMode = .stdout
os OS // the OS to compile for
backend Backend
build_mode BuildMode
output_mode OutputMode = .stdout
// verbosity VerboseLevel
is_verbose bool
is_verbose bool
// nofmt bool // disable vfmt
is_test bool // `v test string_test.v`
is_script bool // single file mode (`v program.v`), main function can be skipped
is_vsh bool // v script (`file.vsh`) file, the `os` module should be made global
is_livemain bool // main program that contains live/hot code
is_liveshared bool // a shared library, that will be used in a -live main program
is_shared bool // an ordinary shared library, -shared, no matter if it is live or not
is_prof bool // benchmark every function
profile_file string // the profile results will be stored inside profile_file
profile_no_inline bool // when true, [inline] functions would not be profiled
translated bool // `v translate doom.v` are we running V code translated from C? allow globals, ++ expressions, etc
is_prod bool // use "-O2"
obfuscate bool // `v -obf program.v`, renames functions to "f_XXX"
is_repl bool
is_run bool
sanitize bool // use Clang's new "-fsanitize" option
is_debug bool // false by default, turned on by -g or -cg, it tells v to pass -g to the C backend compiler.
is_vlines bool // turned on by -g, false by default (it slows down .tmp.c generation slightly).
show_cc bool // -showcc, print cc command
show_c_output bool // -show-c-output, print all cc output even if the code was compiled correctly
is_test bool // `v test string_test.v`
is_script bool // single file mode (`v program.v`), main function can be skipped
is_vsh bool // v script (`file.vsh`) file, the `os` module should be made global
is_livemain bool // main program that contains live/hot code
is_liveshared bool // a shared library, that will be used in a -live main program
is_shared bool // an ordinary shared library, -shared, no matter if it is live or not
is_prof bool // benchmark every function
profile_file string // the profile results will be stored inside profile_file
profile_no_inline bool // when true, [inline] functions would not be profiled
translated bool // `v translate doom.v` are we running V code translated from C? allow globals, ++ expressions, etc
is_prod bool // use "-O2"
obfuscate bool // `v -obf program.v`, renames functions to "f_XXX"
is_repl bool
is_run bool
sanitize bool // use Clang's new "-fsanitize" option
is_debug bool // false by default, turned on by -g or -cg, it tells v to pass -g to the C backend compiler.
is_vlines bool // turned on by -g, false by default (it slows down .tmp.c generation slightly).
show_cc bool // -showcc, print cc command
show_c_output bool // -show-c-output, print all cc output even if the code was compiled correctly
// NB: passing -cg instead of -g will set is_vlines to false and is_debug to true, thus making v generate cleaner C files,
// which are sometimes easier to debug / inspect manually than the .tmp.c files by plain -g (when/if v line number generation breaks).
// use cached modules to speed up compilation.
use_cache bool // = true
retry_compilation bool = true
is_stats bool // `v -stats file_test.v` will produce more detailed statistics for the tests that were run
use_cache bool // = true
retry_compilation bool = true
is_stats bool // `v -stats file_test.v` will produce more detailed statistics for the tests that were run
// TODO Convert this into a []string
cflags string // Additional options which will be passed to the C compiler.
cflags string // Additional options which will be passed to the C compiler.
// For example, passing -cflags -Os will cause the C compiler to optimize the generated binaries for size.
// You could pass several -cflags XXX arguments. They will be merged with each other.
// You can also quote several options at the same time: -cflags '-Os -fno-inline-small-functions'.
m64 bool // true = generate 64-bit code, defaults to x64
ccompiler string // the name of the C compiler used
ccompiler_type CompilerType // the type of the C compiler used
third_party_option string
building_v bool
autofree bool // `v -manualfree` => false, `v -autofree` => true; false by default for now.
m64 bool // true = generate 64-bit code, defaults to x64
ccompiler string // the name of the C compiler used
ccompiler_type CompilerType // the type of the C compiler used
third_party_option string
building_v bool
autofree bool // `v -manualfree` => false, `v -autofree` => true; false by default for now.
// Disabling `free()` insertion results in better performance in some applications (e.g. compilers)
compress bool
compress bool
// skip_builtin bool // Skips re-compilation of the builtin module
// to increase compilation time.
// This is on by default, since a vast majority of users do not
// work on the builtin module itself.
// generating_vh bool
enable_globals bool // allow __global for low level code
is_fmt bool
is_vet bool
is_bare bool
no_preludes bool // Prevents V from generating preludes in resulting .c files
custom_prelude string // Contents of custom V prelude that will be prepended before code in resulting .c files
lookup_path []string
output_cross_c bool
prealloc bool
vroot string
out_name_c string // full os.real_path to the generated .tmp.c file; set by builder.
out_name string
display_name string
bundle_id string
path string // Path to file/folder to compile
enable_globals bool // allow __global for low level code
is_fmt bool
is_vet bool
is_bare bool
no_preludes bool // Prevents V from generating preludes in resulting .c files
custom_prelude string // Contents of custom V prelude that will be prepended before code in resulting .c files
lookup_path []string
output_cross_c bool
prealloc bool
vroot string
out_name_c string // full os.real_path to the generated .tmp.c file; set by builder.
out_name string
display_name string
bundle_id string
path string // Path to file/folder to compile
// -d vfmt and -d another=0 for `$if vfmt { will execute }` and `$if another { will NOT get here }`
compile_defines []string // just ['vfmt']
compile_defines_all []string // contains both: ['vfmt','another']

View File

@ -19,17 +19,17 @@ const (
pub struct Scanner {
pub mut:
file_path string
text string
pos int
line_nr int
last_nl_pos int // for calculating column
is_inside_string bool
is_inter_start bool // for hacky string interpolation TODO simplify
is_inter_end bool
is_enclosed_inter bool
is_debug bool
line_comment string
file_path string
text string
pos int
line_nr int
last_nl_pos int // for calculating column
is_inside_string bool
is_inter_start bool // for hacky string interpolation TODO simplify
is_inter_end bool
is_enclosed_inter bool
is_debug bool
line_comment string
// prev_tok TokenKind
is_started bool
is_print_line_on_error bool

View File

@ -37,8 +37,8 @@ pub:
ctdefine string // compile time define. myflag, when [if myflag] tag
attrs []Attr
pub mut:
name string
source_fn voidptr // set in the checker, while processing fn declarations
name string
source_fn voidptr // set in the checker, while processing fn declarations
}
fn (f &Fn) method_equals(o &Fn) bool {
@ -77,7 +77,7 @@ pub:
name string
is_mut bool
mut:
typ Type
typ Type
}
pub fn new_table() &Table {

View File

@ -35,14 +35,14 @@ pub struct TypeSymbol {
pub:
parent_idx int
pub mut:
info TypeInfo
kind Kind
name string // the internal & source name of the type, i.e. `[5]int`.
cname string // the name with no dots for use in the generated C code
methods []Fn
mod string
is_public bool
language Language
info TypeInfo
kind Kind
name string // the internal & source name of the type, i.e. `[5]int`.
cname string // the name with no dots for use in the generated C code
methods []Fn
mod string
is_public bool
language Language
}
// max of 8
@ -609,7 +609,7 @@ pub fn (kinds []Kind) str() string {
pub struct Struct {
pub:
attrs []Attr
attrs []Attr
pub mut:
embeds []Type
fields []Field
@ -649,7 +649,7 @@ pub struct Aggregate {
mut:
fields []Field // used for faster lookup inside the module
pub:
types []Type
types []Type
}
// NB: FExpr here is a actually an ast.Expr .
@ -659,7 +659,7 @@ pub type FExpr = byteptr | voidptr
pub struct Field {
pub:
name string
name string
pub mut:
typ Type
default_expr FExpr
@ -681,15 +681,15 @@ fn (f &Field) equals(o &Field) bool {
pub struct Array {
pub:
nr_dims int
nr_dims int
pub mut:
elem_type Type
}
pub struct ArrayFixed {
pub:
nr_dims int
size int
nr_dims int
size int
pub mut:
elem_type Type
}

View File

@ -3,8 +3,8 @@ module util
import strings
struct Possibility {
value string
svalue string
value string
svalue string
mut:
similarity f32
}

View File

@ -23,7 +23,7 @@ pub struct ModFileAndFolder {
pub:
// vmod_file contains the full path of the found 'v.mod' file, or ''
// if no 'v.mod' file was found in file_path_dir, or in its parent folders.
vmod_file string
vmod_file string
// vmod_folder contains the file_path_dir, if there is no 'v.mod' file in
// *any* of the parent folders, otherwise it is the first parent folder,
// where a v.mod file was found.
@ -33,7 +33,7 @@ pub:
[ref_only]
pub struct ModFileCacher {
mut:
cache map[string]ModFileAndFolder
cache map[string]ModFileAndFolder
// folder_files caches os.ls(key)
folder_files map[string][]string
}

View File

@ -12,11 +12,11 @@ const (
struct AssetManager {
mut:
css []Asset
js []Asset
css []Asset
js []Asset
pub mut:
// when true assets will be minified
minify bool
minify bool
// the directory to store the cached/combined files
cache_dir string
}

View File

@ -41,11 +41,11 @@ pub const (
pub struct Context {
mut:
content_type string = 'text/plain'
status string = '200 OK'
content_type string = 'text/plain'
status string = '200 OK'
pub:
req http.Request
conn net.TcpConn
req http.Request
conn net.TcpConn
// TODO Response
pub mut:
static_files map[string]string

View File

@ -19,7 +19,7 @@ struct Fragment {
struct Frame {
mut:
// length of the websocket header part
header_len int = 2
header_len int = 2
// size of total frame
frame_size int = 2
fin bool // true if final fragment of message

View File

@ -16,7 +16,7 @@ const (
// Client represents websocket client
pub struct Client {
is_server bool
is_server bool
mut:
ssl_conn &openssl.SSLConn // secure connection used when wss is used
flags []Flag // flags used in handshake
@ -26,9 +26,9 @@ mut:
open_callbacks []OpenEventHandler // all callbacks on_open
close_callbacks []CloseEventHandler // all callbacks on_close
pub:
is_ssl bool // true if secure socket is used
uri Uri // uri of current connection
id string // unique id of client
is_ssl bool // true if secure socket is used
uri Uri // uri of current connection
id string // unique id of client
pub mut:
conn net.TcpConn // underlying TCP socket connection
nonce_size int = 16 // size of nounce used for masking

View File

@ -15,12 +15,12 @@ mut:
message_callbacks []MessageEventHandler // new message callback functions
close_callbacks []CloseEventHandler // close message callback functions
pub:
port int // port used as listen to incoming connections
is_ssl bool // true if secure connection (not supported yet on server)
port int // port used as listen to incoming connections
is_ssl bool // true if secure connection (not supported yet on server)
pub mut:
clients map[string]&ServerClient // clients connected to this server
ping_interval int = 30 // interval for sending ping to clients (seconds)
state State // current state of connection
clients map[string]&ServerClient // clients connected to this server
ping_interval int = 30 // interval for sending ping to clients (seconds)
state State // current state of connection
}
// ServerClient represents a connected client
@ -29,8 +29,8 @@ pub:
resource_name string // resource that the client access
client_key string // unique key of client
pub mut:
server &Server
client &Client
server &Server
client &Client
}
// new_server instance a new websocket server on provided port and route