mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vfmt: change all '$expr' to '${expr}' (#16428)
This commit is contained in:
@@ -31,7 +31,7 @@ pub fn (k ValueKind) str() string {
|
||||
}
|
||||
|
||||
fn format_message(msg string, line int, column int) string {
|
||||
return '[x.json2] $msg ($line:$column)'
|
||||
return '[x.json2] ${msg} (${line}:${column})'
|
||||
}
|
||||
|
||||
pub struct DecodeError {
|
||||
@@ -63,8 +63,8 @@ pub fn (err InvalidTokenError) code() int {
|
||||
|
||||
// msg returns the message of the InvalidTokenError
|
||||
pub fn (err InvalidTokenError) msg() string {
|
||||
footer_text := if err.expected != .none_ { ', expecting `$err.expected`' } else { '' }
|
||||
return format_message('invalid token `$err.token.kind`$footer_text', err.token.line,
|
||||
footer_text := if err.expected != .none_ { ', expecting `${err.expected}`' } else { '' }
|
||||
return format_message('invalid token `${err.token.kind}`${footer_text}', err.token.line,
|
||||
err.token.full_col())
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ pub fn (err UnknownTokenError) code() int {
|
||||
|
||||
// msg returns the error message of the UnknownTokenError
|
||||
pub fn (err UnknownTokenError) msg() string {
|
||||
return format_message("unknown token '$err.token.lit' when decoding ${err.kind}.",
|
||||
return format_message("unknown token '${err.token.lit}' when decoding ${err.kind}.",
|
||||
err.token.line, err.token.full_col())
|
||||
}
|
||||
|
||||
|
@@ -53,12 +53,12 @@ fn test_encoder_unescaped_utf32() {
|
||||
mut sb := strings.new_builder(20)
|
||||
enc.encode_value(jap_text, mut sb)!
|
||||
|
||||
assert sb.str() == '"$jap_text"'
|
||||
assert sb.str() == '"${jap_text}"'
|
||||
sb.go_back_to(0)
|
||||
|
||||
emoji_text := json2.Any('🐈')
|
||||
enc.encode_value(emoji_text, mut sb)!
|
||||
assert sb.str() == '"$emoji_text"'
|
||||
assert sb.str() == '"${emoji_text}"'
|
||||
}
|
||||
|
||||
fn test_encoder_prettify() {
|
||||
|
@@ -44,7 +44,7 @@ pub fn (f Any) as_map() map[string]Any {
|
||||
} else if f is []Any {
|
||||
mut mp := map[string]Any{}
|
||||
for i, fi in f {
|
||||
mp['$i'] = fi
|
||||
mp['${i}'] = fi
|
||||
}
|
||||
return mp
|
||||
}
|
||||
|
@@ -45,14 +45,14 @@ fn (mut e Employee) from_json(any json2.Any) {
|
||||
fn test_simple() {
|
||||
x := Employee{'Peter', 28, 95000.5, .worker}
|
||||
s := json2.encode<Employee>(x)
|
||||
eprintln('Employee x: $s')
|
||||
eprintln('Employee x: ${s}')
|
||||
assert s == '{"name":"Peter","age":28,"salary":95000.5,"title":2}'
|
||||
y := json2.decode<Employee>(s) or {
|
||||
println(err)
|
||||
assert false
|
||||
return
|
||||
}
|
||||
eprintln('Employee y: $y')
|
||||
eprintln('Employee y: ${y}')
|
||||
assert y.name == 'Peter'
|
||||
assert y.age == 28
|
||||
assert y.salary == 95000.5
|
||||
@@ -83,7 +83,7 @@ fn test_character_unescape() {
|
||||
return
|
||||
}
|
||||
lines := obj.as_map()
|
||||
eprintln('$lines')
|
||||
eprintln('${lines}')
|
||||
assert lines['newline'] or { 0 }.str() == 'new\nline'
|
||||
assert lines['tab'] or { 0 }.str() == '\ttab'
|
||||
assert lines['backslash'] or { 0 }.str() == 'back\\slash'
|
||||
|
@@ -157,7 +157,7 @@ fn (mut s Scanner) text_scan() Token {
|
||||
break
|
||||
} else if !s.text[s.pos].is_hex_digit() {
|
||||
x := s.text[s.pos].ascii_str()
|
||||
return s.error('`$x` is not a hex digit')
|
||||
return s.error('`${x}` is not a hex digit')
|
||||
}
|
||||
codepoint << s.text[s.pos]
|
||||
}
|
||||
@@ -248,10 +248,10 @@ fn (mut s Scanner) num_scan() Token {
|
||||
fn (s Scanner) invalid_token() Token {
|
||||
if s.text[s.pos] >= 32 && s.text[s.pos] <= 126 {
|
||||
x := s.text[s.pos].ascii_str()
|
||||
return s.error('invalid token `$x`')
|
||||
return s.error('invalid token `${x}`')
|
||||
} else {
|
||||
x := s.text[s.pos].str_escaped()
|
||||
return s.error('invalid token `$x`')
|
||||
return s.error('invalid token `${x}`')
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -244,7 +244,7 @@ fn my_init(mut app App_data) {
|
||||
}
|
||||
|
||||
fn draw_frame(mut app App_data) {
|
||||
cframe_txt := 'Current Frame: $app.frame_c'
|
||||
cframe_txt := 'Current Frame: ${app.frame_c}'
|
||||
|
||||
app.gg.begin()
|
||||
|
||||
@@ -285,7 +285,7 @@ fn main() {
|
||||
for font_path in font_paths {
|
||||
mut tf := ttf.TTF_File{}
|
||||
tf.buf = os.read_bytes(font_path) or { panic(err) }
|
||||
println('TrueTypeFont file [$font_path] len: $tf.buf.len')
|
||||
println('TrueTypeFont file [${font_path}] len: ${tf.buf.len}')
|
||||
tf.init()
|
||||
println(tf.get_info_string())
|
||||
app.tf << tf
|
||||
|
@@ -95,7 +95,7 @@ pub fn (mut bmp BitMap) save_as_ppm(file_name string) {
|
||||
npixels := bmp.width * bmp.height
|
||||
mut f_out := os.create(file_name) or { panic(err) }
|
||||
f_out.writeln('P3') or { panic(err) }
|
||||
f_out.writeln('$bmp.width $bmp.height') or { panic(err) }
|
||||
f_out.writeln('${bmp.width} ${bmp.height}') or { panic(err) }
|
||||
f_out.writeln('255') or { panic(err) }
|
||||
for i in 0 .. npixels {
|
||||
pos := i * bmp.bp
|
||||
@@ -103,7 +103,7 @@ pub fn (mut bmp BitMap) save_as_ppm(file_name string) {
|
||||
c_r := bmp.buf[pos]
|
||||
c_g := bmp.buf[pos + 1]
|
||||
c_b := bmp.buf[pos + 2]
|
||||
f_out.write_string('$c_r $c_g $c_b ') or { panic(err) }
|
||||
f_out.write_string('${c_r} ${c_g} ${c_b} ') or { panic(err) }
|
||||
}
|
||||
}
|
||||
f_out.close()
|
||||
|
@@ -56,7 +56,7 @@ pub fn (mut tf_skl TTF_render_Sokol) create_text(in_txt string, in_font_size f32
|
||||
if sz > 0 {
|
||||
unsafe { free(tf_skl.bmp.buf) }
|
||||
}
|
||||
dprintln('create_text Alloc: $sz bytes')
|
||||
dprintln('create_text Alloc: ${sz} bytes')
|
||||
tf_skl.bmp.buf = unsafe { malloc_noscan(sz) }
|
||||
tf_skl.bmp.buf_size = sz
|
||||
}
|
||||
@@ -94,7 +94,7 @@ pub fn (mut tf_skl TTF_render_Sokol) create_text_block(in_txt string, in_w int,
|
||||
if sz > 0 {
|
||||
unsafe { free(tf_skl.bmp.buf) }
|
||||
}
|
||||
dprintln('Alloc: $sz bytes')
|
||||
dprintln('Alloc: ${sz} bytes')
|
||||
tf_skl.bmp.buf = unsafe { malloc_noscan(sz) }
|
||||
tf_skl.bmp.buf_size = sz
|
||||
}
|
||||
|
@@ -106,10 +106,10 @@ pub fn (mut tf TTF_File) init() {
|
||||
tf.read_kern_table()
|
||||
tf.read_panose_table()
|
||||
tf.length = tf.glyph_count()
|
||||
dprintln('Number of symbols: $tf.length')
|
||||
dprintln('Number of symbols: ${tf.length}')
|
||||
dprintln('*****************************')
|
||||
dprintln('Unit per em: $tf.units_per_em')
|
||||
dprintln('advance_width_max: $tf.advance_width_max')
|
||||
dprintln('Unit per em: ${tf.units_per_em}')
|
||||
dprintln('advance_width_max: ${tf.advance_width_max}')
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -675,11 +675,11 @@ fn (mut tf TTF_File) read_offset_tables() {
|
||||
tf.entry_selector = tf.get_u16()
|
||||
tf.range_shift = tf.get_u16()
|
||||
|
||||
dprintln('scalar_type : [0x$tf.scalar_type.hex()]')
|
||||
dprintln('num tables : [$num_tables]')
|
||||
dprintln('search_range : [0x$tf.search_range.hex()]')
|
||||
dprintln('entry_selector: [0x$tf.entry_selector.hex()]')
|
||||
dprintln('range_shift : [0x$tf.range_shift.hex()]')
|
||||
dprintln('scalar_type : [0x${tf.scalar_type.hex()}]')
|
||||
dprintln('num tables : [${num_tables}]')
|
||||
dprintln('search_range : [0x${tf.search_range.hex()}]')
|
||||
dprintln('entry_selector: [0x${tf.entry_selector.hex()}]')
|
||||
dprintln('range_shift : [0x${tf.range_shift.hex()}]')
|
||||
|
||||
mut i := 0
|
||||
for i < num_tables {
|
||||
@@ -689,7 +689,7 @@ fn (mut tf TTF_File) read_offset_tables() {
|
||||
offset: tf.get_u32()
|
||||
length: tf.get_u32()
|
||||
}
|
||||
dprintln('Table: [$tag]')
|
||||
dprintln('Table: [${tag}]')
|
||||
// dprintln("${tf.tables[tag]}")
|
||||
|
||||
if tag != 'head' {
|
||||
@@ -708,7 +708,7 @@ fn (mut tf TTF_File) read_offset_tables() {
|
||||
fn (mut tf TTF_File) read_head_table() {
|
||||
dprintln('*** READ HEAD TABLE ***')
|
||||
tf.pos = tf.tables['head'].offset
|
||||
dprintln('Offset: $tf.pos')
|
||||
dprintln('Offset: ${tf.pos}')
|
||||
|
||||
tf.version = tf.get_fixed()
|
||||
tf.font_revision = tf.get_fixed()
|
||||
@@ -804,7 +804,7 @@ fn (mut tf TTF_File) read_cmap_table() {
|
||||
platform_id := tf.get_u16()
|
||||
platform_specific_id := tf.get_u16()
|
||||
offset := tf.get_u32()
|
||||
dprintln('CMap platform_id=$platform_id specific_id=$platform_specific_id offset=$offset')
|
||||
dprintln('CMap platform_id=${platform_id} specific_id=${platform_specific_id} offset=${offset}')
|
||||
if platform_id == 3 && platform_specific_id <= 1 {
|
||||
tf.read_cmap(table_offset + offset)
|
||||
}
|
||||
@@ -818,7 +818,7 @@ fn (mut tf TTF_File) read_cmap(offset u32) {
|
||||
length := tf.get_u16()
|
||||
language := tf.get_u16()
|
||||
|
||||
dprintln(' Cmap format: $format length: $length language: $language')
|
||||
dprintln(' Cmap format: ${format} length: ${length} language: ${language}')
|
||||
if format == 0 {
|
||||
dprintln(' Cmap 0 Init...')
|
||||
mut cmap := TrueTypeCmap{}
|
||||
@@ -858,7 +858,7 @@ fn (mut tm TrueTypeCmap) init_0(mut tf TTF_File) {
|
||||
tm.format = 0
|
||||
for i in 0 .. 256 {
|
||||
glyph_index := tf.get_u8()
|
||||
dprintln(' Glyph[$i] = %glyph_index')
|
||||
dprintln(' Glyph[${i}] = %glyph_index')
|
||||
tm.arr << glyph_index
|
||||
}
|
||||
}
|
||||
@@ -1021,7 +1021,7 @@ fn (mut tf TTF_File) create_kern_table0(vertical bool, cross bool) Kern0Table {
|
||||
search_range := tf.get_u16()
|
||||
entry_selector := tf.get_u16()
|
||||
range_shift := tf.get_u16()
|
||||
dprintln('n_pairs: $n_pairs search_range: $search_range entry_selector: $entry_selector range_shift: $range_shift')
|
||||
dprintln('n_pairs: ${n_pairs} search_range: ${search_range} entry_selector: ${entry_selector} range_shift: ${range_shift}')
|
||||
|
||||
mut kt0 := Kern0Table{
|
||||
swap: (vertical && !cross) || (!vertical && cross)
|
||||
@@ -1053,7 +1053,7 @@ fn (mut tf TTF_File) read_kern_table() {
|
||||
assert version == 0 // must be 0
|
||||
n_tables := tf.get_u16()
|
||||
|
||||
dprintln('Kern Table version: $version Kern nTables: $n_tables')
|
||||
dprintln('Kern Table version: ${version} Kern nTables: ${n_tables}')
|
||||
|
||||
for _ in 0 .. n_tables {
|
||||
st_version := tf.get_u16() // sub table version
|
||||
@@ -1062,7 +1062,7 @@ fn (mut tf TTF_File) read_kern_table() {
|
||||
format := coverage >> 8
|
||||
cross := coverage & 4
|
||||
vertical := (coverage & 0x1) == 0
|
||||
dprintln('Kerning subtable version [$st_version] format [$format] length [$length] coverage: [$coverage.hex()]')
|
||||
dprintln('Kerning subtable version [${st_version}] format [${format}] length [${length}] coverage: [${coverage.hex()}]')
|
||||
if format == 0 {
|
||||
dprintln('kern format: 0')
|
||||
kern := tf.create_kern_table0(vertical, cross != 0)
|
||||
@@ -1135,18 +1135,18 @@ fn (mut tf TTF_File) read_panose_table() {
|
||||
******************************************************************************/
|
||||
pub fn (tf TTF_File) get_info_string() string {
|
||||
txt := '----- Font Info -----
|
||||
font_family : $tf.font_family
|
||||
font_sub_family : $tf.font_sub_family
|
||||
full_name : $tf.full_name
|
||||
postscript_name : $tf.postscript_name
|
||||
version : $tf.version
|
||||
font_revision : $tf.font_revision
|
||||
magic_number : $tf.magic_number.hex()
|
||||
flags : $tf.flags.hex()
|
||||
created unixTS : $tf.created
|
||||
modified unixTS : $tf.modified
|
||||
box : [x_min:$tf.x_min, y_min:$tf.y_min, x_Max:$tf.x_max, y_Max:$tf.y_max]
|
||||
mac_style : $tf.mac_style
|
||||
font_family : ${tf.font_family}
|
||||
font_sub_family : ${tf.font_sub_family}
|
||||
full_name : ${tf.full_name}
|
||||
postscript_name : ${tf.postscript_name}
|
||||
version : ${tf.version}
|
||||
font_revision : ${tf.font_revision}
|
||||
magic_number : ${tf.magic_number.hex()}
|
||||
flags : ${tf.flags.hex()}
|
||||
created unixTS : ${tf.created}
|
||||
modified unixTS : ${tf.modified}
|
||||
box : [x_min:${tf.x_min}, y_min:${tf.y_min}, x_Max:${tf.x_max}, y_Max:${tf.y_max}]
|
||||
mac_style : ${tf.mac_style}
|
||||
-----------------------
|
||||
'
|
||||
return txt
|
||||
@@ -1181,7 +1181,7 @@ fn tst() {
|
||||
assert tf.get_u16().hex() == 'f1f2'
|
||||
assert tf.get_u32().hex() == '81234567'
|
||||
|
||||
dprintln('buf len: $tf.buf.len')
|
||||
dprintln('buf len: ${tf.buf.len}')
|
||||
// dprintln( tf.get_u8().hex() )
|
||||
// dprintln( tf.get_u16().hex() )
|
||||
// dprintln( tf.get_u32().hex() )
|
||||
|
@@ -163,7 +163,7 @@ fn test_main() {
|
||||
mut tf := ttf.TTF_File{}
|
||||
$if create_data ? {
|
||||
tf.buf = os.read_bytes(font_path) or { panic(err) }
|
||||
println('TrueTypeFont file [$font_path] len: $tf.buf.len')
|
||||
println('TrueTypeFont file [${font_path}] len: ${tf.buf.len}')
|
||||
save_raw_data_as_array(tf.buf, 'test_ttf_Font_arr.bin')
|
||||
} $else {
|
||||
mut mut_font_bytes := font_bytes
|
||||
|
Reference in New Issue
Block a user