diff --git a/robotpy_build/autowrap/cxxparser.py b/robotpy_build/autowrap/cxxparser.py index d2d77c82..24384505 100644 --- a/robotpy_build/autowrap/cxxparser.py +++ b/robotpy_build/autowrap/cxxparser.py @@ -1637,7 +1637,7 @@ def _on_fn_make_lambda(self, data: FunctionData, fctx: FunctionContext): for out in reversed(tmp_params): odef = out.default if not odef: - lambda_pre.insert(0, f"{out.cpp_type} {out.arg_name}") + lambda_pre.insert(0, f"{out.cpp_type} {out.arg_name}{{}}") elif odef.startswith("{"): lambda_pre.insert(0, f"{out.cpp_type} {out.arg_name}{odef}") else: diff --git a/tests/cpp/rpytest/ft/__init__.py b/tests/cpp/rpytest/ft/__init__.py index 9e919f01..a1c25b0d 100644 --- a/tests/cpp/rpytest/ft/__init__.py +++ b/tests/cpp/rpytest/ft/__init__.py @@ -108,6 +108,7 @@ fnParamFundConstRef, fnParamFundPtr, fnParamFundRef, + fnParamOutNotSet, fnRenamed, fnRenamedParam, fnSimpleDefaultParam, @@ -225,6 +226,7 @@ "fnParamFundConstRef", "fnParamFundPtr", "fnParamFundRef", + "fnParamOutNotSet", "fnRenamed", "fnRenamedParam", "fnSimpleDefaultParam", diff --git a/tests/cpp/rpytest/ft/include/parameters.h b/tests/cpp/rpytest/ft/include/parameters.h index cc00dc78..68f2ab94 100644 --- a/tests/cpp/rpytest/ft/include/parameters.h +++ b/tests/cpp/rpytest/ft/include/parameters.h @@ -28,6 +28,11 @@ int fnParamFundPtr(int x, int * y) return x - 1; } +// parameters that are not set should be zero initialized +int fnParamOutNotSet(int *z) { + return 1; +} + // do a namespace thing because we messed that up once namespace ohno { // parameters that are pointers and fundamental types are out by default diff --git a/tests/test_ft_parameters.py b/tests/test_ft_parameters.py index 602edbf9..aca76534 100644 --- a/tests/test_ft_parameters.py +++ b/tests/test_ft_parameters.py @@ -22,6 +22,10 @@ def test_fund_const_ref(): assert ft.fnParamFundConstRef(1, 2) == 3 +def test_param_out_not_set(): + assert ft.fnParamOutNotSet() == (1, 0) + + def test_fn_disable_none(): with pytest.raises(TypeError): ft.fnParamDisableNone(None)