More enums.
authorRichard W.M. Jones <rjones@redhat.com>
Sun, 1 Jan 2012 21:22:30 +0000 (21:22 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Sun, 1 Jan 2012 21:22:30 +0000 (21:22 +0000)
generator/wrappi_c.ml
generator/wrappi_enums.ml
lib/.gitignore
lib/implementation_files.mk

index 80b832b..bdf65c8 100644 (file)
@@ -111,9 +111,6 @@ typedef struct wrap_h wrap_h;
           pr "  WRAP_%s_%s = %d,\n"
             (String.uppercase name) (String.uppercase id) i
       ) en.en_identifiers;
-
-      pr "  WRAP_%s_ENUM_MAX = %d\n"
-        (String.uppercase name) (Array.length en.en_identifiers);
       pr "};\n";
       pr "typedef int wrap_%s_enum;\n" name;
       pr "\n";
index 3b33ec5..0e2c32c 100644 (file)
@@ -86,7 +86,25 @@ let extend_api api =
         ep_includes = []
       } in
 
-      eps := StringMap.add fname ep !eps
+      eps := StringMap.add fname ep !eps;
+
+      (* Add an entry point wrap_<name>_enum_nr. *)
+      let fname = sprintf "%s_enum_nr" name in
+      let code = sprintf "  return %d;\n" (Array.length en.en_identifiers) in
+      let c_code = {
+        cc_loc = Loc.ghost;
+        cc_code = code;
+      } in
+      let ep = {
+        ep_loc = Loc.ghost;
+        ep_local = true;
+        ep_name = fname;
+        ep_ftype = Return TInt, [], [];
+        ep_code = Some c_code;
+        ep_includes = []
+      } in
+
+      eps := StringMap.add fname ep !eps;
   );
 
   { api with api_entry_points = !eps }
index 2f8a6ba..846aa7f 100644 (file)
@@ -6,5 +6,6 @@
 /error-get_error_func.c
 /mkdir-mkdir.c
 /mknod-mknod_char.c
+/ghost-location-scheme_enum_nr.c
 /ghost-location-scheme_enum_to_string.c
 /ghost-location-scheme_string_to_enum.c
index 8290343..c0abae2 100644 (file)
@@ -25,6 +25,7 @@ local_implementation_files := \
        error-get_errno.c \
        error-get_error.c \
        error-get_error_func.c \
+       ghost-location-scheme_enum_nr.c \
        ghost-location-scheme_enum_to_string.c \
        ghost-location-scheme_string_to_enum.c