From 20480068caefae4ff62c3564113df0788a2a1c87 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 19 Jul 2011 16:34:06 +0100 Subject: [PATCH] java: Tidy up the generated C bindings file. --- generator/generator_java.ml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/generator/generator_java.ml b/generator/generator_java.ml index 4d51c53..0152bb3 100644 --- a/generator/generator_java.ml +++ b/generator/generator_java.ml @@ -390,7 +390,6 @@ Java_com_redhat_et_libguestfs_GuestFS__1close pr "JNICALL\n"; pr "Java_com_redhat_et_libguestfs_GuestFS_"; pr "%s" (replace_str ("_" ^ name) "_" "_1"); - pr "\n"; pr " (JNIEnv *env, jobject obj, jlong jg"; List.iter ( function @@ -486,6 +485,11 @@ Java_com_redhat_et_libguestfs_GuestFS__1close pr " %s %s;\n" t n ) args; + if optargs <> [] then ( + pr " struct guestfs_%s_argv optargs_s;\n" name; + pr " const struct guestfs_%s_argv *optargs = &optargs_s;\n" name + ); + let needs_i = (match ret with | RStringList _ | RStructList _ | RHashtable _ -> true @@ -537,8 +541,6 @@ Java_com_redhat_et_libguestfs_GuestFS__1close ) args; if optargs <> [] then ( - pr " struct guestfs_%s_argv optargs_s;\n" name; - pr " const struct guestfs_%s_argv *optargs = &optargs_s;\n" name; pr " optargs_s.bitmask = joptargs_bitmask;\n"; List.iter ( function @@ -553,6 +555,8 @@ Java_com_redhat_et_libguestfs_GuestFS__1close ) optargs; ); + pr "\n"; + (* Make the call. *) if optargs = [] then pr " r = guestfs_%s " name @@ -561,6 +565,8 @@ Java_com_redhat_et_libguestfs_GuestFS__1close generate_c_call_args ~handle:"g" style; pr ";\n"; + pr "\n"; + (* Release the parameters. *) List.iter ( function @@ -599,6 +605,8 @@ Java_com_redhat_et_libguestfs_GuestFS__1close | _ -> assert false ) optargs; + pr "\n"; + (* Check for errors. *) (match errcode_of_ret ret with | `CannotReturnError -> () -- 1.8.3.1