[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 3/3] generator: do not output GUESTFS_HAVE_* defines for internal stuff



Output the GUESTFS_HAVE_* defines only for actions with visibility
different than VInternal, and for structs not marked as internal.
The reason is that all the above are usable only by the library itself
(and at most by tests), and users of the library now cannot even get the
function declarations.
---
 generator/c.ml | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/generator/c.ml b/generator/c.ml
index 4497c48..bee1ab0 100644
--- a/generator/c.ml
+++ b/generator/c.ml
@@ -694,9 +694,11 @@ and generate_guestfs_private_h () =
  *)
 and generate_all_structs structs =
   List.iter (
-    fun { s_name = typ; s_cols = cols } ->
-      pr "#define GUESTFS_HAVE_STRUCT_%s 1\n" (String.uppercase typ);
-      pr "\n";
+    fun { s_name = typ; s_cols = cols; s_internal = internal } ->
+      if not internal then (
+        pr "#define GUESTFS_HAVE_STRUCT_%s 1\n" (String.uppercase typ);
+        pr "\n";
+      );
       pr "struct guestfs_%s {\n" typ;
       List.iter (
         function
@@ -731,10 +733,12 @@ and generate_all_structs structs =
   ) structs
 
 and generate_all_headers actions =
-  let generate_action_header { name = shortname;
-                               style = ret, args, optargs as style;
-                               deprecated_by = deprecated_by } =
-    pr "#define GUESTFS_HAVE_%s 1\n" (String.uppercase shortname);
+  let generate_action_header ({ name = shortname;
+                                style = ret, args, optargs as style;
+                                deprecated_by = deprecated_by } as act) =
+    let not_internal = not (is_internal act) in
+    if not_internal then
+      pr "#define GUESTFS_HAVE_%s 1\n" (String.uppercase shortname);
 
     if optargs <> [] then (
       iteri (
-- 
2.7.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]