1// 2// The LLVM Compiler Infrastructure 3// 4// This file is distributed under the University of Illinois Open Source 5// License. See LICENSE.TXT for details. 6 7// 8// byrefcopy.m 9// testObjects 10// 11// Created by Blaine Garst on 5/13/08. 12// 13 14#include <stdio.h> 15#include <Block.h> 16#include <Block_private.h> 17 18// CONFIG 19 20void callVoidVoid(void (^closure)(void)) { 21 closure(); 22} 23 24int main(int argc, char *argv[]) { 25 int __block i = 10; 26 27 void (^block)(void) = ^{ ++i; }; 28 //printf("original (old style) is %s\n", _Block_dump_old(block)); 29 //printf("original (new style) is %s\n", _Block_dump(block)); 30 void (^blockcopy)(void) = Block_copy(block); 31 //printf("copy is %s\n", _Block_dump(blockcopy)); 32 // use a copy & see that it updates i 33 callVoidVoid(block); 34 35 if (i != 11) { 36 printf("*** %s didn't update i\n", argv[0]); 37 return 1; 38 } 39 printf("%s: success\n", argv[0]); 40 return 0; 41} 42