mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Cleanup from rewrite of NSData.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2460 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0060d4a2a4
commit
5a29032c27
4 changed files with 8 additions and 169 deletions
|
@ -1,3 +1,9 @@
|
|||
Tue Sep 30 08:57:44 1997 Adam Fedor <fedor@doc.com>
|
||||
|
||||
* src/NSData.m: Remove obsolete includes.
|
||||
* src/NSMutableData.m: Remove file.
|
||||
* src/NSSerializer.m: Remove references to obsolete data classes.
|
||||
|
||||
Sun Sep 28 21:15:00 1997 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* checks/nsdata.m: Added a whole lot of trivial checks.
|
||||
|
|
|
@ -63,8 +63,6 @@
|
|||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSGData.h>
|
||||
#include <Foundation/NSHData.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <string.h> /* for memset() */
|
||||
#include <unistd.h> /* SEEK_* on SunOS 4 */
|
||||
|
|
|
@ -1,157 +0,0 @@
|
|||
/* Implementation of NSMutableData for GNUStep
|
||||
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: April 1995
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <foundation/NSData.h>
|
||||
|
||||
/* xxx Pretty messy. Needs work. */
|
||||
|
||||
@implementation NSMutableData
|
||||
|
||||
+ (id) dataWithCapacity: (unsigned int)numBytes
|
||||
{
|
||||
return [[[[NSGMutableData class] alloc] initWithCapacity:numBytes]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
+ (id) dataWithLength: (unsigned int)length
|
||||
{
|
||||
return [[[[NSGMutableData class] alloc] initWithLength:length]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
- (id) initWithCapacity: (unsigned int)capacity
|
||||
{
|
||||
return [self initWithBytesNoCopy: objc_malloc (capacity)
|
||||
length:capacity];
|
||||
}
|
||||
|
||||
/* This is the designated initializer */
|
||||
- (id) initWithBytesNoCopy: (void*)bytes
|
||||
length: (unsigned int)length
|
||||
{
|
||||
/* xxx Eventually we'll have to be aware of malloc'ed memory
|
||||
vs vm_allocate'd memory, etc. */
|
||||
[self subclassResponsibility:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) initWithLength: (unsigned int)length
|
||||
{
|
||||
[self initWithCapacity:length];
|
||||
memset([self bytes], 0, length);
|
||||
return self;
|
||||
}
|
||||
|
||||
/* This method not in OpenStep */
|
||||
- (unsigned) capacity
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Adjusting Capacity
|
||||
|
||||
- (void) increaseLengthBy: (unsigned int)extraLength
|
||||
{
|
||||
[self setLength:[self length]+extraLength];
|
||||
}
|
||||
|
||||
- (void) setLength: (unsigned int)length
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
}
|
||||
|
||||
- (void*) mutableBytes
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Appending Data
|
||||
|
||||
- (void) appendBytes: (const void*)bytes
|
||||
length: (unsigned int)length
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
}
|
||||
|
||||
- (void) appendData: (NSData*)other
|
||||
{
|
||||
[self appendBytes:[other bytes]
|
||||
length:[other length]];
|
||||
}
|
||||
|
||||
|
||||
// Modifying Data
|
||||
|
||||
- (void) replaceBytesInRange: (NSRange)aRange
|
||||
withBytes: (const void*)bytes
|
||||
{
|
||||
memcpy([self bytes] + aRange.location, bytes, aRange.length);
|
||||
}
|
||||
|
||||
- (void) resetBytesInRange: (NSRange)aRange
|
||||
{
|
||||
memset([self bytes] + aRange.location, 0, aRange.length);
|
||||
}
|
||||
|
||||
// Serializing Data
|
||||
|
||||
- (void) serializeAlignedBytesLength: (unsigned int)length
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
}
|
||||
|
||||
- (void) serializeDataAt: (const void*)data
|
||||
ofObjCType: (const char*)type
|
||||
context: (id <NSObjCTypeSerializationCallBack>)callback
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
}
|
||||
|
||||
- (void) serializeInt: (int)value
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
}
|
||||
|
||||
- (void) serializeInt: (int)value
|
||||
atIndex: (unsigned int)location
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
}
|
||||
|
||||
- (void) serializeInts: (int*)intBuffer
|
||||
count: (unsigned int)numInts
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
}
|
||||
|
||||
- (void) serializeInts: (int*)intBuffer
|
||||
count: (unsigned int)numInts
|
||||
atIndex: (unsigned int)location
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -29,10 +29,6 @@
|
|||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSException.h>
|
||||
|
||||
@class NSGData;
|
||||
@class NSGMutableData;
|
||||
@class NSHData;
|
||||
@class NSHMutableData;
|
||||
@class NSGMutableCString;
|
||||
@class NSGCString;
|
||||
#ifdef UNICODE
|
||||
|
@ -94,16 +90,12 @@ typedef enum {
|
|||
assert(objPtr != 0);
|
||||
assert(type == @encode(id));
|
||||
object = *objPtr;
|
||||
if ([object isKindOfClass: [NSMutableData class]] ||
|
||||
[object isKindOfClass: [NSHMutableData class]] ||
|
||||
[object isKindOfClass: [NSGMutableData class]]) {
|
||||
if ([object isKindOfClass: [NSMutableData class]]) {
|
||||
[data serializeInt: ST_MDATA];
|
||||
[data serializeInt: [object length]];
|
||||
[data appendBytes: [object bytes] length: [object length]];
|
||||
}
|
||||
else if ([object isKindOfClass: [NSData class]] ||
|
||||
[object isKindOfClass: [NSHData class]] ||
|
||||
[object isKindOfClass: [NSGData class]]) {
|
||||
else if ([object isKindOfClass: [NSData class]]) {
|
||||
[data serializeInt: ST_DATA];
|
||||
[data serializeInt: [object length]];
|
||||
[data appendBytes: [object bytes] length: [object length]];
|
||||
|
|
Loading…
Reference in a new issue