From c3a7d4490ac1469388f510022bfc5f297d905c38 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Wed, 9 Jul 2008 12:43:42 +0100 Subject: [PATCH] Add a __str__ function to CppMethod, allowing to pretty-print a method description (great for debugging purposes). --- pybindgen/cppmethod.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/pybindgen/cppmethod.py b/pybindgen/cppmethod.py index 9dea0eb..91e11c3 100644 --- a/pybindgen/cppmethod.py +++ b/pybindgen/cppmethod.py @@ -279,7 +279,30 @@ class CppMethod(ForwardWrapperBase): return "{\"%s\", (PyCFunction) %s, %s, %s }," % \ (method_name, self.wrapper_actual_name, '|'.join(flags), (self.docstring is None and "NULL" or ('"'+self.docstring+'"'))) - + + def __str__(self): + if self.class_ is None: + cls_name = "???" + else: + cls_name = self.class_.full_name + if self.is_const: + const = ' const' + else: + const = '' + if self.is_virtual: + virtual = "virtual " + else: + virtual = '' + if self.is_pure_virtual: + pure_virtual = " = 0" + else: + pure_virtual = '' + + return ("%s: %s%s %s::%s (%s)%s%s;" % + (self.visibility, virtual, self.return_value.ctype, cls_name, self.method_name, + ', '.join(["%s %s" % (param.ctype, param.name) for param in self.parameters]), + const, pure_virtual)) + class CppOverloadedMethod(overloading.OverloadedWrapper): "Support class for overloaded methods"