I'm not sure if this is intentional or a bug. When writing in the script language namespaces seem to inherit everything from the global, but when registering it it doesn't:
Script code:
namespace test {
void blah() {
string s;
}
}
That works, but if I register a global function inside of a namespace like this
pEngine->SetDefaultNamespace("BlahNS");
pEngine->RegisterGlobalFunction("bool foo(const string &in)", asFUNCTION(Foo), asCALL_CDECL);
I get the following error:
System function (1, 18) : ERR : Identifier 'string' is not a data type
(0, 0) : ERR : Failed in call to function 'RegisterGlobalFunction' with 'bool isDir(const string &in)' (Code: -10)
VelScript: /home/droz/Projects/Velox/VelScript/Include/Script.h:235: void Vel::Script::FunctionGroup::Register(asIScriptEngine*): Assertion `Ret >= 0' failed.
Aborted
If I register it with:
pEngine->SetDefaultNamespace("BlahNS");
pEngine->RegisterGlobalFunction("bool foo(const ::string &in)", asFUNCTION(Foo), asCALL_CDECL);
it works.