Annotation of objc/Test/msgTest/rettest.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * "Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.0 (the 'License').  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License."
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: /* rettest.h:
                     25:  * Definitions used in classes which test correct operation
                     26:  * for methods of all possible return types
                     27:  */
                     28: 
                     29: /* structure types */
                     30: 
                     31: /* structure which is 16 bits wide */
                     32: struct S_BITS_16 { char buf[2]; };
                     33: 
                     34: /* structure which is 32 bits wide */
                     35: struct S_BITS_32 { char buf[4]; };
                     36: 
                     37: /* structure which is 64 bits wide */
                     38: struct S_BITS_64 { char buf[8]; };
                     39: 
                     40: /* structure wider than 64 bits */
                     41: struct S_BITS_BIG { char buf[64]; };
                     42: 
                     43: /* union which is 16 bits wide */
                     44: union U_BITS_16 { struct S_BITS_16 mem; short int s; };
                     45: 
                     46: /* union which is 32 bits wide */
                     47: union U_BITS_32 { struct S_BITS_32 mem; long int i; };
                     48: 
                     49: /* union which is 64 bits wide */
                     50: union U_BITS_64 { struct S_BITS_64 mem; double d; };
                     51: 
                     52: /* union wider than 64 bits */
                     53: union U_BITS_BIG { struct S_BITS_BIG mem; char buf[64]; };
                     54: 
                     55: /* enum which only needs 8 bits to represent values */
                     56: enum E_BITS_8 { e8_one=0, e8_two=127 };
                     57: 
                     58: /* enum which only needs 16 bits to represent values */
                     59: enum E_BITS_16 { e16_one=0, e16_two=32767 };
                     60: 
                     61: #ifdef INT_32
                     62: /* enum which needs 32 bits to represent values
                     63:  * only use this if 'INT_32' is defined
                     64:  * really need 'sizeof' operator in preprocessor!!!!
                     65:  */
                     66: enum E_BITS_32 { e32_one=0, e32_two=100000L };
                     67: typedef enum E_BITS_32 E_BITS_32_t;
                     68: #endif
                     69: 
                     70: /* macros to generate methods testing various return types
                     71:  * These macros require V7 preprocessor abilities: formal
                     72:  * expansion inside string literals, token concatenation
                     73:  * by elimination of comments.
                     74:  */
                     75: 
                     76: /* Define a method to return value <VAL> as type <TYP>,
                     77:  * with optional local declarations <DECLS>.  This expects
                     78:  * the macro <THIS_CLASS> has already been defined as the
                     79:  * factory id for the current class.
                     80:  */
                     81: #define makeMethod(TYP,VAL,DECLS) \
                     82: - (TYP) ret_ ## TYP:(TYP*)retRef { \
                     83:        DECLS ; \
                     84:        doArgCheck((Class)THIS_CLASS,@selector(ret_ ## TYP:),self,_cmd);\
                     85:        *retRef = VAL; return VAL; }
                     86: 
                     87: /* Define a method to return a value of type <TYP>
                     88:  * gotten by passing the message on to "super"
                     89:  */
                     90: #define makeSuperMethod(TYP) \
                     91: - (TYP) ret_ ## TYP:(TYP*)retRef { \
                     92:        doArgCheck((Class)THIS_CLASS,@selector(ret_ ## TYP:),self,_cmd);\
                     93:        return [super ret_ ## TYP:retRef]; }
                     94: 
                     95: /* Macro to print a diagnostic complaining about
                     96:  * a return value other than expected.
                     97:  */
                     98: #define RETERR(FMT,V1,V2) \
                     99:        retError(FMT,__FILE__,__LINE__,V1,V2)
                    100: #define RETERR4(FMT,V1,V2,V3,V4) \
                    101:        retError(FMT,__FILE__,__LINE__,V1,V2,V3,V4)
                    102: 
                    103: /* Macro to declare instances of various types
                    104:  * for return value testing.
                    105:  */
                    106: #if 0
                    107: #define RETDECL(TYP)   TYP TYP/**/_value, TYP/**/_refValue
                    108: #endif
                    109: 
                    110: #define RETDECL(TYP)   TYP TYP ## _value, TYP ## _refValue
                    111: 
                    112: /* Macro to call a method and test the return
                    113:  */
                    114: #if 0
                    115: #define RETTEST(CLS,TYP) \
                    116:        ((TYP/**/_value = [CLS ret_/**/TYP:&TYP/**/_refValue]), \
                    117:                (TYP/**/_value != TYP/**/_refValue))
                    118: 
                    119: #define SRETTEST(CLS,TYP) \
                    120:        ((TYP/**/_value = [CLS ret_/**/TYP:&TYP/**/_refValue]), \
                    121:                retCompare(&TYP/**/_value, &TYP/**/_refValue, sizeof(TYP)))
                    122: #endif
                    123: #define RETTEST(CLS,TYP) \
                    124:        ((TYP ## _value = [CLS ret_ ## TYP:&TYP ## _refValue]), \
                    125:                (TYP ## _value != TYP ## _refValue))
                    126: 
                    127: #define SRETTEST(CLS,TYP) \
                    128:        ((TYP ## _value = [CLS ret_ ## TYP:&TYP ## _refValue]), \
                    129:                retCompare(&TYP ## _value, &TYP ## _refValue, sizeof(TYP)))
                    130: 
                    131: /* Macro to set what we're about to test for fault recovery */
                    132: extern char* currentTest, *currentFile;
                    133: extern int currentLine;
                    134: #define NEXTTEST(STR) \
                    135:        (currentTest = STR, currentFile = __FILE__, currentLine = __LINE__)
                    136: 
                    137: 
                    138: /* typedefs for multi-word C type names */
                    139: typedef unsigned char uchar_t;
                    140: typedef unsigned short ushort_t;
                    141: typedef unsigned long ulong_t;
                    142: 
                    143: typedef struct S_BITS_16 S_BITS_16_t;
                    144: typedef struct S_BITS_32 S_BITS_32_t;
                    145: typedef struct S_BITS_64 S_BITS_64_t;
                    146: typedef struct S_BITS_BIG S_BITS_BIG_t;
                    147: 
                    148: typedef union U_BITS_16 U_BITS_16_t;
                    149: typedef union U_BITS_32 U_BITS_32_t;
                    150: typedef union U_BITS_64 U_BITS_64_t;
                    151: typedef union U_BITS_BIG U_BITS_BIG_t;
                    152: 
                    153: typedef enum E_BITS_8 E_BITS_8_t;
                    154: typedef enum E_BITS_16 E_BITS_16_t;

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.