Skip to content

Conversation

jnastarot
Copy link
Contributor

It fixes the issue of incorrectly generated bindings for methods that have a referenced return value and an array in the parameters at the same time

    Image& setSignature(const uint8_t signature[20]) {
        memcpy(_signature, signature, sizeof(_signature));
        return *this;
    }
.def("setSignature",
    [](enma::dex::Image & self, const std::array<uint8_t, 20>& signature) -> enma::dex::Image &
    {
        auto setSignature_adapt_fixed_size_c_arrays = [&self](const std::array<uint8_t, 20>& signature) -> enma::dex::Image &
        {
            auto lambda_result = self.setSignature(signature.data());
            return lambda_result;
        };

        return setSignature_adapt_fixed_size_c_arrays(signature);
    },
    nb::arg("signature")

The 'auto' keyword must be emitted with a reference

auto& lambda_result = self.setSignature(signature.data());

@jnastarot jnastarot changed the title Fix case when a return value has ref Fix case when a return value has a ref Nov 30, 2024
@pthom
Copy link
Owner

pthom commented Nov 30, 2024

Great!
Would you mind adding a test (somewhere in src/litgen/tests/internal/adapted_types/adapted_function_test.py).

@jnastarot
Copy link
Contributor Author

Added test 2a7cf9c

@pthom pthom merged commit 2a7cf9c into pthom:main Dec 2, 2024
3 checks passed
@pthom
Copy link
Owner

pthom commented Dec 2, 2024

Perfect, thanks a lot!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants