From 4ada0a7815075c9cbe9d8b00da791c105ae739a9 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Tue, 9 Nov 2010 12:08:06 +0000 Subject: generator: Add Pointer parameter type to the generator. This allows generic "foo *bar" pointers to be passed to library functions (not to daemon functions). In the language bindings (except Perl) these are handled as generic int64s with the assumption being that any pointer can be converted to and from this. There is room to add specific support for some pointer types in future by specializing the match cases. However this is inherently tricky because it depends on the implementation details of other bindings (eg. to support virDomainPtr in OCaml depends on the implementation details of the ocaml-libvirt project). Perl is slightly different in that you have to supply a typemap. Again this would depend on the implementation detail of an external library unless you supplied a generic typemap for int64. --- generator/generator_java.ml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'generator/generator_java.ml') diff --git a/generator/generator_java.ml b/generator/generator_java.ml index b5517408..5ac92f74 100644 --- a/generator/generator_java.ml +++ b/generator/generator_java.ml @@ -217,7 +217,7 @@ and generate_java_prototype ?(public=false) ?(privat=false) ?(native=false) pr "boolean %s" n | Int n -> pr "int %s" n - | Int64 n -> + | Int64 n | Pointer (_, n) -> pr "long %s" n ) args; @@ -347,7 +347,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close pr ", jboolean j%s" n | Int n -> pr ", jint j%s" n - | Int64 n -> + | Int64 n | Pointer (_, n) -> pr ", jlong j%s" n ) args; if optargs <> [] then @@ -410,6 +410,8 @@ Java_com_redhat_et_libguestfs_GuestFS__1close pr " int %s;\n" n | Int64 n -> pr " int64_t %s;\n" n + | Pointer (t, n) -> + pr " %s %s;\n" t n ) args; let needs_i = @@ -458,6 +460,8 @@ Java_com_redhat_et_libguestfs_GuestFS__1close | Int n | Int64 n -> pr " %s = j%s;\n" n n + | Pointer (t, n) -> + pr " %s = (%s) j%s;\n" n t n ) args; if optargs <> [] then ( @@ -497,9 +501,10 @@ Java_com_redhat_et_libguestfs_GuestFS__1close pr " (*env)->ReleaseStringUTFChars (env, o, %s[i]);\n" n; pr " }\n"; pr " free (%s);\n" n - | Bool n - | Int n - | Int64 n -> () + | Bool _ + | Int _ + | Int64 _ + | Pointer _ -> () ) args; (* Check for errors. *) -- cgit