Hi, it seems that restrictions for static functions (global functions with namespace of the class name) have changed. The older versions of AngelScript engine seemed capable of computing the uniqueness of a funcion based on its input parameters but the current version of 2.34 seems to give up on any global function matching if a name matches a class method (ignoring parameters).
Is this restriction going to be intended going forward?
Example code:
void MessageCallback(const asSMessageInfo *msg, void *param)
{
const char *type = "ERR ";
if (msg->type == asMSGTYPE_WARNING)
type = "WARN";
else if (msg->type == asMSGTYPE_INFORMATION)
type = "INFO";
printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message);
}
class TestObj {
public:
static void staticFunc() {}
void memberFunc1(int test) {}
};
const char* file1 = " \
class SomeClass { \n\
void function1() { \n\
TestObj@ temp; temp.memberFunc1(0); \n\
TestObj::memberFunc1(); \n\
} \n\
} \n\
void main() { \n\
TestObj@ temp; temp.memberFunc1(0); \n\
TestObj::memberFunc1(); \n\
} \n\
";
void FakeFunc(asIScriptGeneric * input) {
}
int main(int argCount, char* argVal[])
{
asIScriptEngine* engine = asCreateScriptEngine();
if (engine == 0)
{
std::cout << "Failed to create script engine." << std::endl;
return -1;
}
int r = 0;
r = engine->SetMessageCallback(asFUNCTION(MessageCallback), 0, asCALL_CDECL);
assert(r >= 0);
r = engine->RegisterObjectType("TestObj", sizeof(TestObj), asOBJ_REF | asOBJ_NOCOUNT);
assert(r >= 0);
r = engine->RegisterObjectMethod("TestObj", "void memberFunc1(int test)", asMETHOD(TestObj, memberFunc1), asCALL_THISCALL);
engine->SetDefaultNamespace("TestObj");
r = engine->RegisterGlobalFunction("void memberFunc1()", asFUNCTION(FakeFunc), asCALL_GENERIC);
assert(r >= 0);
engine->SetDefaultNamespace("");
asIScriptModule* mod1 = engine->GetModule("test1", asGM_ALWAYS_CREATE);
r = mod1->AddScriptSection("test1", file1, strlen(file1));
assert(r >= 0);
r = mod1->Build();
assert(r >= 0);
return 0;
}