Advertisement

std::string returned via reference

Started by June 30, 2011 10:57 AM
9 comments, last by xynapse 13 years, 7 months ago
WitchLord - thank you,

this is what happens now.



[87003562] <X::MessageCallback> [Level] Compiling void Init() (Line 6/1)
[87003562] < X::MessageCallback> [Level] Error, There is no copy operator for this type available. (Line 27/42)
[87003578] < X::MessageCallback> [Level] Error, There is no copy operator for this type available. (Line 28/45)
[87003578] <X::CScriptsManager::LoadScript> Error, build failed.




Do i have to define the copy operator/and the others to finally make it run?

perfection.is.the.key
WitchLord, thank you very much.




What does the compiler complain about now is:







[87324421] <xscriptsmanager.cpp:344 X::CScriptsManager::LoadScript> "data/scripts/level0.xs", module: Level.
[87324437] <xscriptsmanager.cpp:62 X::MessageCallback> [Level] Compiling void Init() (Line 6/1)
[87324437] <xscriptsmanager.cpp:66 X::MessageCallback> [Level] Error, There is no copy operator for this type available. (Line 27/42)
[87324437] <xscriptsmanager.cpp:66 X::MessageCallback> [Level] Error, There is no copy operator for this type available. (Line 28/45)
[87324437] <xscriptsmanager.cpp:388 X::CScriptsManager::LoadScript> Error, build failed.







Lines 27,28 in script are:



Level.getEntityName("CameraPosition0",CameraPosition);
if(Level.getEntityName("CameraPosition0",CameraPosition)==true)



And of course Level.getEntityName is registered as:




eScripting->RegisterObjectMethod("XBSP", "bool getEntityName(const string &in, tEntity &out)", asMETHODPR(XBSP,XS_getEntityName, (const std::string &in,tEntity &out), bool), asCALL_THISCALL);






and XS_getEntityName is a wrapper:



bool XBSP::XS_getEntityName(const std::string &name, tEntity &ret)
{

tEntity *b = getEntityName(name);
if( b )
{

ret = *b;
return true;

}
// entity doesn't exist
return false;
}



I run AngelScript 2.20.3 and can't see that kind of behaviour with this version,

what else is required to make it finally work..?




Thanks for any input guys.

perfection.is.the.key
Advertisement
Think i've got it.



tEntity &tEntity::operator=(const tEntity &other)
{
// Copy only the buffer, not the reference counter
*this=other;

// Return a reference to this object
return *this;
}





eScripting->RegisterObjectMethod("tEntity", "tEntity &opAssign(const tEntity &in)", asMETHODPR(tEntity, operator =, (const tEntity&), tEntity&), asCALL_THISCALL);










perfection.is.the.key
Think im close, as the operator= is required






tEntity &tEntity::operator=(const tEntity &other)
{
// Copy only the buffer, not the reference counter
this->class_name=other.classs_name;




// Return a reference to this object
return *this;
}





eScripting->RegisterObjectMethod("tEntity", "tEntity &opAssign(const tEntity &in)", asMETHODPR(tEntity, operator =, (const tEntity&), tEntity&), asCALL_THISCALL);






And that looks ok.

perfection.is.the.key

This topic is closed to new replies.

Advertisement