Skip to content

Commit

Permalink
tag c.Gen.write and strings.Builder.write_string with @[expand_simple…
Browse files Browse the repository at this point in the history
…_interpolation]
  • Loading branch information
spytheman committed Sep 9, 2024
1 parent 6c749ea commit a56da42
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion vlib/strings/builder.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub fn (b &Builder) byte_at(n int) u8 {
}

// write appends the string `s` to the buffer
@[inline]
@[expand_simple_interpolation; inline]
pub fn (mut b Builder) write_string(s string) {
if s.len == 0 {
return
Expand Down
18 changes: 16 additions & 2 deletions vlib/v/gen/c/text_manipulation.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module c

import v.util

@[expand_simple_interpolation]
fn (mut g Gen) write(s string) {
$if trace_gen ? {
if g.file == unsafe { nil } {
Expand All @@ -15,10 +16,23 @@ fn (mut g Gen) write(s string) {
}
if g.indent > 0 && g.empty_line {
g.out.write_string(util.tabs(g.indent))
// g.out_parallel[g.out_idx].write_string(util.tabs(g.indent))
}
g.out.write_string(s)
////g.out_parallel[g.out_idx].write_string(s)
g.empty_line = false
}

fn (mut g Gen) write_decimal(x i64) {
$if trace_gen ? {
if g.file == unsafe { nil } {
eprintln('gen file: <nil> | last_fn_c_name: ${g.last_fn_c_name:-45} | write_decimal: ${x}')
} else {
eprintln('gen file: ${g.file.path:-30} | last_fn_c_name: ${g.last_fn_c_name:-45} | write_decimal: ${x}')
}
}
if g.indent > 0 && g.empty_line {
g.out.write_string(util.tabs(g.indent))
}
g.out.write_decimal(x)
g.empty_line = false
}

Expand Down

0 comments on commit a56da42

Please sign in to comment.