From c9ff6f535dbb9a67e81766e6906ce5840f4e050c Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Sun, 23 Mar 2008 19:03:38 +0000 Subject: [PATCH] Add CppClass.is_subclass method. --- pybindgen/cppclass.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pybindgen/cppclass.py b/pybindgen/cppclass.py index aa4b581..611aaa5 100644 --- a/pybindgen/cppclass.py +++ b/pybindgen/cppclass.py @@ -492,6 +492,18 @@ class CppClass(object): def __repr__(self): return "" % self.full_name + def is_subclass(self, other): + """Return True if this CppClass instance represents a class that is a + subclass of another class represented by the CppClasss object `other'.""" + if not isinstance(other, CppClass): + raise TypeError + cls = self + while cls is not None: + if cls is other: + return True + cls = cls.parent + return False + def write_incref(self, code_block, obj_expr): """ Write code to increase the reference code of an object of this