Possible namespace bug?

Started by
0 comments, last by WitchLord 11 years, 3 months ago

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.

Advertisement
At the moment AngelScript doesn't search for symbols in the parent namespaces. With the current implementation it is actually a bug that the script sees the string type inside the namespace. The script should behave as the registration does.

I'll look into implementing the search for symbols in the parent namespaces as soon as possible. I only held off on it because I wanted the basic namespace feature to mature enough before that, i.e. most of the bugs identified and fixed.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement