home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / ConversionScripts / NotificationConversion.tops < prev    next >
Text File  |  1996-01-22  |  17KB  |  309 lines

  1. /* 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. */
  2.  
  3. /*********** NotificationConversion: calls excpetions (method moved to NSWorkspace) *************/
  4.  
  5. replace "[<delegate> app:<sender> <t sel2>:<arg2>]" with "[<delegate> app:<sender> SKIP_SECOND_WARNING:0 <t sel2>:<arg2>]"
  6.     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]]"
  7.     where ("<sel2>", "<notificationName>", "<obj>", "<key>") isOneOf {
  8.     ("mounted", "NSWorkspaceDidLaunchApplicationNotification", "<arg2>", "@\"NSDevicePath\""),
  9.     ("unmounting", "NSWorkspaceWillUnmountNotification", "<arg2>", "@\"NSDevicePath\""),
  10.     ("unmounted", "NSWorkspaceDidUnmountNotification", "<arg2>", "@\"NSDevicePath\""),
  11.     ("applicationWillLaunch", "NSWorkspaceWillLaunchApplicationNotification", "<arg2>", "@\"NSApplicationName\""),
  12.     ("fileOperationCompleted", "NSWorkspaceDidPerformFileOperationNotification", "[NSNumber numberWithInt:<arg2>]", "@\"NSOperationNumber\""),
  13.     ("applicationDidLaunch", "NSWorkspaceDidLaunchApplicationNotification", "<arg2>", "@\"NSApplicationName\""),
  14.     ("applicationDidTerminate", "NSWorkspaceDidTerminateApplicationNotification", "<arg2>", "@\"NSApplicationName\"")
  15.     }
  16.  
  17. replace "[<delegate> app:<sender> powerOffIn:<ms> andSave:<save>]" with "[<delegate> app:<sender> powerOffIn:<ms> SKIP_SECOND_WARNING:0 andSave:<save>]"
  18.     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>]"
  19.  
  20. /*********** NotificationConversion: convert notification implementations (Application) *************/
  21.  
  22. replace "[<rec> <method>:<sender>]" with "[<rec> SKIP_SECOND_WARNING:0 <method>:<sender>]"
  23.     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>]"
  24.     where ("<method>", "<notificationName>") isOneOf {
  25.     ("appDidHide", "NSApplicationDidHideNotification"),
  26.     ("appDidUnhide", "NSApplicationDidUnhideNotification"),
  27.     ("appDidBecomeActive", "NSApplicationDidBecomeActiveNotification"),
  28.     ("appDidResignActive", "NSApplicationDidResignActiveNotification"),
  29.     ("appWillUpdate", "NSApplicationWillUpdateNotification"),
  30.     ("appDidUpdate", "NSApplicationDidUpdateNotification"),
  31.     ("appWillInit", "NSApplicationWillFinishLaunchingNotification"),
  32.     ("appDidInit", "NSApplicationDidFinishLaunchingNotification")
  33.     }
  34.  
  35. replacemethod "<old>" with "<new>" {
  36.     replace "<notification_type>" with "(NSNotification *)"
  37.     replace "<notification_param>" with "notification"
  38.     replace "<implementation>" with "NSApplication *theApplication = [notification object];
  39.     <implementation>"
  40.     }
  41.     within ("<implementation>") {
  42.     replace "<notification_param>" with "theApplication"
  43.     }
  44.     where ("<old>", "<new>") isOneOf {
  45.     ("appDidHide:<notification>", "applicationDidHide:<notification>"),
  46.     ("appDidUnhide:<notification>", "applicationDidUnhide:<notification>"),
  47.     ("appDidBecomeActive:<notification>", "applicationDidBecomeActive:<notification>"),
  48.     ("appDidResignActive:<notification>", "applicationDidResignActive:<notification>"),
  49.     ("appWillUpdate:<notification>", "applicationWillUpdate:<notification>"),
  50.     ("appDidUpdate:<notification>", "applicationDidUpdate:<notification>" ),
  51.     ("appWillInit:<notification>", "applicationWillFinishLaunching:<notification>"),
  52.     ("appDidInit:<notification>", "applicationDidFinishLaunching:<notification>")
  53.     }
  54.  
  55. /*********** NotificationConversion: convert notification implementations (Text) *************/
  56.  
  57. replacemethod "textDidChange:<notification>" with "textDidBeginEditing:<notification>" {
  58.     replace "<notification_type>" with "(NSNotification *)"
  59.     replace "<notification_param>" with "notification"
  60.     replace "<call>" with "[[NSNotificationCenter defaultCenter] postNotificationName:NSTextDidBeginEditingNotification object:<notification_arg>]"
  61.     replace "<implementation>" with "NSText *theText = [notification object];
  62.     <implementation>"
  63.     }
  64.     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."
  65.     within ("<implementation>") {
  66.     replace "<notification_param>" with "theText"
  67.     }
  68.  
  69. replacemethod "textDidEnd:<notification> endChar:<end>" with "textDidEndEditing:<notification>" {
  70.     replace "<notification_type>" with "(NSNotification *)"
  71.     replace "<notification_param>" with "notification"
  72.     replace "<call>" with "[[NSNotificationCenter defaultCenter] postNotificationName:NSTextDidEndEditingNotification object:<notification_arg> userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:<end_arg>], @\"NSTextMovement\", nil]]"
  73.     replace "<implementation>" with "NSText *theText = [notification object];
  74.     int <end_param> = [[[notification userInfo] objectForKey:@\"NSTextMovement\"] intValue];
  75.     <implementation>"
  76.     }
  77.     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."
  78.     within ("<implementation>") {
  79.     replace "<notification_param>" with "theText"
  80.     }
  81.  
  82. replacemethod "textDidGetKeys:<notification> isEmpty:<flag>" with "textDidChange:<notification>" {
  83.     replace "<notification_type>" with "(NSNotification *)"
  84.     replace "<notification_param>" with "notification"
  85.     replace "<call>" with "[[NSNotificationCenter defaultCenter] postNotificationName:NSTextDidChangeNotification object:<notification_arg>]"
  86.     replace "<implementation>" with "NSText *theText = [notification object];
  87.     BOOL <flag_param> = [[theText text] isEqualToString:@\"\"];
  88.     <implementation>"
  89.     }
  90.     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."
  91.     within ("<implementation>") {
  92.     replace "<notification_param>" with "_theText"
  93.     }
  94.     where ("<old>", "<new>") isOneOf {
  95.     ("textDidGetKeys:<notification> isEmpty:<flag>", "textDidChange:<notification>"),
  96.     ("text:<notification> isEmpty:<flag>", "textDidChange:<notification>")
  97.     }
  98.  
  99. replace "NSText *theText = [notification object];" with same
  100.     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]"
  101.  
  102. /*********** NotificationConversion: convert notification implementations (Window) *************/
  103.  
  104. replace "[<rec> <method>:<sender>]" with "[<rec> SKIP_SECOND_WARNING:0 <method>:<sender>]"
  105.     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>]"
  106.     where ("<method>", "<notificationName>") isOneOf {
  107.     ("windowDidExpose", "NSWindowDidExposeNotification"),
  108.     ("windowDidBecomeKey", "NSWindowDidBecomeKeyNotification"),
  109.     ("windowDidResignKey", "NSWindowDidResignKeyNotification"),
  110.     ("windowDidBecomeMain", "NSWindowDidBecomeMainNotification"),
  111.     ("windowDidResignMain", "NSWindowDidResignMainNotification"),
  112.     ("windowDidMiniaturize", "NSWindowDidMiniaturizeNotification"),
  113.     ("windowDidDeminiaturize", "NSWindowDidDeminiaturizeNotification"),
  114.     ("windowDidResize", "NSWindowDidResizeNotification"),
  115.     ("windowDidUpdate", "NSWindowDidUpdateNotification"),
  116.     ("windowDidChangeScreen", "NSWindowDidChangeScreenNotification"),
  117.     ("windowWillMove", "NSWindowWillMoveNotification"),
  118.     ("windowDidMove", "NSWindowDidMoveNotification"),
  119.     ("windowWillMiniaturize", "NSWindowWillMiniaturizeNotification")
  120.     }
  121.  
  122. replacemethod "<sel>" with same {
  123.     replace "<notification_type>" with "(NSNotification *)"
  124.     replace "<notification_param>" with "notification"
  125.     replace "<implementation>" with "NSWindow *theWindow = [notification object];
  126.     <implementation>"
  127.     }
  128.     within ("<implementation>") {
  129.     replace "<notification_param>" with "theWindow"
  130.     }
  131.     where "<sel>" isOneOf {
  132.     "windowDidExpose:<notification>",
  133.     "windowDidBecomeKey:<notification>",
  134.     "windowDidResignKey:<notification>",
  135.     "windowDidBecomeMain:<notification>",
  136.     "windowDidResignMain:<notification>",
  137.     "windowDidMiniaturize:<notification>",
  138.     "windowDidDeminiaturize:<notification>",
  139.     "windowDidResize:<notification>",
  140.     "windowDidUpdate:<notification>",
  141.     "windowDidChangeScreen:<notification>",
  142.     "windowWillMove:<notification>",
  143.     "windowDidMove:<notification>",
  144.     "windowWillMiniaturize:<notification>"
  145.     }
  146.  
  147. /*********** NotificationConversion: convert notification implementations (SplitView) *************/
  148.  
  149. replacemethod "splitViewDidResizeSubviews:<notification>" with same {
  150.     replace "<notification_type>" with "(NSNotification *)"
  151.     replace "<notification_param>" with "notification"
  152.     replace "<call>" with "[[NSNotificationCenter defaultCenter] postNotificationName:NSSplitViewDidResizeSubviewsNotification object:<notification_arg>]"
  153.     replace "<implementation>" with "NSSplitView *splitView = [notification object];
  154.     <implementation>"
  155.     }
  156.     within ("<implementation>") {
  157.     replace "<notification_param>" with "splitView"
  158.     }
  159.  
  160. /*********** NotificationConversion: obsolete Application delegate methods *************/
  161.  
  162. replacemethod "app:unmounting:" with same
  163.     error "NotificationConversion: 'app:unmounting:' is obsolete ; observe NSWorkspace 'NSWorkspaceWillUnmountNotification' notification"
  164.  
  165. replacemethod "app:mounted:" with same
  166.     error "NotificationConversion: 'app:mounted:' is obsolete ; observe NSWorkspace 'NSWorkspaceDidMountNotification' notification"
  167.  
  168. replacemethod "app:unmounted:" with same
  169.     error "NotificationConversion: 'app:unmounted:' is obsolete ; observe NSWorkspace 'NSWorkspaceDidUnmountNotification' notification"
  170.  
  171. replacemethod "app:applicationDidTerminate:" with same
  172.     error "NotificationConversion: 'app:applicationDidTerminate:' is obsolete ; observe NSWorkspace 'NSWorkspaceDidTerminateApplicationNotification' notification"
  173.  
  174. replacemethod "app:applicationWillLaunch:" with same
  175.     error "NotificationConversion: 'app:applicationWillLaunch:' is obsolete ; observe NSWorkspace 'NSWorkspaceWillLaunchApplicationNotification' notification"
  176.  
  177. replacemethod "app:applicationDidLaunch:" with same
  178.     error "NotificationConversion: 'app:applicationDidLaunch:' is obsolete ; observe NSWorkspace 'NSWorkspaceDidLaunchApplicationNotification' notification"
  179.  
  180. replacemethod "app:fileOperationCompleted:" with same
  181.     error "NotificationConversion: 'app:fileOperationCompleted:' is obsolete ; observe NSWorkspace 'NSWorkspaceDidPerformFileOperationNotification' notification"
  182.  
  183. replacemethod "app:powerOffIn:andSave:" with same
  184.     error "NotificationConversion: 'powerOffIn:andSave:' is obsolete ; observe NSWorkspace 'NSWorkspaceWillPowerOffNotification' notification"
  185.  
  186. /*********** NotificationConversion: simple renaming *************/
  187.  
  188. replacemethod "appWillTerminate:" with "applicationShouldTerminate:"
  189.  
  190. replacemethod "windowWillClose:" with "windowShouldClose:"
  191.  
  192. replacemethod "app:openFile:<file>type:<type>" with "application:openFile:<file>" 
  193.     within ("<implementation>") {
  194.     replace "<type_param>" with "[<file_param> pathExtension]"
  195.     }
  196.  
  197. replacemethod "app:openTempFile:<file>type:<type>" with "application:openTempFile:<file>"
  198.     within ("<implementation>") {
  199.     replace "<type_param>" with "[<file_param> pathExtension]"
  200.     }
  201.  
  202. replacemethod "app:openFileWithoutUI:<file>type:<type>" with "application:openFileWithoutUI:<file>" {
  203.     replace "<rettype>" with "(BOOL)"
  204.     }
  205.     within ("<implementation>") {
  206.     replace "<type_param>" with "[<file_param> pathExtension]"
  207.     }
  208.  
  209. replacemethod "windowWillMiniaturize:toMiniwindow:" with "windowWillMiniaturize:"
  210.  
  211. replacemethod "browser:getNumRowsInColumn:" with "browser:numberOfRowsInColumn:"
  212.  
  213. replacemethod "browser:columnIsValid:" with "browser:isColumnValid:"
  214.  
  215. /*********** NotificationConversion: clean up if ([<delegate> respondsTo...]) *************/
  216.  
  217. replace "if ([<delegate> respondsToSelector:@selector(<b sel>)])<w w1>{<w w2>[<noteCenter> postNotification:<b rest>] ;<w w3>}" with "[<noteCenter> postNotification:<b rest>];"
  218.     where "<sel>" isOneOf {
  219.     "applicationDidHide:",
  220.     "applicationDidUnhide:",
  221.     "applicationDidBecomeActive:",
  222.     "applicationDidResignActive:",
  223.     "applicationWillUpdate:",
  224.     "applicationDidUpdate:",
  225.     "applicationWillFinishLaunching:",
  226.     "applicationDidFinishLaunching:",
  227.     "splitViewDidResizeSubviews:",
  228.     "windowDidExpose:",
  229.     "windowDidBecomeKey:",
  230.     "windowDidResignKey:",
  231.     "windowDidBecomeMain:",
  232.     "windowDidResignMain:",
  233.     "windowDidMiniaturize:",
  234.     "windowDidDeminiaturize:",
  235.     "windowDidResize:",
  236.     "windowDidUpdate:",
  237.     "windowDidChangeScreen:",
  238.     "windowWillMove:",
  239.     "windowDidMove:",
  240.     "windowWillMiniaturize:",
  241.     "textDidChange:",
  242.     "textDidEnd:endChar:"
  243.     "textDidGetKeys:isEmpty:"
  244.     "text:isEmpty:",
  245.     "app:mounted:",
  246.     "app:unmounting:",
  247.     "app:unmounted:",
  248.     "app:fileOperationCompleted:",
  249.     "app:applicationWillLaunch:",
  250.     "app:applicationDidLaunch:",
  251.     "app:applicationDidTerminate:",
  252.     "app:powerOffIn:andSave:"
  253.     }
  254.  
  255. /*********** NotificationConversion: additional errors and warnings *************/
  256.  
  257.     
  258. replacemethod "<new>" with same
  259.     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"
  260.     where ("<old>", "<new>") isOneOf {
  261.     ("appDidHide:", "applicationDidHide:"),
  262.     ("appDidUnhide:" "applicationDidUnhide:"),
  263.     ("appDidBecomeActive:", "applicationDidBecomeActive:"),
  264.     ("appDidResignActive:", "applicationDidResignActive:"),
  265.     ("appWillUpdate:", "applicationWillUpdate:"),
  266.     ("appDidUpdate:", "applicationDidUpdate:"),
  267.     ("appWillInit:", "applicationWillFinishLaunching:"),
  268.     ("appDidInit:", "applicationDidFinishLaunching:")
  269.     }
  270.  
  271. replacemethod "splitViewDidResizeSubviews:" with same
  272.     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"
  273.  
  274. replacemethod "<sel>" with same
  275.     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"
  276.     where "<sel>" isOneOf {
  277.     "windowDidExpose:",
  278.     "windowDidBecomeKey:",
  279.     "windowDidResignKey:",
  280.     "windowDidBecomeMain:",
  281.     "windowDidResignMain:",
  282.     "windowDidMiniaturize:",
  283.     "windowDidDeminiaturize:",
  284.     "windowDidResize:",
  285.     "windowDidUpdate:",
  286.     "windowDidChangeScreen:",
  287.     "windowWillMove:",
  288.     "windowDidMove:",
  289.     "windowWillMiniaturize:",
  290.     }
  291.  
  292. replacemethod "<new>" with same
  293.     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"
  294.     where ("<old>", "<new>") isOneOf {
  295.     ("textDidChange:", "textDidBeginEditing"),
  296.     ("textDidEnd:", "textDidEndEditing"),
  297.     ("textDidGetKeys:", "textDidChange"),
  298.     ("text:isEmpty:", "textDidChange")
  299.     }
  300.  
  301. replacemethod "<sel>" with same
  302.     error "NotificationConversion: <sel> is obsolete.  Register for NSColorList NSColorListDidChangeNotification"
  303.     where "<sel>" isOneOf {
  304.     "colorListDidChange:colorName:",
  305.     }
  306.  
  307. /* clean up tokens inserted early in the script to defeat matches later in the script */
  308. replace "SKIP_SECOND_WARNING:0 <token nextTok>" with "<nextTok>"
  309.