Re: calling functions generically

Ignacio Castaño <[email protected]>
Newsgroups gmane.games.devel.general
Message-ID <[email protected]>
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
[email protected]


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Gamedevlists-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=557
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.