Re: [Pyobjc-dev] AppKit/__init__.py complexity
Brought to you by:
ronaldoussoren
From: Bill B. <bb...@co...> - 2003-02-28 16:15:57
|
On Friday, Feb 28, 2003, at 10:51 US/Eastern, Just van Rossum wrote: > That's indeed not so bad. What worries me more is that they all seem > hand-rolled. Would it be possible -- in theory at least -- to generate > them from header files? Sure. It is just a matter of parsing the types of the arguments and return values. The other challenge is to be able to identify which methods need to be parsed out and which don't. In most cases, delegate methods and data sources are declared in a category [without impelmentation] like.... @interface NSObject(NSTableViewDelegate) @interface NSObject(NSTableDataSource) ... and, I suppose since they return (void), we ought to also grab some of the notification declarations as they effectively act like delegate methods (if the delegate implements the standard notification method, it'll automatically become an observer of the corresponding notification)... @interface NSObject(NSTableViewNotifications) A simple grep identifies these delegate declarations: [bumbox:Frameworks/AppKit.framework/Headers] bbum% grep 'Delegate)' *.h NSApplication.h:@interface NSObject(NSApplicationDelegate) NSBrowser.h:@interface NSObject(NSBrowserDelegate) NSControl.h:@interface NSObject(NSControlSubclassDelegate) NSDrawer.h:@interface NSObject(NSDrawerDelegate) NSFontManager.h:@interface NSObject(NSFontManagerDelegate) NSImage.h:@interface NSObject(NSImageDelegate) NSLayoutManager.h:@interface NSObject (NSLayoutManagerDelegate) NSOutlineView.h:@interface NSObject(NSOutlineViewDelegate) NSSavePanel.h:@interface NSObject(NSSavePanelDelegate) NSSplitView.h:@interface NSObject(NSSplitViewDelegate) NSTabView.h:@interface NSObject(NSTabViewDelegate) NSTableView.h:@interface NSObject(NSTableViewDelegate) NSText.h:@interface NSObject(NSTextDelegate) NSTextStorage.h:@interface NSObject (NSTextStorageDelegate) NSTextView.h:@interface NSObject (NSTextViewDelegate) NSToolbar.h:@interface NSObject (NSToolbarDelegate) NSWindow.h:@interface NSObject(NSWindowDelegate) ... and these Notifications: [bumbox:Frameworks/AppKit.framework/Headers] bbum% grep 'Notifications)' *.h NSApplication.h:@interface NSObject(NSApplicationNotifications) NSComboBox.h:@interface NSObject (NSComboBoxNotifications) NSControl.h:@interface NSObject(NSControlSubclassNotifications) NSDrawer.h:@interface NSObject(NSDrawerNotifications) NSOutlineView.h:@interface NSObject(NSOutlineViewNotifications) NSTableView.h:@interface NSObject(NSTableViewNotifications) NSToolbar.h:@interface NSObject (NSToolbarNotifications) NSWindow.h:@interface NSObject(NSWindowNotifications) ... and these DataSources: [bumbox:Frameworks/AppKit.framework/Headers] bbum% grep 'DataSource)' *.h NSComboBox.h:@interface NSObject (NSComboBoxDataSource) NSComboBoxCell.h:@interface NSObject (NSComboBoxCellDataSource) NSOutlineView.h:@interface NSObject(NSOutlineViewDataSource) NSTableView.h:@interface NSObject(NSTableDataSource) In all, we really should consider all methods that are declared as a category on NSObject. In some cases, there will be a default implementation within the runtime already tacked onto NSObject thus obviating the need for an informal_protocol declaration. [bumbox:Frameworks/AppKit.framework/Headers] bbum% grep -e '@interface.*NSObject.*(.*)' *.h | grep -v DataSource | grep -v Delegate | grep -v Notifications NSAccessibility.h:@interface NSObject (NSAccessibility) NSApplication.h:@interface NSObject(NSServicesRequests) NSApplicationScripting.h:@interface NSObject (NSApplicationScriptingDelegation) NSColorPanel.h:@interface NSObject(NSColorPanelResponderMethod) NSDragging.h:@interface NSObject(NSDraggingDestination) NSDragging.h:@interface NSObject(NSDraggingSource) NSFontManager.h:@interface NSObject(NSFontManagerResponderMethod) NSMenu.h:@interface NSObject(NSMenuValidation) NSNibLoading.h:@interface NSObject (NSNibAwaking) NSPasteboard.h:@interface NSObject(NSPasteboardOwner) NSToolbarItem.h:@interface NSObject (NSToolbarItemValidation) NSView.h:@interface NSObject(NSToolTipOwner) The Foundation and other frameworks will also have a handful of similar declarations. b.bum |