RegisterGlobalFunction - calling convention?
When using RegisterGlobalFunction, how does one decide what calling convention to use? I understand the differences between calling conventions, I just don't understand why I need to specify what one to use, if all my code is being compiled the same...obviously I've missed something - can anyone point me in the right direction?
Cheers
Different kinds of functions are called different ways. Specifically, members have an invisible this pointer that's not in the function's signature, but still needs to be passed. OBJLAST is the bastard child of CDECL and THISCALL, and just tells AngelScript to stick that this pointer on the end of the parameter list instead of the beginning.
Incidentally, a global function is always going to use CDECL or GENERIC.
Incidentally, a global function is always going to use CDECL or GENERIC.
So is there a preference to use one over another? In your example, you said to stick 'this' at the end instead of the start. Why?
Cheers
Cheers
the compiler needs to know what object is going to be accessing it's own members, so instead of recreating the code per object, it adds the 'this' to the end of the call, and then, unknown to the coder, every access to an objects 'x' variable, becomes 'this->x' so that it knows who's 'x' to access. each calling convention has it's own set of rules that apply to it, which can be viewed here.
now, if I missed something here, or am incorrect about something, please inform me, because I don't really mess around with calling conventions often, and only have knowledge gained from reading about them.
hope it helps,
-Wynter Woods(aka Zerotri)
now, if I missed something here, or am incorrect about something, please inform me, because I don't really mess around with calling conventions often, and only have knowledge gained from reading about them.
hope it helps,
-Wynter Woods(aka Zerotri)
zerotri - thank you. Will check that link out.
I guess I still don't understand when a should declare a function I am exposing to AS as STD or CDECL ... or other. Can you possibly give examples?
I guess I still don't understand when a should declare a function I am exposing to AS as STD or CDECL ... or other. Can you possibly give examples?
Global function : CDECL
Member function : THISCALL
A global function in C++; but looks like a member function in AngelScript : OBJLAST
The above aren't implemented for your platform : GENERIC
Though, really, you need to do your own research about the this pointer. It's unlikely you have the theoretical basis to grok calling conventions just yet.
Member function : THISCALL
A global function in C++; but looks like a member function in AngelScript : OBJLAST
The above aren't implemented for your platform : GENERIC
Though, really, you need to do your own research about the this pointer. It's unlikely you have the theoretical basis to grok calling conventions just yet.
Quote: Original post by Deyja
Though, really, you need to do your own research about the this pointer. It's unlikely you have the theoretical basis to grok calling conventions just yet.
i'd agree. I know enough about it to know how it can pooch the stack at times, but past that... O_o
Thanks for the list. Very helpful!
A global function in AngelScript and Member function in C++.
What call to do more correctly?
------------------------------------
------------------------------------
What call to do more correctly?
------------------------------------
int MyClass::Do(int tmp){ return 1;}asCSE->RegisterGlobalFunction("int Do(int tmp)", asMETHOD(MyClass, Do), ??????What Call??????);
------------------------------------
Quote: Original post by russian
A global function in AngelScript and Member function in C++.
What call to do more correctly?
------------------------------------int MyClass::Do(int tmp){ return 1;}asCSE->RegisterGlobalFunction("int Do(int tmp)", asMETHOD(MyClass, Do), ??????What Call??????);
------------------------------------
THISCALL?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement