diff --git a/pybindgen/cppmethod.py b/pybindgen/cppmethod.py index 542c211..fe9f5e7 100644 --- a/pybindgen/cppmethod.py +++ b/pybindgen/cppmethod.py @@ -70,6 +70,9 @@ class CppMethod(ForwardWrapperBase): DeprecationWarning, stacklevel=2) method_name, return_value = return_value, method_name + if return_value is None: + return_value = ReturnValue.new('void') + if unblock_threads is None: unblock_threads = settings.unblock_threads super(CppMethod, self).__init__( diff --git a/pybindgen/function.py b/pybindgen/function.py index 353b1f4..5068444 100644 --- a/pybindgen/function.py +++ b/pybindgen/function.py @@ -34,6 +34,9 @@ class Function(ForwardWrapperBase): warnings.warn("Function has changed API; see the API documentation (but trying to correct...)", DeprecationWarning, stacklevel=2) function_name, return_value = return_value, function_name + + if return_value is None: + return_value = ReturnValue.new('void') super(Function, self).__init__( return_value, parameters, diff --git a/tests/foomodulegen.py b/tests/foomodulegen.py index 8cd1932..c215eaf 100755 --- a/tests/foomodulegen.py +++ b/tests/foomodulegen.py @@ -76,7 +76,7 @@ int %s::custom_method_added_by_a_hook(int x) is_virtual=True)) Zbr.add_static_attribute(ReturnValue.new('int'), 'instance_count') - mod.add_function(Function('store_zbr', ReturnValue.new('void'), + mod.add_function(Function('store_zbr', None, [Parameter.new('Zbr*', 'zbr', transfer_ownership=True)])) mod.add_function(Function('invoke_zbr', ReturnValue.new('int'), [Parameter.new('int', 'x')])) @@ -179,7 +179,7 @@ int %s::custom_method_added_by_a_hook(int x) 'call_get_prefix', ReturnValue.new('std::string'), [])) SomeObject.add_method(CppMethod('set_foo_value', - ReturnValue.new('void'), + None, [Parameter.new('Foo', 'foo')])) SomeObject.add_method(CppMethod( 'get_foo_value', ReturnValue.new('Foo'), []))