| 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;
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 "\