block-pointer-type.C [plain text]
void * _NSConcreteStackBlock;
#ifndef _BLOCK_PRIVATE_H_
#define _BLOCK_PRIVATE_H_
enum {
BLOCK_NEEDS_FREE = (1 << 24),
BLOCK_HAS_COPY_DISPOSE = (1 << 25),
BLOCK_NO_COPY = (1 << 26), BLOCK_IS_GC = (1 << 27),
};
struct Block_basic {
long reserved;
int Block_flags; int Block_size; void (*Block_invoke)(void *);
void (*Block_copy)(void *dst, void *src);
void (*Block_dispose)(void *);
};
struct Block_byref {
long reserved;
struct Block_byref *forwarding;
int refcount;
int size;
void (*byref_keep)(struct Block_byref *dst, struct Block_byref *src);
void (*byref_destroy)(struct Block_byref *);
};
void Block_destroy_byref(struct Block_byref *shared_struct);
struct Block_byref *Block_share_byref(struct Block_byref *shared_struct);
int Block_size(struct Block_basic *aBlock);
void _Block_set_allocator_pair(void *(*alloc)(const unsigned long), void (*dealloc)(const void *));
#endif
int GlobalInt;
void setGlobalInt(int value) { GlobalInt = value; }
int getGlobalInt() { int tmp = GlobalInt; GlobalInt = 0; return tmp; }
#if __BLOCKS__
int parameters_example_real(int verbose) {
int desiredValue = 100;
void (^myBlock)(int);
myBlock = ^ (int param) {
setGlobalInt(param);
};
myBlock(desiredValue);
int globalValue = getGlobalInt();
return 0;
}
#endif __BLOCKS__
struct parameters_example_struct {
struct Block_basic base;
};
void invoke_parameters_example(struct parameters_example_struct *aBlock, int param) {
{
setGlobalInt(param);
}
}
int parameters_example(int verbose) {
int desiredValue = 100;
struct parameters_example_struct literal = {
{ 0, 0, sizeof(struct parameters_example_struct),
(void (*)(void *))invoke_parameters_example,
},
};
struct parameters_example_struct *myBlock = &literal;
void (*correct)(struct parameters_example_struct *, int);
correct = (void (*)(struct parameters_example_struct *, int))myBlock->base.Block_invoke;
correct(myBlock, desiredValue);
return 0;
}
int main(int argc, char *argv[]) { parameters_example(1); return 0; }