It seems that the reason is exactly that I have registered a get_opIndex
returning a different type before. (I tried to implement a get_opIndex
that returns a uint
containing the code point of the indexed character in string in order to handle non-ASCII characters.)
My simplest code for reproducing the problem:
#include <angelscript.h>
#include <cassert>
#include <cstdint>
#include <iostream>
void log_msg(asSMessageInfo* msg, void*)
{
std::cerr << msg->message << std::endl;
}
std::uint32_t get_opIndex(const std::string&, int)
{
return 0;
}
void set_opIndex(const std::string&, int, const std::string&)
{
/* empty */
}
int main(int argc, char** argv)
{
asIScriptEngine* engine = asCreateScriptEngine();
engine->SetMessageCallback(asFUNCTION(log_msg), nullptr, asCALL_CDECL);
int r = engine->RegisterObjectType(
"string", sizeof(std::string), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK
);
assert(r >= 0);
r = engine->RegisterObjectMethod(
"string",
"uint get_opIndex(int idx) const property",
asFUNCTION(get_opIndex),
asCALL_CDECL_OBJFIRST
);
assert(r >= 0);
// Exploded here
r = engine->RegisterObjectMethod(
"string",
"void set_opIndex(int idx, const string &in) property",
asFUNCTION(set_opIndex),
asCALL_CDECL_OBJFIRST
);
assert(r >= 0);
engine->ShutDownAndRelease();
return 0;
}
If I remove the line for registering get_opIndex
, the error will disappear.