Skip to content

Commit

Permalink
fix formatting fn with super long parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Jul 1, 2024
1 parent 06ee9cb commit 4280e51
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 14 deletions.
3 changes: 2 additions & 1 deletion vlib/builtin/cfns.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ fn C.SendMessageTimeoutW(hWnd voidptr, msg u32, wParam &u16, lParam &u32, fuFlag
lpdwResult &u64) isize

fn C.CreateProcessW(lpApplicationName &u16, lpCommandLine &u16, lpProcessAttributes voidptr,
lpThreadAttributes voidptr, bInheritHandles bool, dwCreationFlags u32, lpEnvironment voidptr, lpCurrentDirectory &u16, lpStartupInfo voidptr, lpProcessInformation voidptr) bool
lpThreadAttributes voidptr, bInheritHandles bool, dwCreationFlags u32, lpEnvironment voidptr,
lpCurrentDirectory &u16, lpStartupInfo voidptr, lpProcessInformation voidptr) bool

fn C.ReadFile(hFile voidptr, lpBuffer voidptr, nNumberOfBytesToRead u32, lpNumberOfBytesRead &u32,
lpOverlapped voidptr) bool
Expand Down
3 changes: 2 additions & 1 deletion vlib/clipboard/x11/clipboard.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ fn C.XConvertSelection(d &C.Display, selection Atom, target Atom, property Atom,
fn C.XSync(d &C.Display, discard int) int

fn C.XGetWindowProperty(d &C.Display, w Window, property Atom, offset i64, length i64, delete int,
req_type Atom, actual_type_return &Atom, actual_format_return &int, nitems &u64, bytes_after_return &u64, prop_return &&u8) int
req_type Atom, actual_type_return &Atom, actual_format_return &int, nitems &u64, bytes_after_return &u64,
prop_return &&u8) int

fn C.XDeleteProperty(d &C.Display, w Window, property Atom) int

Expand Down
3 changes: 2 additions & 1 deletion vlib/db/mssql/_cdefs.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ fn C.SQLSetConnectAttr(connection_handle C.SQLHDBC, attribute C.SQLINTEGER, valu
string_length C.SQLINTEGER) C.SQLRETURN

fn C.SQLDriverConnect(hdbc C.SQLHDBC, hwnd C.SQLHWND, sz_conn_str_in &C.SQLCHAR, cb_conn_str_in C.SQLSMALLINT,
sz_conn_str_out &C.SQLCHAR, cb_conn_str_out_max C.SQLSMALLINT, pcb_conn_str_out &C.SQLSMALLINT, f_driver_completion C.SQLUSMALLINT) C.SQLRETURN
sz_conn_str_out &C.SQLCHAR, cb_conn_str_out_max C.SQLSMALLINT, pcb_conn_str_out &C.SQLSMALLINT,
f_driver_completion C.SQLUSMALLINT) C.SQLRETURN

fn C.SQLDisconnect(connection_handle C.SQLHDBC) C.SQLRETURN

Expand Down
3 changes: 2 additions & 1 deletion vlib/gg/gg_ui.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ pub fn (ctx &Context) has_text_style() bool {
}

pub fn (ctx &Context) set_text_style(font_name string, font_path string, size int, color gx.Color,
align int, vertical_align int) {}
align int, vertical_align int) {
}

// default draw_text (draw_text_def but without set_text_cfg)
pub fn (ctx &Context) draw_text_default(x int, y int, text string) {
Expand Down
9 changes: 6 additions & 3 deletions vlib/js/dom/dom.js.v
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ mut:
}

