Nested Namespaces

Started by
4 comments, last by BasicMind 8 years, 8 months ago

I have an issue where if I use nested namespace I can't access them with-in a method.


r = e->SetDefaultNamespace("dev::log");
r = e->RegisterGlobalFunction("void info(const ::string &in)",    asFUNCTION(util::log_info),    asCALL_CDECL); assert(r >= 0);
r = e->RegisterGlobalFunction("void warning(const ::string &in)", asFUNCTION(util::log_warning), asCALL_CDECL); assert(r >= 0);
r = e->RegisterGlobalFunction("void error(const ::string &in)",   asFUNCTION(util::log_error),   asCALL_CDECL); assert(r >= 0);

If I run this function this works.


void main()
{
  dev::log::info("doop");
  dev::log::warning("doop");
  dev::log::error("doop");
}

But if I instance and run huh().


class Test
{
  void huh()
  {
    dev::log::info("Hi");
  } 
}

I get the error


ERR  : Namespace 'dev' doesn't exist.

Error doesn't happen with one level of namespaces, ie. just 'log'

Have I done something incorrect?

Advertisement

Nothing to so in the first place.

some guesses:

Missing header file?

In which namespace is class Test?

The class Test and function void main exist in the same file 'test.as' and both in global namespace.

This looks like a bug in the AngelScript compiler. I'll investigate it tonight when I get home from work.

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

I've fixed this bug in revision 2207.

If you do not wish to upgrade to the latest WIP I believe you can work around the problem by adding 'r = e->SetDefaultNamespace("dev");' to explicitly register the 'dev' namespace too.

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

Thanks,

Yep that worked also.


  r = e->SetDefaultNamespace("dev");
  r = e->SetDefaultNamespace("dev::log");

This topic is closed to new replies.

Advertisement