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

  1. /*********** ImageConversion: colors ***********/
  2.  
  3. replace "[<obj> numColors]" with "NSNumberOfColorComponents([<obj> colorSpaceName])"
  4.  
  5. replacemethod "setNumColors:" with same
  6.     error "ImageConversion: 'setNumColors:' is obsolete; possibly use 'setColorSpaceName:' instead"
  7.     
  8. /*********** ImageConversion: moved from NSImage to NSImageRep ***********/
  9.  
  10. replace "[<isKindOf(NSImage) class> <old>:<arg>]" with "[NSImageRep <new>:<arg>]"
  11.     where ("<old>", "<new>") isOneOf {
  12.      ("registerImageRep", "registerImageRepClass"),
  13.      ("unregisterImageRep", "unregisterImageRepClass"),
  14.      ("imageRepForFileType", "imageRepClassForFileType"),
  15.      ("imageRepForPasteboardType", "imageRepClassForPasteboardType"),
  16.      ("imageRepForStream", "imageRepClassForData")
  17.     }
  18.  
  19. replacemethod "<old>" with "<new>"
  20.     error "ImageConversion: <new> (used to be <old>) is now implemented by the NSImageRep class."
  21.     where ("<old>", "<new>") isOneOf {
  22.      ("registerImageRep:", "registerImageRepClass:"),
  23.      ("unregisterImageRep:", "unregisterImageRepClass:"),
  24.      ("imageRepForFileType:", "imageRepClassForFileType:"),
  25.      ("imageRepForPasteboardType:", "imageRepClassForPasteboardType:"),
  26.      ("imageRepForStream:", "imageRepClassForData:")
  27.     }
  28.  
  29. /*********** ImageConversion: writeTIFF ***********/
  30.  
  31. replacemethod "<old>" with "<new>" {
  32.     replace "<rettype>" with "(NSData *)"
  33.     replace "<call>" with "<stream_arg> = <call>"
  34.     }
  35.     where ("<old>", "<new>") isOneOf {
  36.     ("writeTIFF:<stream> usingCompression:<comp>", "TIFFRepresentationUsingCompression:<comp> factor:0.0"),
  37.     ("writeTIFF:<stream> allRepresentations:<flag> usingCompression:<comp> andFactor:<fact>", "TIFFRepresentationUsingCompression:<comp> factor:<fact>"),
  38.     ("writeTIFF:<stream> allRepresentations:", "TIFFRepresentation"),
  39.     ("writeTIFF:<stream>", "TIFFRepresentation")
  40.     }
  41.  
  42. /*********** ImageConversion: new... ***********/
  43.  
  44. replace "[<obj> <method>:<a>]" with "[[<obj> <replacement>] retain]"
  45.     where ("<method>", "<replacement>") isOneOf {
  46.       ("newListFromSection", "imageRepsWithContentsOfFile:[[NSBundle mainBundle] pathForImageResource:<a>]"),
  47.       ("newListFromFile", "imageRepsWithContentsOfFile:<a>"),
  48.       ("newListFromStream", "imageRepsWithData:<a>")
  49.     }
  50. replace "[<obj> <method>:<a> zone:<z>]" with "[[<obj> <replacement>] retain]"
  51.     where ("<method>", "<replacement>") isOneOf {
  52.       ("newListFromSection", "imageRepsWithContentsOfFile:[[NSBundle mainBundle] pathForImageResource:<a>]"),
  53.       ("newListFromFile", "imageRepsWithContentsOfFile:<a>"),
  54.       ("newListFromStream", "imageRepsWithData:<a>")
  55.     }
  56.  
  57. /*********** ImageConversion: init... ***********/
  58.  
  59. replace "[[<isKindOf(NSImage) class> <b alloc>] initFromSection:<section>]" with "[<class> imageNamed:<section>]"
  60.     warning "ImageConversion: [<class> imageNamed:...] used to be [[<class> alloc..] initFromSection...]; the image is named as a side effect of this conversion"
  61.  
  62. replace "[[<isKindOf(NSImage) class> <b alloc>] <old>:<a>]" with "[[<class> <b alloc>] <new>:<a>]"
  63.     where ("<old>", "<new>") isOneOf {
  64.       ("initFromFile", "initByReferencingFile"),
  65.       ("initFromStream", "initWithData"),
  66.     }
  67.  
  68. replace "[[NSImageRep <b alloc>] initFromPasteboard:<pboard>]" with "[NSImageRep imageRepWithPasteboard:<pboard>]"
  69.  
  70. replacemethod "initFromPasteboard:" with "initWithPasteboard:"
  71.     
  72. replacemethod "initFromImage:rect:" with same
  73.     warning "ImageConversion: NSImages 'initFromImage:rect:' is obsolete. Use the copy method instead."
  74.  
  75. replace "[[NSBitmapImageRep <b alloc>] initFromSection:<section>]" with "[[NSBitmapImageRep imageRepWithContentsOfFile:[[NSBundle mainBundle] pathForImageResource:<section>]] retain]"
  76.  
  77. replace "[[NSBitmapImageRep <b alloc>] initFromFile:<file>]" with "[[NSBitmapImageRep imageRepWithContentsOfFile:<file>] retain]"
  78.  
  79. replace "[[NSBitmapImageRep <b alloc>] initFromStream:<stream>]" with "[[NSBitmapImageRep <b alloc>] initWithData:<stream>]"
  80.  
  81. replace "[[NSEPSImageRep <b alloc>] initFromSection:<section>]" with "[[NSEPSImageRep imageRepWithContentsOfFile:[[NSBundle mainBundle] pathForImageResource:<section>]] retain]"
  82.  
  83. replace "[[NSEPSImageRep <b alloc>] initFromFile:<file>]" with "[[NSEPSImageRep imageRepWithContentsOfFile:<file>] retain]"
  84.  
  85. replace "[[NSEPSImageRep <b alloc>] initFromStream:<stream>]" with "[[NSEPSImageRep <b alloc>] initWithData:<stream>]"
  86.  
  87. replace "[<bitmaprep> initData:NULL fromRect:<rect>]" with "[<bitmaprep> initWithFocusedViewRect:<rect>]"
  88.  
  89. replace "[<bitmaprep> initData:<data> fromRect:<rect>]" with "[<bitmaprep> initWithFocusedViewRect:<rect>]"
  90.     warning "ImageConversion: 'initWithFocusedViewRect:' used to be 'initData:fromRect:' with <data> as the first arg; ignoring <data>"
  91.  
  92. replacemethod "initData:<data> fromRect:<rect>" with "initWithFocusedViewRect:<rect>"
  93.     warning "ImageConversion: 'initWithFocusedViewRect:' used to be 'initData:fromRect:'; the data pointer is obsolete"
  94.  
  95. replace "<t target> = [<bitmaprep> initData:<1> pixelsWide:<2> pixelsHigh:<3> bitsPerSample:<4> samplesPerPixel:<5> hasAlpha:<6> isPlanar:<7> colorSpace:<8> bytesPerRow:<9> bitsPerPixel:<10>]" with "{
  96.     unsigned char *conversion_tmp[5] = {NULL}; 
  97.     conversion_tmp[0] = <1>; 
  98.     <target> = [<bitmaprep> initWithBitmapDataPlanes:&conversion_tmp[0] pixelsWide:<2> pixelsHigh:<3> bitsPerSample:<4> samplesPerPixel:<5> hasAlpha:<6> isPlanar:<7> colorSpaceName:<8> bytesPerRow:<9> bitsPerPixel:<10>];
  99.     }"
  100.  
  101. replace "[<bitmaprep> initData:<1> pixelsWide:<2> pixelsHigh:<3> bitsPerSample:<4> samplesPerPixel:<5> hasAlpha:<6> isPlanar:<7> colorSpace:<8> bytesPerRow:<9> bitsPerPixel:<10>]" with "{
  102.     unsigned char *conversion_tmp[5] = {NULL};
  103.     conversion_tmp[0] = <1>;
  104.     [<bitmaprep> initWithBitmapDataPlanes:&conversion_tmp[0] pixelsWide:<2> pixelsHigh:<3> bitsPerSample:<4> samplesPerPixel:<5> hasAlpha:<6> isPlanar:<7> colorSpaceName:<8> bytesPerRow:<9> bitsPerPixel:<10>];
  105.     }"
  106.  
  107. replacemethod "initData:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpace:bytesPerRow:bitsPerPixel:" with  "initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:"
  108.  
  109. replace "@<intOrImp> <isKindOf(NSImage) class><w w1><any code><w w2>@end" with same
  110.     where "<intOrImp>" isOneOf {
  111.     "interface",
  112.     "implementation"
  113.     }
  114.     within ("<code>") {
  115.     replace "<old>" with "<new>" 
  116.         where ("<old>", "<new>") isOneOf {
  117.         ("- initFromFile", "- initByReferencingFile"),
  118.         ("- initFromStream", "- initWithData"),
  119.         }
  120.     }
  121.         
  122. /*********** ImageConversion: cache depth ***********/
  123.  
  124. replacemethod "setCacheDepthBounded:<flag>" with "setCacheDepthMatchesImageDepth:<flag>" {
  125.     replace "<flag_arg>" with "!<flag_arg>"
  126.     }
  127.     within ("<implementation>") {
  128.     replace "<flag_param>" with "!<flag_param>"
  129.     }
  130.     
  131. replacemethod "isCacheDepthBounded" with "cacheDepthMatchesImageDepth" {
  132.     replace "<call>" with "(!<call>)"
  133.     }
  134.     within ("<implementation>") {
  135.     replace "return <retval>;" with "return !(<retval>);"
  136.     }
  137.     
  138. replace "[<token image> useCacheWithDepth:<depth>]" with "[<image> addRepresentation:[[[NSCachedImageRep alloc] initWithSize:[<image> size] depth:<depth> separate:[<image> isCachedSeparately] alpha:YES] autorelease]]"
  139.     warning "ImageConversion: Make sure that <image> can be evaluated multiple times."
  140.  
  141. replace "[<image> useCacheWithDepth:<depth>]" with "[<image> addRepresentation:[[[NSCachedImageRep alloc] initWithSize:[<image> size] depth:<depth> separate:[<image> isCachedSeparately] alpha:YES] autorelease]]"
  142.     warning "ImageConversion: Make sure that <image> can be evaluated multiple times."
  143.  
  144. /*********** ImageConversion: loadFromStream, loadFromFile ***********/
  145.  
  146. replace "[<image> loadFromStream:<stream>]" with "[<image> addRepresentations:[NSImageRep imageRepsWithData:<stream>]]"
  147.  
  148. replace "[<image> loadFromFile:<file>]" with "[<image> addRepresentations:[NSImageRep imageRepsWithContentsOfFile:<file>]]"
  149.  
  150. replacemethod "loadFromStream:" with same
  151.     error "ImageConversion: 'loadFromStream:' is obsolete. Use addRepresentation: to add representations to an image once it is created."
  152.     
  153. replacemethod "loadFromFile:" with same
  154.     error "ImageConversion: 'loadFromFile:' is obsolete. Use addRepresentation: to add representations to an image once it is created."
  155.     
  156. replacemethod "canLoadFromStream:" with "canInitWithData:" {
  157.     replace "<stream_type>" with "(NSData *)"
  158.     }
  159.     error "ImageConversion: 'canInitWithData:' (used to be 'canLoadFromStream:') takes an NSData instance (used to take NXStream)."
  160.     
  161. /*********** ImageConversion: getWindow ***********/
  162.  
  163. replace "[<token cachedrep> getWindow:<win> andRect:<rect>]" with "{
  164.     *(<win>) = [<cachedrep> window]; 
  165.     *(<rect>) = [<cachedrep> rect];
  166.     }"
  167.  
  168. replace "[<cachedrep> getWindow:<win> andRect:<rect>]" with "{
  169.     NSCachedImageRep *tmpCachedRep = <cachedrep>;
  170.      *(<win>) = [tmpCachedRep window];
  171.      *(<rect>) = [tmpCachedRep rect];
  172.      }"
  173.  
  174. /*********** ImageConversion: getEPS ***********/
  175.  
  176. replacemethod "getEPS:length:" with "EPSRepresentation" {
  177.     replace "<call>" with "<eps> = <call>"
  178.     }
  179.     error "ImageConversion: 'EPSRepresentation' returns an NSData instance (used to be 'getEPS:length:')"
  180.     
  181. /*********** ImageConversion: others ***********/
  182.  
  183. replace "[<image> useDrawMethod:<method> inObject:<obj>]" with "[<image> addRepresentation:[[[NSCustomImageRep alloc] initWithDrawSelector:<method> delegate:<obj>] autorelease]]"
  184.  
  185. replace "[<cachedimage> getWindow:<win> andRect:<rect>];" with "{
  186.     *<win> = [<cachedimage> window]; 
  187.     *<rect> = [<cachedimage> rect];
  188.     }"
  189.  
  190. replace "*&" with ""
  191.  
  192. replacemethod "getWindow:andRect:" with same
  193.     error "ImageConversion: 'getWindow:andRect' has been replaced by two methods: 'window' and 'rect'"
  194.     
  195. /*********** ImageConversion: simple renaming ***********/
  196.  
  197. replacemethod "<old>" with "<new>"
  198.     where ("<old>", "<new>") isOneOf {
  199.     ("canInitFromPasteboard:", "canInitWithPasteboard:"),
  200.     ("composite:<op>fromRect:<rect>toPoint:<point>", "compositeToPoint:<point>fromRect:<rect>operation:<op>"),
  201.     ("composite:<op>toPoint:<point>", "compositeToPoint:<point>operation:<op>"),
  202.     ("dissolve:<delta>fromRect:<rect>toPoint:<point>", "dissolveToPoint:<point>fromRect:<rect>fraction:<delta>"),
  203.     ("dissolve:<delta>toPoint:<point>", "dissolveToPoint:<point>fraction:<delta>"),
  204.     ("drawAt:", "drawAtPoint:"),
  205.     ("drawIn:", "drawInRect:"),
  206.     ("findImageNamed:", "imageNamed:"),
  207.     ("getCompression:andFactor:", "getCompression:factor:")
  208.     ("getDataPlanes:", "getBitmapDataPlanes:"),
  209.     ("initDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpace:bytesPerRow:bitsPerPixel:",  "initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:")
  210.     ("initDrawMethod:inObject:", "initWithDrawSelector:delegate:"),
  211.     ("initFromWindow:rect:", "initWithWindow:rect:")
  212.     ("initSize:", "initWithSize:")
  213.     ("isColorMatchPreferred", "prefersColorMatch"),
  214.     ("isEPSUsedOnResolutionMismatch", "usesEPSOnResolutionMismatch"),
  215.     ("isMatchedOnMultipleResolution", "matchesOnMultipleResolution"),
  216.     ("isScalable", "scalesWhenResized"),
  217.     ("isUnique", "isCachedSeparately"),
  218.     ("lockFocusOn:", "lockFocusOnRepresentation:")
  219.     ("numPlanes", "numberOfPlanes"),
  220.     ("representationList", "representations"),
  221.     ("setColorMatchPreferred:", "setPrefersColorMatch:"),
  222.     ("setCompression:andFactor:", "setCompression:factor:")
  223.     ("setEPSUsedOnResolutionMismatch:", "setUsesEPSOnResolutionMismatch:"),
  224.     ("setMatchedOnMultipleResolution:", "setMatchesOnMultipleResolution:"),
  225.     ("setScalable:", "setScalesWhenResized:"),
  226.     ("setUnique:", "setCachedSeparately:"),
  227.     ("useRepresentation:", "addRepresentation:")
  228.     }
  229.  
  230. replacemethod "bestRepresentation" with  "bestRepresentationForDevice:<device>" {
  231.     replace "<device_type>" with "(NSDictionary *)"
  232.     replace "<device_param>" with "deviceDescription"
  233.     replace "<device_arg>" with "nil"
  234.     }
  235.     
  236. /*********** ImageConversion: obsolete methods ***********/
  237.  
  238. replacemethod "<sel>" with same
  239.     error "ImageConversion: <sel> is obsolete."
  240.     where "<sel>" isOneOf {
  241.       "getImage:rect:",
  242.       "lastRepresentation",
  243.       "useFromFile:",
  244.       "useFromSection:",
  245.       "sizeImage:",
  246.       "sizeImage:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpace:"
  247.     }
  248.  
  249. replacemethod "<sel>" with same
  250.     error "ImageConversion: <sel> is obsolete."
  251.     where "<sel>" isOneOf {
  252.       "getImage:rect:",
  253.       "lastRepresentation",
  254.       "useFromFile:",
  255.       "useFromSection:"
  256.     }
  257.  
  258. /*********** ImageConversion: obsolete functions ***********/
  259.  
  260. replace "NXSizeBitmap(<b args>)" with same
  261.     warning "ImageConversion: NXSizeBitmap/NXReadBitmap can be replaced by the much cleaner [[NSBitmapImageRep alloc] initWithFocusedViewRect:rect]"
  262.  
  263. replace "NXReadBitmap(<b args>)" with same
  264.     warning "ImageConversion: NXSizeBitmap/NXReadBitmap can be replaced by the much cleaner [[NSBitmapImageRep alloc] initWithFocusedViewRect:rect]"
  265.  
  266.  
  267.