From 4eb7f0dbdf20c28b1b0b8e3b487576aba6c4f4c6 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Sun, 15 Jan 2006 05:24:16 +0000 Subject: [PATCH] Add method for passing one BOOL. Unlike NSObject's performSelector, an NSInvocation does not make any attempt to translate arguments. It just copies from the buffer passed to addArgument:atIndex: the size of paramter specified. A BOOL is one byte (as opposed to a _Bool bool, or boolean_t which are four bytes...) so it was copying just one byte of the address of the NSNumber object and invoking it with that. --- stepmania/src/archutils/Darwin/SMMainThread.h | 4 ++++ stepmania/src/archutils/Darwin/SMMainThread.m | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/stepmania/src/archutils/Darwin/SMMainThread.h b/stepmania/src/archutils/Darwin/SMMainThread.h index 0e2209dd02..543f814c64 100644 --- a/stepmania/src/archutils/Darwin/SMMainThread.h +++ b/stepmania/src/archutils/Darwin/SMMainThread.h @@ -9,6 +9,7 @@ - (void) dealloc; - (void) addAction:(SEL)sel withTarget:(id)target; - (void) addAction:(SEL)sel withTarget:(id)target andObject:(id)object; +- (void) addAction:(SEL)sel withTarget:(id)target andBool:(BOOL)b; // You must pass pointers to the objects to this method. - (void) addAction:(SEL)sel withTarget:(id)target andNumObjects:(int)num, ...; - (void) performOnMainThread; @@ -16,6 +17,9 @@ #define ADD_ACTION0(mt, t, s) [mt addAction:@selector(s) withTarget:(t)] #define ADD_ACTION1(mt, t, s, o) [mt addAction:@selector(s) withTarget:(t) andObject:(o)] +#define ADD_ACTIONb(mt, t, s, b) [mt addAction:@selector(s) withTarget:(t) andBool:(b)] +#define ADD_ACTIONn(mt, t, s, n, ...) \ +[mt addAction:@selector(s) withTarget:(t) andNumObjects:(n), ## __VA_ARGS__] /* * (c) 2006 Steve Checkoway diff --git a/stepmania/src/archutils/Darwin/SMMainThread.m b/stepmania/src/archutils/Darwin/SMMainThread.m index 7da7054238..aa4282cebf 100644 --- a/stepmania/src/archutils/Darwin/SMMainThread.m +++ b/stepmania/src/archutils/Darwin/SMMainThread.m @@ -36,6 +36,11 @@ [self addAction:sel withTarget:target andNumObjects:1, &object]; } +- (void) addAction:(SEL)sel withTarget:(id)target andBool:(BOOL)b +{ + [self addAction:sel withTarget:target andNumObjects:1, &b]; +} + - (void) addAction:(SEL)sel withTarget:(id)target andNumObjects:(int)num, ... { NSMethodSignature *sig = [target methodSignatureForSelector:sel];