Description
The current Obj-C name generation makes clunky methods that don't feel like Dart or like Obj-C. I think it would be much better if it used heuristics like Swift/Obj-C interop, and signature segments were converted to named parameters instead.
E.g., NSNotificationCenter has
addObserverForName:object:queue:usingBlock:
, which- ffigen renders as
addObserverForName_object_queue_usingBlock_(NSString? name, ObjCObjectBase? obj, NSOperationQueue? queue, ObjCBlock<ffi.Void Function(NSNotification)> block)
, while - Swift renders as
addObserver(forName name: NSNotification.Name, object obj: Any?, queue: OperationQueue?, using block: @escaping @Sendable (Notification) -> Void )
I don't see why Dart couldn't make it addObserver({NSString name, ObjCObjectBase? object, NSOperationQueue? queue, ObjCBlock<ffi.Void Function(NSNotification)> block
, or any other number of slight variations using heuristics of Obj-C naming conventions (like handling "with" and "from", if param names aren't always good enough).
This would give results more like Obj-C, more like idiomatic Dart, more like Swift, and more readable all around. They would be slightly less deterministically discoverable, but I would gladly trade that slight inconvenience for better readability and more idiomatic code. Especially since realistically I think we can expect most people to do what I'm doing, which is using IDE autocomplete rather than copy/pasting Obj-C signatures and manually translating them.
Metadata
Metadata
Assignees
Type
Projects
Status