mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
patch for kvo struct setters by Eric Wasylishen
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28793 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6bf3a906e9
commit
3e76492092
2 changed files with 130 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2009-10-11 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
|
* Source/NSKeyValueObserving.m: add setters for common structures.
|
||||||
|
|
||||||
2009-10-10 Richard Frith-Macdonald <rfm@gnu.org>
|
2009-10-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Headers/Foundation/NSString.h:
|
* Headers/Foundation/NSString.h:
|
||||||
|
|
|
@ -132,6 +132,10 @@ static inline void setup()
|
||||||
- (void) setterLongLong: (unsigned long long)val;
|
- (void) setterLongLong: (unsigned long long)val;
|
||||||
#endif
|
#endif
|
||||||
- (void) setterShort: (unsigned short)val;
|
- (void) setterShort: (unsigned short)val;
|
||||||
|
- (void) setterRange: (NSRange)val;
|
||||||
|
- (void) setterPoint: (NSPoint)val;
|
||||||
|
- (void) setterSize: (NSSize)val;
|
||||||
|
- (void) setterRect: (NSRect)rect;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/* An instance of this records all the information for a single observation.
|
/* An instance of this records all the information for a single observation.
|
||||||
|
@ -533,6 +537,32 @@ replacementForClass(Class c)
|
||||||
imp = [[GSKVOSetter class]
|
imp = [[GSKVOSetter class]
|
||||||
instanceMethodForSelector: @selector(setter:)];
|
instanceMethodForSelector: @selector(setter:)];
|
||||||
break;
|
break;
|
||||||
|
case _C_STRUCT_B:
|
||||||
|
if (strcmp(@encode(NSRange), type) == 0)
|
||||||
|
{
|
||||||
|
imp = [[GSKVOSetter class]
|
||||||
|
instanceMethodForSelector: @selector(setterRange:)];
|
||||||
|
}
|
||||||
|
else if (strcmp(@encode(NSPoint), type) == 0)
|
||||||
|
{
|
||||||
|
imp = [[GSKVOSetter class]
|
||||||
|
instanceMethodForSelector: @selector(setterPoint:)];
|
||||||
|
}
|
||||||
|
else if (strcmp(@encode(NSSize), type) == 0)
|
||||||
|
{
|
||||||
|
imp = [[GSKVOSetter class]
|
||||||
|
instanceMethodForSelector: @selector(setterSize:)];
|
||||||
|
}
|
||||||
|
else if (strcmp(@encode(NSRect), type) == 0)
|
||||||
|
{
|
||||||
|
imp = [[GSKVOSetter class]
|
||||||
|
instanceMethodForSelector: @selector(setterRect:)];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imp = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
imp = 0;
|
imp = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -801,6 +831,102 @@ replacementForClass(Class c)
|
||||||
}
|
}
|
||||||
RELEASE(key);
|
RELEASE(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setterRange: (NSRange)val
|
||||||
|
{
|
||||||
|
NSString *key;
|
||||||
|
Class c = [self class];
|
||||||
|
void (*imp)(id,SEL,NSRange);
|
||||||
|
|
||||||
|
imp = (void (*)(id,SEL,NSRange))[c instanceMethodForSelector: _cmd];
|
||||||
|
|
||||||
|
key = newKey(_cmd);
|
||||||
|
if ([c automaticallyNotifiesObserversForKey: key] == YES)
|
||||||
|
{
|
||||||
|
// pre setting code here
|
||||||
|
[self willChangeValueForKey: key];
|
||||||
|
(*imp)(self, _cmd, val);
|
||||||
|
// post setting code here
|
||||||
|
[self didChangeValueForKey: key];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(*imp)(self, _cmd, val);
|
||||||
|
}
|
||||||
|
RELEASE(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setterPoint: (NSPoint)val
|
||||||
|
{
|
||||||
|
NSString *key;
|
||||||
|
Class c = [self class];
|
||||||
|
void (*imp)(id,SEL,NSPoint);
|
||||||
|
|
||||||
|
imp = (void (*)(id,SEL,NSPoint))[c instanceMethodForSelector: _cmd];
|
||||||
|
|
||||||
|
key = newKey(_cmd);
|
||||||
|
if ([c automaticallyNotifiesObserversForKey: key] == YES)
|
||||||
|
{
|
||||||
|
// pre setting code here
|
||||||
|
[self willChangeValueForKey: key];
|
||||||
|
(*imp)(self, _cmd, val);
|
||||||
|
// post setting code here
|
||||||
|
[self didChangeValueForKey: key];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(*imp)(self, _cmd, val);
|
||||||
|
}
|
||||||
|
RELEASE(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setterSize: (NSSize)val
|
||||||
|
{
|
||||||
|
NSString *key;
|
||||||
|
Class c = [self class];
|
||||||
|
void (*imp)(id,SEL,NSSize);
|
||||||
|
|
||||||
|
imp = (void (*)(id,SEL,NSSize))[c instanceMethodForSelector: _cmd];
|
||||||
|
|
||||||
|
key = newKey(_cmd);
|
||||||
|
if ([c automaticallyNotifiesObserversForKey: key] == YES)
|
||||||
|
{
|
||||||
|
// pre setting code here
|
||||||
|
[self willChangeValueForKey: key];
|
||||||
|
(*imp)(self, _cmd, val);
|
||||||
|
// post setting code here
|
||||||
|
[self didChangeValueForKey: key];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(*imp)(self, _cmd, val);
|
||||||
|
}
|
||||||
|
RELEASE(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setterRect: (NSRect)val
|
||||||
|
{
|
||||||
|
NSString *key;
|
||||||
|
Class c = [self class];
|
||||||
|
void (*imp)(id,SEL,NSRect);
|
||||||
|
|
||||||
|
imp = (void (*)(id,SEL,NSRect))[c instanceMethodForSelector: _cmd];
|
||||||
|
|
||||||
|
key = newKey(_cmd);
|
||||||
|
if ([c automaticallyNotifiesObserversForKey: key] == YES)
|
||||||
|
{
|
||||||
|
// pre setting code here
|
||||||
|
[self willChangeValueForKey: key];
|
||||||
|
(*imp)(self, _cmd, val);
|
||||||
|
// post setting code here
|
||||||
|
[self didChangeValueForKey: key];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(*imp)(self, _cmd, val);
|
||||||
|
}
|
||||||
|
RELEASE(key);
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue