Remote protocol working.
[wrappi.git] / generator / wrappi_main.ml
index 42b2140..2b40ec2 100644 (file)
 open Unix
 open Printf
 
+open Wrappi_utils
+open Wrappi_types
 open Wrappi_pr
 
-let eps = Wrappi_globals.get_entry_points ()
-let nr_eps = List.length eps
+let api = Wrappi_accumulator.get_api ()
+let nr_tds = StringMap.cardinal api.api_typedefs
+let nr_ens = StringMap.cardinal api.api_enums
+let nr_sds = StringMap.cardinal api.api_structs
+let nr_uns = StringMap.cardinal api.api_unions
+let nr_eps = StringMap.cardinal api.api_entry_points
+
+(* Extend the API with some entry points which are purely
+ * generated from other things, eg. from enums.
+ *)
+let api = Wrappi_enums.extend_api api
+let api = Wrappi_structs.extend_api api
 
 let dump_and_exit () =
-  printf "entry points (%d):\n" nr_eps;
+  printf "typedefs (%d):\n" nr_tds;
+  iter_typedefs api (fun td -> printf "  %s\n" (string_of_typedef td));
+
+  printf "enums (%d):\n" nr_ens;
+  iter_enums api (fun en -> printf "  %s\n" (string_of_enum en));
 
-  List.iter (fun ep ->
-    printf "  %s\n" (Wrappi_types.string_of_entry_point ep)
-  ) eps;
+  printf "structs (%d):\n" nr_sds;
+  iter_structs api (fun sd -> printf "  %s\n" (string_of_struct sd));
+
+  printf "unions (%d):\n" nr_uns;
+  iter_unions api (fun un -> printf "  %s\n" (string_of_union un));
+
+  printf "entry points (%d):\n" nr_eps;
+  iter_entry_points api (fun ep -> printf "  %s\n" (string_of_entry_point ep));
 
   exit 0
 
@@ -70,7 +91,8 @@ let perror msg = function
       eprintf "%s: %s\n" msg (Printexc.to_string exn)
 
 let () =
-  printf "generator, %d entry points\n" nr_eps;
+  printf "generator, %d typedefs, %d enums, %d structs, %d unions, %d entry points\n"
+    nr_tds nr_ens nr_sds nr_uns nr_eps;
 
   (* Acquire a lock so parallel builds won't run the generator
    * simultaneously.  It's assumed that ./configure.ac only exists in
@@ -96,12 +118,9 @@ Run it from the top source directory using the command
      perror "lock: configure.ac" exn;
      exit 1);
 
-  (* Create a structure that we'll pass around to each generator function. *)
-  let api = {
-    Wrappi_types.api_entry_points = eps
-  } in
-
   (* Generate code. *)
+  Wrappi_c_impl.generate api;
+  Wrappi_c_xdr.generate api;
   Wrappi_c.generate api;
 
   printf "generated %d lines of code in %d files\n"