open Printf
+let inputs = ["wrappi_c_impl.ml"]
+
let c_of_ptype ~param = function
| TBool -> "int"
| TBuffer -> assert false (* XXX not implemented *)
- | TEnum name -> sprintf "enum wrap_%s" name
+ | TEnum name -> sprintf "wrap_%s_enum" name
| TFile -> if param then "const char *" else "char *"
| THash t -> if param then "char * const *" else "char **"
| TInt -> "int" (* XXX not int, correct type depends on preconditions *)
pr ")\n"
let generate_implementation ep =
- generate_header CStyle LGPLv2plus;
+ generate_header inputs CStyle LGPLv2plus;
pr "\
/* Automatically generated implementation of '%s'.
- * This API was defined in '%s' at line %d.
- */
+" ep.ep_name;
-" ep.ep_name (Loc.file_name ep.ep_loc) (Loc.start_line ep.ep_loc);
+ if not (Loc.is_ghost ep.ep_loc) then
+ pr " * This API was defined in '%s' at line %d.\n"
+ (Loc.file_name ep.ep_loc) (Loc.start_line ep.ep_loc);
+
+ pr " */
- pr "\
#include <config.h>
#include <stdio.h>
(match ep.ep_code with
| None -> () (* XXX implicit code *)
| Some { cc_loc = loc; cc_code = code } ->
- pr "#line %d \"%s\"\n" (Loc.start_line loc) (Loc.file_name loc);
+ if not (Loc.is_ghost loc) then
+ pr "#line %d \"%s\"\n" (Loc.start_line loc) (Loc.file_name loc);
pr "%s" code
);
pr_defn ep;
pr "{\n";
- pr " assert (w->scheme == NULL); /* XXX */;\n";
- pr "\n";
- pr " ";
+ pr " if (w->scheme == NULL) {\n";
+ pr " /* Local connection. */\n";
+ pr " ";
let ret, req, opt = ep.ep_ftype in
pr ");\n";
(match ret with
- | RVoid -> pr " return;\n"
+ | RVoid -> pr " return;\n"
| _ -> ()
);
+ pr " } else {\n";
+ pr " /* Remote connection. */\n";
+ pr " abort (); /* XXX */\n";
+ pr " }\n";
+
pr "}\n"
)
filename
let generate_lib_implementation_files_mk api =
- generate_header HashStyle GPLv2plus;
+ generate_header inputs HashStyle GPLv2plus;
let eps = StringMap.bindings api.api_entry_points in
let cmp (a, _) (b, _) = compare a b in