bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fwd: RFC GDL2: move +load implementations to +initialize]


From: David Ayers
Subject: Re: [Fwd: RFC GDL2: move +load implementations to +initialize]
Date: Fri, 31 Jan 2003 23:21:01 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021212

Hello all,
Hello Mirko,

As I'm still having problems with this issue, I  though I'd post this
updated patch, which should insure everything is initialized for all
"legal" situtaions. (I didn't put [EODatabaseContext class] into EODatabaseChannel, as you can't have a valid channel with out getting from a context and therefor the context recieved initialized before a valid notification could be posted.)

Plus a change in EOQualifier operatorSelectorForString: somehow got lost.

Cheers,
Dave

David Ayers wrote:

Mirko Viviani wrote:

The problem is really this... how to be sure that a message will be sent to
these classes ?


I must admit, if you really want to catch this case of:

int main (int argc, char **argv)
{
 EOCooperatingObjectStore *coopstore;

coopstore = [[NSNotificationCenter defaultCenter] postNotification: @"EOCooperatingObjectStoreNeeded"
   object: nil]
}

then I'd have to pass this on to the real objc runtime experts.

But lets see what we can do...

The current implemetaion of _registerDatabaseContext: either needs some EOGlobalID, EOFetchSpecification or a customEntityObject. In the later case (customEntityObject) we can be pretty sure that EODatabaseContext has been initialized. So putting an [EODatabaseContext class] in the implemetatiin of +initialize of EOFetchSpecification and EOGlobalD would put us on the very safe side for any 'legal' notification.

The implementation of _registerDatabaseChannel: expects an EODatabaseContext in the notification, so we could add a [EODatabaseChannel class] to EODatabaseContext's implementation of +initialize.

I think this should be all the security we need.

Cheers,
Dave



? dev-libs/gdl2/Testing
? dev-libs/gdl2/Testing.tar.gz
Index: dev-libs/gdl2/ChangeLog
===================================================================
RCS file: /cvsroot/gnustep/gnustep/dev-libs/gdl2/ChangeLog,v
retrieving revision 1.30
diff -u -r1.30 ChangeLog
--- dev-libs/gdl2/ChangeLog     21 Jan 2003 18:09:52 -0000      1.30
+++ dev-libs/gdl2/ChangeLog     27 Jan 2003 12:38:38 -0000
@@ -1,3 +1,18 @@
+2003-01-27  David Ayers <d.ayers@inode.at>
+
+       * EOAccess/EODatabaseContext.m
+       * EOAccess/EODatabaseChannel.m:
+       Move registration for EODatabaseChannelNeddedNotification from
+       +load to +initialize.
+
+       * EOControl/EOFetchSpecification.m
+       * EOControl/EOGlobalID.m:
+       Insure that EODatabaseContext is initialized early.
+
+       * EOControl/EOQualifier.m ([EOQualifier
+       +operatorSelectorForString:]): Parse 'doesContain' instead of
+       'contains'.
+       
 2003-01-21  David Ayers <d.ayers@inode.at>
 
        * EOControl/EOQualifier.m ([EOQualifier +allQualifierOperators]): 
Index: dev-libs/gdl2/EOAccess/EODatabaseChannel.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/dev-libs/gdl2/EOAccess/EODatabaseChannel.m,v
retrieving revision 1.4
diff -u -r1.4 EODatabaseChannel.m
--- dev-libs/gdl2/EOAccess/EODatabaseChannel.m  31 Dec 2002 16:24:40 -0000      
1.4
+++ dev-libs/gdl2/EOAccess/EODatabaseChannel.m  27 Jan 2003 12:38:39 -0000
@@ -68,13 +68,16 @@
 
 @implementation EODatabaseChannel
 
-+ (void)load
++ (void)initialize
 {
-  [[NSNotificationCenter defaultCenter]
-    addObserver: self
-    selector: @selector(_registerDatabaseChannel:)
-    name: EODatabaseChannelNeededNotification
-    object: nil];
+  if (self == [EODatabaseChannel class])
+    {
+      [[NSNotificationCenter defaultCenter]
+       addObserver: self
+       selector: @selector(_registerDatabaseChannel:)
+       name: EODatabaseChannelNeededNotification
+       object: nil];
+    }
 }
 
 + (void)_registerDatabaseChannel: (NSNotification *)notification
