aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorcomex2015-01-16 07:46:57 -0500
committercomex2015-01-16 07:46:57 -0500
commit060ea96bccec1926aa0b91357191734d1a5cc738 (patch)
tree6f6ea3aac4aedca3605de51e762a5c7f4c01b221 /test
parentand now for something completely different: assembly maybestret-IMPL (diff)
downloadsubstitute-060ea96bccec1926aa0b91357191734d1a5cc738.tar.gz
this is all wrong.
since we don't know whether it's stret, we don't mark the block stret. thus imp_implementationWithBlock doesn't do the stret/block swap, even though it would for a real block, so we can and must always assume the block is first
Diffstat (limited to 'test')
-rw-r--r--test/test-imp-forwarding.m15
1 files changed, 12 insertions, 3 deletions
diff --git a/test/test-imp-forwarding.m b/test/test-imp-forwarding.m
index da2ece2..e7bff27 100644
--- a/test/test-imp-forwarding.m
+++ b/test/test-imp-forwarding.m
@@ -1,9 +1,10 @@
#include "../lib/objc.c"
#include <objc/runtime.h>
#include <stdio.h>
+#import <Foundation/Foundation.h>
static void imp1(id self, SEL sel, int a, int b) {
- printf("imp1: self=%p sel=%s a=%d b=%d\n", self, sel_getName(sel), a, b);
+ NSLog(@"imp1: self=%@ sel=%s a=%d b=%d\n", self, sel_getName(sel), a, b);
}
struct big {
@@ -11,16 +12,24 @@ struct big {
};
static struct big imp2(id self, SEL sel, int a, int b) {
- printf("imp2: self=%p sel=%s a=%d b=%d\n", self, sel_getName(sel), a, b);
+ NSLog(@"imp2: self=%@ sel=%s a=%d b=%d\n", self, sel_getName(sel), a, b);
return (struct big) {{0}};
}
+struct big (^test)(id, int) = ^(id self, int a) {
+ NSLog(@"self=%@ a=%d", self, a);
+ return (struct big) {{0}};
+};
+
int main() {
+ IMP testi = imp_implementationWithBlock(test);
+ ((struct big (*)(id, SEL, int)) testi)(@"test", @selector(dumb), 5);
IMP old = (IMP) imp1;
SEL sel = @selector(some);
struct temp_block_literal temp_block = get_temp_block(&old, sel);
IMP new = imp_implementationWithBlock((id) &temp_block);
((void (*)(id, SEL, int, int)) new)(@"foo", sel, 1, 2);
old = (IMP) imp2;
- ((struct big (*)(id, SEL, int, int)) new)(@"bar", sel, 1, 2);
+ struct big big = ((struct big (*)(id, SEL, int, int)) new)(@"bar", sel, 1, 2);
+ printf("out? %d\n", big.x[0]);
}