home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / IntermediateFrameworks4 / AppKit.framework / Headers / nextstd.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-15  |  2.0 KB  |  82 lines

  1. /*
  2.     nextstd.h
  3.     Application Kit, Release 2.0
  4.     Copyright (c) 1988, 1989, 1990, NeXT, Inc.  All rights reserved. 
  5. */
  6.  
  7. /* This file has some standard macros useful in any program. */
  8.  
  9. @class NSString;
  10.  
  11. #ifndef NEXTSTD_H
  12. #define NEXTSTD_H
  13.  
  14. #import <math.h>
  15. #import <stdio.h>
  16. #import <libc.h>
  17.  
  18. #ifndef MAX
  19. #define  MAX(A,B)    ((A) > (B) ? (A) : (B))
  20. #endif
  21. #ifndef MIN
  22. #define  MIN(A,B)    ((A) < (B) ? (A) : (B))
  23. #endif
  24. #ifndef ABS
  25. #define  ABS(A)        ((A) < 0 ? (-(A)) : (A))
  26. #endif
  27.  
  28. #define  NX_MALLOC( VAR, TYPE, NUM )                \
  29.    ((VAR) = (TYPE *) malloc((unsigned)(NUM)*sizeof(TYPE))) 
  30.  
  31. #define  NX_REALLOC( VAR, TYPE, NUM )                \
  32.    ((VAR) = (TYPE *) realloc((VAR), (unsigned)(NUM)*sizeof(TYPE)))
  33.  
  34. #define  NX_FREE( PTR )    free((PTR))
  35.  
  36. #define  NX_ZONEMALLOC( Z, VAR, TYPE, NUM )                \
  37.    ((VAR) = (TYPE *) NSZoneMalloc((Z), (unsigned)(NUM)*sizeof(TYPE))) 
  38.  
  39. #define  NX_ZONEREALLOC( Z, VAR, TYPE, NUM )                \
  40.    ((VAR) = (TYPE *) NSZoneRealloc ((Z), (char *)(VAR),         \
  41.        (unsigned)(NUM)*sizeof(TYPE)))
  42.  
  43. #ifndef NBITSCHAR
  44. #define NBITSCHAR    8
  45. #endif NBITSCHAR
  46.  
  47. #ifndef NBITSINT
  48. #define NBITSINT    (sizeof(int)*NBITSCHAR)
  49. #endif NBITSINT
  50.  
  51. #ifndef TRUE
  52. #define TRUE        1
  53. #endif TRUE
  54. #ifndef FALSE
  55. #define FALSE        0
  56. #endif FALSE
  57.  
  58. /*
  59.  * compile with -DNX_BLOCKASSERTS to turn off asserts in your code
  60.  */
  61.  
  62. #ifndef NX_BLOCKASSERTS
  63. extern void NSLog(NSString *format, ...);
  64. #define NX_ASSERT(exp,str)        {if(!(exp)) NSLog(@"Assertion failed: %s\n", str);}
  65. #else NX_BLOCKASSERTS
  66. #define NX_ASSERT(exp,str) {}
  67. #endif NX_BLOCKASSERTS
  68.  
  69. /*
  70.  * Used to insert messages in showps output.  If you use this macro, you can
  71.  * compile with -DNX_BLOCKPSDEBUG to turn it off.  Note that it only writes
  72.  * its messages when showps is on.
  73.  */
  74.  
  75. #ifndef NX_BLOCKPSDEBUG
  76. #define NX_PSDEBUG()        {if ((DPSGetCurrentContext())->chainChild && (DPSGetCurrentContext())->chainChild->programEncoding == dps_ascii) DPSPrintf( DPSGetCurrentContext(),"\n%% *** Debug *** Object:%d Class:%s Method:%s\n", ((int)self), ([[self class] description]), SELNAME(_cmd));}
  77. #else NX_BLOCKPSDEBUG
  78. #define NX_PSDEBUG() {}
  79. #endif NX_BLOCKPSDEBUG
  80.  
  81. #endif
  82.