/* #pragma pseudocode */
typedef void (*ARRAY_PUSH)(void*);
typedef struct _Node
{
struct _Node *next;
struct _Node *prev;
void *data;
}NODE, *PNODE;
typedef struct _Array
{
ARRAY_PUSH push_back;
ARRAY_PUSH push_front;
PNODE head;
PNODE tail;
}ARRAY, *PARRAY;
void array_pushb(void *data)
{
PARRAY array;
PNODE newnode;
/* And here's some inline assembler */
_asm("movl %edi, %array");
array->head->next = malloc(sizeof(NODE);
/* Yadda, yadda, yadda */
}
PARRAY array_init()
{
PARRAY array = malloc(sizeof(ARRAY));
array->push_back = array_pushb;
/* More init code here... */
return array;
}
It's easy to write a linked list (this is a indexed double linked list with a twist PARRAY mesh_array = array_init(); mesh_array->push_back(ONE_MILLION_POLLIES_MESH_WITH_BIG_BOOBS); PMESH mesh = (PMESH)mesh_array->get(index);In Lcc Win32, it's extremely easy as it saves the address of the struct calling the function via the function pointer in the edi register, so it's a simple thing to extract it and make a fake 'this' pointer.. But I've been trying to figure out how to do the same trick with GCC (and more lately the Visual Toolkit) as I guess that those compilers might be able to outrun Lcc's optimiz.. optimizations... opti..WAAHHH! Don't now how to spell that, you gotta figure thatone out yourself. I've read the GCC online docs, but I might be stupid as hell, cause I can't figure out how to do this. Anyone who can point me in the right direction?? "For every complex problem there is an answer that is clear, simple, and wrong." H L Mencken [edited by - Rickmeister on May 31, 2004 7:51:52 PM]