home *** CD-ROM | disk | FTP | other *** search
/ Openstep 4.2 (Developer) / Openstep Developer 4.2.iso / NextDeveloper / OpenStepConversion / IntermediateFrameworks1 / AppKit.framework / Headers / nextstd.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-15  |  2.0 KB  |  81 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. #ifndef NEXTSTD_H
  10. #define NEXTSTD_H
  11.  
  12. #import <math.h>
  13. #import <stdio.h>
  14. #import <libc.h>
  15.  
  16. #ifndef MAX
  17. #define  MAX(A,B)    ((A) > (B) ? (A) : (B))
  18. #endif
  19. #ifndef MIN
  20. #define  MIN(A,B)    ((A) < (B) ? (A) : (B))
  21. #endif
  22. #ifndef ABS
  23. #define  ABS(A)        ((A) < 0 ? (-(A)) : (A))
  24. #endif
  25.  
  26. #define  NX_MALLOC( VAR, TYPE, NUM )                \
  27.    ((VAR) = (TYPE *) malloc((unsigned)(NUM)*sizeof(TYPE))) 
  28.  
  29. #define  NX_REALLOC( VAR, TYPE, NUM )                \
  30.    ((VAR) = (TYPE *) realloc((VAR), (unsigned)(NUM)*sizeof(TYPE)))
  31.  
  32. #define  NX_FREE( PTR )    free((PTR))
  33.  
  34. #define  NX_ZONEMALLOC( Z, VAR, TYPE, NUM )                \
  35.    ((VAR) = (TYPE *) NSZoneMalloc((Z), (unsigned)(NUM)*sizeof(TYPE))) 
  36.  
  37. #define  NX_ZONEREALLOC( Z, VAR, TYPE, NUM )                \
  38.    ((VAR) = (TYPE *) NSZoneRealloc ((Z), (char *)(VAR),         \
  39.        (unsigned)(NUM)*sizeof(TYPE)))
  40.  
  41. #ifndef NBITSCHAR
  42. #define NBITSCHAR    8
  43. #endif NBITSCHAR
  44.  
  45. #ifndef NBITSINT
  46. #define NBITSINT    (sizeof(int)*NBITSCHAR)
  47. #endif NBITSINT
  48.  
  49. #ifndef TRUE
  50. #define TRUE        1
  51. #endif TRUE
  52. #ifndef FALSE
  53. #define FALSE        0
  54. #endif FALSE
  55.  
  56. /*
  57.  * compile with -DNX_BLOCKASSERTS to turn off asserts in your code
  58.  */
  59. @class NSString;
  60.  
  61. #ifndef NX_BLOCKASSERTS
  62. extern void NSLog(NSString *format, ...);
  63. #define NX_ASSERT(exp,str)        {if(!(exp)) NSLog(@"Assertion failed: %s\n", str);}
  64. #else NX_BLOCKASSERTS
  65. #define NX_ASSERT(exp,str) {}
  66. #endif NX_BLOCKASSERTS
  67.  
  68. /*
  69.  * Used to insert messages in showps output.  If you use this macro, you can
  70.  * compile with -DNX_BLOCKPSDEBUG to turn it off.  Note that it only writes
  71.  * its messages when showps is on.
  72.  */
  73.  
  74. #ifndef NX_BLOCKPSDEBUG
  75. #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));}
  76. #else NX_BLOCKPSDEBUG
  77. #define NX_PSDEBUG() {}
  78. #endif NX_BLOCKPSDEBUG
  79.  
  80. #endif
  81.