From d790d9747f838fd57163ec40e5f362af6e7cf911 Mon Sep 17 00:00:00 2001 From: rfm Date: Sun, 6 Jul 2008 09:18:30 +0000 Subject: [PATCH] Fixups for DO compatibility. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26747 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 14 ++++++++ Source/Additions/GSCompatibility.m | 14 +++++++- Source/NSArray.m | 52 ++++++++++++++++++++++++---- Source/NSDictionary.m | 54 +++++++++++++++++++++++++++--- Source/NSRunLoop.m | 26 ++++++++++++-- Source/NSSerializer.m | 12 ++++++- Source/NSSet.m | 14 +++++++- Source/NSSortDescriptor.m | 28 ++++++++++++++-- 8 files changed, 197 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index e44d86e57..d44729c25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2008-07-06 Richard Frith-Macdonald + + * Source/NSRunLoop.m: + * Source/NSArray.m: + * Source/NSSortDescriptor.m: + * Source/Additions/GSCompatibility.m: + * Source/NSDictionary.m: + * Source/NSSerializer.m: + * Source/NSSet.m: + Wherever ([-getObjects:]) is called, check to see if the receiver is + a proxy, and if so we populate the buffer by calling ([-objectAtIndex:]) + instead. This because a proxy via DO does not know how many itesm are + in the buffer and assumes it's only one. + 2008-07-06 Richard Frith-Macdonald * configure.ac: use libffi in preference to ffcall as it doesn't mess diff --git a/Source/Additions/GSCompatibility.m b/Source/Additions/GSCompatibility.m index 5b44ed7d1..90287ae87 100644 --- a/Source/Additions/GSCompatibility.m +++ b/Source/Additions/GSCompatibility.m @@ -102,7 +102,19 @@ GSDebugFunctionMsg(const char *func, const char *file, int line, NSString *fmt) unsigned c = [array count]; id objects[c]; - [array getObjects: objects]; + if ([array isProxy]) + { + unsigned i; + + for (i = 0; i < c; i++) + { + objects[i] = [array objectAtIndex: i]; + } + } + else + { + [array getObjects: objects]; + } if (shouldCopy == YES) { unsigned i; diff --git a/Source/NSArray.m b/Source/NSArray.m index ce12bf145..96401c1f1 100644 --- a/Source/NSArray.m +++ b/Source/NSArray.m @@ -315,17 +315,33 @@ static SEL rlSel; - (NSArray*) arrayByAddingObjectsFromArray: (NSArray*)anotherArray { id na; - unsigned c, l; + unsigned c; + unsigned l; + unsigned e; c = [self count]; l = [anotherArray count]; + e = c + l; { - GS_BEGINIDBUF(objects, c+l); + GS_BEGINIDBUF(objects, e); [self getObjects: objects]; - [anotherArray getObjects: &objects[c]]; - na = [NSArrayClass arrayWithObjects: objects count: c+l]; + if ([anotherArray isProxy]) + { + unsigned i = c; + unsigned j = 0; + + while (i < e) + { + objects[i++] = [anotherArray objectAtIndex: j++]; + } + } + else + { + [anotherArray getObjects: &objects[c]]; + } + na = [NSArrayClass arrayWithObjects: objects count: e]; GS_ENDIDBUF(); } @@ -582,7 +598,19 @@ static SEL rlSel; unsigned c = [array count]; GS_BEGINIDBUF(objects, c); - [array getObjects: objects]; + if ([array isProxy]) + { + unsigned i; + + for (i = 0; i < c; i++) + { + objects[i] = [array objectAtIndex: i]; + } + } + else + { + [array getObjects: objects]; + } if (shouldCopy == YES) { unsigned i; @@ -617,7 +645,19 @@ static SEL rlSel; unsigned c = [array count]; GS_BEGINIDBUF(objects, c); - [array getObjects: objects]; + if ([array isProxy]) + { + unsigned i; + + for (i = 0; i < c; i++) + { + objects[i] = [array objectAtIndex: i]; + } + } + else + { + [array getObjects: objects]; + } self = [self initWithObjects: objects count: c]; GS_ENDIDBUF(); return self; diff --git a/Source/NSDictionary.m b/Source/NSDictionary.m index 7ab841815..0f91884e5 100644 --- a/Source/NSDictionary.m +++ b/Source/NSDictionary.m @@ -437,8 +437,32 @@ static SEL appSel; { GS_BEGINIDBUF(o, objectCount*2); - [objects getObjects: o]; - [keys getObjects: o + objectCount]; + if ([objects isProxy]) + { + unsigned i; + + for (i = 0; i < objectCount; i++) + { + o[i] = [objects objectAtIndex: i]; + } + } + else + { + [objects getObjects: o]; + } + if ([keys isProxy]) + { + unsigned i; + + for (i = 0; i < objectCount; i++) + { + o[objectCount + i] = [keys objectAtIndex: i]; + } + } + else + { + [keys getObjects: o + objectCount]; + } self = [self initWithObjects: o forKeys: o + objectCount count: objectCount]; @@ -899,7 +923,17 @@ compareIt(id o1, id o2, void* context) id result; GS_BEGINIDBUF(obuf, c); - [keys getObjects: obuf]; + if ([keys isProxy]) + { + for (i = 0; i < c; i++) + { + obuf[i] = [keys objectAtIndex: i]; + } + } + else + { + [keys getObjects: obuf]; + } for (i = 0; i < c; i++) { id o = (*myObj)(self, objSel, obuf[i]); @@ -1245,7 +1279,19 @@ compareIt(id o1, id o2, void* context) IMP remObj = [self methodForSelector: remSel]; GS_BEGINIDBUF(keys, c); - [keyArray getObjects: keys]; + if ([keyArray isProxy]) + { + unsigned i; + + for (i = 0; i < c; i++) + { + keys[i] = [keyArray objectAtIndex: i]; + } + } + else + { + [keyArray getObjects: keys]; + } while (c--) { (*remObj)(self, remSel, keys[c]); diff --git a/Source/NSRunLoop.m b/Source/NSRunLoop.m index f81481e4b..3a471b786 100644 --- a/Source/NSRunLoop.m +++ b/Source/NSRunLoop.m @@ -360,7 +360,17 @@ static inline BOOL timerInvalidated(NSTimer *t) delay: seconds]; [[loop _timedPerformers] addObject: item]; RELEASE(item); - [modes getObjects: marray]; + if ([modes isProxy]) + { + for (i = 0; i < count; i++) + { + marray[i] = [modes objectAtIndex: i]; + } + } + else + { + [modes getObjects: marray]; + } for (i = 0; i < count; i++) { [loop addTimer: item->timer forMode: marray[i]]; @@ -1405,7 +1415,19 @@ static inline BOOL timerInvalidated(NSTimer *t) argument: argument order: order]; - [modes getObjects: array]; + if ([modes isProxy]) + { + unsigned i; + + for (i = 0; i < count; i++) + { + array[i] = [modes objectAtIndex: i]; + } + } + else + { + [modes getObjects: array]; + } while (count-- > 0) { NSString *mode = array[count]; diff --git a/Source/NSSerializer.m b/Source/NSSerializer.m index fcd5e836a..5402f9155 100644 --- a/Source/NSSerializer.m +++ b/Source/NSSerializer.m @@ -280,7 +280,17 @@ serializeToInfo(id object, _NSSerializerInfo* info) id objects[count]; unsigned int i; - [object getObjects: objects]; + if ([object isProxy]) + { + for (i = 0; i < count; i++) + { + objects[i] = [object objectAtIndex: i]; + } + } + else + { + [object getObjects: objects]; + } for (i = 0; i < count; i++) { serializeToInfo(objects[i], info); diff --git a/Source/NSSet.m b/Source/NSSet.m index 5574b42fd..98d7c5a19 100644 --- a/Source/NSSet.m +++ b/Source/NSSet.m @@ -381,7 +381,19 @@ static Class NSMutableSet_concrete_class; { GS_BEGINIDBUF(objs, count); - [other getObjects: objs]; + if ([other isProxy]) + { + unsigned i; + + for (i = 0; i < count; i++) + { + objs[i] = [other objectAtIndex: i]; + } + } + else + { + [other getObjects: objs]; + } self = [self initWithObjects: objs count: count]; GS_ENDIDBUF(); return self; diff --git a/Source/NSSortDescriptor.m b/Source/NSSortDescriptor.m index 9c12d82a4..da6d84754 100644 --- a/Source/NSSortDescriptor.m +++ b/Source/NSSortDescriptor.m @@ -312,7 +312,19 @@ SortRange(id *objects, NSRange range, id *descriptors, GS_BEGINIDBUF(objects, count); [self getObjects: objects]; - [sortDescriptors getObjects: descriptors]; + if ([sortDescriptors isProxy]) + { + unsigned i; + + for (i = 0; i < numDescriptors; i++) + { + descriptors[i] = [sortDescriptors objectAtIndex: i]; + } + } + else + { + [sortDescriptors getObjects: descriptors]; + } SortRange(objects, NSMakeRange(0, count), descriptors, numDescriptors); a = [[NSArray alloc] initWithObjects: objects count: count]; [self setArray: a]; @@ -333,7 +345,19 @@ SortRange(id *objects, NSRange range, id *descriptors, { GS_BEGINIDBUF(descriptors, dCount); - [sortDescriptors getObjects: descriptors]; + if ([sortDescriptors isProxy]) + { + unsigned i; + + for (i = 0; i < dCount; i++) + { + descriptors[i] = [sortDescriptors objectAtIndex: i]; + } + } + else + { + [sortDescriptors getObjects: descriptors]; + } SortRange(_contents_array, NSMakeRange(0, _count), descriptors, dCount); GS_ENDIDBUF();