Original Post
Heya, I'm currently working on some stuff for my engine which retrieves and stores functors for use in a scripting system. I'm coding in MSVC 7. Now, I know that different functors [read member functors] can have different sizes (either 4 or 8 bytes usually). Is there any way to store and retrieve pointers to member functions or pointers to global functions and not their parameters for use in assembly 'call' statements? Currently, I've got to have a big switch which calls the right function [an __asm{ call Foo::Bar }], but I'd like something a little bit easier to change. I've handled all of the parameters and return stuffs, and just need to actually store these call function pointers somewhere. So... is there a way to, for example make this code work [ie compile]... Kudos, CJM
#include <windows.h>
class Foo
{
public:
char Bar();
};
char Foo::Bar()
{
return '0';
}
class Class
{
public:
int Func();
};
int Class::Func()
{
return 211;
}
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
//need to be able to store address of Foo::Bar or Class::Func (and not parameters) in a variable
int(*funcPtr)(void)=0;
switch (0)
{
case 0:
funcPtr=reinterpret_cast<int(*)(void)>(&Foo::Bar);
break;
default:
funcPtr=reinterpret_cast<int(*)(void)>(&Class::Func);
break;
}
return 0;
}