X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=generator%2Fgenerator_ruby.ml;h=49ddf1ffdd433cc4acd0e4827f32f1dadf8b5e72;hb=8037da06feea097716ce700f38c0eac0d5411a7c;hp=d0a7cd209db02ceee1253165225c3d03473e485c;hpb=14490c3e1aac61c6ac90f28828896683f64f0dc9;p=libguestfs.git diff --git a/generator/generator_ruby.ml b/generator/generator_ruby.ml index d0a7cd2..49ddf1f 100644 --- a/generator/generator_ruby.ml +++ b/generator/generator_ruby.ml @@ -148,6 +148,8 @@ static VALUE ruby_guestfs_close (VALUE gv) pr " int %s = NUM2INT (%sv);\n" n n | Int64 n -> pr " long long %s = NUM2LL (%sv);\n" n n + | Pointer (t, n) -> + pr " %s %s = (%s) (intptr_t) NUM2LL (%sv);\n" t n t n ) args; pr "\n"; @@ -182,21 +184,20 @@ static VALUE ruby_guestfs_close (VALUE gv) pr "\n"; ); - let error_code = - match ret with - | RErr | RInt _ | RBool _ -> pr " int r;\n"; "-1" - | RInt64 _ -> pr " int64_t r;\n"; "-1" - | RConstString _ | RConstOptString _ -> - pr " const char *r;\n"; "NULL" - | RString _ -> pr " char *r;\n"; "NULL" - | RStringList _ | RHashtable _ -> pr " char **r;\n"; "NULL" - | RStruct (_, typ) -> pr " struct guestfs_%s *r;\n" typ; "NULL" - | RStructList (_, typ) -> - pr " struct guestfs_%s_list *r;\n" typ; "NULL" - | RBufferOut _ -> - pr " char *r;\n"; - pr " size_t size;\n"; - "NULL" in + (match ret with + | RErr | RInt _ | RBool _ -> pr " int r;\n" + | RInt64 _ -> pr " int64_t r;\n" + | RConstString _ | RConstOptString _ -> + pr " const char *r;\n" + | RString _ -> pr " char *r;\n" + | RStringList _ | RHashtable _ -> pr " char **r;\n" + | RStruct (_, typ) -> pr " struct guestfs_%s *r;\n" typ + | RStructList (_, typ) -> + pr " struct guestfs_%s_list *r;\n" typ + | RBufferOut _ -> + pr " char *r;\n"; + pr " size_t size;\n" + ); pr "\n"; if optargs = [] then @@ -210,13 +211,20 @@ static VALUE ruby_guestfs_close (VALUE gv) function | Pathname _ | Device _ | Dev_or_Path _ | String _ | Key _ | FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ | Int64 _ - | BufferIn _ -> () + | BufferIn _ | Pointer _ -> () | StringList n | DeviceList n -> pr " free (%s);\n" n ) args; - pr " if (r == %s)\n" error_code; - pr " rb_raise (e_Error, \"%%s\", guestfs_last_error (g));\n"; + (match errcode_of_ret ret with + | `CannotReturnError -> () + | `ErrorIsMinusOne -> + pr " if (r == -1)\n"; + pr " rb_raise (e_Error, \"%%s\", guestfs_last_error (g));\n" + | `ErrorIsNULL -> + pr " if (r == NULL)\n"; + pr " rb_raise (e_Error, \"%%s\", guestfs_last_error (g));\n" + ); pr "\n"; (match ret with