mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-02-21 02:20:55 +00:00
* EOControl/EOKeyValueCoding.h/m: Rewritten and documented.
Declared and documented EOKeyValueCoding categories currently implemented by gnustep-base/Foundation in NSKeyValueCoding. Removed FOUNDATION_HAS_KVC conditionals as gnustep-base/Foundation implement NSKeyValueCoding. (-[NSObject takeStoredValuesFromDictionary:]): Added declaration reportedly missing in Apple's headers to compelte EOKeyValueCoding declarations. Most implementations rewritten. * EOControl/EONull.h/m: Define EONull to NSNull to allow pointer equality checks. Implement EONull as NSNull subclass that returns the NSNull instance. Remove old assertions. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@17534 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9238fc1a32
commit
894f3554ac
5 changed files with 823 additions and 558 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2003-08-23 David Ayers <d.ayers@inode.at>
|
||||
|
||||
* EOControl/EOKeyValueCoding.h/m: Rewritten and documented.
|
||||
Declared and documented EOKeyValueCoding categories currently
|
||||
implemented by gnustep-base/Foundation in NSKeyValueCoding.
|
||||
Removed FOUNDATION_HAS_KVC conditionals as gnustep-base/Foundation
|
||||
implement NSKeyValueCoding.
|
||||
(-[NSObject takeStoredValuesFromDictionary:]): Added declaration
|
||||
reportedly missing in Apple's headers to compelte EOKeyValueCoding
|
||||
declarations.
|
||||
Most implementations rewritten.
|
||||
|
||||
* EOControl/EONull.h/m: Define EONull to NSNull to allow pointer
|
||||
equality checks. Implement EONull as NSNull subclass that returns
|
||||
the NSNull instance. Remove old assertions.
|
||||
|
||||
2003-07-11 David Ayers <d.ayers@inode.at>
|
||||
|
||||
* *.m: Include GNUstep.h if GNUSTEP is not defined for OS X.
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
Author: Mirko Viviani <mirko.viviani@rccr.cremona.it>
|
||||
Date: February 2000
|
||||
|
||||
Modified: David Ayers <d.ayers@inode.at>
|
||||
Date: February 2003
|
||||
|
||||
This file is part of the GNUstep Database Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
|
@ -36,34 +39,109 @@
|
|||
#include <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#include <EOControl/EODefines.h>
|
||||
#include "EODefines.h"
|
||||
|
||||
/**
|
||||
* GDL2 aims to be compatible with EOF of WebObjects 4.5 and expects to be
|
||||
* compiled with gnustep-base or the current version Foundation of Mac OS X
|
||||
* together with gnustep-baseadd, the Additions subproject of gnustep-base.
|
||||
* As many of the EOKeyValueCoding methods have moved to NSKeyValueCoding,
|
||||
* GDL2 merely implements those methods which are not part of NSKeyValueCoding
|
||||
* or reimplements those methods to insure WebObjects 4.5 compatibility or
|
||||
* augment the behavior for GDL2 specific features.
|
||||
*/
|
||||
@interface NSObject (EOKeyValueCoding)
|
||||
|
||||
/**
|
||||
* Unimplemented here. Relies on NSKeyValueCoding.
|
||||
*/
|
||||
- (id)valueForKey: (NSString *)key;
|
||||
|
||||
/**
|
||||
* Unimplemented here. Relies on NSKeyValueCoding.
|
||||
*/
|
||||
- (void)takeValue: (id)value forKey: (NSString *)key;
|
||||
|
||||
/**
|
||||
* Unimplemented here. Relies on NSKeyValueCoding.
|
||||
*/
|
||||
- (id)storedValueForKey: (NSString *)key;
|
||||
|
||||
/**
|
||||
* Unimplemented here. Relies on NSKeyValueCoding.
|
||||
*/
|
||||
- (void)takeStoredValue: (id)value forKey: (NSString *)key;
|
||||
|
||||
|
||||
@interface NSObject (EOKVCPAdditions2)
|
||||
- (void)smartTakeValue: (id)anObject
|
||||
forKey: (NSString *)aKey;
|
||||
- (void)smartTakeValue: (id)anObject
|
||||
forKeyPath: (NSString *)aKeyPath;
|
||||
- (void)takeStoredValue: value
|
||||
forKeyPath: (NSString *)key;
|
||||
- (id)storedValueForKeyPath: (NSString *)key;
|
||||
#if !FOUNDATION_HAS_KVC
|
||||
- (void)takeStoredValuesFromDictionary: (NSDictionary *)dictionary;
|
||||
#endif
|
||||
- (NSDictionary *)valuesForKeyPaths: (NSArray *)keyPaths;
|
||||
- (NSDictionary *)storedValuesForKeyPaths: (NSArray *)keyPaths;
|
||||
/**
|
||||
* Unimplemented here. Relies on NSKeyValueCoding.
|
||||
*/
|
||||
+ (BOOL)accessInstanceVariablesDirectly;
|
||||
|
||||
/**
|
||||
* Unimplemented here. Relies on NSKeyValueCoding.
|
||||
*/
|
||||
+ (BOOL)useStoredAccessor;
|
||||
|
||||
|
||||
/**
|
||||
* Does nothing. Key bindings are currently not cached so there is no
|
||||
* need to flush them. This method exists for API compatibility.
|
||||
*/
|
||||
+ (void)flushAllKeyBindings;
|
||||
|
||||
|
||||
/**
|
||||
* Unimplemented here. Relies on NSKeyValueCoding.
|
||||
*/
|
||||
- (id)handleQueryWithUnboundKey: (NSString *)key;
|
||||
|
||||
/**
|
||||
* Unimplemented here. Relies on NSKeyValueCoding.
|
||||
*/
|
||||
- (void)handleTakeValue: (id)value forUnboundKey: (NSString *)key;
|
||||
|
||||
/**
|
||||
* This method is invoked by the EOKeyValueCoding mechanism when an attempt
|
||||
* is made to set an null value for a scalar attribute. This implementation
|
||||
* raises an NSInvalidArgument exception. <br/>
|
||||
* The NSKeyValueCoding -unableToSetNilForKey: is overriden to invoke this
|
||||
* method instead. We manipulate the runtime to insure that our implementation
|
||||
* of unableToSetNilForKey: is used in favor of the one in gnustep-base or
|
||||
* Foundation.
|
||||
*/
|
||||
- (void)unableToSetNullForKey: (NSString *)key;
|
||||
|
||||
@end
|
||||
|
||||
#if NeXT_Foundation_LIBRARY
|
||||
@interface NSObject (MacOSXRevealed)
|
||||
- (void)takeStoredValuesFromDictionary: (NSDictionary *)dictionary;
|
||||
@interface NSObject (EOKeyValueCodingAdditions)
|
||||
|
||||
/**
|
||||
* Unimplemented here. Relies on NSKeyValueCoding.
|
||||
*/
|
||||
- (id)valueForKeyPath: (NSString *)keyPath;
|
||||
|
||||
/**
|
||||
* Unimplemented here. Relies on NSKeyValueCoding.
|
||||
*/
|
||||
- (void)takeValue: (id)value forKeyPath: (NSString *)keyPath;
|
||||
|
||||
/**
|
||||
* Unimplemented here. Relies on NSKeyValueCoding.
|
||||
*/
|
||||
- (NSDictionary *)valuesForKeys: (NSArray *)keys;
|
||||
|
||||
/**
|
||||
* Unimplemented here. Relies on NSKeyValueCoding.
|
||||
*/
|
||||
- (void)takeValuesFromDictionary: (NSDictionary *)dictionary;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
||||
@interface NSArray (EOKeyValueCoding)
|
||||
- (id)valueForKey: (NSString *)key;
|
||||
- (id)valueForKeyPath: (NSString *)keyPath;
|
||||
|
||||
- (id)computeSumForKey: (NSString *)key;
|
||||
- (id)computeAvgForKey: (NSString *)key;
|
||||
- (id)computeCountForKey: (NSString *)key;
|
||||
|
@ -72,22 +150,56 @@
|
|||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
#if !FOUNDATION_HAS_KVC
|
||||
@interface NSDictionary (EOKeyValueCoding)
|
||||
/*
|
||||
* Overrides gnustep-base and Foundations implementation.
|
||||
* See documentation or source file for details on how it differs.
|
||||
*/
|
||||
- (id)valueForKey: (NSString *)key;
|
||||
- (id)storedValueForKey: (NSString *)key;
|
||||
- (id)valueForKeyPath: (NSString *)keyPath;
|
||||
- (id)storedValueForKeyPath: (NSString*)keyPath;
|
||||
@end
|
||||
|
||||
|
||||
@interface NSMutableDictionary (EOKeyValueCoding)
|
||||
/*
|
||||
* Overrides gnustep-base and Foundations implementation.
|
||||
* See documentation or source file for details on how it differs.
|
||||
*/
|
||||
- (void)takeValue: (id)value
|
||||
forKey: (NSString*)key;
|
||||
@end
|
||||
#endif
|
||||
|
||||
|
||||
@interface NSObject (EOKVCGDL2Additions)
|
||||
/* These are hooks for EOGenericRecord KVC implementaion. */
|
||||
- (void)smartTakeValue: (id)anObject
|
||||
forKey: (NSString *)aKey;
|
||||
- (void)smartTakeValue: (id)anObject
|
||||
forKeyPath: (NSString *)aKeyPath;
|
||||
|
||||
- (void)takeStoredValue: value
|
||||
forKeyPath: (NSString *)key;
|
||||
- (id)storedValueForKeyPath: (NSString *)key;
|
||||
|
||||
- (NSDictionary *)valuesForKeyPaths: (NSArray *)keyPaths;
|
||||
- (NSDictionary *)storedValuesForKeyPaths: (NSArray *)keyPaths;
|
||||
@end
|
||||
|
||||
|
||||
#define EOUnknownKeyException NSUnknownKeyException;
|
||||
GDL2CONTROL_EXPORT NSString *EOTargetObjectUserInfoKey;
|
||||
GDL2CONTROL_EXPORT NSString *EOUnknownUserInfoKey;
|
||||
|
||||
/*
|
||||
* The following declaration is reportedly missing in Apple's headers,
|
||||
* yet are implemented.
|
||||
*/
|
||||
#if NeXT_Foundation_LIBRARY
|
||||
@interface NSObject (MacOSX)
|
||||
- (void)takeStoredValuesFromDictionary: (NSDictionary *)dictionary;
|
||||
@end
|
||||
#endif
|
||||
|
||||
#endif /* __EOKeyValueCoding_h__ */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -28,20 +28,22 @@
|
|||
#define __EONull_h__
|
||||
|
||||
#ifndef NeXT_Foundation_LIBRARY
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSNull.h>
|
||||
#else
|
||||
#include <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#include <EOControl/EODefines.h>
|
||||
#include "EODefines.h"
|
||||
|
||||
@interface EONull : NSObject <NSCopying>
|
||||
/* Type is ommited to avoid compiler warnings
|
||||
triggerd by NSNull. */
|
||||
+ null;
|
||||
@end /* EONull */
|
||||
@class NSString;
|
||||
|
||||
@interface NSObject (EONull)
|
||||
#define EONull NSNull
|
||||
|
||||
@interface EONull (EOSQLFormatting)
|
||||
- (NSString *)sqlString;
|
||||
@end
|
||||
|
||||
@interface NSObject (EONullTest)
|
||||
- (BOOL)isEONull;
|
||||
- (BOOL)isNotEONull;
|
||||
@end
|
||||
|
@ -49,3 +51,4 @@
|
|||
GDL2CONTROL_EXPORT BOOL isNilOrEONull(id v);
|
||||
|
||||
#endif /* __EONull_h__ */
|
||||
|
||||
|
|
|
@ -39,10 +39,7 @@
|
|||
RCS_ID("$Id$")
|
||||
|
||||
#ifndef NeXT_Foundation_LIBRARY
|
||||
#include <Foundation/NSNull.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#else
|
||||
#include <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
@ -55,74 +52,7 @@ RCS_ID("$Id$")
|
|||
#include <EOControl/EODebug.h>
|
||||
|
||||
|
||||
@implementation EONull
|
||||
|
||||
static EONull *sharedEONull = nil;
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
sharedEONull = (EONull *)[NSNull null];
|
||||
}
|
||||
|
||||
+ null
|
||||
{
|
||||
return sharedEONull;
|
||||
}
|
||||
|
||||
+ (id) allocWithZone:(NSZone *)zone
|
||||
{
|
||||
return sharedEONull;
|
||||
}
|
||||
|
||||
- (id) copy
|
||||
{
|
||||
NSAssert1(NO,@"EONull instance received:%@",NSStringFromSelector(_cmd));
|
||||
return sharedEONull;
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone *)zone
|
||||
{
|
||||
NSAssert1(NO,@"EONull instance received:%@",NSStringFromSelector(_cmd));
|
||||
return sharedEONull;
|
||||
}
|
||||
|
||||
- (id) retain
|
||||
{
|
||||
NSAssert1(NO,@"EONull instance received:%@",NSStringFromSelector(_cmd));
|
||||
return sharedEONull;
|
||||
}
|
||||
|
||||
- (id) autorelease
|
||||
{
|
||||
NSAssert1(NO,@"EONull instance received:%@",NSStringFromSelector(_cmd));
|
||||
return sharedEONull;
|
||||
}
|
||||
|
||||
- (void) release
|
||||
{
|
||||
NSAssert1(NO,@"EONull instance received:%@",NSStringFromSelector(_cmd));
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
NSAssert1(NO,@"EONull instance received:%@",NSStringFromSelector(_cmd));
|
||||
}
|
||||
|
||||
- (id)valueForKey: (NSString *)key
|
||||
{
|
||||
NSAssert1(NO,@"EONull instance received:%@",NSStringFromSelector(_cmd));
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString *) sqlString
|
||||
{
|
||||
NSAssert1(NO,@"EONull instance received:%@",NSStringFromSelector(_cmd));
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end /* EONull */
|
||||
|
||||
@implementation NSNull (EOSQLFormatting)
|
||||
@implementation EONull (EOSQLFormatting)
|
||||
|
||||
- (NSString *)sqlString
|
||||
{
|
||||
|
@ -145,7 +75,7 @@ static EONull *sharedEONull = nil;
|
|||
|
||||
- (BOOL)isEONull
|
||||
{
|
||||
return (((id)self) == sharedEONull || (((id)self) == [NSNull null]));
|
||||
return ((id)self == [NSNull null]);
|
||||
}
|
||||
|
||||
- (BOOL)isNotEONull
|
||||
|
@ -159,3 +89,35 @@ BOOL isNilOrEONull(id v)
|
|||
{
|
||||
return ((!v) || [v isEONull]);
|
||||
}
|
||||
|
||||
/*
|
||||
* We keep this class to support NSClassFromString() which
|
||||
* scripting libraries my depend on. Note that this is
|
||||
* not a fail-safe implementation. You should rely on
|
||||
* [EONull+null] and pointer comparison. Do not rely on
|
||||
* [obj isKindOfClass: NSClassFromString(@"EONull")]
|
||||
* or similar constructs. They will return wrong results.
|
||||
* This is a small backdraw from using the new extension classes
|
||||
* in base / Foundation.
|
||||
*/
|
||||
#undef EONull
|
||||
@interface EONull : NSNull
|
||||
@end
|
||||
@implementation EONull
|
||||
+ (Class) class
|
||||
{
|
||||
return [NSNull class];
|
||||
}
|
||||
|
||||
+ (id) allocWithZone: (NSZone *)zone
|
||||
{
|
||||
return [NSNull null];
|
||||
}
|
||||
|
||||
+ null
|
||||
{
|
||||
return [NSNull null];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in a new issue