mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
hande data objects
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6839 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fe2ffe47ae
commit
e101b26a1e
1 changed files with 42 additions and 0 deletions
|
@ -35,6 +35,7 @@
|
||||||
#include <base/CStream.h>
|
#include <base/CStream.h>
|
||||||
#include <base/Port.h>
|
#include <base/Port.h>
|
||||||
#include <base/MemoryStream.h>
|
#include <base/MemoryStream.h>
|
||||||
|
#include <Foundation/NSData.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
#include <Foundation/DistributedObjects.h>
|
#include <Foundation/DistributedObjects.h>
|
||||||
|
|
||||||
|
@ -213,6 +214,20 @@ static BOOL debug_connected_coder = NO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) encodeDataObject: (NSData*)anObject
|
||||||
|
{
|
||||||
|
unsigned l = [anObject length];
|
||||||
|
|
||||||
|
[self encodeValueOfObjCType: @encode(unsigned) at: &l];
|
||||||
|
if (l)
|
||||||
|
{
|
||||||
|
const void *b = [anObject bytes];
|
||||||
|
|
||||||
|
[self encodeArrayOfObjCType: @encode(unsigned char)
|
||||||
|
count: l
|
||||||
|
at: b];
|
||||||
|
}
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@ -351,6 +366,33 @@ static BOOL debug_connected_coder = NO;
|
||||||
[self release];
|
[self release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSData*) decodeDataObject
|
||||||
|
{
|
||||||
|
unsigned l;
|
||||||
|
|
||||||
|
[self decodeValueOfObjCType: @encode(unsigned) at: &l];
|
||||||
|
if (l)
|
||||||
|
{
|
||||||
|
void *b;
|
||||||
|
NSData *d;
|
||||||
|
NSZone *z;
|
||||||
|
|
||||||
|
#if GS_WITH_GC
|
||||||
|
z = GSAtomicMallocZone();
|
||||||
|
#else
|
||||||
|
z = NSDefaultMallocZone();
|
||||||
|
#endif
|
||||||
|
b = NSZoneMalloc(z, l);
|
||||||
|
[self decodeArrayOfObjCType: @encode(unsigned char)
|
||||||
|
count: l
|
||||||
|
at: b];
|
||||||
|
d = [[NSData alloc] initWithBytesNoCopy: b length: l fromZone: z];
|
||||||
|
IF_NO_GC(AUTORELEASE(d));
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
return [NSData data];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue