home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / ConversionScripts / FoundationConversion.tops < prev    next >
Text File  |  1996-08-30  |  10KB  |  240 lines

  1. /* dependencies: after NSNameConversion */
  2.  
  3. /*********** NSArrayConversion: method return vals ***********/
  4.  
  5. /* just mark them here, next section converts them */
  6.  
  7. replace "<t list> = [<rec> <method>]" with "(CONVERSION_WASLIST)(<t list>) = [<rec> <method>]"
  8.     where "<method>" isOneOf {
  9.     "newListFromSection:<section>",
  10.     "newListFromFile:<file>",
  11.     "newListFromStream:<stream>",
  12.     "newListFromSection:<section> zone:<zone>",
  13.     "newListFromFile:<file> zone:<zone>",
  14.     "newListFromStream:<stream> zone:<zone>",
  15.     "subviews",
  16.     "cellList",
  17.     "windowList",
  18.     "representationList",
  19.     "availableColorLists"
  20.     }
  21.  
  22. replacemethod "<sel>" with same {
  23.     replace "<rettype>" with "(NSArray *)"
  24.     }
  25.     where "<sel>" isOneOf {
  26.     "newListFromSection:",
  27.     "newListFromFile:",
  28.     "newListFromStream:",
  29.     "newListFromSection:zone:",
  30.     "newListFromFile:zone:",
  31.     "newListFromStream:zone:",
  32.     "subviews",
  33.     "cellList",
  34.     "windowList",
  35.     "representationList",
  36.     "availableColorLists"
  37.     }
  38.     
  39. replacemethod "getSelectedCells:<list>" with same {
  40.     replace "<list_arg>" with "(CONVERSION_WASLIST)(<list_arg>)"
  41.     replace "<list_type>" with "(NSArray *)"
  42.     }
  43.     within ("<implementation>") {
  44.     replace "<list_param>" with "(CONVERSION_WASLIST)(<list_param>)"
  45.     }
  46.     
  47. /* how expensize is this??? */
  48. replace "{<w w1><b imp><w w2>}" with same
  49.     within ("<imp>") {
  50.     replace "<any imp1><w w3>(CONVERSION_WASLIST)(<list>)<w w4><any imp2>" with same
  51.         within ("<imp1>") {
  52.         replace "<list>" with "(CONVERSION_WASLIST)(<list>)"
  53.         }
  54.         within ("<imp2>") {
  55.         replace "<list>" with "(CONVERSION_WASLIST)(<list>)"
  56.         }
  57.     }
  58.     
  59. /*********** NSArrayConversion: List instance variables ***********/
  60.  
  61. replace "@implementation<w w1><isKindOf(NSView) class><w w2><any implementation><w w3>@end" with same
  62.     within ("<implementation>") {
  63.     replace "subviews" with "(CONVERSION_WASLIST)(subviews)"
  64.     }
  65.  
  66. replace "@implementation<w w1><isKindOf(NSApplication) class><w w2><any implementation><w wv3>@end" with same
  67.     within ("<implementation>") {
  68.     replace "windowList" with "(CONVERSION_WASLIST)(windowList)"
  69.     }
  70.  
  71. replace "@implementation<w w1><isKindOf(NSMatrix) class><w w2><any implementation><w w3>@end" with same
  72.     within ("<implementation>") {
  73.     replace "cellList" with "(CONVERSION_WASLIST)(cellList)"
  74.     }
  75.  
  76. replace "<token var><w w2>=<w w3>(CONVERSION_WASLIST)" with "(CONVERSION_WASLIST)(<token var>)<w w2>=<w w3>(CONVERSION_WASLIST)"
  77.  
  78. replace "-<w w><b method><w w1>{<scope implementation>}" with same
  79.     within ("<implementation>") {
  80.     replace "<any imp1><w w2>(CONVERSION_WASLIST)(<var>)<w w3><any imp2>" with same
  81.         within ("<imp1>") {
  82.         replace "<var>" with "(CONVERSION_WASLIST)(<var>)"
  83.         }
  84.         within ("<imp2>") {
  85.         replace "<var>" with "(CONVERSION_WASLIST)(<var>)"
  86.         }
  87.     }
  88.  
  89. replace "(CONVERSION_WASLIST)((CONVERSION_WASLIST)(<b list>))" with "(CONVERSION_WASLIST)(<b list>)"
  90.  
  91. replace "[(CONVERSION_WASLIST)(<b variable>) <b listmethod>]" with "[(CONVERSION_WASLIST)(<b variable>) <b arraymethod>]"
  92.     where ("<listmethod>", "<arraymethod>") isOneOf {
  93.     ("objectAt:<exp index>", "objectAtIndex:<exp index>"),
  94.     ("free", "release"),
  95.     ("insertObject:<exp obj> at:<exp index>", "insertObject:<exp obj> atIndex:<exp index>"),
  96.     ("removeObjectAt:<exp index>", "removeObjectAtIndex:<exp index>"),
  97.     ("replaceObjectAt:<exp index> with:<exp obj>", "replaceObjectAtIndex:<exp index> withObject:<exp obj>"),
  98.     ("indexOf:<exp obj>", "indexOfObject:<exp obj>"),
  99.     ("empty", "removeAllObjects"),
  100.     ("makeObjectsPerform:<b sel> with:<exp obj>", "makeObjectsPerform:<b sel> withObject:<exp obj>")
  101.     }
  102.  
  103. replace "[(CONVERSION_WASLIST)(<b variable>) <b method>]" with same
  104.     error "FoundationConversion: The receiver, an NSArray (used to be a List), is immutable, you cannot alter the objects within it"
  105.     where "<method>" isOneOf {
  106.     "addObjectIfAbsent",
  107.     "appendList",
  108.     "replaceObject:<oldobj> with:<newobj>",
  109.     "freeObjects",
  110.     "removeObjectAtIndex:<exp index>",
  111.     "replaceObjectAtIndex:<exp index> withObject:<exp obj>"
  112.     }
  113.     
  114. replace "NX_ADDRESS((CONVERSION_WASLIST)(<b variable>)" with same
  115.     error "FoundationConversion: NX_ADDRESS is obsolete. You must use NSArray methods to access objects in an NSArray."
  116.     
  117. replace "while ([(CONVERSION_WASLIST)(<b variable>) <b method>]" with same
  118.     error "FoundationConversion:  NSArray raises (instead of returning nil) on an invalid index or nil object"
  119.     where "<method>" isOneOf {
  120.     "objectAtIndex:<exp index>",
  121.     "insertObject:<exp obj> atIndex:<exp index>",
  122.     "removeObjectAtIndex:<exp index>",
  123.     "replaceObjectAtIndex:<exp index> withObject:<exp obj>",
  124.     "removeLastObject:<exp obj>",
  125.     "removeAllObjects",
  126.     }
  127.     
  128. replace "id (CONVERSION_WASLIST)" with "NSArray *(CONVERSION_WASLIST)"
  129.  
  130. replace "List *(CONVERSION_WASLIST)" with "NSArray *(CONVERSION_WASLIST)"
  131.  
  132. replace "(CONVERSION_WASLIST)(<b list>)" with "<b list>"
  133.  
  134. replace "(CONVERSION_WASLIST)" with ""
  135.  
  136. replace "NX_NOT_IN_LIST" with "NSNotFound"
  137.     
  138. /*********** NSDateConversion: NSDate change in NSDataLink.h  ***********/
  139.  
  140. replace "[<exp obj> lastUpdateTime]" with "[<exp obj> lastUpdateTime]"
  141.     error "FoundationConversion:  lastUpdateTime now returns an NSDate instead of a time_t" 
  142.  
  143.  
  144. /*********** NSEnumeratorConversion: NSDataLinkManager now uses NSEnumerator ***********/
  145.  
  146. replace "NSLinkEnumerationState <token var>;" with "NSEnumerator *<token var>;" 
  147.  
  148. replace "[<exp obj> nextLinkUsing:&<exp state>]" with "[<exp state> nextObject]" 
  149.  
  150. replace "[<exp obj> prepareEnumerationState:&<exp state> forLinksOfType:NSLinkInDestination]" with "<exp state> = [<exp obj> destinationLinkEnumerator]" 
  151.  
  152. replace "[<exp obj> prepareEnumerationState:&<exp state> forLinksOfType:NSLinkInSource]" with "<exp state> = [<exp obj> sourceLinkEnumerator]" 
  153.  
  154. replace "[<exp obj> prepareEnumerationState:<exp state> forLinksOfType:NSLinkInDestination]" with "<exp state> = [<exp obj> destinationLinkEnumerator]" 
  155.  
  156. replace "[<exp obj> prepareEnumerationState:<exp state> forLinksOfType:NSLinkInSource]" with "<exp state> = [<exp obj> sourceLinkEnumerator]" 
  157.  
  158. replace "[<exp obj> nextLinkUsing:<exp state>]" with "[<exp state> nextObject]" 
  159.  
  160.  
  161. /*********** ExceptionConversion: NXLocalHandler *************/
  162.  
  163. replace "NXLocalHandler" with same
  164.     error "FoundationConversion:  NXLocalHandler has been replaced by localException, an instance of NSException"
  165.     
  166. replace "NXHandler" with same
  167.     error "FoundationConversion:  The NXHandler structure has been replaced by NSException objects."
  168.     
  169. replace "NXSetUncaughtExceptionHandler" with "NSSetUncaughtExceptionHandler"
  170.     warning "FoundationConversion:  This used to call NXSetUncaughtExceptionHandler.  Please make sure that the function you are passing takes an (NSException *) instead of the old arguments."
  171.     
  172. replace "NXGetUncaughtExceptionHandler" with "NSGetUncaughtExceptionHandler"
  173.     warning "FoundationConversion:  This used to call NXGetUncaughtExceptionHandler.  The uncaught exception handler now takes a single (NSException *) argument.  Make sure your code is aware of it if necessary."
  174.  
  175. replace "NXUncaughtExceptionHandler" with "NSUncaughtExceptionHandler"
  176.     error "FoundationConversion:  The NXUncaughtExceptionHandler function typedef has been replaced by NSUncaughtExceptionHandler.  Be aware that the arguments passed to these handlers have changed.  NSUncaughtExceptionHandler functions now take a single (NSException *) argument."
  177.  
  178. /*********** ExceptionConversion: Error catching *************/
  179.  
  180. replace "NX_DURING" with "NS_DURING"
  181.  
  182. replace "NX_HANDLER" with "NS_HANDLER"
  183.  
  184. replace "NX_ENDHANDLER" with "NS_ENDHANDLER"
  185.  
  186. replace "NX_VALRETURN(<val>)" with "NS_VALUERETURN(<val>, typeof(<val>))"
  187.  
  188. replace "NX_VOIDRETURN" with "NS_VOIDRETURN"
  189.  
  190. replace "NX_RERAISE()" with "[localException raise]"
  191.  
  192. replace "\<objc/error.h>" with "<Foundation/NSException.h>"
  193.  
  194. /*********** ExceptionConversion: Error raising *************/
  195.  
  196. replace "NX_RAISE(<b args>)" with same
  197.     error "FoundationConversion:  NX_RAISE is obsolete.  Use the NSException class instead."
  198.  
  199. /*********** StringConversion: WindowServerMemory *************/
  200.  
  201. replace    "NSGetWindowServerMemory(<b args>)" with "NSGetWindowServerMemory(<b args>)"
  202.     error "FoundationConversion:  The last argument has been converted to a pointer to a pointer to an NSString."
  203.  
  204.  
  205. /*********** NXBundle Conversion *************/
  206.  
  207. /* many are too generic for replacemethod conversion */
  208.  
  209. replacemethod "initForDirectory:" with "initWithPath:"
  210.  
  211. /* directory has already undergone string conversion (for SavePanel) */
  212. replace "[[NXBundle bundleForClass:<class>] directory]" with "[[NSBundle bundleForClass:<class>] bundlePath]"
  213.     warning "FoundationConversion: The NSBundle bundlePath method returns the top-level directory of the bundle.  With the new bundle scheme, resources are installed in a subdirectory of the bundlePath (called Resources) instead of directly in the bundlePath.  If you are using the bundlePath to build paths to resources within your bundle, you should try to use pathForResource:ofType: instead."
  214.  
  215. replace "[[NXBundle mainBundle] directory]" with "[[NSBundle mainBundle] bundlePath]"
  216.     warning "FoundationConversion: The NSBundle bundlePath method returns the top-level directory of the bundle.  With the new bundle scheme, resources are installed in a subdirectory of the bundlePath (called Resources) instead of directly in the bundlePath.  If you are using the bundlePath to build paths to resources within your bundle, you should try to use pathForResource:ofType: instead."
  217.  
  218. replace "[[NXBundle mainBundle] setVersion:<version>]" with "[[NSBundle mainBundle] setBundleVersion:<version>]"
  219.  
  220. replace "[[NXBundle bundleForClass:<class>] setVersion:<version>]" with "[[NSBundle bundleForClass:<class>] setBundleVersion:<version>]"
  221.  
  222. replace "[[NXBundle mainBundle] version]" with "[[NSBundle mainBundle] bundleVersion]"
  223.  
  224. replace "[[NXBundle bundleForClass:<class>] version]" with "[[NSBundle bundleForClass:<class>] bundleVersion]"
  225.  
  226. /* getPath:forResource:ofType: handled in string conversion */
  227.  
  228. replace "NXBundle" with "NSBundle"
  229.  
  230. replace "\<objc/NSBundle.h>" with "<Foundation/NSBundle.h>"
  231.  
  232. /*********** NXargc, NXArgv conversion *************/
  233.  
  234. replace "NXArgc" with "[[[NSProcessInfo processInfo] arguments] count]"
  235.  
  236. replace "NXArgv[<expr>]" with "[[[NSProcessInfo processInfo] arguments] objectAtIndex:<expr>]"
  237.  
  238. /*********** FoundationConversion cleanup *************/
  239.  
  240.