From: Richard W.M. Jones Date: Sat, 31 Dec 2011 18:38:40 +0000 (+0000) Subject: Separate local and remote functions. X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=b5d8f76790194561f08fb500b3cc2cb10504199e;p=wrappi.git Separate local and remote functions. --- diff --git a/generator/wrappi_c.ml b/generator/wrappi_c.ml index 16e6caf..3011ab1 100644 --- a/generator/wrappi_c.ml +++ b/generator/wrappi_c.ml @@ -46,6 +46,27 @@ let c_of_rtype = function | RVoid -> "void" | Return t -> c_of_ptype ~param:false t +(* Print the extern... declaration of a single entry point. *) +let pr_extern_decl ep = + let ret, req, opt = ep.ep_ftype in + pr "extern %s wrap_%s (wrap_h *w" (c_of_rtype ret) ep.ep_name; + + (* Required parameters. *) + List.iter ( + fun (name, t, _) -> + let t = c_of_ptype ~param:true t in + let sep = (* "const char *" - omit space after asterisk *) + let len = String.length t in + if isalnum t.[len-1] then " " else "" in + pr ", %s%s%s" t sep name + ) req; + + (* Optional parameters. *) + if opt <> [] then + pr ", ..."; + + pr ");\n" + let generate_lib_wrappi_h api = generate_header CStyle LGPLv2plus; @@ -71,31 +92,19 @@ typedef struct wrap_h wrap_h; extern wrap_h *wrap_create (void); extern void wrap_close (wrap_h *w); -/* API entry points. */ "; - iter_entry_points api ( - fun ep -> - let ret, req, opt = ep.ep_ftype in - pr "extern %s wrap_%s (wrap_h *w" (c_of_rtype ret) ep.ep_name; - - (* Required parameters. *) - List.iter ( - fun (name, t, _) -> - let t = c_of_ptype ~param:true t in - let sep = (* "const char *" - omit space after asterisk *) - let len = String.length t in - if isalnum t.[len-1] then " " else "" in - pr ", %s%s%s" t sep name - ) req; - - (* Optional parameters. *) - if opt <> [] then - pr ", ..."; + (* Separate the local and remote functions. *) + pr "\ +/* Handle functions. */ +"; + iter_entry_points api (fun ep -> if ep.ep_local then pr_extern_decl ep); - pr ");\n" + pr "\ - ); +/* API entry points. */ +"; + iter_entry_points api (fun ep -> if not ep.ep_local then pr_extern_decl ep); pr "\