I'm working with 1.10.1 patched for backslash string.
I was trying to play with arrays and an assert occurs.
this is the script :
CString[] arCs(5000);
int i;
for (i = 0; i < arCs.length(); i++)
arCs = CString("youkoulélé");
The assert occurs :
as_bytecode.cpp line 570 on
// Make sure we found a destructor
assert( n < destructors.GetLength() );
I have tried to use without arrays and the assert also occurs !
CString arCs;
arCs = CString("youkoulélé");
So this is how CString is declared :
in_pAsEngine->RegisterObjectType("CString", sizeof(string), asOBJ_CLASS);
in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_CONSTRUCT, "void f()", asFUNCTIONP(CString_Constructor, (CString &)), asCALL_CDECL_OBJLAST);
in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_CONSTRUCT, "void f(const bstr &)", asFUNCTIONP(CString_Constructor, (asBSTR &, CString &)), asCALL_CDECL_OBJLAST);
in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_CONSTRUCT, "void f(const string &)", asFUNCTIONP(CString_Constructor, (string &, CString &)), asCALL_CDECL_OBJLAST);
in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_CONSTRUCT, "void f(const bstr &, int)", asFUNCTIONP(CString_Constructor, (asBSTR &, int, CString &)), asCALL_CDECL_OBJLAST);
in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(CString_Destructor), asCALL_CDECL_OBJLAST);
in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_ASSIGNMENT, "CString &f(const bstr &)", asFUNCTION(asCStringCopy), asCALL_CDECL_OBJLAST);
in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_ASSIGNMENT, "CString &f(const CString &)", asFUNCTION(asCStringCopyCString), asCALL_CDECL_OBJLAST);
in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_ASSIGNMENT, "CString &f(const string &)", asFUNCTION(asCStringCopyString), asCALL_CDECL_OBJLAST);
in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_ADD_ASSIGN, "CString &f(const bstr &)", asFUNCTION(asCStringAppend), asCALL_CDECL_OBJLAST);
in_pAsEngine->RegisterObjectBehaviour("CString", asBEHAVE_ADD_ASSIGN, "CString &f(const CString &)", asFUNCTION(asCStringAppendCString), asCALL_CDECL_OBJLAST);
in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_ADD, "CString f(const CString &, const CString &)", asFUNCTION((CString(*)(const CString*,const CString*))asCStringConcatenate), asCALL_CDECL);
in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_ADD, "CString f(const CString &, const bstr&)", asFUNCTION((CString(*)(const CString*,const asBSTR*))asCStringConcatenate), asCALL_CDECL);
in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_EQUAL, "bool f(const CString &, const CString &)", asFUNCTION((bool(*)(const CString*,const CString*))asCStringEqual), asCALL_CDECL);
in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_EQUAL, "bool f(const CString &, const bstr &)", asFUNCTION((bool(*)(const CString*,const asBSTR*))asCStringEqual), asCALL_CDECL);
in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_NOTEQUAL, "bool f(const CString &, const CString &)", asFUNCTION(asCStringNotEqual), asCALL_CDECL);
in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_LESSTHAN, "bool f(const CString &, const CString &)", asFUNCTION(asCStringLessThan), asCALL_CDECL);
in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_LEQUAL, "bool f(const CString &, const CString &)", asFUNCTION(asCStringLessThanOrEqual), asCALL_CDECL);
in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_GREATERTHAN, "bool f(const CString &, const CString &)", asFUNCTION(asCStringGreaterThan), asCALL_CDECL);
in_pAsEngine->RegisterGlobalBehaviour(asBEHAVE_GEQUAL, "bool f(const CString &, const CString &)", asFUNCTION(asCStringGreaterThanOrEqual), asCALL_CDECL);
Workaround :
CString arCs;
CString arCs2("youkoulélé");
arCs = arCs2;
Any idea ?
Regards,
AbrKen.