unarchive 705602
reopen 705602
found 705602 0.12.0-9+nmu1
forcemerge 705602 753483
clone 705602 -1
reassign -1 gnustep-base 1.22.1-4
retitle -1 Regression: -performSelector: does not work with message forwarding
severity -1 serious
# Most probably more packages are affected.
affects -1 steptalk
forwarded -1 http://savannah.gnu.org/bugs/?36706
tags -1 + patch fixed-upstream
thanks

Yavor Doganov wrote:
> It appears that some of the patches (581934.patch specifically,
> possibly in combination with others) are broken and/or incomplete
> and have caused the package to be entirely unusable.

It is embarrassing how I missed this given the fact that I reported
#705602 and #645933...

Blindly excluding stuff that doesn't work is a completely misguided
approach to fixing bugs.  If the package's own tools are failing
miserably, that's a pretty strong indication that there's something
utterly wrong with the library.  We are just sweeping the bugs under
the carpet, nothing more.

Michael Gilbert wrote:
> I've tested that the reverse dependency steptalk works fine both
> before and after these changes, so the library files in the package
> seem to work even though the tools don't.

How did you perform the test?  The StepTalk GDL2 module just exposes
the GDL2 API and makes it available to StepTalk scripts.  So the
appropriate test is to try to access the API from a script.  This is
broken (as expected):

$ echo "Environment loadModule: 'GDL2'." > test.st
$ stexec test.st
2014-07-03 15:51:18.880 stexec[19953] File NSPropertyList.m: 1012. In 
parsePlItem Missing semicolon in dictionary at line 45 char 896
stexec: Uncaught exception NSInvalidArgumentException, reason: -[nil 
_unnamed_method]: unrecognized selector sent to instance (null)

This reveals the bug in gnustep-base as cloned/reassigned above.  With
the attached performselector.patch applied:

$ stexec test.st 
2014-07-03 15:54:58.773 stexec[21392] File NSPropertyList.m: 1012. In 
parsePlItem Missing semicolon in dictionary at line 45 char 896
stexec: Uncaught exception NSInvalidArgumentException, reason: Can not 
determine type information for +[GDL2CDNSObject (null)]

Anyway, it would have been enough to test one of the gnustep-dl2 own
examples or just eoutil.  Also, DBModeler is actually shipped in the
"fixed" package; /usr/bin/DBModeler is just a symlink.

Attached is a revised 581934.patch with the complete fixes, all taken
from upstream SVN (except the soname change).  It appears to work now:

