home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / ConversionScripts / ArchiverConversion.tops < prev    next >
Encoding:
Text File  |  1995-03-30  |  7.7 KB  |  159 lines

  1. /*********** ArchiverConversion: Constants ***********/
  2.  
  3. replace "TYPEDSTREAM_CALLER_ERROR"  with "NSArchiverCallerError"
  4.  
  5. replace "TYPEDSTREAM_FILE_INCONSISTENCY"  with "NSArchiverArchiveInconsistency"
  6.  
  7. replace "TYPEDSTREAM_CLASS_ERROR"  with "NSArchiverClassError"
  8.  
  9. replace "TYPEDSTREAM_TYPE_DESCRIPTOR_ERROR"  with "NSArchiverDescriptorError"
  10.  
  11. replace "TYPEDSTREAM_WRITE_REFERENCE_ERROR"  with "NSArchiverWriteReferenceError"
  12.  
  13. replace "TYPEDSTREAM_INTERNAL_ERROR"  with "NSArchiverInternalError"
  14.  
  15. /*********** ArchiverConversion: Archiver creation ***********/
  16.  
  17. replace "NXTypedStream" with "NSArchiver"
  18.  
  19. replace "NXOpenTypedStream(<stream>, NX_READONLY)" with "[[NSUnarchiver alloc] initForReadingWithData:<stream>]"
  20.     error "ArchiverConversion: '[[NSUnarchiver alloc] init...]' used to be 'NXOpenTypedStream(...)'; <stream> should be converted to 'NSData *'."
  21.  
  22. replace "NXOpenTypedStream(<stream>, NX_WRITEONLY)" with "[[NSArchiver alloc] initForWritingWithMutableData:<stream>]"
  23.     error "ArchiverConversion: '[[NSUnarchiver alloc] init...]' used to be 'NXOpenTypedStream(...)'; <stream> should be converted to 'NSMutableData *'."
  24.  
  25. replace "NXOpenTypedStream(<stream>, <mode>)" with same
  26.     error "ArchiverConversion: 'NXOpenTypedStream(<stream>, <mode>)' should be '[[NSUnarchiver alloc] initForReadingWithData:<stream>]' for reading or '[[NSArchiver alloc] initForWritingWithMutableData:<stream>]' for writing. <stream> should be converted to 'NSMutableData *'."
  27.  
  28. replace "NXOpenTypedStreamForFile(<filename>, NX_READONLY)" with "[[NSUnarchiver alloc] initForReadingWithData:[NSData dataWithContentsOfFile:<filename>]]"
  29.  
  30. replace "NXOpenTypedStreamForFile(<filename>, NX_WRITEONLY)" with "[[NSArchiver alloc] initForWritingWithMutableData:[NSMutableData data]]"
  31.     error "ArchiverConversion:  [<archiver> initForWritingWithMutableData:...] - used to be NXOpenTypedStreamForFile(<filename>, NX_WRITEONLY)) - NSArchiver contents must be explicitly writen to <filename> when archiving is completed"
  32.      
  33. replace "NXOpenTypedStreamForFile(<filename>, <mode>)" with same
  34.     error "ArchiverConversion: 'NXOpenTypedStreamForFile(<filename>, <mode>)' should be '[[NSUnarchiver alloc] initForReadingWithData:[NSData dataWithContentsOfFile:<filename>]]' for reading or '[[NSArchiver alloc] initForWritingWithMutableData:[NSMutableData data]]' for writing. If writing, NSArchiver contents must be explicitly writen to <filename> when archiving is completed."
  35.      
  36. replace "NXCloseTypedStream(<stream>)" with "[<stream> release]"
  37.     warning "ArchiverConvesion: [<stream> release] was NXCloseTypedStream(<stream>); <stream> has been converted to an NSArchiver instance (was NXTypedStream); if <stream> was opened with NXOpenTypedStreamForFile(<filename>, NX_WRITEONLY) contents of <stream> must be explicitly written to <filename>; a warning will have appeared if this is the case"
  38.  
  39. /*********** ArchiverConversion: Buffer functions ***********/
  40.  
  41. replace "NXWriteRootObjectToBuffer(<b args>)" with "NXWriteRootObjectToBuffer(<b args>)"
  42.     error "ArchiverConversion: uses of typed streams should be converted to use NSArchiver and NSUnarchiver instead"
  43.  
  44. replace "NXReadObjectFromBuffer(<b args>)" with "NXReadObjectFromBuffer(<b args>)"
  45.     error "ArchiverConversion: uses of typed streams should be converted to use NSArchiver and NSUnarchiver instead"
  46.  
  47. replace "NXReadObjectFromBufferWithZone(<b args>)" with "NXReadObjectFromBufferWithZone(<b args>)"
  48.     error "ArchiverConversion: uses of typed streams should be converted to use NSArchiver and NSUnarchiver instead"
  49.  
  50. replace "NXFreeObjectBuffer(<b args>)" with "NXFreeObjectBuffer(<b args>)"
  51.     error "ArchiverConversion: uses of typed streams should be converted to use NSArchiver and NSUnarchiver instead"
  52.  
  53. /*********** ArchiverConversion: awake, finishArchiving, startArchiving ***********/
  54.  
  55. replacemethod "awake" with same
  56.     error "ArchiverConversion: put the contents of your 'awake' method at the end of your 'initWithCoder:' method instead"
  57.  
  58. replacemethod "finishUnarchiving" with "awakeAfterUsingCoder:<coder>" {
  59.     replace "<coder_type>" with "(NSCoder *)"
  60.     replace "<coder_param>" with "aDecoder"
  61.     replace "<coder_arg>" with "nil"
  62.     }
  63.     within ("<implementation>") {
  64.         replace "return nil" with "return self"
  65.     }    
  66.  
  67. replacemethod "startArchiving:" with same
  68.     error "ArchiverConversion: 'startArchiving:' is obsolete; 'replacementObjectForCoder:' is a possible replacement"
  69.         
  70. /*********** ArchiverConversion: writing ***********/
  71.  
  72. replace "NXWriteArray(<coder>, <type>, <count>, <val>)" with "[<coder> encodeArrayOfObjCType:<type> count:<count> at:<val>]" 
  73.  
  74. replace "NXWriteObject(<coder>, <obj>)" with "[<coder> encodeObject:<obj>]" 
  75.  
  76. replace "NXWriteObjectReference(<coder>, <obj>)" with "[<coder> encodeConditionalObject:<obj>]" 
  77.  
  78. replace "NXWritePoint(<coder>, <point>)" with "[<coder> encodePoint:*<point>]" 
  79.  
  80. replace "NXWriteRect(<coder>, <rect>)" with "[<coder> encodeRect:*<rect>]" 
  81.  
  82. replace "NXWriteRootObject(<stream>, <obj>)" with "[<stream> encodeRootObject:<obj>]"
  83.  
  84. replace "NXWriteSize(<coder>, <size>)" with "[<coder> encodeSize:*<size>]" 
  85.  
  86. replace "NXWriteType(<coder>, <type>, <val>)" with "[<coder> encodeValueOfObjCType:<type> at:<val>]" 
  87.  
  88. replace "NXWriteTypes(<coder>, <b args>)"  with "[<coder> encodeValuesOfObjCTypes:<b args>]" 
  89.     
  90. /*********** ArchiverConversion: reading ***********/
  91.  
  92. replace "NXReadArray(<coder>, <type>, <count>, <val>)" with "[<coder> decodeArrayOfObjCType:<type> count:<count> at:<val>]" 
  93.  
  94. replace "NXReadObject(<coder>)" with "[[<coder> decodeObject] retain]" 
  95.  
  96. replace "NXReadPoint(<coder>, <point>)" with "*<point> = [<coder> decodePoint]" 
  97.  
  98. replace "NXReadRect(<coder>, <rect>)" with "*<rect> = [<coder> decodeRect]" 
  99.  
  100. replace "NXReadSize(<coder>, <size>)" with "*<size> = [<coder> decodeSize]" 
  101.  
  102. replace "NXReadType(<coder>, <type>, <val>)" with "[<coder> decodeValueOfObjCType:<type> at:<val>]" 
  103.  
  104. replace "NXReadTypes(<coder>, <b args>)" with "[<coder> decodeValuesOfObjCTypes:<b args>]" 
  105.  
  106. /*********** ArchiverConversion: zones ***********/
  107.  
  108. replace "NXSetTypedStreamZone(<coder>, <zone>)" with"[<coder> setObjectZone:<zone>]"
  109.  
  110. replace "NXGetTypedStreamZone(<coder>)" with "[<coder> objectZone]" 
  111.  
  112. /*********** ArchiverConversion: versions ***********/
  113.  
  114. replace "NXSystemVersion(<coder>)" with "[<coder> systemVersion]" 
  115.  
  116. replace "NXTypedStreamClassVersion(<coder>, <class>)" with "[<coder> versionForClassName:[NSString stringWithCString:<class>]]"
  117.  
  118. /*********** ArchiverConversion: other functions ***********/
  119.  
  120. replace "NXFlushTypedStream(<coder>)" with same
  121.     error "ArchiverConversion:  NXFlushTypedStream is no longer applicable"
  122.     
  123. replace "NXEndOfTypedStream(<coder>)" with "[<coder> isAtEnd]" 
  124.  
  125. /*********** ArchiverConversion: super ***********/
  126.  
  127. /*********** ArchiverConversion: cleanup ***********/
  128.  
  129. replacemethod "write:<stream>" with "encodeWithCoder:<stream>" {
  130.     replace "<rettype>" with "(void)"
  131.     replace "<stream_type>" with "(NSCoder *)"
  132.     replace "<stream_param>" with "aCoder"
  133.     }
  134.     within ("<implementation>") {
  135.         replace "<stream_param>" with "aCoder"
  136.     }
  137.  
  138. replacemethod "read:<stream>" with "initWithCoder:<stream>" {
  139.     replace "<rettype>" with "(id)"
  140.     replace "<stream_type>" with "(NSCoder *)"
  141.     replace "<stream_param>" with "aDecoder"
  142.     }
  143.     within ("<implementation>") {
  144.         replace "<stream_param>" with "aDecoder"
  145.     }
  146.  
  147. replace "[[NSString stringWithCString:<aString>] cString]" with "<aString>"
  148.  
  149. replace "[[<aString> cString] cString]" with "[<aString> cString]"
  150.  
  151. replace "[NSString stringWithCString:[<aString> cString]]" with "<aString>"
  152.  
  153. replace "[NSString stringWithCString:@<string stringconst>]" with "@<string stringconst>"
  154.  
  155. replace "[NSString stringWithCString:<string stringconst>]" with "@<string stringconst>"
  156.  
  157. replace "[@<string stringconst> cString]" with "<string stringconst>"
  158.  
  159.