-
Notifications
You must be signed in to change notification settings - Fork 22
Add support for equality operators via new 'requires' keyword for interfaces #169
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
Add support for equality operators via new 'requires' keyword for interfaces #169
Conversation
…embers of a class-in-a-class Operators.
…uals() & hashCode()
…lock; should fix unit test failure.
December 2024 CI runners don't have sbt anymore Therefore, install it via actions, fix cross-language-cpp#171
…embers of a class-in-a-class Operators.
…uals() & hashCode()
…lock; should fix unit test failure.
…jinni-generator into AndrewAtAvenza/requires
|
you should be able to fix the formatCheck CI by running if that stopped working, please let me know |
Much obliged! I took a look at that on Monday but thought I had to install it and could figure out how to do that. Glad it's just there, that's really handy. Sorry it's been quiet the last couple of days. I'm landing some big branches and blocking a release. Should be back to this tomorrow or Friday. I took a quick look at how it might look publishing Java to C++ and I've got some thoughts I'll post to the discussion thread later. |
No worries, take your time. This an OS project, so contributing shall also make fun. No stress |
|
I finally added the integration test but it reminded of one thing that's missing before I can offer it for review: I'm basically hardcoding in the C++ method names in the Obviously there is logic somewhere that takes a method name like |
|
yes, there is some 'magic' that does naming tricks: I assume you mean that. I was never a big fan of this. Hard to test and awful to maintain. The question is, could you have access to the various *IdentStyle and get the names from it, |
Yeah, that is exactly what I was talking about. I figured if it was possible to access it, better to conform. If it's not possible though and you're cool with hard-coding it, then I guess it is ready? Well, once I re-apply the formatting I forgot last push. |
|
The various ident styles are accessible via the Spec class, and this spec is part of every generator or in the Marshall classes via properties. Here is an example where the function name is resolved |
I'll give it a shot, might as well be consistent if I can. If not, well, we can leave it hard-coded.' Thanks! |
|
OK, equality should be good to go. The only thing I haven't done is finish implementing the It looks like the |
…reTo() calling through to Operators::compare() * updated unit test to include tests for eq, ord & eq+ord
|
Sorry this has taken so long, but I think it's finally ready for review! |
|
Cool! I am confused to see the .github files in the diff. For the rest, I trust in your expertise because, after this work, you are more into the topic of djinni generators than I now. So we will keep this here open for a while so others can check, and then merge after a while |
That confuses me as well. If you want, I can rebuild the branch fairly easily off the new HEAD to be sure, it'd just mean copy & pasting a dozen files. |
|
You worked enough; I am going to approve that now |
|
I will leave that open for a day or two, then I merge it (if nobody else does it, who can, feel free to do it) Once merged, we will have the 'latest' release. I will send out some announcements so people can test before we tag a new release. |
|
Just had a thought: is there documentation that needs to be updated as part of this PR? e.g. explaining how to use the feature or how its limited to Java? |
Excellent thought; thank you so much! This is very likely the best place to add the new option: The docs using mkdocs , the part can be previews local by just using this repo, For local, if you have a python even, pip install and mkdocs serve should give you the preview of the pages for the generator |
Sounds good, I'll find time this afternoon to write something up. Might as well be complete! |
|
Sorry for the delay, work stuff came up! I tried to run the documentation locally but ran into a problem: doesn't seem to work on Windows! Fortunately, the changes I'm making are pretty minor, the styling is minimal and GItHub has pretty good MD previews. I think it should be okay, but please let me know if I should change anything. I mostly used the Deriving section as a template, but as a sub-section of Interfaces. |
|
Thanks for trying! Please add the docs. If there should be something to fix, I can do that. |
I pushed the additions when I made the comment -- updating the idl.md file (using GitHub's preview feature). There wasn't a whole lot to add so it didn't really need much in the way of previewing, more proofing! |
|
Looks good, lets give the PR two more days, in case anyone wants to test it, and the I will merge it |
This is the proof-of-concept for adding the new
interfacekeywordrequires(). While this keyword will currently accept botheqandord, it only generates code foreq. Also, it currently only works for Java -> C++ (not even the reverse).Currently,
eqmeans defining both 'equals()andhashCode()in Java and directing them tooperator==(const & other) constandint32_t hashCode() const` respectively. The former should be fine, but the latter could clash with a user-defined method name. Maybe this is an acceptable trade-off though?