[Libguestfs] [PATCH 6/7] ruby: show warnings for deprecated functions

Pino Toscano ptoscano at redhat.com
Tue Apr 23 16:28:15 UTC 2019


Emit a warning when a deprecated function is used, so users have a way
to know that they are using one.
---
 generator/ruby.ml | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/generator/ruby.ml b/generator/ruby.ml
index 76fcb58eb..ea129fcba 100644
--- a/generator/ruby.ml
+++ b/generator/ruby.ml
@@ -253,6 +253,16 @@ and generate_ruby_c actions () =
         pr "\n"
       );
 
+      (match f.deprecated_by with
+      | Not_deprecated -> ()
+      | Replaced_by alt ->
+        pr "  rb_warn (\"Guestfs#%s is deprecated; use #%s instead\");\n" f.name alt;
+        pr "\n"
+      | Deprecated_no_replacement ->
+        pr "  rb_warn (\"Guestfs#%s is deprecated\");\n" f.name;
+        pr "\n"
+      );
+
       List.iter (
         function
         | String (_, n) ->
-- 
2.20.1




More information about the Libguestfs mailing list