From 33c786bfbf7762f4acdcf9e17769a583c92d02af Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Sun, 6 Jan 2008 15:01:42 +0000 Subject: [PATCH] Discover the typeid map variable name as early as possible --- pybindgen/cppclass.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pybindgen/cppclass.py b/pybindgen/cppclass.py index 9320289..cf12a8c 100644 --- a/pybindgen/cppclass.py +++ b/pybindgen/cppclass.py @@ -350,7 +350,7 @@ class CppClass(object): "Cannot disable subclassing if the parent class allows it" self.allow_subclassing = allow_subclassing - self.typeid_map_name = None # name of C++ variable + self.typeid_map_name = None if name != 'dummy': ## register type handlers @@ -509,6 +509,11 @@ class CppClass(object): ## re-register the class type handlers, now with class full name self.register_alias(self.full_name) + if self.get_type_narrowing_root() is self: + self.typeid_map_name = "%s__typeid_map" % self.pystruct + else: + self.typeid_map_name = None + def register_alias(self, alias): """Re-register the class with another base name, in addition to any @@ -584,8 +589,6 @@ class CppClass(object): def _register_typeid(self, module): """register this class with the typeid map root class""" root = self.get_type_narrowing_root() - if root.typeid_map_name is None: - root.typeid_map_name = "%s__typeid_map" % root.pystruct module.after_init.write_code("%s.register_wrapper(typeid(%s), &%s);" % (root.typeid_map_name, self.full_name, self.pytypestruct))