diff options
author | Richard Jones <rjones@redhat.com> | 2010-11-09 12:08:06 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2010-11-10 10:52:12 +0000 |
commit | 4ada0a7815075c9cbe9d8b00da791c105ae739a9 (patch) | |
tree | 3dbc7ddf2571460e58f366bfad39e5e66ed43891 /generator/generator_java.ml | |
parent | eaedf025f5c45a4e05cbf25e145215d48bea8f8d (diff) | |
download | libguestfs-4ada0a7815075c9cbe9d8b00da791c105ae739a9.tar.gz libguestfs-4ada0a7815075c9cbe9d8b00da791c105ae739a9.tar.xz libguestfs-4ada0a7815075c9cbe9d8b00da791c105ae739a9.zip |
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.
Diffstat (limited to 'generator/generator_java.ml')
-rw-r--r-- | generator/generator_java.ml | 15 |
1 files changed, 10 insertions, 5 deletions
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. *) |