$ ../Tools/obj/eoutil dump library.eomodel -dest database -schemaCreate tables
$ ./obj/eoexample
2014-07-03 16:05:26.164 eoexample[21438] File NSKeyValueCoding.m: 913. In 
-[NSObject(KeyValueCoding) valuesForKeys:] This method is deprecated, use 
-dictionaryWithValuesForKeys:
2014-07-03 16:05:26.320 eoexample[21438] ("<EOGenericRecord 0xf13080 : 
classDescription=<EOEntityClassDescription 0xef7610 - Entity: authors>
values={name = Anonymous; toBooks = \"<0xf2ba60 EOCheapCopyMutableArray : 
()>\"; }>")
2014-07-03 16:05:26.321 eoexample[21438] DVLP WARNING EODatabaseContext.m 
(4714): TODO
2014-07-03 16:05:26.496 eoexample[21438] ("<EOGenericRecord 0xf13080 : 
classDescription=<EOEntityClassDescription 0xef7610 - Entity: authors>
values={name = \"John Doe\"; toBooks = \"<0xf2ba60 EOCheapCopyMutableArray : 
()>\"; }>")

$ file /tmp/example.db 
/tmp/example.db: SQLite 3.x database
$ sqlite3 /tmp/example.db 
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
authors  books  
sqlite> .dump authors
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE authors (authorID integer PRIMARY KEY NOT NULL, name varchar NOT 
NULL);
INSERT INTO "authors" VALUES(1,'John Doe');
COMMIT;
sqlite> .quit

Test steptalk with the attached gdl2.st script:
$ rm /tmp/example.db
$ ../Tools/obj/eoutil dump library.eomodel -dest database -schemaCreate tables
$ stexec gdl2.st
2014-07-03 16:09:51.001 stexec[21463] File NSPropertyList.m: 1012. In 
parsePlItem Missing semicolon in dictionary at line 45 char 896
2014-07-03 16:09:51.129 stexec[21463] File NSKeyValueCoding.m: 913. In 
-[NSObject(KeyValueCoding) valuesForKeys:] This method is deprecated, use 
-dictionaryWithValuesForKeys:
("<EOGenericRecord 0x1166fa0 : classDescription=<EOEntityClassDescription 
0x11653a0 - Entity: authors>
values={name = Foo; toBooks = \"<0x1173a60 EOCheapCopyMutableArray : ()>\"; }>")

DBModeler starts successfully but crashes when opening a model file
(or trying to create a new one).  The attached dbmodeler.patch fixes
this; it is a separate issue.  I haven't tested the GDL2 gorm palette,
although I suspect it'll work with these changes.  Federico, could you
please try it?  (You don't need to rebuild gnustep-base as gnustep-dl2
is not affected by the message forwarding bug, AFAICT.)
Description: Rewrite KVC mechanism to be compatible with the new ObjC runtime.
 Bump EOControl soname due to introduced ABI break.
Bug-Debian: http://bugs.debian.org/753483
Bug-Debian: http://bugs.debian.org/705602
Bug-Debian: http://bugs.debian.org/645933
Origin: upstream, commit: 29958, 29965-6, 30099, 30106, 30109, 30112, 30116
Last-Update: 2014-07-03
---

--- gnustep-dl2-0.12.0.orig/EOControl/EOClassDescription.m
+++ gnustep-dl2-0.12.0/EOControl/EOClassDescription.m
@@ -739,19 +739,19 @@
 
 @end
 
-
-@implementation NSObject (EOClassDescriptionPrimitives)
-
-- (void)GDL2CDNSObjectICategoryID
-{
-}
+@interface GDL2CDNSObject
+@end
+@interface GDL2CDNSObject (EOClassDescription) <NSObject>
++ (EOClassDescription*) classDescriptionForClass: (Class)aClass;
+- (id) valueForKey: (NSString*)aKey;
+- (void) takeValue: (id)anObject forKey: (NSString*)aKey;
+@end
+@implementation GDL2CDNSObject
 
 + (void)load
 {
-  GDL2_ActivateCategory("NSObject",
-                        @selector(GDL2CDNSObjectICategoryID), YES);
+  GDL2_Activate(GSClassFromName("NSObject"), self);
 }
-
 // when you enable the NSDebugMLLogs here you will have a loop. dave
 - (EOClassDescription *)classDescription
 {
--- gnustep-dl2-0.12.0.orig/EOControl/EOKeyValueCoding.m
+++ gnustep-dl2-0.12.0/EOControl/EOKeyValueCoding.m
@@ -50,9 +50,9 @@
 #include <Foundation/NSEnumerator.h>
 #include <Foundation/NSException.h>
 #include <Foundation/NSHashTable.h>
+#include <Foundation/NSKeyValueCoding.h>
 #include <Foundation/NSMapTable.h>
 #include <Foundation/NSObjCRuntime.h>
-#include <Foundation/NSObject.h>
 #include <Foundation/NSString.h>
 #include <Foundation/NSValue.h>
 #else
@@ -92,19 +92,29 @@
 #define INITIALIZE if (!initialized) initialize();
 
 
-@implementation NSObject (_EOKeyValueCodingCompatibility)
+@interface     GDL2KVCNSObject
+@end
+@interface     GDL2KVCNSObject (NSKeyValueCoding) <NSObject>
+- (void) unableToSetNilForKey: (NSString*)aKey;
+- (BOOL) validateValue: (id*)aValue
+               forKey: (NSString*)aKey
+                error: (NSError**)anError;
+- (BOOL) validateValue: (id*)aValue
+           forKeyPath: (NSString*)aKey
+                error: (NSError**)anError;
+- (id) valueForKey: (NSString*)aKey;
+- (id) valueForKeyPath: (NSString*)aKey;
+- (id) valueForUndefinedKey: (NSString*)aKey;
+- (NSDictionary*) valuesForKeys: (NSArray*)keys;
+@end
 
-- (void)GDL2KVCNSObjectICategoryID
-{
-}
+@implementation GDL2KVCNSObject
 
 + (void)load
 {
-  GDL2_ActivateCategory("NSObject",
-                       @selector(GDL2KVCNSObjectICategoryID), YES);
+  GDL2_Activate(GSClassFromName("NSObject"), self);
 }
 
-
 /* This is what -base(add) will call.  It should invoke what the API
    specifies should be overridden.  */
 - (void) setNilValueForKey: (NSString*)aKey
@@ -138,6 +148,7 @@
   const char   *type = 0;
   int          off;
   unsigned     size = [aKey length];
+  id           self_id = self;
 
   if (size > 0)
     {
@@ -179,7 +190,7 @@
            }
        }
     }
-  GSObjCSetVal(self, [aKey UTF8String], anObject, sel, type, size, off);
+  GSObjCSetVal(self_id, [aKey UTF8String], anObject, sel, type, size, off);
 }
 
 
@@ -235,18 +246,20 @@
 @end
 
 
-@implementation NSArray (EOKeyValueCoding)
-
-- (void)GDL2KVCNSArrayICategoryID
-{
-}
+@interface     GDL2KVCNSArray : NSObject
+@end
+@interface GDL2KVCNSArray (NSArray)
+- (NSUInteger) count;
+- (NSArray *)resultsOfPerformingSelector: (SEL)sel
+                             withObject: (NSString *)key
+                           defaultResult: (id)defaultResult;
+@end
+@implementation        GDL2KVCNSArray
 
 + (void)load
 {
-  GDL2_ActivateCategory("NSArray",
-                       @selector(GDL2KVCNSArrayICategoryID), YES);
+  GDL2_Activate(GSClassFromName("NSArray"), self);
 }
-
 /**
  * EOKeyValueCoding protocol<br/>
  * This overrides NSObjects implementation of this method.
@@ -543,16 +556,24 @@
 @end
 
 
-@implementation NSDictionary (EOKeyValueCoding)
-
-- (void)GDL2KVCNSDictionaryICategoryID
-{
-}
+@interface     GDL2KVCNSDictionary : NSObject
+@end
+@interface     GDL2KVCNSDictionary (NSDictionary)
+- (NSArray*) allKeys;
+- (NSArray*) allValues;
+- (id) objectForKey: (id)aKey;
+- (NSUInteger) count;
+- (void)smartTakeValue: (id)object
+            forKeyPath: (NSString *)keyPath;
+- (void)takeValue: (id)value
+       forKeyPath: (NSString *)keyPath
+          isSmart: (BOOL)smartFlag;
+@end
+@implementation        GDL2KVCNSDictionary
 
 + (void)load
 {
-  GDL2_ActivateCategory("NSDictionary",
-                       @selector(GDL2KVCNSDictionaryICategoryID), YES);
+  GDL2_Activate(GSClassFromName("NSDictionary"), self);
 }
 
 /**
@@ -851,18 +872,21 @@
           isSmart: (BOOL)smartFlag;
 @end
 
-@implementation NSMutableDictionary (EOKVCGNUstepExtensions)
-
-- (void)GDL2KVCNSMutableDictionaryICategoryID
-{
-}
+@interface     GDL2KVCNSMutableDictionary : NSDictionary
+@end
+@interface     GDL2KVCNSMutableDictionary (NSMutableDictionary)
+- (void) removeObjectForKey: (id)aKey;
+- (void) setObject: (id)anObject forKey: (id)aKey;
+- (void)takeValue: (id)value
+       forKeyPath: (NSString *)keyPath
+          isSmart: (BOOL)smartFlag;
+@end
+@implementation GDL2KVCNSMutableDictionary
 
 + (void)load
 {
-  GDL2_ActivateCategory("NSMutableDictionary",
-                       @selector(GDL2KVCNSMutableDictionaryICategoryID), YES);
+  GDL2_Activate(GSClassFromName("NSMutableDictionary"), self);
 }
-
 /**
  * Method to augment the NSKeyValueCoding implementation
  * to account for added functionality such as quoted key paths.
--- gnustep-dl2-0.12.0.orig/EOControl/EONSAddOns.h
+++ gnustep-dl2-0.12.0/EOControl/EONSAddOns.h
@@ -51,11 +51,7 @@
 GSUseStrictWO451Compatibility(NSString *key);
 
 GDL2CONTROL_EXPORT void
-GDL2_ActivateCategory(const char *className, SEL sel, BOOL isInstance);
-
-GDL2CONTROL_EXPORT void
-GDL2_ActivateAllGDL2Categories(void);
-
+GDL2_Activate(Class sup, Class cls);
 
 @interface NSObject (NSObjectPerformingSelector)
 - (NSArray *)resultsOfPerformingSelector: (SEL)sel
--- gnustep-dl2-0.12.0.orig/EOControl/EONSAddOns.m
+++ gnustep-dl2-0.12.0/EOControl/EONSAddOns.m
@@ -61,9 +62,15 @@
 #include <EOControl/EODebug.h>
 
 #include <limits.h>
+#include <assert.h>
 
 #include "EOPrivate.h"
 
+@class GDL2KVCNSObject;
+@class GDL2KVCNSArray;
+@class GDL2KVCNSDictionary;
+@class GDL2KVCNSMutableDictionary;
+@class GDL2CDNSObject;
 
 static NSRecursiveLock *local_lock = nil;
 static BOOL GSStrictWO451Flag = NO;
@@ -98,6 +105,7 @@
 void
 GDL2_DumpMethodList(Class cls, SEL sel, BOOL isInstance)
 {
+/*
   void *iterator = 0;
   GSMethodList mList;
   
@@ -113,40 +121,15 @@
              mList, meth, imp);
     }
   fprintf(stderr,"List finished\n"); fflush(stderr);
+*/
 }
 
 void
