-
Notifications
You must be signed in to change notification settings - Fork 588
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
Problem with std::unique_ptr as callback parameter #613
Comments
It might work if we force a cast on std::unique<...> instead of Stream with something like |
I've tried
but got and errors
|
Ok, maybe something like |
I've changed code a bit to this:
map config:
And helper:
I've tried all these variants and they failed ( |
I've pushed a couple of fixes in commit b411ac6, and with that something like |
Unfortunately no, it doesn't compile
|
Also when I try to use javacpp 1.5.8-SNAPSHOT (from repository) I've got errors even for worked code with other callbacks. If I try to compile it locally, I have failed test ThreadTest.testJNIThreadAttachFromNativeCallbacks |
Yeah, well, you'll need to give me something to work with. Everything works fine here, I can't fix what isn't broken! |
test-javacpp-library.tar.gz |
|
please remove files from gen/java dir after switching. it doesn't clean automatically |
I get a different error in that case, but still the same regardless of the version of JavaCPP:
|
How I compile this preset: I go to the main directory, run These code compiles fine for me |
Ah, I see what the issue is. JavaCPP 1.5.8-SNAPSHOT adds "basic container" support for std::function, but since you're not using that in the project, you need to remove the |
It works! Thanks a lot! |
test-client-library-3.tar.gz When I try to call this callback with unique_ptr, I got SIGABRT error. Could you please take a look into main class in test-client-library? To make it work you also need 'mvn clean install' in main folder test-javacpp-library and for platform too. |
This should be fixed in commit 81252dd. Please give it a try with the snapshots! Thanks |
Great, it works! Many thanks for quick fix! |
test-client-library-4.tar.gz Found one more issue with unique_ptr. This unique_ptr object (MyStream object) is passed to my callback and than I need store it for later usage. But when I try to use it later, object looks corrupted. This is test class (from test-client-library-4.tar.gz):
This is test output:
Could you please help with it? |
To do that, in C++, we need to create a new instance of that std::unique_ptr, but I don't see how we can do that with an adapter, that's not what it was designed to do. We probably need to create a wrapper object for that std::unique_ptr instance. |
That said, I think I managed to make it work in commit 45a6a4b. |
Looks like it works with sample code, will test it later with my library. This is great, thank you very much! |
Fixes for this issue have been released with JavaCPP 1.5.8. Thanks for reporting and for testing all this! |
Amazing! Thanks you for fixing them and for helping me and for such cool javacpp lib! I have completed writing javacpp mappings and now I'm able to use c++ functions from our company library in my kotlin code. |
I have problem with creating FunctionPointer for callback which receives std::unique_ptr as argument.
This is my test function:
This is my FunctionPointer:
I saw uning MoveUniquePtr in tensorflow preset, but there callback returns unique_ptr, not use it as argument.
Here is my map:
If I remove cpp function testOnStreamOpenCb, compilation fails because of testOnStreamOpenCb.
Could you please advice me something?
The text was updated successfully, but these errors were encountered: