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

  1. /*********** HashToDictConversion: declaration, creation ***********/
  2. replace "\<objc/HashTable.h>" with "<Foundation/NSDictionary.h>"
  3.  
  4. replace "\<objc/NXStringTable.h>" with "<Foundation/NSDictionary.h>"
  5.  
  6. replace "[[HashTable <alloc>] <hashinit>]" with "[[NSMutableDictionary <alloc>] <dictinit>]"
  7.     where ("<hashinit>", "<dictinit>") isOneOf {
  8.     ("init", "init"),
  9.     ("initKeyDesc:", "init"),
  10.     ("initKeyDesc:valueDesc:", "init"),
  11.     ("initKeyDesc:valueDesc:capacity:<cap>", "initWithCapacity:<cap>"),
  12.     }
  13.     
  14. replace "HashTable" with "NSMutableDictionary"
  15.  
  16. /*********** HashToDictConversion: inserting ***********/
  17.  
  18. replace "{ <w w> <obj> = [<hash> insertKey:<key> value:<value>]" with "{<w w><obj> = [<hash> valueForKey:<key>]; [<hash> insertKey:<key> value:<value>]"
  19.  
  20. replace "; <w w> <obj> = [<hash> insertKey:<key> value:<value>]" with ";<w w><obj> = [<hash> valueForKey:<key>];<w w>[<hash> insertKey:<key> value:<value>]"
  21.  
  22. replace ") <w w> <obj> = [<hash> insertKey:<key> value:<value>];" with ") {<w w><obj> = [<hash> valueForKey:<key>];<w w>[<hash> insertKey:<key> value:<value>];<w w>}"
  23.  
  24. replace "} <w w> <obj> = [<hash> insertKey:<key> value:<value>]" with "}<w w><obj> = [<hash> valueForKey:<key>];<w w>[<hash> insertKey:<key> value:<value>]"
  25.  
  26. replace "<obj> = [<hash> insertKey:<key> value:<value>];" with "<obj> = [<hash> valueForKey:<key>];<w w>[<hash> insertKey:<key> value:<value>];<w w>}"
  27.  
  28. replacemethod "insertKey:<key> value:<value>" with "setObject:<value> forKey:<key>" {
  29.     replace "<key_arg>" with "[NSString stringWithCString:<key_arg>]"
  30.     }
  31.     
  32. /*********** HashToDictConversion: accessing ***********/
  33.  
  34. replace "![<hash> isKey:<key>]" with "([<hash> objectForKey:[NSString stringWithCString:<key>]] == nil)"
  35.  
  36. replace "[<hash> isKey:<key>]" with "([<hash> objectForKey:[NSString stringWithCString:<key>]] != nil)"
  37.  
  38. replacemethod "valueForKey:<key>" with "objectForKey:<key>" {
  39.     replace "<key_arg>" with "[NSString stringWithCString:<key_arg>]"
  40.     }
  41.     
  42. /*********** HashToDictConversion: removing ***********/
  43.  
  44. replacemethod "removeKey:" with "removeObjectForKey:"
  45.  
  46. /*********** HashToDictConversion: enumerating ***********/
  47.  
  48. replace "NXInitHashState" with same
  49.     warning "HashAndStringTableConversion: If converting to NSDictionary, you want to use an enumerator here. See [NSDictionary keyEnumerator]."
  50.     
  51. replace "NXNextHashState" with same
  52.     warning "HashAndStringTableConversion: If converting to NSDictionary, you want to use an enumerator here. See [NSDictionary keyEnumerator]."
  53.  
  54. replace "initState" with same
  55.     warning "HashAndStringTableConversion: If converting to NSDictionary, you want to use an enumerator here. See [NSDictionary keyEnumerator]."
  56.  
  57. replace "nextState:" with same
  58.     warning "HashAndStringTableConversion: If converting to NSDictionary, you want to use an enumerator here. See [NSDictionary keyEnumerator]."
  59.  
  60.  
  61. /*********** HashToDictConversion: freeing ***********/
  62.  
  63. replacemethod "freeObjects" with "removeAllObjects"
  64.  
  65. replacemethod "freeKeys:values:" with same
  66.     error "HashAndStringTableConversion: the HashTable method 'freeKeys:values:' must be converted to an NSMutableDictionary method"
  67.     
  68. /*********** StringTableConversion: allocation ***********/
  69.  
  70. replace "[NXStringTable alloc]" with "[NSDictionary alloc]"
  71. replace "[NXStringTable allocWithZone:<zone>]" with "[NSDictionary allocWithZone:<zone>]"
  72. replace "[NXStringTable newFromFile:<file>]" with "[[NSDictionary alloc] initWithDictionary:[[NSString stringWithContentsOfFile:[NSString stringWithCString:<file>]] propertyListFromStringsFileFormat]]"
  73. replace "NXStringTable" with "NSDictionary"
  74.  
  75. /*********** StringTableConversion: reading ***********/
  76.  
  77. replace "[<stringTable> readFromFile:<file>]" with "[<stringTable> addEntriesFromDictionary:[[NSString stringWithContentsOfFile:[NSString stringWithCString:<file>]] propertyListFromStringsFileFormat]]"
  78.  
  79. /*********** StringTableConversion: writing ***********/
  80.  
  81. replace "[<stringTable> writeToFile:<file>]" with "[[<stringTable> descriptionInStringsFileFormat] writeToFile:[NSString stringWithCString:<file>] atomically:NO]"
  82.  
  83. /*********** StringTableConversion: accessing ***********/
  84.  
  85. replace "[<stringTable> valueForStringKey:<file>]" with "[<stringTable> objectForKey:[NSString stringWithCString:<file>]]"
  86.  
  87. /*********** Fix up sub-optimal conversions ***********/
  88.  
  89. replace "[NSString stringWithCString:<string stringconst>]" with "@<string stringconst>"
  90.   
  91.