-GDL2_ActivateCategory(const char *className, SEL sel, BOOL isInstance)
+GDL2_Activate(Class sup, Class cls)
 {
-  Class cls;
-  GSMethodList mList;
-
-  cls = GSClassFromName(className);
-  mList = GSMethodListForSelector(cls, sel, 0, isInstance);
-
-  GSRemoveMethodList(cls, mList, isInstance);
-  GSAddMethodList(cls, mList, isInstance);
-
-  GSFlushMethodCacheForClass(cls);
-}
-
-void
-GDL2_ActivateAllGDL2Categories(void)
-{
-  /* EOKeyValueCoding */
-  GDL2_ActivateCategory("NSObject",
-                        @selector(GDL2KVCNSObjectICategoryID), YES);
-  GDL2_ActivateCategory("NSArray",
-                       @selector(GDL2KVCNSArrayICategoryID), YES);
-  GDL2_ActivateCategory("NSDictionary",
-                        @selector(GDL2KVCNSDictionaryICategoryID), YES);
-  GDL2_ActivateCategory("NSMutableDictionary",
-                        @selector(GDL2KVCNSMutableDictionaryICategoryID), YES);
-
-  /* EOClassDescription */
-  GDL2_ActivateCategory("NSObject",
-                        @selector(GDL2CDNSObjectICategoryID), YES);
-
+  assert(sup!=Nil);
+  assert(cls!=Nil);
+  GSObjCAddClassOverride(sup, cls);
 }
 
 
