|
|
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: // A class to test all possible return types ! 25: ! 26: #include <objc/objc.h> ! 27: #include "rettest.h" ! 28: ! 29: #import "ret1.h" ! 30: ! 31: @implementation MsgTest : Object ! 32: ! 33: #include <stdio.h> ! 34: ! 35: // Exit handler ! 36: + retTest$exitCleanup:arg/*;*/, int estat { ! 37: extern myCleanup(); ! 38: myCleanup(estat, arg); ! 39: } ! 40: // enable trap catching and install an exit handler ! 41: + initialize { ! 42: extern (*_onExit)(); ! 43: ! 44: if (self == [MsgTest class]) { ! 45: // enable trap catching ! 46: //settrap(); ! 47: ! 48: // arrange to get sent a message on exit. ! 49: //(*_onExit)(self,@selector(retTest$exitCleanup:),(id)0); ! 50: } ! 51: return self; ! 52: } ! 53: ! 54: // scalar types ! 55: #define THIS_CLASS [MsgTest class] ! 56: makeMethod(char,99,;) ! 57: makeMethod(uchar_t, 199,;) ! 58: makeMethod(short, 1999,;) ! 59: makeMethod(ushort_t, 19999,;) ! 60: makeMethod(int, 2999,;) ! 61: makeMethod(unsigned, 29999,;) ! 62: makeMethod(long, 399999,;) ! 63: makeMethod(ulong_t, 3999999,;) ! 64: makeMethod(float, 3.1416,;) ! 65: makeMethod(double, 2.7123456789876,;) ! 66: makeMethod(id,self,;) ! 67: makeMethod(STR,junk,char* junk = "hello there") ! 68: ! 69: ! 70: // ! 71: // structure-returning methods ! 72: // ! 73: static struct S_BITS_16 extStructBits16 = { 101, 102 }; ! 74: static struct S_BITS_32 extStructBits32 = { 103, 104, 105, 106 }; ! 75: static struct S_BITS_64 extStructBits64 = ! 76: { 110, 111, 112, 113, 114, 115, 116, 117 }; ! 77: static struct S_BITS_BIG extStructBitsBig ={ ! 78: 0,1,2,3,4,5,6,7, ! 79: 8,9,10,11,12,13,14,15, 16,17,18,19,20,21,22,23, ! 80: 24,25,26,27,28,29,30,31, ! 81: 32,33,34,35,36,37,38,39, ! 82: 40,41,42,43,44,45,46,47, ! 83: 48,49,50,51,52,53,54,55, ! 84: 56,57,58,59,60,61,62,63, ! 85: }; ! 86: ! 87: makeMethod(S_BITS_16_t,junk,S_BITS_16_t junk; junk = extStructBits16) ! 88: makeMethod(S_BITS_32_t,junk,S_BITS_32_t junk; junk = extStructBits32) ! 89: makeMethod(S_BITS_64_t,junk,S_BITS_64_t junk; junk = extStructBits64) ! 90: makeMethod(S_BITS_BIG_t,junk,S_BITS_BIG_t junk; junk = extStructBitsBig) ! 91: ! 92: // ! 93: // union-returning methods ! 94: // ! 95: ! 96: makeMethod(U_BITS_16_t,junk,U_BITS_16_t junk; junk.mem = extStructBits16) ! 97: makeMethod(U_BITS_32_t,junk,U_BITS_32_t junk; junk.mem = extStructBits32) ! 98: ! 99: #if 1 ! 100: makeMethod(U_BITS_64_t,junk,U_BITS_64_t junk; junk.mem = extStructBits64) ! 101: #else ! 102: // deliberately make bad method to see if diagnostics work ! 103: - (U_BITS_64_t) ret_U_BITS_64_t:(U_BITS_64_t*) retRef { ! 104: U_BITS_64_t junk; ! 105: junk.mem = extStructBits64; ! 106: // force a fault ! 107: *(int*)0 = *(int*)0; ! 108: return junk; ! 109: } ! 110: #endif ! 111: ! 112: makeMethod(U_BITS_BIG_t,junk,U_BITS_BIG_t junk; junk.mem = extStructBitsBig) ! 113: ! 114: // Enum types ! 115: ! 116: makeMethod(E_BITS_8_t,junk,E_BITS_8_t junk; junk = e8_two) ! 117: makeMethod(E_BITS_16_t,junk,E_BITS_16_t junk; junk = e16_two) ! 118: #ifdef INT_32 ! 119: makeMethod(E_BITS_32_t,junk,E_BITS_32_t junk; junk = e32_two) ! 120: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.