-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failure to bind vector of smart pointers #21
Comments
Binding smart pointers with pydind11 is complex. Concerning the stubs, your solution was a step in the right direction. litgen/src/litgen/internal/cpp_to_python.py Lines 517 to 520 in 5c0740d
Now, concerning your usage:
For an example, see this integration test: https://github.com/pthom/litgen/blob/main/src/litgen/integration_tests/mylib/smart_ptr.h And its bindings: https://github.com/pthom/litgen/blob/main/src/litgen/integration_tests/mylib/smart_ptr.h.pyi Where I had to specify the holder type for SmartElem litgen/src/litgen/integration_tests/autogenerate_mylib.py Lines 53 to 54 in 5c0740d
Read here the doc for class_held_as_shared__regex: Lines 405 to 420 in 5c0740d
|
Note: you will need to update litgen to the latest commit |
Thank you for the updates! This did the trick. Understood about the caveats on smart pointers. Mainly just tinkering at this point to understand how to use litgen. So far it seems pretty straight forward. |
Starting to use litgen to make bindings and ran into an issue when using vectors of smart points. litgen does not seem to interpret vectors of smart pointers correctly.
example.h
resulting stubs with no options specified which are obviously wrong and do not throw any errors when generating other than black formatting errors.
I was able to get around this and get something more expected using the following type replacement option and regex
This results in stubs looking like this
Im not sure if this is best approach or just the naive solution. Considering how smart pointers of a class and a vector of classes gets bound, I would expect to get this result. Would appreciate your insight.
The text was updated successfully, but these errors were encountered: