-
Notifications
You must be signed in to change notification settings - Fork 289
Prepare QS to include Swift #3023
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
Conversation
n8henrie
commented
Jan 26, 2025
- macos-12 runner is deprecated
- Remove complex macros, which break compilation with Swift
- Remove complex macros, which are incompatible with Swift
- Add missing imports
- Add blank swift file
- Use Swift 6.0
- Fix minimum version message and https URL
- Remove outdated version target
- Add bare minimum to run swift from objc
- Swift 6.0 not avail in GHA runners at this point (xcode 15), stick to swift 5 for now
- Remove dummy Swift code
Follow `macos-latest`; if issues come up, can always temporarily pin to the latest working version
https://developer.apple.com/documentation/swift/using-imported-c-macros-in-swift#Use-Functions-and-Generics-Instead-of-Complex-Macros > C macros that are more complex than simple constant definitions have > no counterpart in Swift. You use complex macros in C and Objective-C > to avoid type-checking constraints or to avoid retyping large amounts > of boilerplate code. However, macros can make debugging and refactoring > difficult. In Swift, you can use functions and generics to achieve the > same results without any compromises.
|
Probably should squash when / if these are merged. @pjrobertson looking forward to your review! |
skurfer
left a comment
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.
Built and ran it locally to be sure, but looks good!
Also, you can just create branches in this repo. No need to have a fork once you have access here.
| id handlerClass = nil; | ||
| NSString *key = nil; | ||
| NSEnumerator *kEnum = [[QSReg tableNamed:kQSPlugInInfoHandlers] keyEnumerator]; | ||
| while((key = [kEnum nextObject]) && (handlerClass = [[QSReg tableNamed:kQSPlugInInfoHandlers] objectForKey:key]) ) { |
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.
Another enumerateKeysAndObjectsUsingBlock
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.
EDIT: moved from above
How does this look?
[[QSReg tableNamed:kQSPlugInInfoHandlers] enumerateKeysAndObjectsUsingBlock:^(NSString *key, id handlerClass, BOOL * _Nonnull stop) {
id value = [bundle dictionaryForFileOrPlistKey:key];
if (!value) {
return;
}
//NSLog(@"----> Registering %@ for %@", key, [self name]);
id handler = [QSReg getClassInstance:handlerClass];
if ([handler respondsToSelector:@selector(handleInfo:ofType:fromBundle:)])
[handler handleInfo:value ofType:key fromBundle:[self bundle]];
}];|
@pjrobertson I think I got those blocks rewritten -- I like that much better, thanks for pointing out that method (initial draft was just a naive translation of the macro). Unfortunately running the tests immediately crashes XCode right now (wtf xcode), so hopefully things pass in CI. QS still seems to run with these changes, so hopefully they're right. |
|
Looks spot on! I've merged :) |