mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
force snake_case in variable names
This commit is contained in:
parent
100bcc2034
commit
840e496a51
@ -41,6 +41,7 @@ fn (f &Fn) find_var(name string) Var {
|
||||
return Var{}
|
||||
}
|
||||
|
||||
|
||||
fn (f mut Fn) open_scope() {
|
||||
f.scope_level++
|
||||
}
|
||||
@ -297,20 +298,19 @@ fn (p mut Parser) fn_decl() {
|
||||
p.cur_fn = f
|
||||
// Register the method
|
||||
if receiver_typ != '' {
|
||||
mut receiver_T := p.table.find_type(receiver_typ)
|
||||
mut receiver_t := p.table.find_type(receiver_typ)
|
||||
// No such type yet? It could be defined later. Create a new type.
|
||||
// struct declaration later will modify it instead of creating a new one.
|
||||
if p.first_run() && receiver_T.name == '' {
|
||||
if p.first_run() && receiver_t.name == '' {
|
||||
// println('fn decl !!!!!!! REG PH $receiver_typ')
|
||||
ttyp := Type {
|
||||
p.table.register_type2(Type {
|
||||
name: receiver_typ.replace('*', '')
|
||||
mod: p.mod
|
||||
is_placeholder: true
|
||||
}
|
||||
p.table.register_type2(ttyp)
|
||||
})
|
||||
}
|
||||
// f.idx = p.table.fn_cnt
|
||||
receiver_T.add_method(f)
|
||||
receiver_t.add_method(f)
|
||||
}
|
||||
else {
|
||||
// println('register_fn typ=$typ isg=$is_generic')
|
||||
@ -734,7 +734,7 @@ fn (p mut Parser) fn_call_args(f *Fn) *Fn {
|
||||
if ! (expected == 'void*' && got == 'int') &&
|
||||
! (expected == 'byte*' && got.contains(']byte')) &&
|
||||
! (expected == 'byte*' && got == 'string') {
|
||||
p.cgen.set_placeholder(ph, '& /*11 EXP:"$expected" .key_goT:"$got" */')
|
||||
p.cgen.set_placeholder(ph, '& /*11 EXP:"$expected" GOT:"$got" */')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1152,6 +1152,9 @@ fn (p mut Parser) var_decl() {
|
||||
v := p.cur_fn.find_var(name)
|
||||
p.error('redefinition of `$name`')
|
||||
}
|
||||
if name.len > 1 && contains_capital(name) {
|
||||
p.error('variable names cannot contain uppercase letters, use snake_case instead')
|
||||
}
|
||||
p.check_space(.decl_assign) // :=
|
||||
// Generate expression to tmp because we need its type first
|
||||
// [TYP .name =] bool_expression()
|
||||
|
@ -43,9 +43,9 @@ fn advance(sys System, dt f64) {
|
||||
dy := sys.s[i].y - sys.s[j].y
|
||||
dz := sys.s[i].z - sys.s[j].z
|
||||
|
||||
dSquared := dx * dx + dy * dy + dz * dz
|
||||
distance := math.sqrt(dSquared)
|
||||
mag := (dt / (dSquared * distance))
|
||||
dsquared := dx * dx + dy * dy + dz * dz
|
||||
distance := math.sqrt(dsquared)
|
||||
mag := (dt / (dsquared * distance))
|
||||
mi := sys.v[i].m
|
||||
|
||||
_vx -= dx * sys.v[j].m * mag
|
||||
|
16
vlib/gg/gg.v
16
vlib/gg/gg.v
@ -107,9 +107,9 @@ pub fn new_context(cfg Cfg) *GG {
|
||||
// i := glm.identity3()
|
||||
shader.set_mat4('projection', glm.identity())
|
||||
}
|
||||
VAO := gl.gen_vertex_array()
|
||||
vao := gl.gen_vertex_array()
|
||||
//println('new gg context VAO=$VAO')
|
||||
VBO := gl.gen_buffer()
|
||||
vbo := gl.gen_buffer()
|
||||
mut scale := 1
|
||||
if cfg.retina {
|
||||
scale = 2
|
||||
@ -126,8 +126,8 @@ pub fn new_context(cfg Cfg) *GG {
|
||||
shader: shader
|
||||
width: cfg.width
|
||||
height: cfg.height
|
||||
VAO: VAO
|
||||
VBO: VBO
|
||||
VAO: vao
|
||||
VBO: vbo
|
||||
// /line_vao: gl.gen_vertex_array()
|
||||
// /line_vbo: gl.gen_buffer()
|
||||
//text_ctx: new_context_text(cfg, scale),
|
||||
@ -272,11 +272,11 @@ fn todo_remove_me(cfg Cfg, scale int) {
|
||||
// projection_new := ortho(0, width, 0, height)// 0 at BOT
|
||||
// projection := gl.ortho(0, width,height,0) // 0 at TOP
|
||||
shader.set_mat4('projection', projection)
|
||||
VAO := gl.gen_vertex_array()
|
||||
vao := gl.gen_vertex_array()
|
||||
//println('new gg text context VAO=$VAO')
|
||||
VBO := gl.gen_buffer()
|
||||
gl.bind_vao(VAO)
|
||||
gl.bind_buffer(GL_ARRAY_BUFFER, VBO)
|
||||
vbo := gl.gen_buffer()
|
||||
gl.bind_vao(vao)
|
||||
gl.bind_buffer(GL_ARRAY_BUFFER, vbo)
|
||||
gl.enable_vertex_attrib_array(0)
|
||||
gl.vertex_attrib_pointer(0, 4, GL_FLOAT, false, 4, 0)
|
||||
}
|
||||
|
24
vlib/gl/gl.v
24
vlib/gl/gl.v
@ -87,15 +87,15 @@ pub fn delete_shader(shader int) {
|
||||
}
|
||||
|
||||
pub fn shader_info_log(shader int) string {
|
||||
infoLog := [512]byte
|
||||
C.glGetShaderInfoLog(shader, 512, 0, infoLog)
|
||||
return tos_clone(infoLog)
|
||||
info_log := [512]byte
|
||||
C.glGetShaderInfoLog(shader, 512, 0, info_log)
|
||||
return tos_clone(info_log)
|
||||
}
|
||||
|
||||
pub fn get_program_info_log(program int) string {
|
||||
infoLog := [1024]byte
|
||||
C.glGetProgramInfoLog(program, 1024, 0, infoLog)
|
||||
return tos_clone(infoLog)
|
||||
info_log := [1024]byte
|
||||
C.glGetProgramInfoLog(program, 1024, 0, info_log)
|
||||
return tos_clone(info_log)
|
||||
}
|
||||
|
||||
pub fn bind_vao(vao u32) {
|
||||
@ -166,9 +166,9 @@ pub fn use_program(program int) {
|
||||
}
|
||||
|
||||
pub fn gen_vertex_array() u32 {
|
||||
VAO := u32(0)
|
||||
C.glGenVertexArrays(1, &VAO)
|
||||
return VAO
|
||||
vao := u32(0)
|
||||
C.glGenVertexArrays(1, &vao)
|
||||
return vao
|
||||
}
|
||||
|
||||
pub fn enable_vertex_attrib_array(n int) {
|
||||
@ -176,9 +176,9 @@ pub fn enable_vertex_attrib_array(n int) {
|
||||
}
|
||||
|
||||
pub fn gen_buffer() u32 {
|
||||
VBO := u32(0)
|
||||
C.glGenBuffers(1, &VBO)
|
||||
return VBO
|
||||
vbo := u32(0)
|
||||
C.glGenBuffers(1, &vbo)
|
||||
return vbo
|
||||
}
|
||||
|
||||
pub fn vertex_attrib_pointer(index, size int, typ int, normalized bool, stride int, ptr int) {
|
||||
|
Loading…
Reference in New Issue
Block a user