http://bbs.youkuaiyun.com/topics/10251675
查看九楼zdhe的回复。
a function call like following
p->func(100); // it will return nothing.
in C++ will be compiled to like following
push 64h //push parameter one by one. c++ always use ESP to pass parameter, because ECX is used for
//THIS pointer. there is no fastcall standard for C++
mov edx,p
mov eax,dword ptr [edx] //save vtable to eax
mov ecx,p // __this call standard ask compiler to save class poiner to ecx.
call dword ptr [eax+4] //it's func1 address, if must func, maybe [eax + 8],....
Have you got any idea?
so before get pointer , just do like following:
wait a common test func and see asmemble code ( for pi->play) , you will know shift
[eax + n] (n is waht you want .)
COM interface make sure this number will never change any more(else the caller program need rebuild ..hehe)
so
_asm{
mov edx,pi
mov eax,dword ptr [edx]
mov eax , [eax + n] //n is fix for you know.
}
then here, eax hold you p->Play ....
从汇编语言层面上证明了不可能直接进行转换。
不过boost::function 和 boost::bind 到底是怎么做到的需要追寻一下源码实现。