Skip to content

Conversation

@AnDevi
Copy link

@AnDevi AnDevi commented Sep 26, 2024

I provided support for wrapping to java std::optional used with types listed below:

  • Custom cpp types
  • Primitive types:
    |- bool
    |- int
    |- flaot
    |- long
    |- double
  • Types from std library:
    |- std::string

I'm using it for quite a while in our project without any problems yet.
I'll also try to provide some tests in here for that implementation.

@vadz
Copy link
Member

vadz commented Sep 26, 2024

Sorry, but how is it actually used on Java side? You need to add some unit tests checking that this works as expected, and they would be useful to understand this.

FWIW I'm surprised that this doesn't seem to use java.util.Optional at all. My own SWIG typemaps for optional map it to this Java type, allowing to use it naturally (or at least I think so) in Java, e.g. calling isPresent() on the returned values etc.

@vadz vadz added the Java label Sep 26, 2024
@AnDevi
Copy link
Author

AnDevi commented Sep 26, 2024 via email

@vadz
Copy link
Member

vadz commented Sep 26, 2024

Is this Android and/or Kotlin-specific then?

@AnDevi
Copy link
Author

AnDevi commented Sep 26, 2024 via email

@christophe-calmejane
Copy link
Contributor

std::optional was introduced in c++17, shouldn't your tests in Examples/test-suite be named cpp17_xxx instead of cpp11_xxx?

@AnDevi
Copy link
Author

AnDevi commented Jan 13, 2025

Thanks @christophe-calmejane , you're right.
I changed those names, and I also added support for enum types hold by optional. I recently found out it's missing.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants