diff --git a/examples/c-hello/hellomodulegen.py b/examples/c-hello/hellomodulegen.py index 9aa244a..2c4fbd8 100755 --- a/examples/c-hello/hellomodulegen.py +++ b/examples/c-hello/hellomodulegen.py @@ -22,6 +22,7 @@ def pre_scan_hook(module_parser, global_annotations['free_function'] = 'hello_foo_unref' global_annotations['incref_function'] = 'hello_foo_ref' global_annotations['decref_function'] = 'hello_foo_unref' + global_annotations['python_name'] = 'Foo' ## constructor? m = constructor_rx.match(pygccxml_definition.name) diff --git a/pybindgen/cppclass.py b/pybindgen/cppclass.py index e743b3a..0440677 100644 --- a/pybindgen/cppclass.py +++ b/pybindgen/cppclass.py @@ -316,7 +316,8 @@ class CppClass(object): peekref_method=None, template_parameters=(), custom_template_class_name=None, incomplete_type=False, free_function=None, - incref_function=None, decref_function=None,): + incref_function=None, decref_function=None, + python_name=None): """Constructor name -- class name parent -- optional parent class wrapper @@ -343,12 +344,14 @@ class CppClass(object): free_function -- name of C function used to deallocate class instances incref_function -- same as incref_method, but as a function instead of method decref_method -- same as decref_method, but as a function instead of method + python_name -- name of the class as it will appear from Python side """ assert outer_class is None or isinstance(outer_class, CppClass) self.incomplete_type = incomplete_type self.outer_class = outer_class self._module = None self.name = name + self.python_name = python_name self.mangled_name = None self.template_parameters = template_parameters self.custom_template_class_name = custom_template_class_name @@ -1015,7 +1018,10 @@ typedef struct { else: class_python_name = self.custom_template_class_name else: - class_python_name = self.name + if self.python_name is None: + class_python_name = self.name + else: + class_python_name = self.python_name if self.outer_class is None: module.after_init.write_code( diff --git a/pybindgen/gccxmlparser.py b/pybindgen/gccxmlparser.py index 38b50f8..d44a7b8 100644 --- a/pybindgen/gccxmlparser.py +++ b/pybindgen/gccxmlparser.py @@ -512,6 +512,8 @@ class ModuleParser(object): kwargs.setdefault('incref_function', value) elif name == 'decref_function': kwargs.setdefault('decref_function', value) + elif name == 'python_name': + kwargs.setdefault('python_name', value) else: warnings.warn_explicit("Class annotation %r ignored" % name, Warning, cls.location.file_name, cls.location.line)