From a315f700e9ac7892dd7e921d37510d346da9d86f Mon Sep 17 00:00:00 2001 From: Travis Cline Date: Sat, 1 Jul 2023 17:59:37 -0700 Subject: [PATCH] cocoa: Add `NSWorkspace` (#111) * gen: propagate errors * cocoa: Add NSWorkspace * github: update go versions * gen: reflect signature --- .github/workflows/test.yml | 6 +- api/appkit/nsworkspace.objc.json | 1473 ++++++++++++++++++++++++++++++ cocoa/NSWorkspace.go | 5 + cocoa/cocoa_objc.gen.go | 505 ++++++++++ gen/cmd/gen.go | 1 + gen/cmd/loader.go | 7 +- gen/gen.go | 21 +- gen/gen_test.go | 3 +- 8 files changed, 2009 insertions(+), 12 deletions(-) create mode 100644 api/appkit/nsworkspace.objc.json create mode 100644 cocoa/NSWorkspace.go diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 907b3ff4..97bcfc87 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,15 +4,15 @@ jobs: test: strategy: matrix: - go-version: [1.17.x, 1.16.x] + go-version: [stable, oldstable] os: [macos-latest] runs-on: ${{ matrix.os }} steps: - name: Install Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: go-version: ${{ matrix.go-version }} - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Test run: go test -v ./... diff --git a/api/appkit/nsworkspace.objc.json b/api/appkit/nsworkspace.objc.json new file mode 100644 index 00000000..f7ee2e68 --- /dev/null +++ b/api/appkit/nsworkspace.objc.json @@ -0,0 +1,1473 @@ +{ + "Class": { + "Name": "NSWorkspace", + "Description": "A workspace that can launch other apps and perform a variety of file-handling services.", + "Declaration": "@interface NSWorkspace : NSObject", + "Platforms": [ + "macOS 10.0+" + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace?language=objc", + "InstanceMethods": [ + { + "Name": "openURL:configuration:completionHandler:", + "Description": "Opens a URL asynchronously using the provided options.", + "Declaration": "- (void)openURL:(NSURL *)url \n configuration:(NSWorkspaceOpenConfiguration *)configuration \ncompletionHandler:(void (^)(NSRunningApplication *app, NSError *error))completionHandler;\n", + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "url", + "Type": { + "Name": "NSURL", + "IsPtr": true + } + }, + { + "Name": "configuration", + "Type": { + "Name": "NSWorkspaceOpenConfiguration", + "IsPtr": true + } + }, + { + "Name": "completionHandler", + "Type": { + "Block": { + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "app", + "Type": { + "Name": "NSRunningApplication", + "IsPtr": true + } + }, + { + "Name": "error", + "Type": { + "Name": "NSError", + "IsPtr": true + } + } + ] + } + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/3172701-openurl?language=objc" + }, + { + "Name": "openURLs:withApplicationAtURL:configuration:completionHandler:", + "Description": "Opens one or more URLs asynchronously in the specified app using the provided options.", + "Declaration": "- (void)openURLs:(NSArray\u003cNSURL *\u003e *)urls \nwithApplicationAtURL:(NSURL *)applicationURL \n configuration:(NSWorkspaceOpenConfiguration *)configuration \ncompletionHandler:(void (^)(NSRunningApplication *app, NSError *error))completionHandler;\n", + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "urls", + "Type": { + "Name": "NSArray", + "IsPtr": true, + "Params": [ + { + "Name": "NSURL", + "IsPtr": true + } + ] + } + }, + { + "Name": "applicationURL", + "Type": { + "Name": "NSURL", + "IsPtr": true + } + }, + { + "Name": "configuration", + "Type": { + "Name": "NSWorkspaceOpenConfiguration", + "IsPtr": true + } + }, + { + "Name": "completionHandler", + "Type": { + "Block": { + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "app", + "Type": { + "Name": "NSRunningApplication", + "IsPtr": true + } + }, + { + "Name": "error", + "Type": { + "Name": "NSError", + "IsPtr": true + } + } + ] + } + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/3172702-openurls?language=objc" + }, + { + "Name": "openURL:", + "Description": "Opens the location at the specified URL.", + "Declaration": "- (BOOL)openURL:(NSURL *)url;", + "Return": { + "Name": "BOOL" + }, + "Args": [ + { + "Name": "url", + "Type": { + "Name": "NSURL", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1533463-openurl?language=objc" + }, + { + "Name": "openApplicationAtURL:configuration:completionHandler:", + "Description": "Launches the app at the specified URL and asynchronously reports back on the app's status.", + "Declaration": "- (void)openApplicationAtURL:(NSURL *)applicationURL \n configuration:(NSWorkspaceOpenConfiguration *)configuration \n completionHandler:(void (^)(NSRunningApplication *app, NSError *error))completionHandler;\n", + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "applicationURL", + "Type": { + "Name": "NSURL", + "IsPtr": true + } + }, + { + "Name": "configuration", + "Type": { + "Name": "NSWorkspaceOpenConfiguration", + "IsPtr": true + } + }, + { + "Name": "completionHandler", + "Type": { + "Block": { + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "app", + "Type": { + "Name": "NSRunningApplication", + "IsPtr": true + } + }, + { + "Name": "error", + "Type": { + "Name": "NSError", + "IsPtr": true + } + } + ] + } + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/3172700-openapplicationaturl?language=objc" + }, + { + "Name": "hideOtherApplications", + "Description": "Hides all applications other than the sender.", + "Declaration": "- (void)hideOtherApplications;", + "Return": { + "Name": "void" + }, + "Args": null, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1530417-hideotherapplications?language=objc" + }, + { + "Name": "duplicateURLs:completionHandler:", + "Description": "Duplicates the specified URLS asynchronously in the same manner as the Finder.", + "Declaration": "- (void)duplicateURLs:(NSArray\u003cNSURL *\u003e *)URLs \n completionHandler:(void (^)(NSDictionary\u003cNSURL *,NSURL *\u003e *newURLs, NSError *error))handler;\n", + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "URLs", + "Type": { + "Name": "NSArray", + "IsPtr": true, + "Params": [ + { + "Name": "NSURL", + "IsPtr": true + } + ] + } + }, + { + "Name": "handler", + "Type": { + "Block": { + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "newURLs", + "Type": { + "Name": "NSDictionary", + "IsPtr": true, + "Params": [ + { + "Name": "NSURL", + "IsPtr": true + }, + { + "Name": "NSURL", + "IsPtr": true + } + ] + } + }, + { + "Name": "error", + "Type": { + "Name": "NSError", + "IsPtr": true + } + } + ] + } + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1524490-duplicateurls?language=objc" + }, + { + "Name": "recycleURLs:completionHandler:", + "Description": "Moves the specified URLs to the trash in the same manner as the Finder.", + "Declaration": "- (void)recycleURLs:(NSArray\u003cNSURL *\u003e *)URLs \n completionHandler:(void (^)(NSDictionary\u003cNSURL *,NSURL *\u003e *newURLs, NSError *error))handler;\n", + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "URLs", + "Type": { + "Name": "NSArray", + "IsPtr": true, + "Params": [ + { + "Name": "NSURL", + "IsPtr": true + } + ] + } + }, + { + "Name": "handler", + "Type": { + "Block": { + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "newURLs", + "Type": { + "Name": "NSDictionary", + "IsPtr": true, + "Params": [ + { + "Name": "NSURL", + "IsPtr": true + }, + { + "Name": "NSURL", + "IsPtr": true + } + ] + } + }, + { + "Name": "error", + "Type": { + "Name": "NSError", + "IsPtr": true + } + } + ] + } + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1530465-recycleurls?language=objc" + }, + { + "Name": "activateFileViewerSelectingURLs:", + "Description": "Activates the Finder, and opens one or more windows selecting the specified files.", + "Declaration": "- (void)activateFileViewerSelectingURLs:(NSArray\u003cNSURL *\u003e *)fileURLs;", + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "fileURLs", + "Type": { + "Name": "NSArray", + "IsPtr": true, + "Params": [ + { + "Name": "NSURL", + "IsPtr": true + } + ] + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1524549-activatefileviewerselectingurls?language=objc" + }, + { + "Name": "selectFile:inFileViewerRootedAtPath:", + "Description": "Selects the file at the specified path.", + "Declaration": "- (BOOL)selectFile:(NSString *)fullPath \ninFileViewerRootedAtPath:(NSString *)rootFullPath;\n", + "Return": { + "Name": "BOOL" + }, + "Args": [ + { + "Name": "fullPath", + "Type": { + "Name": "NSString", + "IsPtr": true + } + }, + { + "Name": "rootFullPath", + "Type": { + "Name": "NSString", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1524399-selectfile?language=objc" + }, + { + "Name": "typeOfFile:error:", + "Description": "Returns the uniform type identifier of the specified file, if it can be determined.", + "Declaration": "- (NSString *)typeOfFile:(NSString *)absoluteFilePath \n error:(NSError * _Nullable *)outError;\n", + "Return": { + "Name": "NSString", + "IsPtr": true + }, + "Args": [ + { + "Name": "absoluteFilePath", + "Type": { + "Name": "NSString", + "IsPtr": true + } + }, + { + "Name": "outError", + "Type": { + "Name": "NSError", + "IsPtr": true, + "IsPtrPtr": true, + "Annotations": [ + "_nullable" + ] + } + } + ], + "Deprecated": true, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1526144-typeoffile?language=objc" + }, + { + "Name": "localizedDescriptionForType:", + "Description": "Returns the localized description for the specified Uniform Type Identifier (UTI).", + "Declaration": "- (NSString *)localizedDescriptionForType:(NSString *)typeName;", + "Return": { + "Name": "NSString", + "IsPtr": true + }, + "Args": [ + { + "Name": "typeName", + "Type": { + "Name": "NSString", + "IsPtr": true + } + } + ], + "Deprecated": true, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1527222-localizeddescriptionfortype?language=objc" + }, + { + "Name": "preferredFilenameExtensionForType:", + "Description": "Returns the preferred filename extension for the specified Uniform Type Identifier (UTI).", + "Declaration": "- (NSString *)preferredFilenameExtensionForType:(NSString *)typeName;", + "Return": { + "Name": "NSString", + "IsPtr": true + }, + "Args": [ + { + "Name": "typeName", + "Type": { + "Name": "NSString", + "IsPtr": true + } + } + ], + "Deprecated": true, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1535654-preferredfilenameextensionfortyp?language=objc" + }, + { + "Name": "filenameExtension:isValidForType:", + "Description": "Returns whether the specified filename extension is appropriate for the Uniform Type Identifier (UTI).", + "Declaration": "- (BOOL)filenameExtension:(NSString *)filenameExtension \n isValidForType:(NSString *)typeName;\n", + "Return": { + "Name": "BOOL" + }, + "Args": [ + { + "Name": "filenameExtension", + "Type": { + "Name": "NSString", + "IsPtr": true + } + }, + { + "Name": "typeName", + "Type": { + "Name": "NSString", + "IsPtr": true + } + } + ], + "Deprecated": true, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1525316-filenameextension?language=objc" + }, + { + "Name": "type:conformsToType:", + "Description": "Returns a Boolean indicating that the first Uniform Type Identifier (UTI) conforms to the second UTI.", + "Declaration": "- (BOOL)type:(NSString *)firstTypeName \nconformsToType:(NSString *)secondTypeName;\n", + "Return": { + "Name": "BOOL" + }, + "Args": [ + { + "Name": "firstTypeName", + "Type": { + "Name": "NSString", + "IsPtr": true + } + }, + { + "Name": "secondTypeName", + "Type": { + "Name": "NSString", + "IsPtr": true + } + } + ], + "Deprecated": true, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1535903-type?language=objc" + }, + { + "Name": "URLForApplicationWithBundleIdentifier:", + "Description": "Returns the URL for the app with the specified identifier.", + "Declaration": "- (NSURL *)URLForApplicationWithBundleIdentifier:(NSString *)bundleIdentifier;", + "Return": { + "Name": "NSURL", + "IsPtr": true + }, + "Args": [ + { + "Name": "bundleIdentifier", + "Type": { + "Name": "NSString", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1534053-urlforapplicationwithbundleident?language=objc" + }, + { + "Name": "getInfoForFile:application:type:", + "Description": "Retrieves information about the specified file.", + "Declaration": "- (BOOL)getInfoForFile:(NSString *)fullPath \n application:(NSString * _Nullable *)appName \n type:(NSString * _Nullable *)type;\n", + "Return": { + "Name": "BOOL" + }, + "Args": [ + { + "Name": "fullPath", + "Type": { + "Name": "NSString", + "IsPtr": true + } + }, + { + "Name": "appName", + "Type": { + "Name": "NSString", + "IsPtr": true, + "IsPtrPtr": true, + "Annotations": [ + "_nullable" + ] + } + }, + { + "Name": "type", + "Type": { + "Name": "NSString", + "IsPtr": true, + "IsPtrPtr": true, + "Annotations": [ + "_nullable" + ] + } + } + ], + "Deprecated": true, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1535102-getinfoforfile?language=objc" + }, + { + "Name": "URLForApplicationToOpenURL:", + "Description": "Returns the URL to the default app that would be opened.", + "Declaration": "- (NSURL *)URLForApplicationToOpenURL:(NSURL *)url;", + "Return": { + "Name": "NSURL", + "IsPtr": true + }, + "Args": [ + { + "Name": "url", + "Type": { + "Name": "NSURL", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1533391-urlforapplicationtoopenurl?language=objc" + }, + { + "Name": "getFileSystemInfoForPath:isRemovable:isWritable:isUnmountable:description:type:", + "Description": "Returns information about the file system at the specified path.", + "Declaration": "- (BOOL)getFileSystemInfoForPath:(NSString *)fullPath \n isRemovable:(BOOL *)removableFlag \n isWritable:(BOOL *)writableFlag \n isUnmountable:(BOOL *)unmountableFlag \n description:(NSString * _Nullable *)description \n type:(NSString * _Nullable *)fileSystemType;\n", + "Return": { + "Name": "BOOL" + }, + "Args": [ + { + "Name": "fullPath", + "Type": { + "Name": "NSString", + "IsPtr": true + } + }, + { + "Name": "removableFlag", + "Type": { + "Name": "BOOL", + "IsPtr": true + } + }, + { + "Name": "writableFlag", + "Type": { + "Name": "BOOL", + "IsPtr": true + } + }, + { + "Name": "unmountableFlag", + "Type": { + "Name": "BOOL", + "IsPtr": true + } + }, + { + "Name": "description", + "Type": { + "Name": "NSString", + "IsPtr": true, + "IsPtrPtr": true, + "Annotations": [ + "_nullable" + ] + } + }, + { + "Name": "fileSystemType", + "Type": { + "Name": "NSString", + "IsPtr": true, + "IsPtrPtr": true, + "Annotations": [ + "_nullable" + ] + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1526987-getfilesysteminfoforpath?language=objc" + }, + { + "Name": "isFilePackageAtPath:", + "Description": "Determines whether the specified path is a file package.", + "Declaration": "- (BOOL)isFilePackageAtPath:(NSString *)fullPath;", + "Return": { + "Name": "BOOL" + }, + "Args": [ + { + "Name": "fullPath", + "Type": { + "Name": "NSString", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1529991-isfilepackageatpath?language=objc" + }, + { + "Name": "iconForFile:", + "Description": "Returns an image containing the icon for the specified file.", + "Declaration": "- (NSImage *)iconForFile:(NSString *)fullPath;", + "Return": { + "Name": "NSImage", + "IsPtr": true + }, + "Args": [ + { + "Name": "fullPath", + "Type": { + "Name": "NSString", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1528158-iconforfile?language=objc" + }, + { + "Name": "iconForFiles:", + "Description": "Returns an image containing the icon for the specified files.", + "Declaration": "- (NSImage *)iconForFiles:(NSArray\u003cNSString *\u003e *)fullPaths;", + "Return": { + "Name": "NSImage", + "IsPtr": true + }, + "Args": [ + { + "Name": "fullPaths", + "Type": { + "Name": "NSArray", + "IsPtr": true, + "Params": [ + { + "Name": "NSString", + "IsPtr": true + } + ] + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1525487-iconforfiles?language=objc" + }, + { + "Name": "iconForContentType:", + "Description": "Returns an image containing the icon for the specified content type.", + "Declaration": "- (NSImage *)iconForContentType:(UTType *)contentType;", + "Return": { + "Name": "NSImage", + "IsPtr": true + }, + "Args": [ + { + "Name": "contentType", + "Type": { + "Name": "UTType", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/3553230-iconforcontenttype?language=objc" + }, + { + "Name": "setIcon:forFile:options:", + "Description": "Sets the icon for the file or directory at the specified path.", + "Declaration": "- (BOOL)setIcon:(NSImage *)image \n forFile:(NSString *)fullPath \n options:(NSWorkspaceIconCreationOptions)options;\n", + "Return": { + "Name": "BOOL" + }, + "Args": [ + { + "Name": "image", + "Type": { + "Name": "NSImage", + "IsPtr": true + } + }, + { + "Name": "fullPath", + "Type": { + "Name": "NSString", + "IsPtr": true + } + }, + { + "Name": "options", + "Type": { + "Name": "NSWorkspaceIconCreationOptions" + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1529882-seticon?language=objc" + }, + { + "Name": "unmountAndEjectDeviceAtPath:", + "Description": "Unmounts and ejects the device at the specified path.", + "Declaration": "- (BOOL)unmountAndEjectDeviceAtPath:(NSString *)path;", + "Return": { + "Name": "BOOL" + }, + "Args": [ + { + "Name": "path", + "Type": { + "Name": "NSString", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1527741-unmountandejectdeviceatpath?language=objc" + }, + { + "Name": "unmountAndEjectDeviceAtURL:error:", + "Description": "Attempts to eject the volume mounted at the given path.", + "Declaration": "- (BOOL)unmountAndEjectDeviceAtURL:(NSURL *)url \n error:(NSError * _Nullable *)error;\n", + "Return": { + "Name": "BOOL" + }, + "Args": [ + { + "Name": "url", + "Type": { + "Name": "NSURL", + "IsPtr": true + } + }, + { + "Name": "error", + "Type": { + "Name": "NSError", + "IsPtr": true, + "IsPtrPtr": true, + "Annotations": [ + "_nullable" + ] + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1530469-unmountandejectdeviceaturl?language=objc" + }, + { + "Name": "desktopImageURLForScreen:", + "Description": "Returns the URL for the desktop image for the given screen.", + "Declaration": "- (NSURL *)desktopImageURLForScreen:(NSScreen *)screen;", + "Return": { + "Name": "NSURL", + "IsPtr": true + }, + "Args": [ + { + "Name": "screen", + "Type": { + "Name": "NSScreen", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1530635-desktopimageurlforscreen?language=objc" + }, + { + "Name": "setDesktopImageURL:forScreen:options:error:", + "Description": "Sets the desktop image for the given screen to the image at the specified URL.", + "Declaration": "- (BOOL)setDesktopImageURL:(NSURL *)url \n forScreen:(NSScreen *)screen \n options:(NSDictionary\u003cNSWorkspaceDesktopImageOptionKey, id\u003e *)options \n error:(NSError * _Nullable *)error;\n", + "Return": { + "Name": "BOOL" + }, + "Args": [ + { + "Name": "url", + "Type": { + "Name": "NSURL", + "IsPtr": true + } + }, + { + "Name": "screen", + "Type": { + "Name": "NSScreen", + "IsPtr": true + } + }, + { + "Name": "options", + "Type": { + "Name": "NSDictionary", + "IsPtr": true, + "Params": [ + { + "Name": "NSWorkspaceDesktopImageOptionKey" + }, + { + "Name": "id" + } + ] + } + }, + { + "Name": "error", + "Type": { + "Name": "NSError", + "IsPtr": true, + "IsPtrPtr": true, + "Annotations": [ + "_nullable" + ] + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1527228-setdesktopimageurl?language=objc" + }, + { + "Name": "desktopImageOptionsForScreen:", + "Description": "Returns the desktop image options for the given screen.", + "Declaration": "- (NSDictionary\u003cNSWorkspaceDesktopImageOptionKey, id\u003e *)desktopImageOptionsForScreen:(NSScreen *)screen;", + "Return": { + "Name": "NSDictionary", + "IsPtr": true, + "Params": [ + { + "Name": "NSWorkspaceDesktopImageOptionKey" + }, + { + "Name": "id" + } + ] + }, + "Args": [ + { + "Name": "screen", + "Type": { + "Name": "NSScreen", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1530855-desktopimageoptionsforscreen?language=objc" + }, + { + "Name": "showSearchResultsForQueryString:", + "Description": "Displays a Spotlight search results window in Finder for the specified query string.", + "Declaration": "- (BOOL)showSearchResultsForQueryString:(NSString *)queryString;", + "Return": { + "Name": "BOOL" + }, + "Args": [ + { + "Name": "queryString", + "Type": { + "Name": "NSString", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1532131-showsearchresultsforquerystring?language=objc" + }, + { + "Name": "noteFileSystemChanged:", + "Description": "Informs the workspace object that the file system changed at the specified path.", + "Declaration": "- (void)noteFileSystemChanged:(NSString *)path;", + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "path", + "Type": { + "Name": "NSString", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1525376-notefilesystemchanged?language=objc" + }, + { + "Name": "extendPowerOffBy:", + "Description": "Requests the system wait for the specified amount of time before turning off the power or logging out the user.", + "Declaration": "- (NSInteger)extendPowerOffBy:(NSInteger)requested;", + "Return": { + "Name": "NSInteger" + }, + "Args": [ + { + "Name": "requested", + "Type": { + "Name": "NSInteger" + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1533106-extendpoweroffby?language=objc" + }, + { + "Name": "requestAuthorizationOfType:completionHandler:", + "Description": "Requests authorization to perform a privileged file operation.", + "Declaration": "- (void)requestAuthorizationOfType:(NSWorkspaceAuthorizationType)type \n completionHandler:(void (^)(NSWorkspaceAuthorization *authorization, NSError *error))completionHandler;\n", + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "type", + "Type": { + "Name": "NSWorkspaceAuthorizationType" + } + }, + { + "Name": "completionHandler", + "Type": { + "Block": { + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "authorization", + "Type": { + "Name": "NSWorkspaceAuthorization", + "IsPtr": true + } + }, + { + "Name": "error", + "Type": { + "Name": "NSError", + "IsPtr": true + } + } + ] + } + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/3025774-requestauthorizationoftype?language=objc" + }, + { + "Name": "setDefaultApplicationAtURL:toOpenContentType:completionHandler:", + "Description": "", + "Declaration": "- (void)setDefaultApplicationAtURL:(NSURL *)applicationURL \n toOpenContentType:(UTType *)contentType \n completionHandler:(void (^)(NSError *error))completionHandler;\n", + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "applicationURL", + "Type": { + "Name": "NSURL", + "IsPtr": true + } + }, + { + "Name": "contentType", + "Type": { + "Name": "UTType", + "IsPtr": true + } + }, + { + "Name": "completionHandler", + "Type": { + "Block": { + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "error", + "Type": { + "Name": "NSError", + "IsPtr": true + } + } + ] + } + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/3753002-setdefaultapplicationaturl?language=objc" + }, + { + "Name": "setDefaultApplicationAtURL:toOpenContentTypeOfFileAtURL:completionHandler:", + "Description": "", + "Declaration": "- (void)setDefaultApplicationAtURL:(NSURL *)applicationURL \n toOpenContentTypeOfFileAtURL:(NSURL *)url \n completionHandler:(void (^)(NSError *error))completionHandler;\n", + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "applicationURL", + "Type": { + "Name": "NSURL", + "IsPtr": true + } + }, + { + "Name": "url", + "Type": { + "Name": "NSURL", + "IsPtr": true + } + }, + { + "Name": "completionHandler", + "Type": { + "Block": { + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "error", + "Type": { + "Name": "NSError", + "IsPtr": true + } + } + ] + } + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/3753003-setdefaultapplicationaturl?language=objc" + }, + { + "Name": "setDefaultApplicationAtURL:toOpenFileAtURL:completionHandler:", + "Description": "", + "Declaration": "- (void)setDefaultApplicationAtURL:(NSURL *)applicationURL \n toOpenFileAtURL:(NSURL *)url \n completionHandler:(void (^)(NSError *error))completionHandler;\n", + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "applicationURL", + "Type": { + "Name": "NSURL", + "IsPtr": true + } + }, + { + "Name": "url", + "Type": { + "Name": "NSURL", + "IsPtr": true + } + }, + { + "Name": "completionHandler", + "Type": { + "Block": { + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "error", + "Type": { + "Name": "NSError", + "IsPtr": true + } + } + ] + } + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/3753004-setdefaultapplicationaturl?language=objc" + }, + { + "Name": "setDefaultApplicationAtURL:toOpenURLsWithScheme:completionHandler:", + "Description": "", + "Declaration": "- (void)setDefaultApplicationAtURL:(NSURL *)applicationURL \n toOpenURLsWithScheme:(NSString *)urlScheme \n completionHandler:(void (^)(NSError *error))completionHandler;\n", + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "applicationURL", + "Type": { + "Name": "NSURL", + "IsPtr": true + } + }, + { + "Name": "urlScheme", + "Type": { + "Name": "NSString", + "IsPtr": true + } + }, + { + "Name": "completionHandler", + "Type": { + "Block": { + "Return": { + "Name": "void" + }, + "Args": [ + { + "Name": "error", + "Type": { + "Name": "NSError", + "IsPtr": true + } + } + ] + } + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/3753005-setdefaultapplicationaturl?language=objc" + }, + { + "Name": "URLForApplicationToOpenContentType:", + "Description": "", + "Declaration": "- (NSURL *)URLForApplicationToOpenContentType:(UTType *)contentType;", + "Return": { + "Name": "NSURL", + "IsPtr": true + }, + "Args": [ + { + "Name": "contentType", + "Type": { + "Name": "UTType", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/3752998-urlforapplicationtoopencontentty?language=objc" + }, + { + "Name": "URLsForApplicationsToOpenContentType:", + "Description": "", + "Declaration": "- (NSArray\u003cNSURL *\u003e *)URLsForApplicationsToOpenContentType:(UTType *)contentType;", + "Return": { + "Name": "NSArray", + "IsPtr": true, + "Params": [ + { + "Name": "NSURL", + "IsPtr": true + } + ] + }, + "Args": [ + { + "Name": "contentType", + "Type": { + "Name": "UTType", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/3752999-urlsforapplicationstoopencontent?language=objc" + }, + { + "Name": "URLsForApplicationsToOpenURL:", + "Description": "", + "Declaration": "- (NSArray\u003cNSURL *\u003e *)URLsForApplicationsToOpenURL:(NSURL *)url;", + "Return": { + "Name": "NSArray", + "IsPtr": true, + "Params": [ + { + "Name": "NSURL", + "IsPtr": true + } + ] + }, + "Args": [ + { + "Name": "url", + "Type": { + "Name": "NSURL", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/3753000-urlsforapplicationstoopenurl?language=objc" + }, + { + "Name": "URLsForApplicationsWithBundleIdentifier:", + "Description": "", + "Declaration": "- (NSArray\u003cNSURL *\u003e *)URLsForApplicationsWithBundleIdentifier:(NSString *)bundleIdentifier;", + "Return": { + "Name": "NSArray", + "IsPtr": true, + "Params": [ + { + "Name": "NSURL", + "IsPtr": true + } + ] + }, + "Args": [ + { + "Name": "bundleIdentifier", + "Type": { + "Name": "NSString", + "IsPtr": true + } + } + ], + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/3753001-urlsforapplicationswithbundleide?language=objc" + } + ], + "InstanceProperties": [ + { + "Name": "notificationCenter", + "Description": "The notification center for workspace notifications.", + "Declaration": "@property(readonly, strong) NSNotificationCenter *notificationCenter;", + "Type": { + "Name": "NSNotificationCenter", + "IsPtr": true + }, + "Attrs": { + "readonly": true, + "strong": true + }, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1525071-notificationcenter?language=objc" + }, + { + "Name": "frontmostApplication", + "Description": "Returns the frontmost app, which is the app that receives key events.", + "Declaration": "@property(nullable, readonly, strong) NSRunningApplication *frontmostApplication;", + "Type": { + "Name": "NSRunningApplication", + "IsPtr": true + }, + "Attrs": { + "nullable": true, + "readonly": true, + "strong": true + }, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1532097-frontmostapplication?language=objc" + }, + { + "Name": "runningApplications", + "Description": "Returns an array of running apps.", + "Declaration": "@property(readonly, copy) NSArray\u003cNSRunningApplication *\u003e *runningApplications;", + "Type": { + "Name": "NSArray", + "IsPtr": true, + "Params": [ + { + "Name": "NSRunningApplication", + "IsPtr": true + } + ] + }, + "Attrs": { + "copy": true, + "readonly": true + }, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1534059-runningapplications?language=objc" + }, + { + "Name": "menuBarOwningApplication", + "Description": "Returns the app that owns the currently displayed menu bar.", + "Declaration": "@property(nullable, readonly, strong) NSRunningApplication *menuBarOwningApplication;", + "Type": { + "Name": "NSRunningApplication", + "IsPtr": true + }, + "Attrs": { + "nullable": true, + "readonly": true, + "strong": true + }, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1525848-menubarowningapplication?language=objc" + }, + { + "Name": "fileLabels", + "Description": "The array of file labels, returned as strings.", + "Declaration": "@property(readonly, copy) NSArray\u003cNSString *\u003e *fileLabels;", + "Type": { + "Name": "NSArray", + "IsPtr": true, + "Params": [ + { + "Name": "NSString", + "IsPtr": true + } + ] + }, + "Attrs": { + "copy": true, + "readonly": true + }, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1533953-filelabels?language=objc" + }, + { + "Name": "fileLabelColors", + "Description": "The array of colors for the file labels.", + "Declaration": "@property(readonly, copy) NSArray\u003cNSColor *\u003e *fileLabelColors;", + "Type": { + "Name": "NSArray", + "IsPtr": true, + "Params": [ + { + "Name": "NSColor", + "IsPtr": true + } + ] + }, + "Attrs": { + "copy": true, + "readonly": true + }, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1527553-filelabelcolors?language=objc" + }, + { + "Name": "accessibilityDisplayShouldDifferentiateWithoutColor", + "Description": "A Boolean value that indicates whether the app avoids conveying information through color alone.", + "Declaration": "@property(readonly) BOOL accessibilityDisplayShouldDifferentiateWithoutColor;", + "Type": { + "Name": "BOOL" + }, + "Attrs": { + "readonly": true + }, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1524656-accessibilitydisplayshoulddiffer?language=objc" + }, + { + "Name": "accessibilityDisplayShouldIncreaseContrast", + "Description": "A Boolean value that indicates whether the app presents a high-contrast user interface.", + "Declaration": "@property(readonly) BOOL accessibilityDisplayShouldIncreaseContrast;", + "Type": { + "Name": "BOOL" + }, + "Attrs": { + "readonly": true + }, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1526290-accessibilitydisplayshouldincrea?language=objc" + }, + { + "Name": "accessibilityDisplayShouldReduceTransparency", + "Description": "A Boolean value that indicates whether the app avoids using semitransparent backgrounds.", + "Declaration": "@property(readonly) BOOL accessibilityDisplayShouldReduceTransparency;", + "Type": { + "Name": "BOOL" + }, + "Attrs": { + "readonly": true + }, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1533006-accessibilitydisplayshouldreduce?language=objc" + }, + { + "Name": "accessibilityDisplayShouldInvertColors", + "Description": "A Boolean value that indicates whether the accessibility option to invert colors is in an enabled state.", + "Declaration": "@property(readonly) BOOL accessibilityDisplayShouldInvertColors;", + "Type": { + "Name": "BOOL" + }, + "Attrs": { + "readonly": true + }, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1644068-accessibilitydisplayshouldinvert?language=objc" + }, + { + "Name": "accessibilityDisplayShouldReduceMotion", + "Description": "A Boolean value that indicates whether the accessibility option to reduce motion is in an enabled state.", + "Declaration": "@property(readonly) BOOL accessibilityDisplayShouldReduceMotion;", + "Type": { + "Name": "BOOL" + }, + "Attrs": { + "readonly": true + }, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1644069-accessibilitydisplayshouldreduce?language=objc" + }, + { + "Name": "switchControlEnabled", + "Description": "A Boolean value that indicates whether Switch Control is currently running.", + "Declaration": "@property(readonly, getter=isSwitchControlEnabled) BOOL switchControlEnabled;", + "Type": { + "Name": "BOOL" + }, + "Attrs": { + "getter": "isSwitchControlEnabled", + "readonly": true + }, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/2880322-switchcontrolenabled?language=objc" + }, + { + "Name": "voiceOverEnabled", + "Description": "A Boolean value that indicates whether VoiceOver is currently running.", + "Declaration": "@property(readonly, getter=isVoiceOverEnabled) BOOL voiceOverEnabled;", + "Type": { + "Name": "BOOL" + }, + "Attrs": { + "getter": "isVoiceOverEnabled", + "readonly": true + }, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/2880317-voiceoverenabled?language=objc" + } + ], + "TypeProperties": [ + { + "Name": "sharedWorkspace", + "Description": "The shared workspace object.", + "Declaration": "@property(class, readonly, strong) NSWorkspace *sharedWorkspace;", + "Type": { + "Name": "NSWorkspace", + "IsPtr": true + }, + "Attrs": { + "class": true, + "readonly": true, + "strong": true + }, + "TopicURL": "https://developer.apple.com/documentation/appkit/nsworkspace/1530344-sharedworkspace?language=objc" + } + ] + }, + "Kind": "class", + "PullDate": "2023-07-01T16:34:44.7059-07:00", + "Version": 2 +} \ No newline at end of file diff --git a/cocoa/NSWorkspace.go b/cocoa/NSWorkspace.go new file mode 100644 index 00000000..e8f3d6db --- /dev/null +++ b/cocoa/NSWorkspace.go @@ -0,0 +1,5 @@ +package cocoa + +type NSWorkspace struct { + gen_NSWorkspace +} diff --git a/cocoa/cocoa_objc.gen.go b/cocoa/cocoa_objc.gen.go index 89a893e7..964d3380 100755 --- a/cocoa/cocoa_objc.gen.go +++ b/cocoa/cocoa_objc.gen.go @@ -451,6 +451,14 @@ void NSWindow_type_setAllowsAutomaticWindowTabbing_(BOOL value) { [NSWindow setAllowsAutomaticWindowTabbing: value]; } +void* NSWorkspace_type_alloc() { + return [NSWorkspace + alloc]; +} +void* NSWorkspace_type_sharedWorkspace() { + return [NSWorkspace + sharedWorkspace]; +} void* NSColor_type_alloc() { return [NSColor alloc]; @@ -4987,6 +4995,147 @@ void NSWindow_inst_setOrderedIndex_(void *id, long value) { setOrderedIndex: value]; } +BOOL NSWorkspace_inst_openURL_(void *id, void* url) { + return [(NSWorkspace*)id + openURL: url]; +} + +void NSWorkspace_inst_hideOtherApplications(void *id) { + [(NSWorkspace*)id + hideOtherApplications]; +} + +void NSWorkspace_inst_activateFileViewerSelectingURLs_(void *id, void* fileURLs) { + [(NSWorkspace*)id + activateFileViewerSelectingURLs: fileURLs]; +} + +BOOL NSWorkspace_inst_selectFile_inFileViewerRootedAtPath_(void *id, void* fullPath, void* rootFullPath) { + return [(NSWorkspace*)id + selectFile: fullPath + inFileViewerRootedAtPath: rootFullPath]; +} + +void* NSWorkspace_inst_URLForApplicationWithBundleIdentifier_(void *id, void* bundleIdentifier) { + return [(NSWorkspace*)id + URLForApplicationWithBundleIdentifier: bundleIdentifier]; +} + +void* NSWorkspace_inst_URLForApplicationToOpenURL_(void *id, void* url) { + return [(NSWorkspace*)id + URLForApplicationToOpenURL: url]; +} + +BOOL NSWorkspace_inst_isFilePackageAtPath_(void *id, void* fullPath) { + return [(NSWorkspace*)id + isFilePackageAtPath: fullPath]; +} + +void* NSWorkspace_inst_iconForFile_(void *id, void* fullPath) { + return [(NSWorkspace*)id + iconForFile: fullPath]; +} + +void* NSWorkspace_inst_iconForFiles_(void *id, void* fullPaths) { + return [(NSWorkspace*)id + iconForFiles: fullPaths]; +} + +BOOL NSWorkspace_inst_unmountAndEjectDeviceAtPath_(void *id, void* path) { + return [(NSWorkspace*)id + unmountAndEjectDeviceAtPath: path]; +} + +void* NSWorkspace_inst_desktopImageURLForScreen_(void *id, void* screen) { + return [(NSWorkspace*)id + desktopImageURLForScreen: screen]; +} + +void* NSWorkspace_inst_desktopImageOptionsForScreen_(void *id, void* screen) { + return [(NSWorkspace*)id + desktopImageOptionsForScreen: screen]; +} + +BOOL NSWorkspace_inst_showSearchResultsForQueryString_(void *id, void* queryString) { + return [(NSWorkspace*)id + showSearchResultsForQueryString: queryString]; +} + +void NSWorkspace_inst_noteFileSystemChanged_(void *id, void* path) { + [(NSWorkspace*)id + noteFileSystemChanged: path]; +} + +long NSWorkspace_inst_extendPowerOffBy_(void *id, long requested) { + return [(NSWorkspace*)id + extendPowerOffBy: requested]; +} + +void* NSWorkspace_inst_URLsForApplicationsToOpenURL_(void *id, void* url) { + return [(NSWorkspace*)id + URLsForApplicationsToOpenURL: url]; +} + +void* NSWorkspace_inst_URLsForApplicationsWithBundleIdentifier_(void *id, void* bundleIdentifier) { + return [(NSWorkspace*)id + URLsForApplicationsWithBundleIdentifier: bundleIdentifier]; +} + +void* NSWorkspace_inst_init(void *id) { + return [(NSWorkspace*)id + init]; +} + +void* NSWorkspace_inst_runningApplications(void *id) { + return [(NSWorkspace*)id + runningApplications]; +} + +void* NSWorkspace_inst_fileLabels(void *id) { + return [(NSWorkspace*)id + fileLabels]; +} + +void* NSWorkspace_inst_fileLabelColors(void *id) { + return [(NSWorkspace*)id + fileLabelColors]; +} + +BOOL NSWorkspace_inst_accessibilityDisplayShouldDifferentiateWithoutColor(void *id) { + return [(NSWorkspace*)id + accessibilityDisplayShouldDifferentiateWithoutColor]; +} + +BOOL NSWorkspace_inst_accessibilityDisplayShouldIncreaseContrast(void *id) { + return [(NSWorkspace*)id + accessibilityDisplayShouldIncreaseContrast]; +} + +BOOL NSWorkspace_inst_accessibilityDisplayShouldReduceTransparency(void *id) { + return [(NSWorkspace*)id + accessibilityDisplayShouldReduceTransparency]; +} + +BOOL NSWorkspace_inst_accessibilityDisplayShouldInvertColors(void *id) { + return [(NSWorkspace*)id + accessibilityDisplayShouldInvertColors]; +} + +BOOL NSWorkspace_inst_accessibilityDisplayShouldReduceMotion(void *id) { + return [(NSWorkspace*)id + accessibilityDisplayShouldReduceMotion]; +} + +BOOL NSWorkspace_inst_isSwitchControlEnabled(void *id) { + return [(NSWorkspace*)id + isSwitchControlEnabled]; +} + +BOOL NSWorkspace_inst_isVoiceOverEnabled(void *id) { + return [(NSWorkspace*)id + isVoiceOverEnabled]; +} + void* NSColor_inst_blendedColorWithFraction_ofColor_(void *id, double fraction, void* color) { return [(NSColor*)id blendedColorWithFraction: fraction @@ -8073,6 +8222,22 @@ func NSWindow_setAllowsAutomaticWindowTabbing_( return } +func NSWorkspace_alloc() ( + r0 NSWorkspace, +) { + ret := C.NSWorkspace_type_alloc() + r0 = NSWorkspace_fromPointer(ret) + return +} + +func NSWorkspace_sharedWorkspace() ( + r0 NSWorkspace, +) { + ret := C.NSWorkspace_type_sharedWorkspace() + r0 = NSWorkspace_fromPointer(ret) + return +} + func NSColor_alloc() ( r0 NSColor, ) { @@ -17732,6 +17897,346 @@ func (x gen_NSWindow) SetOrderedIndex_( return } +type NSWorkspaceRef interface { + Pointer() uintptr + Init_asNSWorkspace() NSWorkspace +} + +type gen_NSWorkspace struct { + objc.Object +} + +func NSWorkspace_fromPointer(ptr unsafe.Pointer) NSWorkspace { + return NSWorkspace{gen_NSWorkspace{ + objc.Object_fromPointer(ptr), + }} +} + +func NSWorkspace_fromRef(ref objc.Ref) NSWorkspace { + return NSWorkspace_fromPointer(unsafe.Pointer(ref.Pointer())) +} + +func (x gen_NSWorkspace) OpenURL_( + url core.NSURLRef, +) ( + r0 bool, +) { + ret := C.NSWorkspace_inst_openURL_( + unsafe.Pointer(x.Pointer()), + objc.RefPointer(url), + ) + r0 = convertObjCBoolToGo(ret) + return +} + +func (x gen_NSWorkspace) HideOtherApplications() { + C.NSWorkspace_inst_hideOtherApplications( + unsafe.Pointer(x.Pointer()), + ) + return +} + +func (x gen_NSWorkspace) ActivateFileViewerSelectingURLs_( + fileURLs core.NSArrayRef, +) { + C.NSWorkspace_inst_activateFileViewerSelectingURLs_( + unsafe.Pointer(x.Pointer()), + objc.RefPointer(fileURLs), + ) + return +} + +func (x gen_NSWorkspace) SelectFile_inFileViewerRootedAtPath_( + fullPath core.NSStringRef, + rootFullPath core.NSStringRef, +) ( + r0 bool, +) { + ret := C.NSWorkspace_inst_selectFile_inFileViewerRootedAtPath_( + unsafe.Pointer(x.Pointer()), + objc.RefPointer(fullPath), + objc.RefPointer(rootFullPath), + ) + r0 = convertObjCBoolToGo(ret) + return +} + +func (x gen_NSWorkspace) URLForApplicationWithBundleIdentifier_( + bundleIdentifier core.NSStringRef, +) ( + r0 core.NSURL, +) { + ret := C.NSWorkspace_inst_URLForApplicationWithBundleIdentifier_( + unsafe.Pointer(x.Pointer()), + objc.RefPointer(bundleIdentifier), + ) + r0 = core.NSURL_fromPointer(ret) + return +} + +func (x gen_NSWorkspace) URLForApplicationToOpenURL_( + url core.NSURLRef, +) ( + r0 core.NSURL, +) { + ret := C.NSWorkspace_inst_URLForApplicationToOpenURL_( + unsafe.Pointer(x.Pointer()), + objc.RefPointer(url), + ) + r0 = core.NSURL_fromPointer(ret) + return +} + +func (x gen_NSWorkspace) IsFilePackageAtPath_( + fullPath core.NSStringRef, +) ( + r0 bool, +) { + ret := C.NSWorkspace_inst_isFilePackageAtPath_( + unsafe.Pointer(x.Pointer()), + objc.RefPointer(fullPath), + ) + r0 = convertObjCBoolToGo(ret) + return +} + +func (x gen_NSWorkspace) IconForFile_( + fullPath core.NSStringRef, +) ( + r0 NSImage, +) { + ret := C.NSWorkspace_inst_iconForFile_( + unsafe.Pointer(x.Pointer()), + objc.RefPointer(fullPath), + ) + r0 = NSImage_fromPointer(ret) + return +} + +func (x gen_NSWorkspace) IconForFiles_( + fullPaths core.NSArrayRef, +) ( + r0 NSImage, +) { + ret := C.NSWorkspace_inst_iconForFiles_( + unsafe.Pointer(x.Pointer()), + objc.RefPointer(fullPaths), + ) + r0 = NSImage_fromPointer(ret) + return +} + +func (x gen_NSWorkspace) UnmountAndEjectDeviceAtPath_( + path core.NSStringRef, +) ( + r0 bool, +) { + ret := C.NSWorkspace_inst_unmountAndEjectDeviceAtPath_( + unsafe.Pointer(x.Pointer()), + objc.RefPointer(path), + ) + r0 = convertObjCBoolToGo(ret) + return +} + +func (x gen_NSWorkspace) DesktopImageURLForScreen_( + screen NSScreenRef, +) ( + r0 core.NSURL, +) { + ret := C.NSWorkspace_inst_desktopImageURLForScreen_( + unsafe.Pointer(x.Pointer()), + objc.RefPointer(screen), + ) + r0 = core.NSURL_fromPointer(ret) + return +} + +func (x gen_NSWorkspace) DesktopImageOptionsForScreen_( + screen NSScreenRef, +) ( + r0 core.NSDictionary, +) { + ret := C.NSWorkspace_inst_desktopImageOptionsForScreen_( + unsafe.Pointer(x.Pointer()), + objc.RefPointer(screen), + ) + r0 = core.NSDictionary_fromPointer(ret) + return +} + +func (x gen_NSWorkspace) ShowSearchResultsForQueryString_( + queryString core.NSStringRef, +) ( + r0 bool, +) { + ret := C.NSWorkspace_inst_showSearchResultsForQueryString_( + unsafe.Pointer(x.Pointer()), + objc.RefPointer(queryString), + ) + r0 = convertObjCBoolToGo(ret) + return +} + +func (x gen_NSWorkspace) NoteFileSystemChanged_( + path core.NSStringRef, +) { + C.NSWorkspace_inst_noteFileSystemChanged_( + unsafe.Pointer(x.Pointer()), + objc.RefPointer(path), + ) + return +} + +func (x gen_NSWorkspace) ExtendPowerOffBy_( + requested core.NSInteger, +) ( + r0 core.NSInteger, +) { + ret := C.NSWorkspace_inst_extendPowerOffBy_( + unsafe.Pointer(x.Pointer()), + C.long(requested), + ) + r0 = core.NSInteger(ret) + return +} + +func (x gen_NSWorkspace) URLsForApplicationsToOpenURL_( + url core.NSURLRef, +) ( + r0 core.NSArray, +) { + ret := C.NSWorkspace_inst_URLsForApplicationsToOpenURL_( + unsafe.Pointer(x.Pointer()), + objc.RefPointer(url), + ) + r0 = core.NSArray_fromPointer(ret) + return +} + +func (x gen_NSWorkspace) URLsForApplicationsWithBundleIdentifier_( + bundleIdentifier core.NSStringRef, +) ( + r0 core.NSArray, +) { + ret := C.NSWorkspace_inst_URLsForApplicationsWithBundleIdentifier_( + unsafe.Pointer(x.Pointer()), + objc.RefPointer(bundleIdentifier), + ) + r0 = core.NSArray_fromPointer(ret) + return +} + +func (x gen_NSWorkspace) Init_asNSWorkspace() ( + r0 NSWorkspace, +) { + ret := C.NSWorkspace_inst_init( + unsafe.Pointer(x.Pointer()), + ) + r0 = NSWorkspace_fromPointer(ret) + return +} + +func (x gen_NSWorkspace) RunningApplications() ( + r0 core.NSArray, +) { + ret := C.NSWorkspace_inst_runningApplications( + unsafe.Pointer(x.Pointer()), + ) + r0 = core.NSArray_fromPointer(ret) + return +} + +func (x gen_NSWorkspace) FileLabels() ( + r0 core.NSArray, +) { + ret := C.NSWorkspace_inst_fileLabels( + unsafe.Pointer(x.Pointer()), + ) + r0 = core.NSArray_fromPointer(ret) + return +} + +func (x gen_NSWorkspace) FileLabelColors() ( + r0 core.NSArray, +) { + ret := C.NSWorkspace_inst_fileLabelColors( + unsafe.Pointer(x.Pointer()), + ) + r0 = core.NSArray_fromPointer(ret) + return +} + +func (x gen_NSWorkspace) AccessibilityDisplayShouldDifferentiateWithoutColor() ( + r0 bool, +) { + ret := C.NSWorkspace_inst_accessibilityDisplayShouldDifferentiateWithoutColor( + unsafe.Pointer(x.Pointer()), + ) + r0 = convertObjCBoolToGo(ret) + return +} + +func (x gen_NSWorkspace) AccessibilityDisplayShouldIncreaseContrast() ( + r0 bool, +) { + ret := C.NSWorkspace_inst_accessibilityDisplayShouldIncreaseContrast( + unsafe.Pointer(x.Pointer()), + ) + r0 = convertObjCBoolToGo(ret) + return +} + +func (x gen_NSWorkspace) AccessibilityDisplayShouldReduceTransparency() ( + r0 bool, +) { + ret := C.NSWorkspace_inst_accessibilityDisplayShouldReduceTransparency( + unsafe.Pointer(x.Pointer()), + ) + r0 = convertObjCBoolToGo(ret) + return +} + +func (x gen_NSWorkspace) AccessibilityDisplayShouldInvertColors() ( + r0 bool, +) { + ret := C.NSWorkspace_inst_accessibilityDisplayShouldInvertColors( + unsafe.Pointer(x.Pointer()), + ) + r0 = convertObjCBoolToGo(ret) + return +} + +func (x gen_NSWorkspace) AccessibilityDisplayShouldReduceMotion() ( + r0 bool, +) { + ret := C.NSWorkspace_inst_accessibilityDisplayShouldReduceMotion( + unsafe.Pointer(x.Pointer()), + ) + r0 = convertObjCBoolToGo(ret) + return +} + +func (x gen_NSWorkspace) IsSwitchControlEnabled() ( + r0 bool, +) { + ret := C.NSWorkspace_inst_isSwitchControlEnabled( + unsafe.Pointer(x.Pointer()), + ) + r0 = convertObjCBoolToGo(ret) + return +} + +func (x gen_NSWorkspace) IsVoiceOverEnabled() ( + r0 bool, +) { + ret := C.NSWorkspace_inst_isVoiceOverEnabled( + unsafe.Pointer(x.Pointer()), + ) + r0 = convertObjCBoolToGo(ret) + return +} + type NSColorRef interface { Pointer() uintptr Init_asNSColor() NSColor diff --git a/gen/cmd/gen.go b/gen/cmd/gen.go index 8aae3c26..498294a1 100644 --- a/gen/cmd/gen.go +++ b/gen/cmd/gen.go @@ -55,6 +55,7 @@ func main() { loadFile("api/appkit/nsviewcontroller.objc.json"), loadFile("api/appkit/nsvisualeffectview.objc.json"), loadFile("api/appkit/nswindow.objc.json"), + loadFile("api/appkit/nsworkspace.objc.json"), loadFile("api/appkit/nscolor.objc.json").Then(func(s *schema.Schema) error { s.Class.TypeMethods = append(s.Class.TypeMethods, schema.Method{ diff --git a/gen/cmd/loader.go b/gen/cmd/loader.go index 389b4d1a..790f6cf5 100644 --- a/gen/cmd/loader.go +++ b/gen/cmd/loader.go @@ -192,11 +192,14 @@ func generatePackage(name string, schemas []*schema.Schema, imports []gen.Packag addFramework(fw) } } - pkg := gen.Convert(desc, combinedImports, schemas...) + pkg, err := gen.Convert(desc, combinedImports, schemas...) + if err != nil { + return fmt.Errorf("generating package %s: %w", name, err) + } outPath := path.Join(name, desc.Name+"_objc.gen.go") var b bytes.Buffer if err := pkg.Generate(&b); err != nil { - return err + return fmt.Errorf("generating package %s: %w", name, err) } code, err := format.Source(b.Bytes()) if err != nil { diff --git a/gen/gen.go b/gen/gen.go index 0768692a..bb0939d6 100644 --- a/gen/gen.go +++ b/gen/gen.go @@ -222,7 +222,8 @@ func toExportedName(name string) string { return string(ch) + name[n:] } -func Convert(desc PackageDescription, imports []PackageContents, schemas ...*schema.Schema) GoPackage { +// Convert converts a schema into a GoPackage. +func Convert(desc PackageDescription, imports []PackageContents, schemas ...*schema.Schema) (GoPackage, error) { pkg := GoPackage{ PackageDescription: desc, } @@ -240,7 +241,13 @@ func Convert(desc PackageDescription, imports []PackageContents, schemas ...*sch Name: cb.Class.Name, Base: "objc.Object", } - if decl := parseClassDeclaration(cb.Class.Declaration); decl.Base != "NSObject" { + decl, err := parseClassDeclaration(cb.Class.Declaration) + if err != nil { + return pkg, fmt.Errorf("issue with class %s failed to parse declaration %+v: %w", cb.Class.Name, cb.Class, err) + + } + + if decl.Base != "NSObject" { // TODO require resolving every base class but for now just fall back on // objc.Object if we don't have the base type in the schema if cls := cb.mapClass(decl.Base); cls != nil { @@ -273,7 +280,7 @@ func Convert(desc PackageDescription, imports []PackageContents, schemas ...*sch for imp := range consumedImports { pkg.Imports = append(pkg.Imports, imp) } - return pkg + return pkg, nil } type declaration struct { @@ -281,14 +288,16 @@ type declaration struct { Base string } -func parseClassDeclaration(decl string) declaration { +func parseClassDeclaration(decl string) (declaration, error) { decl = strings.TrimPrefix(decl, "@interface ") parts := strings.Split(decl, ":") if len(parts) != 2 { - panic(fmt.Errorf("unable to parse: %q", decl)) + //panic(fmt.Errorf("unable to parse: %q", decl)) + return declaration{}, fmt.Errorf("unable to parse: %q (%d parts)", decl, len(parts)) + } return declaration{ Name: strings.TrimSpace(parts[0]), Base: strings.TrimSpace(parts[1]), - } + }, nil } diff --git a/gen/gen_test.go b/gen/gen_test.go index 7314e361..366843ed 100644 --- a/gen/gen_test.go +++ b/gen/gen_test.go @@ -16,7 +16,8 @@ func TestExportedName(t *testing.T) { } func TestParseClassDeclaration(t *testing.T) { - d := parseClassDeclaration("@interface NSString : NSObject") + d, err := parseClassDeclaration("@interface NSString : NSObject") + assert.NoError(t, err) assert.Equal(t, declaration{ Name: "NSString", Base: "NSObject",