java: Generate overloaded non-optargs method for each optargs method.

For example the existing method:

  public void mkfs_opts (String fstype, String device, Map<..> optargs);

is now accompanied by this overloaded method which is a simple wrapper:

  public void mkfs_opts (String fstype, String device)
    throws LibGuestFSException
  {
    mkfs_opts (fstype, device, null);
  }
This commit is contained in:
Richard W.M. Jones
2012-07-13 13:59:00 +01:00
parent 60805c9217
commit 0da2dbef26
3 changed files with 25 additions and 2 deletions

View File

@@ -178,6 +178,29 @@ public class GuestFS {
);
pr " }\n";
pr "\n";
(* Generate an overloaded method that has no optargs argument,
* and make it call the method above with 'null' for the last
* arg.
*)
if optargs <> [] then (
pr " ";
generate_java_prototype ~public:true ~semicolon:false
name (ret, args, []);
pr "\n";
pr " {\n";
(match ret with
| RErr -> pr " "
| _ -> pr " return "
);
pr "%s (" name;
List.iter (fun arg -> pr "%s, " (name_of_argt arg)) args;
pr "null);\n";
pr " }\n";
pr "\n"
);
(* Prototype for the native method. *)
pr " ";
generate_java_prototype ~privat:true ~native:true name style;
pr "\n";

View File

@@ -9,7 +9,7 @@ guestfs-java - How to use libguestfs from Java
import com.redhat.et.libguestfs.*;
GuestFS g = new GuestFS ();
g.add_drive_opts ("disk.img", null);
g.add_drive_opts ("disk.img");
g.launch ();
=head1 DESCRIPTION

View File

@@ -27,7 +27,7 @@ public class GuestFS080OptArgs
try {
GuestFS g = new GuestFS ();
g.add_drive_opts ("/dev/null", null);
g.add_drive_opts ("/dev/null");
HashMap<String,Object> optargs;