-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Update CxxMethodBridging with snake_case #41617
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
[cxx-interop] Update CxxMethodBridging with snake_case #41617
Conversation
Updated the |
Hey @cabmeurer. Really, sorry. I should have elaborated more in the forum post. The idea behind this whole set of features is that unlike C++, Swift has a formalized style. As we import APIs we can try to be smart about this and transform them to adopt Swift's style (to a certain extent). It is unlikely that we'll ever want to transform something to snake_case in Swift. Right now we will transform You can also look at that PR to see how to write the tests. Start by adding a snake_case struct to implicit-computed-properties.h and then seeing how this changes the output that is checked in implicit-computed-properties-module-interface.swift. Let me know if you need help with any of this. That being said, this PR looks really good! If we wanted to import something as snake case, this patch would have been perfect :) |
Ahh yeah that makes a lot more sense, will change this PR to allow for Thank you! |
Well, that's what happens today. What we want is |
Oh yeah makes sense edit: Okay, pushed that changes hopefully this is what we are wanting lol |
fd92c9c
to
1075dbc
Compare
test/Interop/Cxx/ergonomics/implicit-computed-properties-module-interface.swift
Outdated
Show resolved
Hide resolved
Yes! This is perfect. Nicely done! |
1075dbc
to
040ac76
Compare
040ac76
to
ae4cc13
Compare
test/Interop/Cxx/ergonomics/implicit-computed-properties-module-interface.swift
Outdated
Show resolved
Hide resolved
This looks good but there are a couple issues with the tests. Are you able to run the tests locally? |
ae4cc13
to
211fd5e
Compare
I ran this: what is the best way to run tests locally? so i am running |
275c08f
to
3855614
Compare
@zoecarver so i made some changes to the tests, that i think should fix it thank you for being so patient |
Yeah, that looks correct. And the tests are passing? BTW if you just want to run the interop tests, you can run |
test/Interop/Cxx/ergonomics/implicit-computed-properties-module-interface.swift
Outdated
Show resolved
Hide resolved
okay, so when i ran
|
Awesome! So the good news is the tests are running. The bad news is the tests are failing 😁 Why might they be failing... Can you post an output? Given that they're all failing, I suspect the stdlib isn't built. But not 100% sure. |
Should we maintain a list of known abbreviations that should keep the same case? It’s not so good to see |
I am into that idea, I can bring it up in the interop workgroup |
3855614
to
d4de548
Compare
d4de548
to
064d457
Compare
Hey @zoecarver, my tests are now all passing locally 🙌 let me know if there are any other changes I need to make |
test/Interop/Cxx/ergonomics/implicit-computed-properties-module-interface.swift
Show resolved
Hide resolved
Awesome! I'm glad you figured it out! Sorry I was sort of quiet over the past couple days. |
All good! Gave me some time to learn more about how our testing works and experiment |
@swift-ci please test |
064d457
to
9bbb2fd
Compare
Hey @bro4all, thanks for looking over this! I made some changes, let me know what other changes i need to make |
9bbb2fd
to
df47aa4
Compare
@@ -96,6 +127,24 @@ struct CXXMethodBridging { | |||
if (output.empty()) | |||
return output; | |||
|
|||
if (classifyNameKind() == NameKind::snake) { | |||
for (std::size_t i = 0; i < output.size(); i++) { | |||
size_t next = i + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the last character is an underscore, output[next]
isn't checked to exist and is erased. We should check the validity of next
.
size_t next = i + 1; | |
size_t next = i + 1; | |
if (output[next] == output.end()) | |
return output; |
df47aa4
to
436847b
Compare
Closing this pull request and created a new one: Add snake_case to CXXMethodBridging |
Update CxxMethodBridging to transform snake_case names
related: #40842