From 1b993407ea1d7683da5358c1b0827651690f88db Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Thu, 30 Jun 2016 16:22:33 +0200 Subject: [PATCH] python interface: extract method print_method_type This reduces code duplication. We use this opportunity to add some documentation. Signed-off-by: Tobias Grosser Signed-off-by: Sven Verdoolaege --- interface/python.cc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/interface/python.cc b/interface/python.cc index 5d182ca3..e9eacf09 100644 --- a/interface/python.cc +++ b/interface/python.cc @@ -115,6 +115,7 @@ struct isl_class { void print(map &classes, set &done); void print_constructor(FunctionDecl *method); void print_representation(const string &python_name); + void print_method_type(FunctionDecl *fd); void print_method_types(); void print_method(FunctionDecl *method, vector super); void print_method_overload(FunctionDecl *method, vector super); @@ -693,6 +694,14 @@ static void print_argtypes(FunctionDecl *fd) printf("]\n"); } +/* Print type definitions for the method 'fd'. + */ +void isl_class::print_method_type(FunctionDecl *fd) +{ + print_restype(fd); + print_argtypes(fd); +} + /* Print declarations for methods printing the class representation. * * In particular, provide an implementation of __str__ and __repr__ methods to @@ -730,15 +739,13 @@ void isl_class::print_method_types() set::iterator in; map >::iterator it; - for (in = constructors.begin(); in != constructors.end(); ++in) { - print_restype(*in); - print_argtypes(*in); - } + for (in = constructors.begin(); in != constructors.end(); ++in) + print_method_type(*in); + for (it = methods.begin(); it != methods.end(); ++it) - for (in = it->second.begin(); in != it->second.end(); ++in) { - print_restype(*in); - print_argtypes(*in); - } + for (in = it->second.begin(); in != it->second.end(); ++in) + print_method_type(*in); + printf("isl.%s_free.argtypes = [c_void_p]\n", name.c_str()); printf("isl.%s_to_str.argtypes = [c_void_p]\n", name.c_str()); printf("isl.%s_to_str.restype = POINTER(c_char)\n", name.c_str()); -- 2.11.4.GIT