i'm working on a cross-platform mud and i'm using angelscript as my scripting language right now i'm working on an mac ibook with os x 10.4.11 using xcode 2.5 as my ide and under windows xp 32bit i'm using mingw with codeblocks
so under windows it works as i would expected it to but under osx the memory location that GetPlayer returns to the script for the cPlayer becomes corrupt
after the completion of the running of the script below.
is there any setting that i might of missed for osx that i should be aware of?
i can provide more information if need be i'm not quite sure what else to put
here
i use the asIScriptEngine::scriptstring() method to do the testing of the script
registering
cBuffer and its script representation buffer are is my custom string class closer to a buffer because of how i use it and functions that i've attached to it
script file
//test.as angelscript
int Send(buffer &name,buffer &message)
{
cPlayer @Player;
@Player = GetPlayer(name);
Player.Send(message);
return Player;
};
class decleration
class cPlayer
{
public:
cPlayer();
cPlayer(cPlayer &Player);
~cPlayer();
int Load(const char * FileName);
int Save(const char * FileName);
int Send(cBuffer & Message);
void AddRef();
void Release();
int State;
int SubState;
cClient * Client;
cBuffer FileName;
cBuffer Name;
cBuffer Password;
int OLC;
int Root;
int Admin;
int ID;
int refCount;
private:
};
[\source]
class registration for engine
int RegisterPlayer(asIScriptEngine * Engine)
{
int r;
r = Engine->RegisterObjectType("cPlayer", sizeof(cPlayer),asOBJ_REF); assert(r >= 0);
r = Engine->RegisterObjectBehaviour("cPlayer", asBEHAVE_ADDREF,"void f()" , asMETHOD(cPlayer,AddRef), asCALL_THISCALL); assert(r >= 0);
r = Engine->RegisterObjectBehaviour("cPlayer", asBEHAVE_RELEASE,"void f()" , asMETHOD(cPlayer,Release), asCALL_THISCALL); assert(r >= 0);
r = Engine->RegisterObjectMethod("cPlayer", "int Send(buffer &in)", asMETHODPR(cPlayer,Send,(cBuffer&),int), asCALL_THISCALL); assert(r >= 0);
r = Engine->RegisterObjectProperty("cPlayer" , "buffer Name" , offsetof(cPlayer,Name)); assert(r >= 0);
r = Engine->RegisterObjectProperty("cPlayer" , "int ID", offsetof(cPlayer,ID)); assert(r >= 0);
r = Engine->RegisterObjectProperty("cPlayer" , "int State", offsetof(cPlayer,State)); assert(r >= 0);
r = Engine->RegisterObjectProperty("cPlayer" , "int SubState",offsetof(cPlayer,SubState)); assert(r>= 0);
r=Engine->RegisterGlobalFunction("cPlayer @ GetPlayer(buffer&)",asFUNCTION(GetPlayer),asCALL_CDECL); assert( r >= 0 );
return 1;
}
[\source]