DO patches (Sep 12 from Richard Frith-MacDonald)

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2419 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 1997-09-12 17:54:10 +00:00
parent d0d21cf13f
commit e149f41c85
11 changed files with 168 additions and 59 deletions

View file

@ -1,3 +1,40 @@
Fri Sep 12 12:27:00 1997 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* src/NSString.m: Added [-classForPortCoder:]) method for
NXConstantString to prevent minor DO memory leak.
Fri Sep 12 6:15:00 1997 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* src/NSAttributedString.m: Added the [-classForPortCoder:] and
[-replacementObjectForPortCoder:] methods to ensure that strings
are always sent over DO bycopy.
* src/NSDistantObject.m: Fixed the types of the parameters to a few
methods to avoid compiler warnings.
* src/NSGAttributedString.m: Added the [-classForPortCoder:] and
[-replacementObjectForPortCoder:] methods to ensure that strings
are always sent over DO bycopy.
* src/NSGCString.m: Added the [-classForPortCoder:] and
[-replacementObjectForPortCoder:] methods to ensure that strings
are always sent over DO bycopy.
* src/NSGString.m: Added the [-classForPortCoder:] and
[-replacementObjectForPortCoder:] methods to ensure that strings
are always sent over DO bycopy.
* src/NSHData.m: Added the [-classForPortCoder:] and
[-replacementObjectForPortCoder:] methods to ensure that data
objects are always sent over DO bycopy.
* src/NSProxy.m: Commented out a couple of methods whose OPENSTEP
style implementation was incomplete so that the old (working)
GNUstep implementation is used.
* src/NSRunLoop.m: Moved some code around to fix problems with
earlier patch being applied in wrong place.
Wed Sep 10 18:03:22 1997 Scott Christley <scottc@net-community.com>
* config.guess: Update.
@ -27,8 +64,9 @@ Tue Sep 9 10:15:00 1997 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* src/TcpPort.m: Fixed a minor retain/release problem.
* src/UnixFileHandle.m: Added loads of checks so that attempts to
use a file handle which has been closed will fail/generate an exception
rather than crashing things! Also modified for changes to NSRunLoop.
use a file handle which has been closed will fail/generate an
exception rather than crashing things! Also modified for changes
to NSRunLoop.
* src/include/NSRunLoop.h: Modified the interface for adding watchers
for events with a count of the number of times they have been added.

View file

@ -71,4 +71,4 @@ set-up correctly, or that the GNUstep Base Library did not link in the
correct header file to use dynamic linking. Diagnosing and fixing
these problems is not trivial and requires some knowledge of dynamic
linking, object file formats and the Objective-C runtime. Contact Adam
Fedor <fedor@boulder.colorado.edu> for help.
Fedor <fedor@doc.com> for help.

View file

@ -102,6 +102,15 @@ static Class NSMutableAttributedString_concrete_class;
return [super initWithCoder:aDecoder];
}
- (Class) classForPortCoder: (NSPortCoder*)aCoder
{
return [self class];
}
- replacementObjectForPortCoder:(NSPortCoder*)aCoder
{
return self;
}
//NSCopying protocol
- copyWithZone: (NSZone*)zone
{

View file

@ -570,17 +570,17 @@ format: @"NSDistantObject objects only encode with PortEncoder class"];
argFrame: frame];
}
- classForCoder: aRmc;
- classForCoder: (NSCoder*)aCoder;
{
return object_get_class (self);
}
- classForPortCoder: aRmc
- classForPortCoder: (NSPortCoder*)aCoder
{
return object_get_class (self);
}
- replacementObjectForCoder:(NSPortCoder*)aCoder
- replacementObjectForCoder:(NSCoder*)aCoder
{
return self;
}

View file

