Skip to content

Commit 67a2ddf

Browse files
committed
Tweak C++ whitespace
1 parent 2bfbfc6 commit 67a2ddf

9 files changed

Lines changed: 759 additions & 1144 deletions

File tree

src/stan_math_backend/Stan_math_code_gen.ml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ let pp_promoted_scalar ppf args =
9999
match args with
100100
| [] -> pf ppf "double"
101101
| hd :: tl ->
102-
pf ppf "stan::promote_args_t<@[%a%a@]>" (list ~sep:comma string) hd
103-
go tl in
102+
pf ppf "@[stan::promote_args_t<@[%a%a@]>@]" (list ~sep:comma string)
103+
hd go tl in
104104
promote_args_chunked ppf
105105
List.(chunks_of ~length:5 (filter_opt (return_arg_types args)))
106106

@@ -191,7 +191,7 @@ let get_templates_and_args exprs fdargs =
191191
let pp_template_decorator ppf = function
192192
| [] -> ()
193193
| templates ->
194-
pf ppf "template @[<hov><%a>@]@ " (list ~sep:comma string) templates
194+
pf ppf "@[template <@[<h 8>%a>@]@]@ " (list ~sep:comma string) templates
195195

196196
let mk_extra_args templates args =
197197
List.map ~f:(fun (t, v) -> t ^ "& " ^ v) (List.zip_exn templates args)
@@ -213,7 +213,7 @@ let pp_fun_def ppf
213213
| FnRng -> (["base_rng__"], ["RNG"])
214214
| FnLpdf _ | FnPlain -> ([], []) in
215215
let pp_body ppf (Stmt.Fixed.{pattern; _} as fdbody) =
216-
pf ppf "@[<hv 8>using local_scalar_t__ = %a;@]@," pp_promoted_scalar fdargs ;
216+
pf ppf "@[<hv 8>using local_scalar_t__ =@ %a;@]@," pp_promoted_scalar fdargs ;
217217
pf ppf "int current_statement__ = 0; @ " ;
218218
if List.exists ~f:(fun (_, _, t) -> UnsizedType.is_eigen_type t) fdargs then
219219
pp_eigen_arg_to_ref ppf fdargs ;
@@ -233,6 +233,7 @@ let pp_fun_def ppf
233233
pp_located_error ppf (pp_statement, blocked_fdbody) ;
234234
pf ppf "@ " in
235235
let pp_sig ppf (name, exprs, variadic) =
236+
Format.open_vbox 2 ;
236237
let argtypetemplates, args = get_templates_and_args exprs fdargs in
237238
let templates =
238239
List.(map ~f:typename (argtypetemplates @ extra_templates)) in
@@ -252,7 +253,8 @@ let pp_fun_def ppf
252253
@ mk_extra_args extra_templates extra
253254
@ ["std::ostream* pstream__"]
254255
@ variadic_args in
255-
pf ppf "%s(@[<hov>%a@]) " name (list ~sep:comma string) arg_strs in
256+
pf ppf "%s(@[<hov>%a@]) " name (list ~sep:comma string) arg_strs ;
257+
Format.close_box () in
256258
pp_sig ppf (fdname, true, `None) ;
257259
match fdbody with
258260
| None -> pf ppf ";@ "
@@ -981,11 +983,11 @@ let pp_prog ppf (p : Program.Typed.t) =
981983
let fns_str, functors = collect_functors_functions p in
982984
let pp_functor_decls ppf tbl =
983985
Hashtbl.iteri tbl ~f:(fun ~key ~data ->
984-
pf ppf "%astruct %s {@,@[<hov 2>%aconst;@]@.};@."
986+
pf ppf "@[<v 2>%astruct %s {@,%aconst;@]@,};@."
985987
(Fmt.option (fun ppf o -> pf ppf "%s" o))
986988
(Option.map ~f:(fun x -> x.template) (List.hd data))
987989
key
988-
(list ~sep:(any "const;@,") text)
990+
(list ~sep:(any "const;@,") (hbox text))
989991
(List.map ~f:(fun x -> x.signature) data) ) in
990992
let pp_functors ppf tbl =
991993
Hashtbl.iter tbl ~f:(fun data ->

0 commit comments

Comments
 (0)