Index: dev-libs/gdl2/EOAccess/EODatabaseContext.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/dev-libs/gdl2/EOAccess/EODatabaseContext.m,v
retrieving revision 1.12
diff -u -r1.12 EODatabaseContext.m
--- dev-libs/gdl2/EOAccess/EODatabaseContext.m  31 Dec 2002 16:24:40 -0000      
1.12
+++ dev-libs/gdl2/EOAccess/EODatabaseContext.m  27 Jan 2003 12:38:40 -0000
@@ -104,19 +104,17 @@
 
 static Class _contextClass = Nil;
 
-+ (void)load
-{
-  [[NSNotificationCenter defaultCenter]
-    addObserver: self
-    selector: @selector(_registerDatabaseContext:)
-    name: EOCooperatingObjectStoreNeeded
-    object: nil];
-}
-
 + (void)initialize
 {
   if (!_contextClass)
+  {
     _contextClass = [EODatabaseContext class];
+    [[NSNotificationCenter defaultCenter]
+      addObserver: self
+      selector: @selector(_registerDatabaseContext:)
+      name: EOCooperatingObjectStoreNeeded
+      object: nil];
+  }
 }
 
 + (EODatabaseContext*)databaseContextWithDatabase: (EODatabase *)database
Index: dev-libs/gdl2/EOControl/EOFetchSpecification.m
===================================================================
RCS file: 
/cvsroot/gnustep/gnustep/dev-libs/gdl2/EOControl/EOFetchSpecification.m,v
retrieving revision 1.4
diff -u -r1.4 EOFetchSpecification.m
--- dev-libs/gdl2/EOControl/EOFetchSpecification.m      31 Dec 2002 16:25:10 
-0000      1.4
+++ dev-libs/gdl2/EOControl/EOFetchSpecification.m      27 Jan 2003 12:38:40 
-0000
@@ -49,6 +49,14 @@
 
 @implementation EOFetchSpecification
 
++ (void)initialize
+{
+  if (self == [EOFetchSpecification class])
+    {
+      [EODatabaseContext class];  /* Insure correct initialization. */
+    }
+}
+
 + (EOFetchSpecification *)fetchSpecification
 {
   return [[[self alloc] init] autorelease];
Index: dev-libs/gdl2/EOControl/EOGlobalID.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/dev-libs/gdl2/EOControl/EOGlobalID.m,v
retrieving revision 1.4
diff -u -r1.4 EOGlobalID.m
--- dev-libs/gdl2/EOControl/EOGlobalID.m        31 Dec 2002 16:25:10 -0000      
1.4
+++ dev-libs/gdl2/EOControl/EOGlobalID.m        27 Jan 2003 12:38:40 -0000
@@ -50,6 +50,14 @@
 
 @implementation EOGlobalID
 
++ (void)initialize
+{
+  if (self == [EOGlobalID class])
+    {
+      [EODatabaseContext class]; /* Insure correct initialization. */
+    }
+}
+
 - (BOOL)isEqual: other
 {
   return NO;
Index: dev-libs/gdl2/EOControl/EOQualifier.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/dev-libs/gdl2/EOControl/EOQualifier.m,v
retrieving revision 1.6
diff -u -r1.6 EOQualifier.m
--- dev-libs/gdl2/EOControl/EOQualifier.m       21 Jan 2003 18:10:00 -0000      
1.6
+++ dev-libs/gdl2/EOControl/EOQualifier.m       27 Jan 2003 12:38:41 -0000
@@ -695,7 +695,7 @@
     return EOQualifierOperatorNotEqual;
   else if ([string isEqualToString: @"!="])
     return EOQualifierOperatorNotEqual;
-  else if ([string isEqualToString: @"contains"])
+  else if ([string isEqualToString: @"doesContain"])
     return EOQualifierOperatorContains;
   else if ([string isEqualToString: @"like"])
     return EOQualifierOperatorLike;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]