progrium / darwinkit

Native Mac APIs for Go. Previously known as MacDriver
MIT License
5.04k stars 160 forks source link

Generator change: keep Objective-C type when parameter is a pointer to a pointer #234

Closed programmingkidx closed 5 months ago

programmingkidx commented 11 months ago

In Objective-C a method's parameter can be used to return information. This information could be anything from error info to an array of objects. Because of the complexity of the translation system, using a Go type to return this information will probably not work. I suggest a new rule be implemented in the generator that prevents the translation of an Objective-C type to a Go type when the parameter is a pointer to a pointer.

Examples of methods that would be effected by this new rule:

- NSNib's instantiateWithOwner:(id)owner topLevelObjects:(NSArray * _Nullable *)topLevelObjects
- NSFileManager's createDirectoryAtPath:(NSString *)path withIntermediateDirectories:(BOOL)createIntermediates attributes:(NSDictionary<NSFileAttributeKey, id> *)attributes error:(NSError * _Nullable *)error
- NSURLConnection's sendSynchronousRequest:(NSURLRequest *)request returningResponse:(NSURLResponse * _Nullable *)response error:(NSError * _Nullable *)error;
- IOUSBHostPipe's sendControlRequest:(IOUSBDeviceRequest)request error:(NSError * _Nullable *)error;
programmingkidx commented 10 months ago

Implemented this pull request for resolving this issue: https://github.com/progrium/macdriver/pull/244