~ubuntu-branches/ubuntu/breezy/gnustep-base/breezy

« back to all changes in this revision

Viewing changes to Source/NSValue.m

  • Committer: Bazaar Package Importer
  • Author(s): Eric Heintzmann
  • Date: 2005-04-17 00:14:38 UTC
  • mfrom: (1.2.1 upstream) (4 hoary)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20050417001438-enf0y07c9tku85z1
Tags: 1.10.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
   modify it under the terms of the GNU Library General Public
13
13
   License as published by the Free Software Foundation; either
14
14
   version 2 of the License, or (at your option) any later version.
15
 
   
 
15
 
16
16
   This library is distributed in the hope that it will be useful,
17
17
   but WITHOUT ANY WARRANTY; without even the implied warranty of
18
18
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23
23
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
24
24
 
25
25
   <title>NSValue class reference</title>
26
 
   $Date: 2002/02/21 13:17:39 $ $Revision: 1.30 $
 
26
   $Date: 2005/02/22 11:22:44 $ $Revision: 1.33 $
27
27
*/
28
28
 
29
 
#include <config.h>
30
 
#include <base/preface.h>
31
 
#include <Foundation/NSValue.h>
32
 
#include <Foundation/NSCoder.h>
33
 
#include <Foundation/NSDictionary.h>
34
 
#include <Foundation/NSZone.h>
35
 
#include <Foundation/NSException.h>
36
 
#include <Foundation/NSMapTable.h>
37
 
#include <Foundation/NSLock.h>
38
 
#include <Foundation/NSData.h>
39
 
#include <Foundation/NSDebug.h>
 
29
#include "config.h"
 
30
#include "GNUstepBase/preface.h"
 
31
#include "Foundation/NSValue.h"
 
32
#include "Foundation/NSCoder.h"
 
33
#include "Foundation/NSDictionary.h"
 
34
#include "Foundation/NSZone.h"
 
35
#include "Foundation/NSException.h"
 
36
#include "Foundation/NSMapTable.h"
 
37
#include "Foundation/NSLock.h"
 
38
#include "Foundation/NSData.h"
 
39
#include "Foundation/NSDebug.h"
40
40
 
41
41
@interface      GSPlaceholderValue : NSValue
42
42
@end
167
167
    theClass = rectValueClass;
168
168
  else if (strcmp(@encode(NSSize), type) == 0)
169
169
    theClass = sizeValueClass;
170
 
  
 
170
 
171
171
  return theClass;
172
172
}
173
173
 
174
 
// Allocating and Initializing 
 
174
// Allocating and Initializing
175
175
 
176
176
+ (NSValue*) value: (const void *)value
177
177
      withObjCType: (const char *)type
212
212
  theObj = [theObj initWithBytes: &point objCType: @encode(NSPoint)];
213
213
  return AUTORELEASE(theObj);
214
214
}
215
 
 
 
215
 
216
216
+ (NSValue*) valueWithPointer: (const void *)pointer
217
217
{
218
218
  NSValue       *theObj;
230
230
  theObj = [theObj initWithBytes: &range objCType: @encode(NSRange)];
231
231
  return AUTORELEASE(theObj);
232
232
}
233
 
 
 
233
 
234
234
+ (NSValue*) valueWithRect: (NSRect)rect
235
235
{
236
236
  NSValue       *theObj;
239
239
  theObj = [theObj initWithBytes: &rect objCType: @encode(NSRect)];
240
240
  return AUTORELEASE(theObj);
241
241
}
242
 
 
 
242
 
243
243
+ (NSValue*) valueWithSize: (NSSize)size
244
244
{
245
245
  NSValue       *theObj;
294
294
  return nil;
295
295
}
296
296
 
297
 
// Accessing Data 
 
297
// Accessing Data
298
298
/* All the rest of these methods must be implemented by a subclass */
299
299
- (void) getValue: (void *)value
300
300
{
321
321
  [self subclassResponsibility: _cmd];
322
322
  return 0;
323
323
}
324
 
 
 
324
 
325
325
- (id) nonretainedObjectValue
326
326
{
327
327
  [self subclassResponsibility: _cmd];
328
328
  return 0;
329
329
}
330
 
 
 
330
 
331
331
- (void *) pointerValue
332
332
{
333
333
  [self subclassResponsibility: _cmd];
334
334
  return 0;
335
 
 
335
}
336
336
 
337
337
- (NSRange) rangeValue
338
338
{
339
339
  [self subclassResponsibility: _cmd];
340
340
  return NSMakeRange(0,0);
341
341
}
342
 
 
 
342
 
343
343
- (NSRect) rectValue
344
344
{
345
345
  [self subclassResponsibility: _cmd];
346
346
  return NSMakeRect(0,0,0,0);
347
347
}
348
 
 
 
348
 
349
349
- (NSSize) sizeValue
350
350
{
351
351
  [self subclassResponsibility: _cmd];
352
352
  return NSMakeSize(0,0);
353
353
}
354
 
 
 
354
 
355
355
- (NSPoint) pointValue
356
356
{
357
357
  [self subclassResponsibility: _cmd];
385
385
  [coder encodeArrayOfObjCType: @encode(unsigned char) count: size at: data];
386
386
  RELEASE(d);
387
387
}
388
 
 
 
388
 
389
389
@class  NSDataStatic;           // Neede for decoding.
390
390
 
391
391
- (id) initWithCoder: (NSCoder *)coder
512
512
        }
513
513
      /*
514
514
       * For performance, decode small values directly onto the stack,
515
 
       * For larger values we allocate and deallocate heap space.  
 
515
       * For larger values we allocate and deallocate heap space.
516
516
       */
517
517
      size = objc_sizeof_type(objctype);
518
518
      if (size <= 64)