mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Byref patches from Frith-MacDonald
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2777 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
60070d1e6e
commit
5f22cd9f54
17 changed files with 218 additions and 30 deletions
|
@ -199,6 +199,11 @@ static BOOL debug_coder = NO;
|
|||
[self encodeBycopyObject: anObject withName: NULL];
|
||||
}
|
||||
|
||||
- (void) encodeByrefObject: (id)anObject
|
||||
{
|
||||
[self encodeByrefObject: anObject withName: NULL];
|
||||
}
|
||||
|
||||
- (void) encodeConditionalObject: (id)anObject
|
||||
{
|
||||
/* NeXT's implementation handles *forward* references by running
|
||||
|
|
|
@ -578,7 +578,7 @@ my_object_is_class(id object)
|
|||
}
|
||||
|
||||
|
||||
/* These next two methods are the designated coder methods called when
|
||||
/* These next three methods are the designated coder methods called when
|
||||
we've determined that the object has not already been
|
||||
encoded---we're not simply going to encode a cross-reference number
|
||||
to the object, we're actually going to encode an object (either a
|
||||
|
@ -611,17 +611,24 @@ my_object_is_class(id object)
|
|||
[encoded_object encodeWithCoder: (id)self];
|
||||
}
|
||||
|
||||
/* This method overridden by ConnectedCoder */
|
||||
/* This method overridden by NSPortCoder */
|
||||
- (void) _doEncodeObject: anObj
|
||||
{
|
||||
[self _doEncodeBycopyObject:anObj];
|
||||
}
|
||||
|
||||
/* This method overridden by NSPortCoder */
|
||||
- (void) _doEncodeByrefObject: anObj
|
||||
{
|
||||
[self _doEncodeObject: anObj];
|
||||
}
|
||||
|
||||
|
||||
/* This is the designated object encoder */
|
||||
- (void) _encodeObject: anObj
|
||||
withName: (NSString*) name
|
||||
isBycopy: (BOOL) bycopy_flag
|
||||
isByref: (BOOL) byref_flag
|
||||
isForwardReference: (BOOL) forward_ref_flag
|
||||
{
|
||||
[self encodeName:name];
|
||||
|
@ -681,6 +688,8 @@ my_object_is_class(id object)
|
|||
[self encodeIndent];
|
||||
if (bycopy_flag)
|
||||
[self _doEncodeBycopyObject:anObj];
|
||||
else if (byref_flag)
|
||||
[self _doEncodeByrefObject:anObj];
|
||||
else
|
||||
[self _doEncodeObject:anObj];
|
||||
[self encodeUnindent];
|
||||
|
@ -730,20 +739,42 @@ my_object_is_class(id object)
|
|||
- (void) encodeObject: anObj
|
||||
withName: (NSString*)name
|
||||
{
|
||||
[self _encodeObject:anObj withName:name isBycopy:NO isForwardReference:NO];
|
||||
[self _encodeObject:anObj
|
||||
withName:name
|
||||
isBycopy:NO
|
||||
isByref:NO
|
||||
isForwardReference:NO];
|
||||
}
|
||||
|
||||
|
||||
- (void) encodeBycopyObject: anObj
|
||||
withName: (NSString*)name
|
||||
{
|
||||
[self _encodeObject:anObj withName:name isBycopy:YES isForwardReference:NO];
|
||||
[self _encodeObject:anObj
|
||||
withName:name
|
||||
isBycopy:YES
|
||||
isByref:NO
|
||||
isForwardReference:NO];
|
||||
}
|
||||
|
||||
- (void) encodeByrefObject: anObj
|
||||
withName: (NSString*)name
|
||||
{
|
||||
[self _encodeObject:anObj
|
||||
withName:name
|
||||
isBycopy:NO
|
||||
isByref:YES
|
||||
isForwardReference:NO];
|
||||
}
|
||||
|
||||
- (void) encodeObjectReference: anObj
|
||||
withName: (NSString*)name
|
||||
{
|
||||
[self _encodeObject:anObj withName:name isBycopy:NO isForwardReference:YES];
|
||||
[self _encodeObject:anObj
|
||||
withName:name
|
||||
isBycopy:NO
|
||||
isByref:NO
|
||||
isForwardReference:YES];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -950,9 +950,11 @@ static id long_day[7] = {@"Sunday",
|
|||
z = [time_zone timeZoneSecondsFromGMT];
|
||||
if (z < 0) {
|
||||
z = -z;
|
||||
z /= 60;
|
||||
k = VSPRINTF_LENGTH(sprintf(&(buf[j]),"-%02d%02d",z/60,z%60));
|
||||
}
|
||||
else {
|
||||
z /= 60;
|
||||
k = VSPRINTF_LENGTH(sprintf(&(buf[j]),"+%02d%02d",z/60,z%60));
|
||||
}
|
||||
j += k;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <config.h>
|
||||
#include <gnustep/base/preface.h>
|
||||
#include <gnustep/base/MallocAddress.h>
|
||||
#include <Foundation/NSCoder.h>
|
||||
#include <gnustep/base/NSCoder.h>
|
||||
|
||||
|
@ -36,7 +37,7 @@
|
|||
}
|
||||
|
||||
- (void) encodeValueOfObjCType: (const char*)type
|
||||
at: (const void*)address;
|
||||
at: (const void*)address
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
}
|
||||
|
@ -47,18 +48,18 @@
|
|||
[self subclassResponsibility:_cmd];
|
||||
}
|
||||
|
||||
- (void) encodeDataObject: (NSData*)data;
|
||||
- (void) encodeDataObject: (NSData*)data
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
}
|
||||
|
||||
- (NSData*) decodeDataObject;
|
||||
- (NSData*) decodeDataObject
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (unsigned int) versionForClassName: (NSString*)className;
|
||||
- (unsigned int) versionForClassName: (NSString*)className
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return 0;
|
||||
|
@ -84,51 +85,66 @@
|
|||
at:where];
|
||||
}
|
||||
|
||||
- (void) encodeBycopyObject: (id)anObject;
|
||||
- (void) encodeBycopyObject: (id)anObject
|
||||
{
|
||||
[self encodeObject:anObject];
|
||||
}
|
||||
|
||||
- (void) encodeConditionalObject: (id)anObject;
|
||||
- (void) encodeByrefObject: (id)anObject
|
||||
{
|
||||
[self encodeObject:anObject];
|
||||
}
|
||||
|
||||
- (void) encodeObject: (id)anObject;
|
||||
- (void) encodeBytes: (void*)d length: (unsigned)l
|
||||
{
|
||||
const char *type = @encode(unsigned char);
|
||||
const unsigned char *where = (const unsigned char*)d;
|
||||
|
||||
[self encodeValueOfObjCType:@encode(unsigned) at:&l];
|
||||
while (l-- > 0)
|
||||
[self encodeValueOfObjCType:type at:where++];
|
||||
}
|
||||
|
||||
- (void) encodeConditionalObject: (id)anObject
|
||||
{
|
||||
[self encodeObject:anObject];
|
||||
}
|
||||
|
||||
- (void) encodeObject: (id)anObject
|
||||
{
|
||||
[self encodeValueOfObjCType:@encode(id)
|
||||
at: &anObject];
|
||||
}
|
||||
|
||||
- (void) encodePropertyList: (id)plist;
|
||||
- (void) encodePropertyList: (id)plist
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
}
|
||||
|
||||
- (void) encodePoint: (NSPoint)point;
|
||||
- (void) encodePoint: (NSPoint)point
|
||||
{
|
||||
[self encodeValueOfObjCType:@encode(NSPoint)
|
||||
at:&point];
|
||||
}
|
||||
|
||||
- (void) encodeRect: (NSRect)rect;
|
||||
- (void) encodeRect: (NSRect)rect
|
||||
{
|
||||
[self encodeValueOfObjCType:@encode(NSRect)
|
||||
at:&rect];
|
||||
}
|
||||
|
||||
- (void) encodeRootObject: (id)rootObject;
|
||||
- (void) encodeRootObject: (id)rootObject
|
||||
{
|
||||
[self encodeObject:rootObject];
|
||||
}
|
||||
|
||||
- (void) encodeSize: (NSSize)size;
|
||||
- (void) encodeSize: (NSSize)size
|
||||
{
|
||||
[self encodeValueOfObjCType:@encode(NSSize)
|
||||
at:&size];
|
||||
}
|
||||
|
||||
- (void) encodeValuesOfObjCTypes: (const char*)types,...;
|
||||
- (void) encodeValuesOfObjCTypes: (const char*)types,...
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, types);
|
||||
|
@ -145,7 +161,7 @@
|
|||
|
||||
- (void) decodeArrayOfObjCType: (const char*)type
|
||||
count: (unsigned)count
|
||||
at: (void*)address;
|
||||
at: (void*)address
|
||||
{
|
||||
unsigned encoded_count;
|
||||
int i, size = objc_sizeof_type(type);
|
||||
|
@ -159,7 +175,25 @@
|
|||
at:where];
|
||||
}
|
||||
|
||||
- (id) decodeObject;
|
||||
- (void*) decodeBytesWithReturnedLength: (unsigned*)l
|
||||
{
|
||||
unsigned count;
|
||||
const char *type = @encode(unsigned char);
|
||||
int i;
|
||||
unsigned char *where;
|
||||
unsigned char *array;
|
||||
|
||||
[self decodeValueOfObjCType:@encode(unsigned) at:&count];
|
||||
*l = count;
|
||||
array = objc_malloc(count);
|
||||
while (count-- > 0)
|
||||
[self decodeValueOfObjCType:type at:where++];
|
||||
|
||||
[[[MallocAddress alloc] initWithAddress: array] autorelease];
|
||||
return array;
|
||||
}
|
||||
|
||||
- (id) decodeObject
|
||||
{
|
||||
id o;
|
||||
[self decodeValueOfObjCType:@encode(id)
|
||||
|
@ -197,7 +231,7 @@
|
|||
return size;
|
||||
}
|
||||
|
||||
- (void) decodeValuesOfObjCTypes: (const char*)types,...;
|
||||
- (void) decodeValuesOfObjCTypes: (const char*)types,...
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, types);
|
||||
|
@ -212,12 +246,12 @@
|
|||
|
||||
// Managing Zones
|
||||
|
||||
- (NSZone*) objectZone;
|
||||
- (NSZone*) objectZone
|
||||
{
|
||||
return NSDefaultMallocZone();
|
||||
}
|
||||
|
||||
- (void) setObjectZone: (NSZone*)zone;
|
||||
- (void) setObjectZone: (NSZone*)zone
|
||||
{
|
||||
;
|
||||
}
|
||||
|
|
|
@ -1018,6 +1018,10 @@ static int messages_received_count;
|
|||
case _C_ID:
|
||||
if (flags & _F_BYCOPY)
|
||||
[op encodeBycopyObject: *(id*)datum withName: ENCODED_ARGNAME];
|
||||
#ifdef _F_BYREF
|
||||
else if (flags & _F_BYREF)
|
||||
[op encodeByrefObject: *(id*)datum withName: ENCODED_ARGNAME];
|
||||
#endif
|
||||
else
|
||||
[op encodeObject: *(id*)datum withName: ENCODED_ARGNAME];
|
||||
break;
|
||||
|
@ -1189,6 +1193,10 @@ static int messages_received_count;
|
|||
case _C_ID:
|
||||
if (flags & _F_BYCOPY)
|
||||
[op encodeBycopyObject:*(id*)datum withName:ENCODED_RETNAME];
|
||||
#ifdef _F_BYREF
|
||||
else if (flags & _F_BYREF)
|
||||
[op encodeByrefObject: *(id*)datum withName: ENCODED_ARGNAME];
|
||||
#endif
|
||||
else
|
||||
[op encodeObject:*(id*)datum withName:ENCODED_RETNAME];
|
||||
break;
|
||||
|
|
|
@ -121,6 +121,11 @@ static Class NSMutableDictionary_concrete_class;
|
|||
autorelease];
|
||||
}
|
||||
|
||||
+ dictionaryWithDictionary: (NSDictionary*)otherDictionary
|
||||
{
|
||||
return [[[self alloc] initWithDictionary: otherDictionary] autorelease];
|
||||
}
|
||||
|
||||
+ dictionaryWithObjects: (id*)objects
|
||||
forKeys: (NSObject**)keys
|
||||
count: (unsigned)count
|
||||
|
|
|
@ -57,6 +57,7 @@ static BOOL debug_connected_coder = NO;
|
|||
unsigned sequence_number;
|
||||
int identifier;
|
||||
BOOL _is_by_copy;
|
||||
BOOL _is_by_ref;
|
||||
}
|
||||
|
||||
+ newForWritingWithConnection: (NSConnection*)c
|
||||
|
@ -143,6 +144,11 @@ static BOOL debug_connected_coder = NO;
|
|||
return _is_by_copy;
|
||||
}
|
||||
|
||||
- (BOOL) isByref
|
||||
{
|
||||
return _is_by_ref;
|
||||
}
|
||||
|
||||
- (unsigned) sequenceNumber
|
||||
{
|
||||
return sequence_number;
|
||||
|
@ -164,10 +170,10 @@ static BOOL debug_connected_coder = NO;
|
|||
|
||||
|
||||
/*
|
||||
* These two methods are called by Coder's designated object encoder when
|
||||
* an object is to be sent over the wire with/without bycopy.
|
||||
* These three methods are called by Coder's designated object encoder when
|
||||
* an object is to be sent over the wire with/without bycopy/byref.
|
||||
* We make sure that if the object asks us whether it is to be sent bycopy
|
||||
* it is told the right thing.
|
||||
* or byref it is told the right thing.
|
||||
*/
|
||||
- (void) _doEncodeObject: anObj
|
||||
{
|
||||
|
@ -182,16 +188,36 @@ static BOOL debug_connected_coder = NO;
|
|||
|
||||
- (void) _doEncodeBycopyObject: anObj
|
||||
{
|
||||
BOOL old = _is_by_copy;
|
||||
BOOL oldBycopy = _is_by_copy;
|
||||
BOOL oldByref = _is_by_ref;
|
||||
id obj;
|
||||
Class cls;
|
||||
|
||||
_is_by_copy = YES;
|
||||
_is_by_ref = NO;
|
||||
obj = [anObj replacementObjectForPortCoder: (NSPortCoder*)self];
|
||||
cls = [obj classForPortCoder];
|
||||
[self encodeClass: cls];
|
||||
[obj encodeWithCoder: (NSCoder*)self];
|
||||
_is_by_copy = old;
|
||||
_is_by_copy = oldBycopy;
|
||||
_is_by_ref = oldByref;
|
||||
}
|
||||
|
||||
- (void) _doEncodeByrefObject: anObj
|
||||
{
|
||||
BOOL oldBycopy = _is_by_copy;
|
||||
BOOL oldByref = _is_by_ref;
|
||||
id obj;
|
||||
Class cls;
|
||||
|
||||
_is_by_copy = NO;
|
||||
_is_by_ref = YES;
|
||||
obj = [anObj replacementObjectForPortCoder: (NSPortCoder*)self];
|
||||
cls = [obj classForPortCoder];
|
||||
[self encodeClass: cls];
|
||||
[obj encodeWithCoder: (NSCoder*)self];
|
||||
_is_by_copy = oldBycopy;
|
||||
_is_by_ref = oldByref;
|
||||
}
|
||||
|
||||
- (void) writeSignature
|
||||
|
@ -427,6 +453,12 @@ static BOOL debug_connected_coder = NO;
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) isByref
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSPort*) replyPort
|
||||
{
|
||||
[self subclassResponsibility:_cmd];
|
||||
|
|
|
@ -302,6 +302,9 @@ objc_skip_type_qualifiers (const char* type)
|
|||
|| *type == _C_INOUT
|
||||
|| *type == _C_OUT
|
||||
|| *type == _C_BYCOPY
|
||||
#ifdef _C_BYREF
|
||||
|| *type == _C_BYREF
|
||||
#endif
|
||||
|| *type == _C_ONEWAY)
|
||||
{
|
||||
type += 1;
|
||||
|
@ -424,6 +427,9 @@ objc_get_type_qualifiers (const char* type)
|
|||
case _C_INOUT: res |= _F_INOUT; break;
|
||||
case _C_OUT: res |= _F_OUT; break;
|
||||
case _C_BYCOPY: res |= _F_BYCOPY; break;
|
||||
#ifdef _C_BYREF
|
||||
case _C_BYREF: res |= _F_BYREF; break;
|
||||
#endif
|
||||
case _C_ONEWAY: res |= _F_ONEWAY; break;
|
||||
default: flag = NO;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue