perl: show warnings for deprecated functions

Emit a deprecation warning when a deprecated function is used, so users
have a way to know that they are using one.
This commit is contained in:
Pino Toscano
2019-04-23 18:02:33 +02:00
parent a7666c1f1c
commit 96aed2fc9e

View File

@@ -335,7 +335,7 @@ PREINIT:
List.iter (
fun { name; style = (ret, args, optargs as style);
c_function; c_optarg_prefix } ->
c_function; c_optarg_prefix; deprecated_by } ->
(match ret with
| RErr -> pr "void\n"
| RInt _ -> pr "SV *\n"
@@ -444,6 +444,16 @@ PREINIT:
pr " PPCODE:\n";
);
(match deprecated_by with
| Not_deprecated -> ()
| Replaced_by alt ->
pr " Perl_ck_warner (aTHX_ packWARN(WARN_DEPRECATED),\n";
pr " \"Sys::Guestfs::%s is deprecated; use Sys::Guestfs::%s instead\");\n" name alt;
| Deprecated_no_replacement ->
pr " Perl_ck_warner (aTHX_ packWARN(WARN_DEPRECATED),\n";
pr " \"Sys::Guestfs::%s is deprecated\");\n" name;
);
(* For optional arguments, convert these from the XSUB "items"
* variable by hand.
*)