1 /* Author: Ziemowit Laski <zlaski@apple.com>. */
5 #include <objc/Object.h>
9 #ifdef __NEXT_RUNTIME__
10 /* The following ain't pretty, but does allow us to have just one copy
12 #include "../objc/execute/next_mapping.h"
14 #include <objc/NXConstStr.h>
17 #define CHECK_IF(expr) if(!(expr)) abort()
19 template <class ARR, class TYPE> class TestT
24 return [array count] * k;
26 TestT(TYPE _k): k(_k) { }
30 const char *getDesc(void) {
37 int abc(TYPE *xyz, Array *array) {
38 return [xyz count] + [array count];
41 @interface Array: Object {
45 + (id)arrayWithObjects:(id)first, ... ;
50 + (id)arrayWithObjects:(id)first, ... {
51 Array *a = [Array new];
53 a->arr = (id *) calloc(8, sizeof(id));
56 va_start (args, first);
58 a->arr[a->count++] = first;
60 for (id el; el = va_arg(args, id); a->count++)
61 a->arr[a->count] = el;
71 CHECK_IF(!strcmp ([@"Object" cString], getDesc<Object>()));
72 CHECK_IF(!strcmp ([@"Array" cString], getDesc<Array>()));
74 Array* a1 = [Array arrayWithObjects:@"One", @"Two", @"Three", nil];
75 Array* a2 = [Array arrayWithObjects:@"Four", @"Five", nil];
77 TestT<Array, int> t(7);
78 CHECK_IF(t.abc(a1) + t.abc(a2) == 35);
79 CHECK_IF(abc(a1, a2) * t.k == 35);