@ -139,6 +139,15 @@ NSDictionary *_attributesAtIndexEffectiveRange(
return nil;
}
- (Class) classForPortCoder: (NSPortCoder*)aCoder
{
return [self class];
}
- replacementObjectForPortCoder:(NSPortCoder*)aCoder
{
return self;
}
- (void) encodeWithCoder: aCoder
{
[super encodeWithCoder:aCoder];
@ -194,6 +203,15 @@ NSDictionary *_attributesAtIndexEffectiveRange(
@implementation NSGMutableAttributedString
- (Class) classForPortCoder: (NSPortCoder*)aCoder
{
return [self class];
}
- replacementObjectForPortCoder:(NSPortCoder*)aCoder
{
return self;
}
- (void) encodeWithCoder: aCoder
{
[super encodeWithCoder:aCoder];

View file

@ -83,6 +83,15 @@
return [self class];
}
- (Class) classForPortCoder: (NSPortCoder*)aCoder
{
return [self class];
}
- replacementObjectForPortCoder:(NSPortCoder*)aCoder
{
return self;
}
- (void) encodeWithCoder: aCoder
{
[aCoder encodeValueOfObjCType:@encode(char*) at:&_contents_chars

View file

@ -225,6 +225,16 @@
return [self class];
}
- (Class) classForPortCoder: (NSPortCoder*)aCoder
{
return [self class];
}
- replacementObjectForPortCoder:(NSPortCoder*)aCoder
{
return self;
}
// FOR IndexedCollection SUPPORT;
- objectAtIndex: (unsigned)index

View file

@ -188,6 +188,11 @@ static void unchar_func(void *s, int c)
return (const void*)buffer;
}
- classForPortCoder: (NSPortCoder*)aCoder
{
return object_get_class (self);
}
- (id) copyWithZone: (NSZone*)zone
{
NSHData* obj = [[NSHData class] allocWithZone:zone];
@ -1040,6 +1045,10 @@ static void unchar_func(void *s, int c)
autorelease];
}
- replacementObjectForPortCoder:(NSPortCoder*)aCoder
{
return self;
}
- (void) rewindStream
{

View file

@ -91,6 +91,7 @@
return object_get_class(self);
}
#if 0
- (BOOL) conformsToProtocol: (Protocol*)aProtocol
{
NSInvocation* inv;
@ -105,6 +106,7 @@
[inv getReturnValue: &result];
return result;
}
#endif
- (void) dealloc
{
@ -220,6 +222,7 @@
}
}
#if 0
- (BOOL) respondsToSelector: (SEL)aSelector
{
NSInvocation* inv;
@ -234,6 +237,7 @@
[inv getReturnValue: &result];
return result;
}
#endif
- retain
{

View file

@ -830,6 +830,60 @@ static int debug_run_loop = 0;
return when;
}
- (RunLoopWatcher*) _getWatcher: (void*)data
type: (RunLoopEventType)type
forMode: (NSString*)mode
{
NSArray *watchers;
RunLoopWatcher *info;
int count;
if (mode == nil)
mode = _current_mode;
watchers = NSMapGet (_mode_2_watchers, mode);
if (watchers == nil) {
return nil;
}
for (count = 0; count < [watchers count]; count++) {
info = [watchers objectAtIndex: count];
if ([info getType] == type) {
if ([info getData] == data) {
return info;
}
}
}
return nil;
}
- (void) _removeWatcher: (void*)data
type: (RunLoopEventType)type
forMode: (NSString*)mode
{
NSMutableArray *watchers;
if (mode == nil )
mode = _current_mode;
watchers = NSMapGet (_mode_2_watchers, mode);
if (watchers) {
int i;
for (i = [watchers count]; i > 0; i--) {
RunLoopWatcher* info;
info = (RunLoopWatcher*)[watchers objectAtIndex:(i-1)];
if ([info getType] == type && [info getData] == data) {
[info invalidate];
[watchers removeObject: info];
}
}
}
}
/* Listen to input sources.
If LIMIT_DATE is nil, then don't wait; i.e. call select() with 0 timeout */
@ -909,59 +963,6 @@ static int debug_run_loop = 0;
wfd_2_object = NSCreateMapTable (NSIntMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
- (RunLoopWatcher*) _getWatcher: (void*)data
type: (RunLoopEventType)type
forMode: (NSString*)mode
{
NSArray *watchers;
RunLoopWatcher *info;
int count;
if (mode == nil)
mode = _current_mode;
watchers = NSMapGet (_mode_2_watchers, mode);
if (watchers == nil) {
return nil;
}
for (count = 0; count < [watchers count]; count++) {
info = [watchers objectAtIndex: count];
if ([info getType] == type) {
if ([info getData] == data) {
return info;
}
}
}
return nil;
}
- (void) _removeWatcher: (void*)data
type: (RunLoopEventType)type
forMode: (NSString*)mode
{
NSMutableArray *watchers;
if (mode == nil )
mode = _current_mode;
watchers = NSMapGet (_mode_2_watchers, mode);
if (watchers) {
int i;
for (i = [watchers count]; i > 0; i--) {
RunLoopWatcher* info;
info = (RunLoopWatcher*)[watchers objectAtIndex:(i-1)];
if ([info getType] == type && [info getData] == data) {
[info invalidate];
[watchers removeObject: info];
}
}
}
}
/* Do the pre-listening set-up for the file descriptors of this mode. */
{
NSArray *watchers;

View file

@ -2326,6 +2326,17 @@ else
@implementation NXConstantString
/*
* NXConstantString overrides [-dealloc] so that it is never deallocated.
* If we pass an NXConstantString to another process it will never get
* deallocated in the other process - causing a memory leak. So we tell
* the DO system to use the super class instead.
*/
- (Class)classForPortCoder: (NSPortCoder*)aCoder
{
return [self superclass];
}
- (void)dealloc
{
}