-
Notifications
You must be signed in to change notification settings - Fork 592
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
Cleanup Swift Metadata #3533
Cleanup Swift Metadata #3533
Conversation
cpp/src/slice2swift/SwiftUtil.cpp
Outdated
@@ -683,36 +670,6 @@ SwiftGenerator::validateSwiftModuleMappings(const UnitPtr& unit) | |||
<< current->second << "'" << endl; |
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.
I would keep the message on a single line, no \n.
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.
I didn't even notice this was split up. Fixed.
ModuleMap mappedModules; | ||
// With a given Swift module a Slice module has to map to a single prefix | ||
std::map<std::string, ModuleMap> mappedModulePrefixes; | ||
// Each Slice unit has to map all top-level modules to a single Swift module. |
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.
It would be helpful to describe what this map is. It seems to be a map filename -> swift module name.
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.
The map was deleted.
The previous check was being applied to all files, even included ones.
This seemed over-zealous to me. Now we only check the single file that is being compiler.
And since we're only checking one file, we don't need a file-name map anymore.
cpp/src/slice2swift/SwiftUtil.cpp
Outdated
// With a given Swift module a Slice module has to map to a single prefix | ||
std::map<std::string, ModuleMap> mappedModulePrefixes; | ||
// Each Slice unit has to map all top-level modules to a single Swift module. | ||
map<string, string> mappedModules; | ||
|
||
// Any modules that are directly contained on the unit are (by definition) top-level modules. | ||
// And since there is only one unit per compilation, this must be all the top-level modules. | ||
for (const auto& module : unit->modules()) |
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.
I would not use module as a variable name. It's an identifier with special meaning in C++20: https://en.cppreference.com/w/cpp/keyword
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.
Fixed.
I renamed it to mod
.
swift/test/Ice/scope/AllTests.swift
Outdated
@@ -201,6 +201,36 @@ func allTests(helper: TestHelper) async throws { | |||
try test(cmap3["a"]!!.s == s1) | |||
} | |||
|
|||
do { | |||
let obj = try communicator.stringToProxy("dpi:\(helper.getTestEndpoint())")! |
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.
No stringToProxy followed by checkedCast in new code, please!
If you want to test ice_isA, call ice_isA.
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.
I was just copy-pasting from the lines above.
I removed all the checkedCast calls from this test; all of them were superfluous.
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 you don't remember the preferred syntax, check the top-level CHANGELOG-3.8.md or the greeter demo:
// Swift
let greeter = try makeProxy(
communicator: communicator,
proxyString: "greeter:tcp -h localhost -p 4061",
type: GreeterPrx.self)
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.
I wasn't familiar enough with Swift to remember that we supported this there.
I updated scope
in Swift to use makeProxy
. The other languages were all already correct.
|
||
module Inner2 | ||
// Check that it's okay for 'swift:module' to have different 'prefix' arguments. |
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.
I am sure we can test this "feature" with a simpler test.
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.
Well, I also want to make sure that it gets mapped to the correct place as well.
Not just that "the compiler doesn't issue an error anymore".
Because we don't have a test for the swift:module anywhere, and scope felt like an adequate place to put it.
Since the point of the metadata is changing the mapped scopes.
swift/test/Ice/scope/Test.ice
Outdated
|
||
void shutdown(); | ||
interface I |
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.
We should definitely never name an interface 'I'.
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.
I was just being consistent with the rest of this test.
I updated the scope
tests to use better names.
swift/test/Ice/scope/Test.ice
Outdated
Test::C opC(Test::C c1, out Test::C c2); | ||
Test::CSeq opCSeq(Test::CSeq c1, out Test::CSeq c2); | ||
Test::CMap opCMap(Test::CMap c1, out Test::CMap c2); | ||
long l; |
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.
Trying hard to find the worse names?
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.
Nope, just following our old 'conventions'!
I updated almost all of the names in this test to be less horrible.
swift/test/Ice/scope/AllTests.swift
Outdated
@@ -201,6 +201,36 @@ func allTests(helper: TestHelper) async throws { | |||
try test(cmap3["a"]!!.s == s1) | |||
} | |||
|
|||
do { | |||
let obj = try communicator.stringToProxy("dpi:\(helper.getTestEndpoint())")! |
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 you don't remember the preferred syntax, check the top-level CHANGELOG-3.8.md or the greeter demo:
// Swift
let greeter = try makeProxy(
communicator: communicator,
proxyString: "greeter:tcp -h localhost -p 4061",
type: GreeterPrx.self)
This PR removes the
swift:inherits
metadata, and implements #3529 (we no longer require re-openings of the same module withswift:module
metadatas to have the same 'prefix' argument)EDIT: It also now changes all the identifiers in the
scope
tests.