From e47e2ef326af29272fba78ea59befe4c192ff68c Mon Sep 17 00:00:00 2001 From: ygrek Date: Sat, 16 May 2009 22:24:47 +0300 Subject: [PATCH] minor --- demo/build | 1 + gen_caml.ml | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/demo/build b/demo/build index 2567615..316d35d 100755 --- a/demo/build +++ b/demo/build @@ -4,4 +4,5 @@ g++ -g -o demo_cxx demo_cxx.cpp -lsqlite3 ../sqlgg.byte -gen caml ../demo.sql > demo_caml_gen.ml ln -sf ../sqlgg_traits.ml sqlgg_traits.ml ln -sf ../sqlgg_sqlite3.ml sqlgg_sqlite3.ml +ocamlc -w Ase sqlgg_traits.ml -i demo_caml_gen.ml > demo_caml_gen.mli #ocamlc -w Ase -g -o demo_caml -I +sqlite3 sqlite3.cma sqlgg_sqlite3.ml sqlgg_traits.ml demo_caml_gen.ml demo_caml.ml diff --git a/gen_caml.ml b/gen_caml.ml index d8f48dd..38f8f9d 100644 --- a/gen_caml.ml +++ b/gen_caml.ml @@ -9,7 +9,7 @@ open Stmt open Gen open Sql -let inline_values = String.concat " " +let inline_values = String.concat " " let quote = String.replace_chars (function '\n' -> "\\n\\\n" | '\r' -> "" | '"' -> "\\\"" | c -> String.make 1 c) let quote s = "\"" ^ quote s ^ "\"" @@ -19,7 +19,7 @@ let rec replace_all ~str ~sub ~by = | (true,s) -> replace_all ~str:s ~sub ~by | (false,s) -> s -let quote_comment_inline str = +let quote_comment_inline str = let str = replace_all ~str ~sub:"*)" ~by:"* )" in replace_all ~str ~sub:"(*" ~by:"( *" @@ -27,7 +27,7 @@ let make_comment str = "(* " ^ (quote_comment_inline str) ^ " *)" let comment fmt = Printf.kprintf (indent_endline & make_comment) fmt let get_column attr index = - output "(T.get_column_%s stmt %u)" + output "(T.get_column_%s stmt %u)" (Type.to_string attr.RA.domain) index @@ -42,7 +42,7 @@ let set_param index param = let output_scheme_binder index scheme = let name = "invoke_callback" in - output "let %s stmt = " name; + output "let %s stmt =" name; inc_indent (); output "callback"; inc_indent (); @@ -50,7 +50,7 @@ let output_scheme_binder index scheme = dec_indent (); dec_indent (); output "in"; - name + name let output_scheme_binder index scheme = match scheme with @@ -61,7 +61,7 @@ let params_to_values = List.mapi (fun i (n,_) -> param_name_to_string n i) let params_to_values = List.unique & params_to_values let output_params_binder index params = - output "let set_params stmt = "; + output "let set_params stmt ="; inc_indent (); List.iteri set_param params; output "()"; @@ -78,15 +78,15 @@ let generate_code index scheme params kind props = let name = choose_name props kind index >> String.uncapitalize in let values = params_to_values params >> inline_values in let all_params = match scheme with [] -> values | _ -> "callback " ^ values in - output "let %s db %s = " name all_params; + output "let %s db %s =" name all_params; inc_indent (); let sql = quote (get_sql props kind params) in let scheme_binder_name = output_scheme_binder index scheme in let params_binder_name = output_params_binder index params in begin match scheme_binder_name with - | None -> + | None -> output "T.execute db %s %s" sql params_binder_name - | Some scheme_binder_name -> + | Some scheme_binder_name -> output "T.select db %s %s %s" sql scheme_binder_name params_binder_name end; dec_indent (); @@ -97,7 +97,7 @@ let start_output () = empty_line (); inc_indent () -let finish_output () = +let finish_output () = dec_indent (); output "end (* module Sqlgg *)" -- 2.11.4.GIT