import_interim_byref.c [plain text]
#include "driver.h"
#if __BLOCKS__
int import_byref_interim_real(int verbose) {
int x = rand();
int y = 15;
void (^myClosure)(void) = ^ (void) { | y | setGlobalInt(x+y); ++y;};
x++;
callVoidVoid(myClosure);
int globalValue = getGlobalInt();
int desiredValue = x+y-2;
if (error_found("import_byref_interim", globalValue, desiredValue, verbose)) return 1;
#if FULL_CLOSURES
void (^myClosureCopy)(void) = Block_copy(myClosure);
callVoidVoid(myClosureCopy);
globalValue = getGlobalInt();
if (error_found("import_byref_interim copy", globalValue, desiredValue, verbose)) return 1;
Block_release(myClosureCopy);
#endif
return 0;
}
#endif __BLOCKS__
struct import_byref_interim_struct {
struct Block_basic base;
const int x;
int *py;
};
void invoke_import_byref_interim(struct import_byref_interim_struct *aBlock) {
{
setGlobalInt(aBlock->x + *aBlock->py);
++*aBlock->py;
}
}
int import_byref_interim(int verbose) {
int x = rand();
int y = 15;
struct import_byref_interim_struct myClosure = {
{ 0, BLOCK_NO_COPY, sizeof(struct import_byref_interim_struct),
(void (*)(void *))invoke_import_byref_interim,
},
x, &y };
x++;
callVoidVoid(&myClosure.base);
int globalValue = getGlobalInt();
int desiredValue = x+y-2;
if (error_found("import_byref_interim", globalValue, desiredValue, verbose)) return 1;
#if FULL_CLOSURES
struct import_byref_interim_struct *myClosureCopy = Block_copy(&myClosure.base);
callVoidVoid(&myClosureCopy->base);
globalValue = getGlobalInt();
if (error_found("import_byref_interim copy", globalValue, desiredValue, verbose)) return 1;
Block_release(myClosureCopy);
#endif
return 0;
}