--- gnustep-dl2-0.12.0.orig/EOControl/GNUmakefile
+++ gnustep-dl2-0.12.0/EOControl/GNUmakefile
@@ -29,6 +29,7 @@
 
 # The library to be compiled
 NATIVE_LIBRARY_NAME=EOControl
+EOControl_INTERFACE_VERSION=0d
 
 EOControl_NEEDS_GUI = no
 
--- gnustep-dl2-0.12.0.orig/EOInterface/EOPopUpAssociation.m
+++ gnustep-dl2-0.12.0/EOInterface/EOPopUpAssociation.m
@@ -24,8 +24,10 @@
 */
 
 #ifdef GNUSTEP
-#include <Foundation/NSString.h>
 #include <Foundation/NSArray.h>
+#include <Foundation/NSString.h>
+#include <Foundation/NSException.h>
+#include <Foundation/NSValue.h>
 
 #include <AppKit/NSPopUpButton.h>
 #else
--- gnustep-dl2-0.12.0.orig/DBModeler/ModelerEntityEditor.m
+++ gnustep-dl2-0.12.0/DBModeler/ModelerEntityEditor.m
@@ -40,6 +40,7 @@
 #ifdef NeXT_GUI_LIBRARY
 #include <AppKit/AppKit.h>
 #else
