home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / ConversionScripts / StreamToString.tops < prev    next >
Encoding:
Text File  |  1996-05-03  |  1.6 KB  |  53 lines

  1.  
  2. /*
  3.     Conversion script for converting NXStream API to NSString API.
  4.  */
  5.  
  6.  
  7. replace    "NXStream *" with "NSMutableString *"
  8.  
  9. replace    "NXWrite(<stream>, <bytes>, <length>)" with "[<stream> appendString:[NSString stringWithCString:<bytes> length:<length>]"
  10.  
  11. replace    "NXPrintf(<stream>, <format>)" with "[<stream> appendString:[NSString stringWithCString:<format>]]"
  12.  
  13. replace    "NXPrintf(<stream>, <format>, <b args>)" with "[<stream> appendFormat:[NSString stringWithCString:<format>], <b args>]"
  14.  
  15. replace    "NXClose(<stream>)" with "[<stream> release]"
  16.  
  17. replace    "NXOpenMemory(NULL, 0, <mode>)" with "[[NSMutableString alloc] init]"
  18.  
  19. replace    "NXOpenMemory(<addr>, <length>, NX_READONLY)" with "[[NSString alloc] initWithCString:<addr> length:<length>]"
  20.  
  21. replace    "NXOpenMemory(<addr>, <length>, <mode>)" with "[[NSMutableString alloc] initWithCString:<addr> length:<length>]"
  22.  
  23. replace    "NXMapFile(<path>, NX_READONLY)" with "[[NSString alloc] initWithData:[NSData dataWithContentsOfMappedFile:<path>]]"
  24.  
  25. replace    "NXSaveToFile(<stream>, <path>)" with "([[<stream> dataUsingEncoding:NSNEXTSTEPStringEncoding] writeToFile:<path> atomically:NO]? 0:-1)"
  26.  
  27. replace    "NXCloseMemory(<stream>, NX_FREEBUFFER)" with "[<stream> release]"
  28.  
  29. replace    "<t function>(<b args>)" with same
  30.     error "StreamConversion: <function> should be converted to an NSString method"
  31.     where "<t function>" isOneOf {
  32.     "NXPutc",
  33.     "NXGetc",
  34.     "NXAtEOS",
  35.     "NXSeek",
  36.     "NXTell",
  37.     "NXRead",
  38.     "NXFlush",
  39.     "NXVPrintf",
  40.     "NXScanf",
  41.     "NXVScanf",
  42.     "NXUngetc",
  43.     "NXOpenFile",
  44.     "NXOpenPort",
  45.     "NXOpenMemory",
  46.     "NXMapFile",
  47.     "NXGetStreamOnSection",
  48.     "NXGetMemoryBuffer",
  49.     "NXCloseMemory",
  50.     "NXPrintfProc",
  51.     "NXRegisterPrintfProc",
  52.     }
  53.