From f698fe8cb489ce39b3e4ebec86260c728403020c Mon Sep 17 00:00:00 2001 From: Samuel Felton Date: Wed, 22 Nov 2023 17:20:44 +0100 Subject: [PATCH] Fix bug introduced in previous commit --- modules/python/config/core.json | 6 +----- modules/python/config/klt.json | 3 ++- modules/python/config/visual_features.json | 7 ------- modules/python/generator/visp_python_bindgen/methods.py | 5 +++-- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/modules/python/config/core.json b/modules/python/config/core.json index de5cb7f84f..86fb50196d 100644 --- a/modules/python/config/core.json +++ b/modules/python/config/core.json @@ -289,11 +289,7 @@ }, "vpMomentDatabase": { "methods": [ - { - "static": false, - "signature": "const vpMoment& get(const char*, bool&)", - "ignore": true - } + ] }, "vpPixelMeterConversion": { diff --git a/modules/python/config/klt.json b/modules/python/config/klt.json index f6f8c5403f..efe99d00ae 100644 --- a/modules/python/config/klt.json +++ b/modules/python/config/klt.json @@ -13,4 +13,5 @@ ] } }, - "enums": {}} \ No newline at end of file + "enums": {} +} diff --git a/modules/python/config/visual_features.json b/modules/python/config/visual_features.json index 4e8352ef6a..f221a84895 100644 --- a/modules/python/config/visual_features.json +++ b/modules/python/config/visual_features.json @@ -21,13 +21,6 @@ ] }, "vpFeatureMomentDatabase": { - "methods": [ - { - "static": false, - "signature": "vpFeatureMoment& get(const char*, bool&)", - "ignore": true - } - ] } } diff --git a/modules/python/generator/visp_python_bindgen/methods.py b/modules/python/generator/visp_python_bindgen/methods.py index 0599c049b3..99e3c7d614 100644 --- a/modules/python/generator/visp_python_bindgen/methods.py +++ b/modules/python/generator/visp_python_bindgen/methods.py @@ -202,6 +202,7 @@ def define_method(method: types.Method, method_config: Dict, is_class_method, sp py_method_name = method_config.get('custom_name') or method_name return_type = get_type(method.return_type, specs, header_env.mapping) + # Detect input and output parameters for a method use_default_param_policy = method_config['use_default_param_policy'] param_is_input, param_is_output = method_config['param_is_input'], method_config['param_is_output'] @@ -218,6 +219,7 @@ def define_method(method: types.Method, method_config: Dict, is_class_method, sp param_names = [param.name or 'arg' + str(i) for i, param in enumerate(method.parameters)] input_param_names = [param_names[i] for i in range(len(param_is_input)) if param_is_input[i]] output_param_names = [param_names[i] for i in range(len(param_is_output)) if param_is_output[i]] + output_param_is_ref = [isinstance(method.parameters[i], types.Reference) for i in range(len(params_strs)) if param_is_output[i]] # Fetch documentation if available if header.documentation_holder is not None: @@ -259,7 +261,6 @@ def define_method(method: types.Method, method_config: Dict, is_class_method, sp output_param_symbols = [] if return_type is None or return_type == 'void': maybe_get_return = '' - output_param_symbols.append('') else: maybe_get_return = f'{return_type} res = ' if '&' in return_type: @@ -277,7 +278,7 @@ def define_method(method: types.Method, method_config: Dict, is_class_method, sp # When returning a tuple we need to explicitely convert references to pointer. # This is required since std::tuple will upcast the ref to its base class and try to store a copy of the object # If a class is pure virtual, this is not possible and will a compilation error! - output_param_symbols.extend(['&' + name for name in output_param_names if '&' in name]) + output_param_symbols.extend(['&' + name if is_ref else name for is_ref, name in zip(output_param_is_ref, output_param_names)]) return_str = f'std::make_tuple({", ".join(output_param_symbols)})' lambda_body = f'''