+#include <Foundation/NSRunLoop.h>
 #include <AppKit/NSImage.h>
 #include <AppKit/NSSplitView.h>
 #include <AppKit/NSScrollView.h>
--- gnustep-dl2-0.12.0.orig/DBModeler/ModelerTableEmbedibleEditor.m
+++ gnustep-dl2-0.12.0/DBModeler/ModelerTableEmbedibleEditor.m
@@ -29,6 +29,8 @@
 #ifdef NeXT_GUI_LIBRARY
 #include <AppKit/AppKit.h>
 #else
+#include <Foundation/NSNotification.h>
+#include <Foundation/NSUserDefaults.h>
 #include <AppKit/NSMenuItem.h>
 #include <AppKit/NSPopUpButton.h>
 #include <AppKit/NSTableColumn.h>
Description: Temporary workaround for an odd gnustep-base bug.
Author: Yavor Doganov <ya...@gnu.org>
Forwarded: not-needed
Last-Update: 2014-07-03
---

--- gnustep-dl2-0.12.0.orig/EOInterface/EOTableViewAssociation.m
+++ gnustep-dl2-0.12.0/EOInterface/EOTableViewAssociation.m
@@ -194,7 +194,7 @@
     {
       tvAssociationMap = 
NSCreateMapTableWithZone(NSNonRetainedObjectMapKeyCallBacks,
                                    NSNonRetainedObjectMapValueCallBacks,
-                                   0, [self zone]);
+                                   0, NSDefaultMallocZone());
       assoc = [[self allocWithZone:NSDefaultMallocZone()] 
initWithObject:tableView];
       NSMapInsert(tvAssociationMap, (void *)tableView, (void *)assoc);
       [assoc bindAspect:@"source" displayGroup:displayGroup key:@""];
" Test for StepTalk's GDL2 module.
  Basically a StepTalk variant of eoexample. "

|model channel ec authorsDS|

Environment loadModule: 'GDL2'.

model := EOModel alloc initWithContentsOfFile: './library.eomodel'.
EOModelGroup defaultGroup addModel: model.
channel := ((EOAdaptor adaptorWithModel: model) 
        createAdaptorContext)
        createAdaptorChannel.

ec := EOEditingContext new.
authorsDS := (EODatabaseDataSource alloc)
                initWithEditingContext: ec
                entityName: 'authors'.
channel openChannel.

authorsDS insertObject: ((authorsDS createObject) 
                takeValue: 'Foo'
                forKey: 'name').
ec saveChanges.

Transcript showLine: (authorsDS fetchObjects).
channel closeChannel.
--- gnustep-base-1.22.1.orig/Source/NSObject.m
+++ gnustep-base-1.22.1/Source/NSObject.m
@@ -1837,7 +1837,7 @@
     [NSException raise: NSInvalidArgumentException
                format: @"%@ null selector given", NSStringFromSelector(_cmd)];
 
-  msg = class_getMethodImplementation(object_getClass(self), aSelector);
+  msg = objc_msg_lookup(self, aSelector);
   if (!msg)
     {
       [NSException raise: NSGenericException
@@ -1862,7 +1862,7 @@
     [NSException raise: NSInvalidArgumentException
                format: @"%@ null selector given", NSStringFromSelector(_cmd)];
 
-  msg = class_getMethodImplementation(object_getClass(self), aSelector);
+  msg = objc_msg_lookup(self, aSelector);
   if (!msg)
     {
       [NSException raise: NSGenericException
@@ -1890,7 +1890,7 @@
     [NSException raise: NSInvalidArgumentException
                format: @"%@ null selector given", NSStringFromSelector(_cmd)];
 
-  msg = class_getMethodImplementation(object_getClass(self), aSelector);
+  msg = objc_msg_lookup(self, aSelector);
   if (!msg)
     {
       [NSException raise: NSGenericException
--- gnustep-base-1.22.1.orig/Source/GSFFIInvocation.m
+++ gnustep-base-1.22.1/Source/GSFFIInvocation.m
@@ -185,6 +185,10 @@
        }
       if (nil == sig)
        {
+         if (nil == receiver)
+           {
+             return NULL;
+           }
          [NSException raise: NSInvalidArgumentException
            format: @"%c[%s %s]: unrecognized selector sent to instance %p",
            (class_isMetaClass(c) ? '+' : '-'),

Reply via email to