Skip to content
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

Prepare QS to include Swift #3023

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Conversation

n8henrie
Copy link
Member

  • 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.
@n8henrie
Copy link
Member Author

Probably should squash when / if these are merged. @pjrobertson looking forward to your review!

Copy link
Member

@skurfer skurfer left a 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.

Quicksilver/Code-QuickStepCore/QSObject.m Show resolved Hide resolved
NSString *minimumVersionString = @"macOS 10.9+";
NSString *oldVersionsString = @"10.3–10.8";
NSString *minimumVersionString = @"macOS 10.14+";
NSString *oldVersionsString = @"10.14";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change correct? The text will now read "Recent versions of Quicksilver require macOS 10.14+. Older 10.14 compatible versions are availa..."

Maybe just remove it all together and make it "Versions for older macOS are available..."

id header = nil;
NSString *key = nil;
NSEnumerator *kEnum = [[QSReg tableNamed:@"QSRegistryHeaders"] keyEnumerator];
while((key = [kEnum nextObject]) && (header = [[QSReg tableNamed:@"QSRegistryHeaders"] objectForKey:key]) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use this for slightly tidier code:

	[[QSReg tableNamed:@"QSRegistryHeaders"] enumerateKeysAndObjectsUsingBlock:^(NSString *key, id header, BOOL * _Nonnull stop) {
		if ([[header objectForKey:@"type"] isEqual:@"mediator"]) {
			NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObject:header forKey:INFO];
			NSMenu *menu = [self menuForTable:key includeDefault:[[header objectForKey:@"allowDefault"] boolValue]];
			if (!menu) continue;
			if (menu)
				[dict setObject:menu forKey:MENU];
			[dict setObject:key forKey:IDENT];
			[helpers addObject:dict];
		}
	}];

id plugin = nil;
NSString *pluginId = nil;
NSEnumerator *kEnum = [[[QSPlugInManager sharedInstance] loadedPlugIns] keyEnumerator];
while((pluginId = [kEnum nextObject]) && (plugin = [[[QSPlugInManager sharedInstance] loadedPlugIns] objectForKey:pluginId]) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here about using enumerateKeysAndObjectsUsingBlock

Quicksilver/Code-QuickStepCore/QSObject.m Show resolved Hide resolved
id handlerClass = nil;
NSString *key = nil;
NSEnumerator *kEnum = [[QSReg tableNamed:kQSPlugInInfoHandlers] keyEnumerator];
while((key = [kEnum nextObject]) && (handlerClass = [[QSReg tableNamed:kQSPlugInInfoHandlers] objectForKey:key]) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another enumerateKeysAndObjectsUsingBlock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants