10.6 compatibility: Fix some new compiler warnings, and work around apparent regressions in NSTask and -stringByStandardizingPath.
5 // Copyright 2008 Jens Alfke. All rights reserved.
11 @implementation ValueArray
14 - (id) initWithCount: (unsigned)count valueSize: (size_t)valueSize
19 _valueSize = valueSize;
24 + (ValueArray*) valueArrayWithCount: (unsigned)count valueSize: (size_t)valueSize
26 return [[(ValueArray*)NSAllocateObject(self,count*valueSize,nil)
27 initWithCount: count valueSize: valueSize]
31 - (unsigned) count {return _count;}
32 - (size_t) valueSize {return _valueSize;}
34 - (const void*) valueAtIndex: (unsigned)i
36 NSParameterAssert(i<_count);
37 return (const char*)object_getIndexedIvars(self) + i*_valueSize;
40 - (void) getValue: (void*)value atIndex: (unsigned)i
42 NSParameterAssert(i<_count);
43 NSParameterAssert(value!=NULL);
44 memcpy(value, object_getIndexedIvars(self) + i*_valueSize, _valueSize);
47 - (void) setValue: (const void*)value atIndex: (unsigned)i
49 NSParameterAssert(i<_count);
50 NSParameterAssert(value!=NULL);
51 memcpy(object_getIndexedIvars(self) + i*_valueSize, value, _valueSize);
56 - (id)initWithCoder:(NSCoder *)decoder
58 NSParameterAssert([decoder allowsKeyedCoding]);
59 NSKeyedUnarchiver *arch = (NSKeyedUnarchiver*)decoder;
60 unsigned count = [arch decodeIntForKey: @"count"];
61 size_t valueSize = [arch decodeIntForKey: @"valueSize"];
64 self = [[[self class] valueArrayWithCount: count valueSize: valueSize] retain];
67 const void *bytes = [arch decodeBytesForKey: @"values" returnedLength: &nBytes];
68 NSAssert(nBytes==count*valueSize,@"Value size mismatch");
69 memcpy( object_getIndexedIvars(self), bytes, nBytes );
75 - (void)encodeWithCoder:(NSCoder *)coder
77 NSParameterAssert([coder allowsKeyedCoding]);
78 NSKeyedArchiver *arch = (NSKeyedArchiver*)coder;
80 [arch encodeInt: _count forKey: @"count"];
81 [arch encodeInt: _valueSize forKey: @"valueSize"];
82 [arch encodeBytes: object_getIndexedIvars(self)
83 length: _count*_valueSize
91 ImplementValueArrayOf(Int,int)
93 ImplementValueArrayOf(Double,double)
97 Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
99 Redistribution and use in source and binary forms, with or without modification, are permitted
100 provided that the following conditions are met:
102 * Redistributions of source code must retain the above copyright notice, this list of conditions
103 and the following disclaimer.
104 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
105 and the following disclaimer in the documentation and/or other materials provided with the
108 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
109 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
110 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
111 BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
112 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
113 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
114 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
115 THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.