From b809e6c15ae91d681bd1452618bde4fd4fed912d Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Sun, 6 Jul 2008 14:54:23 +0100 Subject: [PATCH] Don't even try to generate code for CppDummyMethod's, they were never meant to generate code. --- pybindgen/cppclass.py | 22 +++++++++++++--------- pybindgen/cppmethod.py | 12 ++++++------ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/pybindgen/cppclass.py b/pybindgen/cppclass.py index f42c1e2..6a2a697 100644 --- a/pybindgen/cppclass.py +++ b/pybindgen/cppclass.py @@ -83,16 +83,20 @@ class CppHelperClass(object): if method.matches_signature(existing): return # don't re-add already existing method - self.virtual_methods.append(method) - if not method.is_pure_virtual: - if method.visibility in ['public', 'protected']: - parent_caller = CppVirtualMethodParentCaller(method) - parent_caller.main_wrapper = method - self.add_virtual_parent_caller(parent_caller) + if isinstance(method, CppDummyMethod): + if method.is_pure_virtual: + self.cannot_be_constructed = True + else: + self.virtual_methods.append(method) + if not method.is_pure_virtual: + if method.visibility in ['public', 'protected']: + parent_caller = CppVirtualMethodParentCaller(method) + parent_caller.main_wrapper = method + self.add_virtual_parent_caller(parent_caller) - proxy = CppVirtualMethodProxy(method) - proxy.main_wrapper = method - self.add_virtual_proxy(proxy) + proxy = CppVirtualMethodProxy(method) + proxy.main_wrapper = method + self.add_virtual_proxy(proxy) def add_virtual_parent_caller(self, parent_caller): diff --git a/pybindgen/cppmethod.py b/pybindgen/cppmethod.py index c6c4706..12e89c7 100644 --- a/pybindgen/cppmethod.py +++ b/pybindgen/cppmethod.py @@ -281,9 +281,9 @@ class DummyReturnValue(ReturnValue): args, kwargs = utils.parse_retval_spec(arg) super(DummyReturnValue, self).__init__(args[0]) def convert_c_to_python(self, wrapper): - raise CodeGenerationError + raise TypeError("this is a DummyReturnValue") def convert_python_to_c(self, wrapper): - raise CodeGenerationError + raise TypeError("this is a DummyReturnValue") def get_c_error_return(self): return '' @@ -308,9 +308,9 @@ class DummyParameter(Parameter): super(DummyParameter, self).__init__(args[0], args[1]) def convert_c_to_python(self, wrapper): - raise CodeGenerationError + raise TypeError("this is a DummyParameter") def convert_python_to_c(self, wrapper): - raise CodeGenerationError + raise TypeError("this is a DummyParameter") class CppDummyMethod(CppMethod): @@ -397,8 +397,8 @@ class CppConstructor(ForwardWrapperBase): self.before_call.indent() try: - if self.visibility != 'public': - raise CodeGenerationError + if self.visibility not in ['public', 'protected']: + raise CodeGenerationError("private constructor") class_.get_construct_name() except CodeGenerationError: self.before_call.write_code('PyErr_SetString(PyExc_TypeError, "class \'%s\' '