From f09837f10c5085ac48b52d595e0ac2766587021d Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 6 Sep 2018 16:36:54 +0200 Subject: [PATCH] python bindings: do not set return of functions returning isl_bool to c_bool While the python method returns a bool, the C function can also return a negative value. Note that there is currently no way of forcing a function returning isl_bool to return isl_bool_error from the python interface, so this fix cannot be tested in any obvious way. Even exporting a function with a callback returning bool and failing inside the callback does not help since the save exception is detected even if the called function does not return a negative value. Signed-off-by: Sven Verdoolaege --- interface/python.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/python.cc b/interface/python.cc index 7e6fd182..c97c5acb 100644 --- a/interface/python.cc +++ b/interface/python.cc @@ -491,9 +491,11 @@ void python_generator::print_class_header(const isl_class &clazz, /* Tell ctypes about the return type of "fd". * In particular, if "fd" returns a pointer to an isl object, * then tell ctypes it returns a "c_void_p". - * Similarly, if "fd" returns an isl_bool, - * then tell ctypes it returns a "c_bool". * If "fd" returns a char *, then simply tell ctypes. + * + * Nothing needs to be done for functions returning + * isl_bool or isl_stat since they are represented by an int and + * ctypes assumes that a function returns int by default. */ void python_generator::print_restype(FunctionDecl *fd) { @@ -501,8 +503,6 @@ void python_generator::print_restype(FunctionDecl *fd) QualType type = fd->getReturnType(); if (is_isl_type(type)) printf("isl.%s.restype = c_void_p\n", fullname.c_str()); - else if (is_isl_bool(type)) - printf("isl.%s.restype = c_bool\n", fullname.c_str()); else if (is_string(type)) printf("isl.%s.restype = POINTER(c_char)\n", fullname.c_str()); } -- 2.11.4.GIT