Added -reopenWith:.
5 // Copyright 2008 Jens Alfke. All rights reserved.
8 #import <Cocoa/Cocoa.h>
11 @interface ValueArray : NSObject <NSCoding>
17 + (ValueArray*) valueArrayWithCount: (unsigned)count valueSize: (size_t)valueSize;
21 - (const void*) valueAtIndex: (unsigned)i;
22 - (void) getValue: (void*)value atIndex: (unsigned)i;
23 - (void) setValue: (const void*)value atIndex: (unsigned)i;
28 #define DeclareValueArrayOf(CAPTYPE,TYPE) \
29 @interface CAPTYPE##Array : ValueArray \
30 + (CAPTYPE##Array*) TYPE##ArrayWithCount: (unsigned)count; \
31 - (TYPE) TYPE##AtIndex: (unsigned)index; \
32 - (void) set##CAPTYPE: (TYPE)value atIndex: (unsigned)index; \
35 #define ImplementValueArrayOf(CAPTYPE,TYPE) \
36 @implementation CAPTYPE##Array \
37 + (CAPTYPE##Array*) TYPE##Array##WithCount: (unsigned)count \
38 {return (id)[super valueArrayWithCount: count valueSize: sizeof(TYPE)];} \
39 - (TYPE) TYPE##AtIndex: (unsigned)i; \
40 {NSParameterAssert(i<_count); return ((const TYPE*)object_getIndexedIvars(self))[i];}\
41 - (void) set##CAPTYPE: (TYPE)value atIndex: (unsigned)i \
42 {NSParameterAssert(i<_count); ((TYPE*)object_getIndexedIvars(self))[i] = value;}\
46 // Declares IntArray class
47 DeclareValueArrayOf(Int,int)
49 DeclareValueArrayOf(Double,double)