pub interface JS.DOMMatrix {
JS.DOMMatrix
JS.DOMMatrix
is2D JS.Boolean
isIdentity JS.Boolean
flipX() JS.DOMMatrix
Expand All @@ -57,7 +59,7 @@ pub interface JS.DOMMatrix {
rotate(rotX JS.Number, rotY JS.Number, rotZ JS.Number) JS.DOMMatrix
rotateAxisAngle(x JS.Number, y JS.Number, z JS.Number, angle JS.Number) JS.DOMMatrix
scale(scaleX JS.Number, scaleY JS.Number, scaleZ JS.Number, originX JS.Number, originY JS.Number,
originZ JS.Number) JS.DOMMatrix
originZ JS.Number)
scale3d(scale JS.Number, originX JS.Number, originY JS.Number, originZ JS.Number) JS.DOMMatrix
skewX(sx JS.Number) JS.DOMMatrix
skewY(sy JS.Number) JS.DOMMatrix
Expand All @@ -70,7 +72,7 @@ pub interface JS.DOMMatrix {
rotateSelf(rotX JS.Number, rotY JS.Number, rotZ JS.Number) JS.DOMMatrix
scale3dSelf(scale JS.Number, originX JS.Number, originY JS.Number, originZ JS.Number) JS.DOMMatrix
scaleSelf(scaleX JS.Number, scaleY JS.Number, scaleZ JS.Number, originX JS.Number, originY JS.Number,
originZ JS.Number) JS.DOMMatrix
originZ JS.Number)
toString() JS.String
mut:
a JS.Number
Expand Down Expand Up @@ -439,6 +441,7 @@ mut:
pub type FillStyle = JS.CanvasGradient | JS.CanvasPattern | JS.String

pub interface JS.CanvasRenderingContext2D {
JS.CanvasGradient
canvas JS.HTMLCanvasElement
beginPath()
clip(path JS.Path2D, fillRule JS.String)
Expand All @@ -448,7 +451,7 @@ pub interface JS.CanvasRenderingContext2D {
stoke(path JS.Path2D)
createLinearGradient(x0 JS.Number, y0 JS.Number, x1 JS.Number, y1 JS.Number) JS.CanvasGradient
createRadialGradient(x0 JS.Number, y0 JS.Number, r0 JS.Number, x1 JS.Number, y1 JS.Number,
r1 JS.Number) JS.CanvasGradient
r1 JS.Number)
createPattern(image JS.CanvasImageSource, repetition JS.String) ?JS.CanvasPattern
arc(x JS.Number, y JS.Number, radius JS.Number, startAngle JS.Number, endAngle JS.Number,
counterclockwise JS.Boolean)
Expand Down
6 changes: 3 additions & 3 deletions vlib/v/ast/str.v
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ fn (t &Table) stringify_fn_after_name(node &FnDecl, mut f strings.Builder, cur_m
}
}
f.write_string('(')
mut has_wrapped := false
mut last_len := 0
for i, param in node.params {
// skip receiver
if node.is_method && i == 0 {
Expand Down Expand Up @@ -229,9 +229,9 @@ fn (t &Table) stringify_fn_after_name(node &FnDecl, mut f strings.Builder, cur_m
}
}
if !is_last_param {
if f.len > 90 && !has_wrapped {
if f.len - last_len > 90 {
f.write_string(',\n\t')
has_wrapped = true
last_len = f.len
} else {
f.write_string(', ')
}
Expand Down
3 changes: 2 additions & 1 deletion vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,8 @@ fn (mut c Checker) enum_decl(mut node ast.EnumDecl) {
}

fn (mut c Checker) check_enum_field_integer_literal(expr ast.IntegerLiteral, is_signed bool,
is_multi_allowed bool, styp string, pos token.Pos, mut useen []u64, umin u64, umax u64, mut iseen []i64, imin i64, imax i64) {
is_multi_allowed bool, styp string, pos token.Pos, mut useen []u64, umin u64, umax u64, mut iseen []i64,
imin i64, imax i64) {
mut overflows := false
mut uval := u64(0)
mut ival := i64(0)
Expand Down
8 changes: 7 additions & 1 deletion vlib/v/fmt/tests/fn_with_long_args_keep.vv
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
fn process_keyholder(super_long_argument1 string, super_long_argument2 string, super_long_argument3 string,
fn process_keyholder1(super_long_argument1 string, super_long_argument2 string, super_long_argument3 string,
super_long_argument4 string, super_long_argument5 string) string {
return ''
}

fn process_keyholder2(super_long_argument1 string, super_long_argument2 string, super_long_argument3 string,
super_long_argument4 string, super_long_argument5 string, super_long_argument6 string, super_long_argument7 string,
super_long_argument8 string) string {
return ''
}

fn main() {}
6 changes: 4 additions & 2 deletions vlib/x/templating/dtm/dynamic_template_manager.v
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,8 @@ fn (mut tm DynamicTemplateManager) check_tmpl_and_placeholders_size(f_path strin
// The function returns the rendered immediately, without waiting for the cache to be created or updated.
//
fn (mut tm DynamicTemplateManager) create_template_cache_and_display(tcs CacheRequest, last_template_mod i64,
unique_time i64, file_path string, tmpl_name string, cache_delay_expiration i64, placeholders &map[string]DtmMultiTypeMap, current_content_checksum string, tmpl_type TemplateType) string {
unique_time i64, file_path string, tmpl_name string, cache_delay_expiration i64, placeholders &map[string]DtmMultiTypeMap,
current_content_checksum string, tmpl_type TemplateType) string {
// Control if cache delay expiration is correctly set. See the function itself for more details.
check_if_cache_delay_iscorrect(cache_delay_expiration, tmpl_name) or {
eprintln(err)
Expand Down Expand Up @@ -1040,7 +1041,8 @@ fn check_if_cache_delay_iscorrect(cde i64, tmpl_name string) ! {
// to decide whether to create a new cache, update an existing or delivered a valid cache content.
//
fn (mut tm DynamicTemplateManager) cache_request_route(is_cache_exist bool, neg_cache_delay_expiration i64,
last_template_mod i64, test_current_template_mod i64, cache_del_exp i64, gen_at i64, c_time i64, content_checksum string, current_content_checksum string) (CacheRequest, i64) {
last_template_mod i64, test_current_template_mod i64, cache_del_exp i64, gen_at i64, c_time i64,
content_checksum string, current_content_checksum string) (CacheRequest, i64) {
if !is_cache_exist || neg_cache_delay_expiration == -1 {
// Require cache creation
unique_ts := get_current_unix_micro_timestamp()
Expand Down

0 comments on commit 4280e51

Please sign in to comment.