/* Throughout this script, the bogus string SKIP_SECOND_WARNING:0 is inserted in invocations of old delegate methods so that that later replacemethod rules only act on implementations of these methods. */
/*********** NotificationConversion: calls excpetions (method moved to NSWorkspace) *************/
warning "NotificationConversion: This delegate message has changed to a notification. If you are trying to simulate the sending of the delegate message, you may want to instead post a notification via [[[NSWorkspace sharedWorkspace] notificationCenter] postNotificationName:<notificationName> object:<sender> userInfo:[NSDictionary dictionaryWithObjectsAndKeys:<obj>, <key>, nil]]"
where ("<sel2>", "<notificationName>", "<obj>", "<key>") isOneOf {
warning "NotificationConversion: This delegate message has changed to a notification. If you are trying to simulate the sending of the delegate message, you may want to instead post a notification via [[NSNotificationCenter defaultCenter] postNotificationName:NSWorkspaceWillPowerOffNotification object:<sender>]"
replace "[<rec> <method>:<sender>]" with "[<rec> SKIP_SECOND_WARNING:0 <method>:<sender>]"
warning "NotificationConversion: This delegate message has changed to a notification. If you are trying to simulate the sending of the delegate message, you may want to instead post a notification via [[NSNotificationCenter defaultCenter] postNotificationName:<notificationName> object:<sender>]"
where ("<method>", "<notificationName>") isOneOf {
replacemethod "textDidChange:<notification>" with "textDidBeginEditing:<notification>" {
replace "<notification_type>" with "(NSNotification *)"
replace "<notification_param>" with "notification"
replace "<call>" with "[[NSNotificationCenter defaultCenter] postNotificationName:NSTextDidBeginEditingNotification object:<notification_arg>]"
replace "<implementation>" with "NSText *theText = [notification object];
<implementation>"
}
warning "NotificationConversion: 'textDidBeginEditing:' used to be 'textDidChange:'. This conversion assumes this method is implemented or sent to a delegate of NSText. If this method was implemented by a NSMatrix or NSTextField textDelegate, use the text notifications in NSControl.h."
within ("<implementation>") {
replace "<notification_param>" with "theText"
}
replacemethod "textDidEnd:<notification> endChar:<end>" with "textDidEndEditing:<notification>" {
replace "<notification_type>" with "(NSNotification *)"
replace "<notification_param>" with "notification"
replace "<implementation>" with "NSText *theText = [notification object];
int <end_param> = [[[notification userInfo] objectForKey:@\"NSTextMovement\"] intValue];
<implementation>"
}
warning "NotificationConversion: 'textDidEndEditing:' used to be 'textDidEnd:'. This conversion assumes this method is implemented or sent to a delegate of NSText. If this method was implemented by a NSMatrix or NSTextField textDelegate, use the text notifications in NSControl.h."
within ("<implementation>") {
replace "<notification_param>" with "theText"
}
replacemethod "textDidGetKeys:<notification> isEmpty:<flag>" with "textDidChange:<notification>" {
replace "<notification_type>" with "(NSNotification *)"
replace "<notification_param>" with "notification"
replace "<call>" with "[[NSNotificationCenter defaultCenter] postNotificationName:NSTextDidChangeNotification object:<notification_arg>]"
replace "<implementation>" with "NSText *theText = [notification object];
warning "NotificationConversion: 'textDidChange:' used to be 'textDidGetKeys:'. This conversion assumes this method is implemented or sent to a delegate of NSText. If this method was implemented by a NSMatrix or NSTextField textDelegate, use the text notifications in NSControl.h."
replace "NSText *theText = [notification object];" with same
warning "NotificationConversion: if this notification was not posted by NSText (eg. was forwarded by NSMatrix or NSTextField from the field editor to their textDelegate), then the text object is found by [[notification userInfo] objectForKey:@\"NSFieldEditor\"] rather than [notification object]"
replace "[<rec> <method>:<sender>]" with "[<rec> SKIP_SECOND_WARNING:0 <method>:<sender>]"
warning "This delegate message has changed to a notification. If you are trying to simulate the sending of the delegate message, you may want to instead post a notification via [[NSNotificationCenter defaultCenter] postNotificationName:<notificationName> object:<sender>]"
where ("<method>", "<notificationName>") isOneOf {
/*********** NotificationConversion: additional errors and warnings *************/
replacemethod "<new>" with same
warning "NotificationConversion: <new> (used to be <old>) is an NSApplication notification method (used to be a delegate method); delegates of NSApplication are automatically set to observe this notification; subclasses of NSApplication do not automatically receive this notification"
replacemethod "splitViewDidResizeSubviews:" with same
warning "NotificationConversion: 'splitViewDidResizeSubviews:' is an NSSplitView notification method (used to be a delegate method); delegates of NSSplitView are automatically set to observe this notification; subclasses of NSSplitView do not automatically receive this notification"
replacemethod "<sel>" with same
warning "NotificationConversion: <sel> is an NSWindow notification method (used to be a delegate method); delegates of NSWindow are automatically set to observe this notification; subclasses of NSWindow do not automatically receive this notification"
where "<sel>" isOneOf {
"windowDidExpose:",
"windowDidBecomeKey:",
"windowDidResignKey:",
"windowDidBecomeMain:",
"windowDidResignMain:",
"windowDidMiniaturize:",
"windowDidDeminiaturize:",
"windowDidResize:",
"windowDidUpdate:",
"windowDidChangeScreen:",
"windowWillMove:",
"windowDidMove:",
"windowWillMiniaturize:",
}
replacemethod "<new>" with same
warning "NotificationConversion: <new> (used to be <old>) is an NSText notification method (used to be a delegate method); delegates of NSText are automatically set to observe this notification; subclasses of NSText do not automatically receive this notification"
where ("<old>", "<new>") isOneOf {
("textDidChange:", "textDidBeginEditing"),
("textDidEnd:", "textDidEndEditing"),
("textDidGetKeys:", "textDidChange"),
("text:isEmpty:", "textDidChange")
}
replacemethod "<sel>" with same
error "NotificationConversion: <sel> is obsolete. Register for NSColorList NSColorListDidChangeNotification"
where "<sel>" isOneOf {
"colorListDidChange:colorName:",
}
/* clean up tokens inserted early in the script to defeat matches later in the script */
replace "SKIP_SECOND_WARNING:0 <token nextTok>" with "<nextTok>"