mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
crude KVO setter for structs
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35324 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
27a33dbedb
commit
e6c15aef54
8 changed files with 156 additions and 45 deletions
|
@ -44,6 +44,10 @@
|
|||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
#import "GSInvocation.h"
|
||||
|
||||
#if defined(USE_LIBFFI)
|
||||
#import "cifframe.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* IMPLEMENTATION NOTES
|
||||
*
|
||||
|
@ -385,6 +389,38 @@ replacementForClass(Class c)
|
|||
return r;
|
||||
}
|
||||
|
||||
#if defined(USE_LIBFFI)
|
||||
static void
|
||||
cifframe_callback(ffi_cif *cif, void *retp, void **args, void *user)
|
||||
{
|
||||
id obj;
|
||||
SEL sel;
|
||||
NSString *key;
|
||||
Class c;
|
||||
void (*imp)(id,SEL,void*);
|
||||
|
||||
obj = *(id *)args[0];
|
||||
sel = *(SEL *)args[1];
|
||||
c = [obj class];
|
||||
|
||||
imp = (void (*)(id,SEL,void*))[c instanceMethodForSelector: sel];
|
||||
key = newKey(sel);
|
||||
if ([c automaticallyNotifiesObserversForKey: key] == YES)
|
||||
{
|
||||
// pre setting code here
|
||||
[obj willChangeValueForKey: key];
|
||||
ffi_call(cif, imp, retp, args);
|
||||
// post setting code here
|
||||
[obj didChangeValueForKey: key];
|
||||
}
|
||||
else
|
||||
{
|
||||
ffi_call(cif, imp, retp, args);
|
||||
}
|
||||
RELEASE(key);
|
||||
}
|
||||
#endif
|
||||
|
||||
@implementation GSKVOReplacement
|
||||
- (void) dealloc
|
||||
{
|
||||
|
@ -557,7 +593,15 @@ replacementForClass(Class c)
|
|||
}
|
||||
else
|
||||
{
|
||||
#if defined(USE_LIBFFI)
|
||||
GSCodeBuffer *b;
|
||||
|
||||
b = cifframe_closure(sig, cifframe_callback);
|
||||
[b retain];
|
||||
imp = [b executable];
|
||||
#else
|
||||
imp = 0;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue