[Cocoa] Correct generation for urlForApplicationToOpen[URL|ContentType]#3435
Conversation
|
Looking at the following: https://bugs.eclipse.org/bugs/show_bug.cgi?id=502090 It seems that there have been times when there was a macOS version update where all the bridge support files have been completely regenerated against a new macOS SDK. The last time was here: Should they have been regenerated since then? |
7fec402 to
aa10550
Compare
Good point. Probably we should do that, yes. We just need to clarify against which macOS SDK version we should do that. It seems possible to pass the minimum supported SDK version to the bridge support generation, but you never know what side effects the actual SDK used might have (like we have seen when building the Equinox binaries against the macOS 26 SDK). |
|
It seems like regenerating the bridgesupport files would be a task of larger effort. I have just generated one of the files ( Thus, I propose to have a separate issue for bridgesupport regeneration. But with respect to this PR: the freshly created AppKitFull.bridgesupport contains the methods I add in this PR with a matching definition: Also the |
There was a problem hiding this comment.
Pull request overview
Ensures the macOS Cocoa bindings for NSWorkspace.URLForApplicationToOpenURL: / URLForApplicationToOpenContentType: and UTType.typeWithFilenameExtension: are fully reproducible by MacGenerator, avoiding silent loss of hand-written bindings during regeneration.
Changes:
- Adds a generated
UTTypewrapper and uses it fromProgram.findAppURLForExtension()instead of raw handle-based Objective-C calls. - Renames
NSWorkspaceJava methods to match MacGenerator’s selector-derived casing and updates call sites accordingly. - Extends the bridgesupport inputs to include the missing
NSWorkspaceselectors and a minimalUTTypeclass so MacGenerator can regenerate these APIs.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| bundles/org.eclipse.swt/Eclipse SWT Program/cocoa/org/eclipse/swt/program/Program.java | Switches extension→app resolution to use the generated UTType wrapper and updated NSWorkspace method names. |
| bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/UTType.java | Introduces a Cocoa object wrapper for UTType with typeWithFilenameExtension. |
| bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java | Keeps selector enum aligned with generated bindings for the added/renamed selectors. |
| bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java | Adds class_UTType and reorders selector constants to match the selector enum. |
| bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSWorkspace.java | Replaces hand-written methods with generator-aligned method names and a typed UTType parameter. |
| bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras | Adds generator input entries for missing NSWorkspace selectors and a minimal UTType class. |
| bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport | Contains regenerated bridgesupport output reflecting the new selectors/class. |
aa10550 to
3d2270d
Compare
NSWorkspace.URLForApplicationToOpenURL: and URLForApplicationToOpenContentType:, introduced as a replacement for deprecated file-association API, were hand-written directly in NSWorkspace.java without registering them for MacGenerator. Since UTType.typeWithFilenameExtension: (the other new API involved, UniformTypeIdentifiers framework, macOS 12+) is not declared in any bridgesupport file, MacGenerator had no way to reproduce these methods and silently dropped them on the next regeneration. - Declare the two NSWorkspace selectors and a minimal UTType class (one method) in AppKitFull.bridgesupport/.extras by hand, since neither API exists in the SDK version the bridgesupport files were generated from, and UTType's own framework has no dedicated bridgesupport file in this project. This makes both methods regenerable instead of being a permanent manual exception. - Rename the two NSWorkspace methods to the casing MacGenerator derives from the Objective-C selector, matching existing conventions elsewhere (e.g. NSURL.URLWithString). - Introduce a proper UTType wrapper class instead of passing its handle around as a raw long, consistent with how every other Cocoa object is represented in this codebase; NSWorkspace.URLForApplicationToOpenContentType now takes a typed UTType argument. - Update Program.findAppURLForExtension() to use the generated UTType.typeWithFilenameExtension() wrapper instead of manual objc_getClass/objc_msgSend calls. Follow-up to eclipse-platform#3187
3d2270d to
345cd8d
Compare
NSWorkspace.URLForApplicationToOpenURL:andURLForApplicationToOpenContentType:, introduced as a replacement for deprecated file-association API, were hand-written directly in NSWorkspace.java without registering them for MacGenerator. SinceUTType.typeWithFilenameExtension:(the other new API involved, UniformTypeIdentifiers framework, macOS 12+) is not declared in any bridgesupport file, MacGenerator had no way to reproduce these methods and silently dropped them on the next regeneration.NSWorkspaceselectors and a minimalUTTypeclass (one method) in AppKitFull.bridgesupport/.extras by hand, since neither API exists in the SDK version the bridgesupport files were generated from, andUTType's own framework has no dedicated bridgesupport file in this project. This makes both methods regenerable instead of being a permanent manual exception.NSWorkspacemethods to the casing MacGenerator derives from the Objective-C selector, matching existing conventions elsewhere (e.g.NSURL.URLWithString).UTTypewrapper class instead of passing its handle around as a raw long, consistent with how every other Cocoa object is represented in this codebase;NSWorkspace.URLForApplicationToOpenContentTypenow takes a typed UTType argument.Program.findAppURLForExtension()to use the generatedUTType.typeWithFilenameExtension()wrapper instead of manual objc_getClass/objc_msgSend calls.The changes in generated code were produced by the
MacGeneratortool.I have verified with a file opened by an external program (Excel) in the workspace that with this change the code still works.
Follow-up to #3187
Hint on this was implicitly given by @Phillipus in #3433 (comment)