Re: [GD-General] calling functions generically
Brought to you by:
vexxed72
From: <cas...@ya...> - 2004-02-14 03:10:22
|
Brett Bibby wrote: > I'm trying to write a generic function calling program such that I > can take a parameter list and the address of a function and build the > call dynamically at runtime on Windows, GameCube and PS2. I have an > array of input and output codes so I know the types and order of > parameters to use for the call, and what (if any) the return value > is. I'm starting with Windows first, and using CodeWarrior for all > platforms. I wrote a small example of a generic function caller for lua 4.0, it's not optimized, but seems works fine: http://lua-users.org/wiki/LuaDeclare If I recall correctly there is a good explanation about the different calling conventions on the msdn. However, it seems that different compilers implement the calling conventions in different ways. In most cases it works as follows: Small results are usually returned in eax:edx. Floating point results are left at the top of the stack. Bigger structures are not returned on the stack, instead of that, a pointer to the structure is pushed as a hidden argument and the result is copied there. Hope that helps. -- Ignacio Castaño cas...@ya... |