First I will give a bit of overview before I ask my question.
In my engine objects CANNOT be instantiated from script. All this happens through C++ and the C++ side of the code manages the lifetime of objects. I have been reading the angelscript docs and it says that if I return an object from C++ to the script engine I have to Add a reference. Also
it says that if the script passes a handle to a C++ object I have to release it once I am done with it.
My question is if my AddReference and Release functions are just dummy routines that don't do anything (since the engine controls when objects are created and destroyed) Do I still need to follow what is described in the manual in regards to references?
Also if I don't follow these rules will this mess up the garbage collector in any way?
To my utter surprise I noticed that the scriptstdstring implementation does not have the asBEHAVE_ADDREF and asBEHAVE_RELEASE behaviors set. How is this possible? I thought that if you did not register these methods in a class they would fail to work and angelscript would crash. If I have a CHuman class can I get away without having these behaviors and still have angelscript behave properly?
Also when declaring routines I noticed that you need to declare parameters properly so they are passed by reference and not by value.
For instance:
// set game path animation
iResult = pcScriptEngine->RegisterObjectMethod ("CHuman",
"void setGamePathAnimation (const string &in strGamePath, const string &in strAnimation)",
asFUNCTION (setGamePathAnimation),
asCALL_CDECL_OBJLAST);
By using the const string &in these strings are passed in by reference. My question is if I return a CHuman class how do I declare it properly so that I can be assured that the object returned is a reference and NOT a copy. Here is the example:
// register the get human function
iResult = pcScriptEngine->RegisterGlobalFunction ("CHuman &getHuman (const string &in strName)",
asFUNCTION (getHuman),
asCALL_CDECL);
I want to ensure that a reference to the desired CHuman object is returned and NOT a copy.
Thanks for anyone that can help my on my myriad of questions.