From 595ae8ecd219bf46111d5f896bcc534a3209e303 Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Fri, 6 Jan 2017 15:26:30 +0100 Subject: [PATCH] python: remove redundant is_string_type In commit 72f7994 (python interface: support 'char *' and 'const *' return types, Thu Jun 30 16:22:34 2016), the is_string_type() method was added accidentally despite is_string() already providing the very functionality. Even worse, is_string_type() has a bug where a "char" interpreted as boolean true and it also contains a seemingly unnecessary call to isFunctionType(). Remove the redundant function definition and switch the two users to is_string(). This change does not change the output of isl.py. Reported-by: Sven Verdoolaege Signed-off-by: Tobias Grosser Signed-off-by: Sven Verdoolaege --- interface/python.cc | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/interface/python.cc b/interface/python.cc index c32ca3fb..437d6eda 100644 --- a/interface/python.cc +++ b/interface/python.cc @@ -217,23 +217,6 @@ static bool is_isl_bool(QualType type) return s == "isl_bool"; } -/* Is "type" that of a pointer to char. - */ -static bool is_string_type(QualType type) -{ - if (type->isPointerType()) { - string s; - - type = type->getPointeeType(); - if (type->isFunctionType()) - return false; - s = type.getAsString(); - return s == "const char" || "char"; - } - - return false; -} - /* Is "type" that of a pointer to a function? */ static bool is_callback(QualType type) @@ -469,7 +452,7 @@ static void print_method_return(FunctionDecl *method) type = type2python(extract_type(return_type)); printf(" return %s(ctx=ctx, ptr=res)\n", type.c_str()); - } else if (is_string_type(return_type)) { + } else if (is_string(return_type)) { printf(" if res == 0:\n"); printf(" raise\n"); printf(" string = str(cast(res, c_char_p).value)\n"); @@ -743,7 +726,7 @@ static void print_restype(FunctionDecl *fd) 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(type)) + else if (is_string(type)) printf("isl.%s.restype = POINTER(c_char)\n", fullname.c_str()); } -- 2.11.4.GIT