X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=generator%2Fgenerator_php.ml;h=4431147f73fabd6933200c83aea150930ef0937a;hp=b71d5c3540a5df1fb281dfbf19d1d4c9a46a7cfe;hb=bb965ded274f911fb5d7889f88db9adaad1d2a52;hpb=14490c3e1aac61c6ac90f28828896683f64f0dc9 diff --git a/generator/generator_php.ml b/generator/generator_php.ml index b71d5c3..4431147 100644 --- a/generator/generator_php.ml +++ b/generator/generator_php.ml @@ -200,7 +200,7 @@ PHP_FUNCTION (guestfs_last_error) pr " char **%s;\n" n; | Bool n -> pr " zend_bool %s;\n" n - | Int n | Int64 n -> + | Int n | Int64 n | Pointer (_, n) -> pr " long %s;\n" n ) args; @@ -236,7 +236,7 @@ PHP_FUNCTION (guestfs_last_error) | OptString n -> "s!" | StringList n | DeviceList n -> "a" | Bool n -> "b" - | Int n | Int64 n -> "l" + | Int n | Int64 n | Pointer (_, n) -> "l" ) args ) in @@ -267,7 +267,7 @@ PHP_FUNCTION (guestfs_last_error) pr ", &z_%s" n | Bool n -> pr ", &%s" n - | Int n | Int64 n -> + | Int n | Int64 n | Pointer (_, n) -> pr ", &%s" n ) args; List.iter ( @@ -330,7 +330,7 @@ PHP_FUNCTION (guestfs_last_error) pr " %s[c] = NULL;\n" n; pr " }\n"; pr "\n" - | Bool n | Int n | Int64 n -> () + | Bool _ | Int _ | Int64 _ | Pointer _ -> () ) args; (* Optional arguments. *) @@ -357,28 +357,27 @@ PHP_FUNCTION (guestfs_last_error) ); (* Return value. *) - let error_code = - match ret with - | RErr -> pr " int r;\n"; "-1" - | RBool _ - | RInt _ -> pr " int r;\n"; "-1" - | RInt64 _ -> pr " int64_t r;\n"; "-1" - | RConstString _ -> pr " const char *r;\n"; "NULL" - | RConstOptString _ -> pr " const char *r;\n"; "NULL" - | RString _ -> - pr " char *r;\n"; "NULL" - | RStringList _ -> - 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" - | RHashtable _ -> - pr " char **r;\n"; "NULL" - | RBufferOut _ -> - pr " char *r;\n"; - pr " size_t size;\n"; - "NULL" in + (match ret with + | RErr -> pr " int r;\n" + | RBool _ + | RInt _ -> pr " int r;\n" + | RInt64 _ -> pr " int64_t r;\n" + | RConstString _ -> pr " const char *r;\n" + | RConstOptString _ -> pr " const char *r;\n" + | RString _ -> + pr " char *r;\n" + | RStringList _ -> + pr " char **r;\n" + | RStruct (_, typ) -> + pr " struct guestfs_%s *r;\n" typ + | RStructList (_, typ) -> + pr " struct guestfs_%s_list *r;\n" typ + | RHashtable _ -> + pr " char **r;\n" + | RBufferOut _ -> + pr " char *r;\n"; + pr " size_t size;\n" + ); (* Call the function. *) if optargs = [] then @@ -406,13 +405,21 @@ PHP_FUNCTION (guestfs_last_error) pr " efree (%s);\n" n; pr " }\n"; pr "\n" - | Bool n | Int n | Int64 n -> () + | Bool _ | Int _ | Int64 _ | Pointer _ -> () ) args; (* Check for errors. *) - pr " if (r == %s) {\n" error_code; - pr " RETURN_FALSE;\n"; - pr " }\n"; + (match errcode_of_ret ret with + | `CannotReturnError -> () + | `ErrorIsMinusOne -> + pr " if (r == -1) {\n"; + pr " RETURN_FALSE;\n"; + pr " }\n" + | `ErrorIsNULL -> + pr " if (r == NULL) {\n"; + pr " RETURN_FALSE;\n"; + pr " }\n" + ); pr "\n"; (* Convert the return value. *)