From: Francois T. <fra...@la...> - 2002-11-01 17:27:41
|
Hi everyone, I'm trying to understand how to use Environment::isNamespace() (which is documented in http://www.csg.is.titech.ac.jp/~chiba/opencxx/ref-appendix.html) The documentation reads: "If this environment represents a name space, then this member function returns the name of that name space. Otherwise, it returns nil." I've written the following small metaprogram that aims at illustrating that: -- [..Some declaration stuff..] void MetaNamespace::TranslateClass(Environment *e) { cerr << "Analysed Class is:" << this->Name() << endl ; cerr << "e->Dump(0): " ; e->Dump(0) ; cerr << "e->Dump(1): " ; e->Dump(1) ; cerr << "e->Dump(2): " ; e->Dump(2) ; cerr << "e->IsNamespace(): \"" << e->IsNamespace()->ToString() << "\"" << endl ; } -- However, when I use it on the following source: -- metaclass MetaNamespace ; class A { }; namespace MyNamespace { class B { }; }; -- I obtain the following result: -- $ occ -E testNamespace.cc Analysed Class is:A e->Dump(0): {A(65), } e->Dump(1): Environment::Dump(): the bottom is reached. e->Dump(2): Environment::Dump(): the bottom is reached. e->IsNamespace(): "(null)" Analysed Class is:B e->Dump(0): {B(66), } e->Dump(1): {A(65), } e->Dump(2): Environment::Dump(): the bottom is reached. e->IsNamespace(): "(null)" -- As expected, B is correctly analysed as not being in the same scope as A: The environment in which B is present is enclosed in the one A is in. But e->IsNamespace() always returns 'null', although I would expect it to return "MyNamespace" at some point (intuitively when analysing B). I'm wondering if the problem comes from my not using Environment::isNamespace() properly, or if there could be some bug at work. I'll be grateful for any hint. Thanks a lot Francois -- Francois Taiani +33 (0) 5 6133 6406 LAAS-CNRS (http://www.laas.fr) Dependable Computing http://www.laas.fr/~ftaiani and Fault Tolerance |