From 7d5b1ebff1b3d28c0151019655c4c4cb37ac082f Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Sun, 8 Jun 2008 22:15:42 +0100 Subject: [PATCH] Define stack_where_defined much earlier --- pybindgen/cppclass.py | 10 +++++----- pybindgen/cppmethod.py | 5 +++++ pybindgen/function.py | 4 +++- pybindgen/module.py | 8 ++++---- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/pybindgen/cppclass.py b/pybindgen/cppclass.py index 1307603..91110f1 100644 --- a/pybindgen/cppclass.py +++ b/pybindgen/cppclass.py @@ -1032,8 +1032,8 @@ public: helper_class.add_virtual_method(method) return None - self._add_method_obj(meth) meth.stack_where_defined = traceback.extract_stack() + self._add_method_obj(meth) return meth def add_function_as_method(self, *args, **kwargs): @@ -1046,8 +1046,8 @@ public: meth = function.Function(*args, **kwargs) except utils.SkipWrapper: return None - self._add_method_obj(meth) meth.stack_where_defined = traceback.extract_stack() + self._add_method_obj(meth) return meth def add_custom_method_wrapper(self, *args, **kwargs): @@ -1058,8 +1058,8 @@ public: meth = CustomCppMethodWrapper(*args, **kwargs) except utils.SkipWrapper: return None - self._add_method_obj(meth) meth.stack_where_defined = traceback.extract_stack() + self._add_method_obj(meth) return meth def set_helper_class_disabled(self, flag=True): @@ -1106,8 +1106,8 @@ public: constructor = CppConstructor(*args, **kwargs) except utils.SkipWrapper: return None - self._add_constructor_obj(constructor) constructor.stack_where_defined = traceback.extract_stack() + self._add_constructor_obj(constructor) return constructor def add_function_as_constructor(self, *args, **kwargs): @@ -1119,8 +1119,8 @@ public: constructor = CppFunctionAsConstructor(*args, **kwargs) except utils.SkipWrapper: return None - self._add_constructor_obj(constructor) constructor.stack_where_defined = traceback.extract_stack() + self._add_constructor_obj(constructor) return constructor def add_static_attribute(self, name, value_type, is_const=False): diff --git a/pybindgen/cppmethod.py b/pybindgen/cppmethod.py index 8647578..dd617a6 100644 --- a/pybindgen/cppmethod.py +++ b/pybindgen/cppmethod.py @@ -3,6 +3,7 @@ Wrap C++ class methods and constructods. """ import warnings +import traceback from copy import copy from typehandlers.base import ForwardWrapperBase, ReverseWrapperBase, \ @@ -60,6 +61,7 @@ class CppMethod(ForwardWrapperBase): @param visibility: visibility of the method within the C++ class @type visibility: a string (allowed values are 'public', 'protected', 'private') """ + self.stack_where_defined = traceback.extract_stack() ## backward compatibility check if isinstance(return_value, str) and isinstance(method_name, ReturnValue): @@ -338,6 +340,7 @@ class CppConstructor(ForwardWrapperBase): """ parameters -- the constructor parameters """ + self.stack_where_defined = traceback.extract_stack() if unblock_threads is None: unblock_threads = settings.unblock_threads @@ -520,6 +523,7 @@ class CppNoConstructor(ForwardWrapperBase): """ reason -- string indicating reason why the class cannot be constructed. """ + self.stack_where_defined = traceback.extract_stack() super(CppNoConstructor, self).__init__( None, [], "return -1;", "return -1;") @@ -679,6 +683,7 @@ class CppVirtualMethodProxy(ReverseWrapperBase): """ xxx """ + self.stack_where_defined = traceback.extract_stack() super(CppVirtualMethodProxy, self).__init__(method.return_value, method.parameters) self.method_name = method.method_name self.method = method diff --git a/pybindgen/function.py b/pybindgen/function.py index ccd9362..5589b49 100644 --- a/pybindgen/function.py +++ b/pybindgen/function.py @@ -10,7 +10,7 @@ import overloading import settings import utils import warnings - +import traceback class Function(ForwardWrapperBase): """ @@ -26,6 +26,8 @@ class Function(ForwardWrapperBase): @param parameters: the function parameters @type parameters: list of L{Parameter} """ + self.stack_where_defined = traceback.extract_stack() + if unblock_threads is None: unblock_threads = settings.unblock_threads diff --git a/pybindgen/module.py b/pybindgen/module.py index cfe2a87..b1fa2c8 100644 --- a/pybindgen/module.py +++ b/pybindgen/module.py @@ -239,8 +239,8 @@ class ModuleBase(dict): func = Function(*args, **kwargs) except utils.SkipWrapper: return None - self._add_function_obj(func) func.stack_where_defined = traceback.extract_stack() + self._add_function_obj(func) return func def add_custom_function_wrapper(self, *args, **kwargs): @@ -252,8 +252,8 @@ class ModuleBase(dict): func = CustomFunctionWrapper(*args, **kwargs) except utils.SkipWrapper: return None - self._add_function_obj(func) func.stack_where_defined = traceback.extract_stack() + self._add_function_obj(func) return func def register_type(self, name, full_name, type_wrapper): @@ -296,8 +296,8 @@ class ModuleBase(dict): DeprecationWarning, stacklevel=2) else: cls = CppClass(*args, **kwargs) - self._add_class_obj(cls) cls.stack_where_defined = traceback.extract_stack() + self._add_class_obj(cls) return cls def add_cpp_namespace(self, name): @@ -340,8 +340,8 @@ class ModuleBase(dict): DeprecationWarning, stacklevel=2) else: enum = Enum(*args, **kwargs) - self._add_enum_obj(enum) enum.stack_where_defined = traceback.extract_stack() + self._add_enum_obj(enum) return enum def declare_one_time_definition(self, definition_name):