Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 namespaces
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

beylevem
Tomato Guru

102 Posts

Posted - Aug 20 2007 :  10:40:07 AM  Show Profile  Reply with Quote
What is the target support for namespaces? Currently, I believe, the following causes problems

namespace ns {
class cls {
void Fn1();
void Fn2();
};
}

using namespace ns;

void ns::cls::Fn1() {}

void cls::Fn2() {}

VA doesn't understand that cls::Fn2() refers to ns::cls::Fn2()

In the dropdown for selecting functions, etc, the cls:: and ns::cls:: entries are grouped separately. Also, some of the refactoring things don't work, etc.

For those who are not macro averse, I have figured out yet another hack:

#ifdef FOOL_VA
#define BEGIN_NAMESPACE(x)
#define END_NAMESAPCE(x)
#else
#define BEGIN_NAMESPACE(x) namespace x {
#define END_NAMESPACE(x) }
#endif

BEGIN_NAMESPACE(ns)
class cls {
void Fn1();
void Fn2();
};
END_NAMESPACE(ns)

feline
Whole Tomato Software

United Kingdom
17256 Posts

Posted - Aug 20 2007 :  12:27:59 PM  Show Profile  Reply with Quote
In an ideal world the target is "if it compiles we support it". Unfortunately we are not quite there yet, but we do try to cover the main cases.

Using VS2005 and VA 1559 I have added this code to a test project. I added the namespace and class to the header file, and the using statement, along with the two function implementations to the matching cpp file.

alt-g is working for me, on both functions, moving me from the cpp to the header and back again. All without the user of any macro's.

"using namespace foo" handling was improved quite a lot a few builds ago, and should be fairly robust now.

zen is the art of being at one with the two'ness

Edited by - feline on Aug 20 2007 12:28:21 PM
Go to Top of Page

beylevem
Tomato Guru

102 Posts

Posted - Oct 06 2007 :  12:57:50 PM  Show Profile  Reply with Quote
Support for namespaces may be improved, but some things still don't work:

namespace N5 {
class C5 {
void fn1();
void fn2();
};
}

using namespace N5;

void N5::C5::fn1() {

}

void C5::fn2() {

}

Position the cursor on fn1() in the class definition and click on go. VA goes to N5::C5::fn1(). Position the cursor on fn2() in the class definition, and click on go. VA goes nowhere.

Click the dropdown which lists the functions. It shows
C5.fn2()
N5
N5.C5
N5.C5.fn1()

I'd be happy with
N5
N5.C5
N5.C5.fn1()
N5.C5.fn2()

If you do find symbol on N5, you get
N5.C5.fn1 void N5::C5::fn1(){...}
N5.C5.fn2 void fn2()


if you search for C5, you get
C5.fn2 void C5::fn2(){...}
N5.C5.fn1 void N5::C5::fn1(){...}
N5.C5.fn2 void fn2()

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17256 Posts

Posted - Oct 08 2007 :  2:44:01 PM  Show Profile  Reply with Quote
I am seeing the alt-g problem when all of the code is in the header file:

case=9251

If I place the code:

using namespace N5;

void N5::C5::fn1() {

}

void C5::fn2() {

}

into the matching cpp file alt-g works perfectly in both directions. Are you placing your implementations into the header file when you see this problem?

For the alt-m list, it is behaving as it is designed to, showing you the function names in the current file, as they are produced.

I see what you are saying about the list, but we also have people who want less information in the list. When you start using long namespace names and long class names this pushes the funtion names a long way across in the list, and the current behaviour offers you a way of cutting down the displayed information.

zen is the art of being at one with the two'ness

Edited by - feline on Oct 09 2007 12:32:28 PM
Go to Top of Page

beylevem
Tomato Guru

102 Posts

Posted - Oct 08 2007 :  5:39:10 PM  Show Profile  Reply with Quote
If I separate the code into source and header files, the navigation works correctly. There is still one anomaly in the find symbol view:

N5.C5.fn1 void N5::C5::fn1() {...}
N5.C5.fn2 void fn2()

I still have cases where goto implementation only offers the header file entry, but there must be something else at work - I'll try and isolate it.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17256 Posts

Posted - Oct 09 2007 :  12:34:39 PM  Show Profile  Reply with Quote
What are you calling the "find symbol view"? Are you looking at the Find Symbol dialog - Alt-Shift-S ?

If so I am not seeing what you are posting.

For the other alt-g oddities, any help in pinning down when this happens would be much appreciated. With a test case to prod I can try and work out why it is failing, or put in a bug report if it is clearly broken.

zen is the art of being at one with the two'ness
Go to Top of Page

beylevem
Tomato Guru

102 Posts

Posted - Oct 09 2007 :  12:52:28 PM  Show Profile  Reply with Quote
Yes, Alt+****+S (I normally use the toolbar button). With The code below, I bring up the view and use C10 as the filter/search string. I get

N10.C10 class C10{...}
N10.C10.fn1 void N10::C10::fn1(){...}
N10.C10.fn2 void fn2()

It's as if it finds the definition for fn1, but the declaration for fn2

file5.h:
namespace N10 {
class C10 {
void fn1();
void fn2();
};
}

file5.cpp:
#include "file5.h"

using namespace N10;

void N10::C10::fn1() { int x = 1; }

void C10::fn2() { int x = 2; }

Go to Top of Page

beylevem
Tomato Guru

102 Posts

Posted - Oct 09 2007 :  12:53:54 PM  Show Profile  Reply with Quote
Alt+Shift+S - I don't know what it did to the formatting....
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17256 Posts

Posted - Oct 10 2007 :  1:27:02 PM  Show Profile  Reply with Quote
formatting, if you mean this forum, then white space formatting is removed when the post is displayed. This is how HTML tends to work. If you are using the "reply to topic" link, so the full reply box, use the button with the "#" picture, which wraps the code in [ code ] [ /code ] tags, which preserve the formatting.

I am seeing the effect with the two different looking entries in the find symbol dialog:

case=9298

zen is the art of being at one with the two'ness
Go to Top of Page

beylevem
Tomato Guru

102 Posts

Posted - Oct 14 2007 :  11:47:31 AM  Show Profile  Reply with Quote
I figured out why namespaces still don't work for me. I typically use one more header file:

file5.cpp:

#include "ns.h"

void N10::C10::fn1() { int x = 1; }

void C10::fn2() { int x = 2; }


ns.h:

#include "file5.h"

using namespace N10;


file5.h:

namespace N10 {
   class C10 {
      void fn1();
      void fn2();
      };
   }


This is a simplified example - normally more than one header file for the same namespace would be #included in ns.h

With this layout, VA does not connect the declaration and definition of fn2. The find symbol view shows two entries, and goto does not work.

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17256 Posts

Posted - Oct 15 2007 :  12:58:50 PM  Show Profile  Reply with Quote
Why are you splitting the "using namespace" into a separate header file? To me this seems like an odd thing to do, and looks likely to confuse things.

Since VA seems to have problems with "using namespace Foo" in a header file, this is definitely likely to confuse things. There is the second question of how far VA should try to propagate this using statement. What if the using namespace is 5 header files away? 10 header files away?

zen is the art of being at one with the two'ness
Go to Top of Page

beylevem
Tomato Guru

102 Posts

Posted - Oct 15 2007 :  1:23:36 PM  Show Profile  Reply with Quote
I am putting the namespace declaration in a header file for conciseness. I typically have

file1.h:
namespace N1 { class C1 { }; }

file2.h:
namespace N1 { class C2 { }; }

...

ns1.h:
#include file1.h
#include file2.h
...
using namespace N1;

I can then #include ns1.h anywhere I need to declare the classes, and use unqualified class names both for implementation and also in client code - e.g. C1* ptr = new C1();

Again, I understand the limitations of VAX parsing, and I'll be adding redundant "using namespace x;" statements in the cpp files - it's a small price to pay to get VAX to understand the code.

My response and demo code is because others may be experiencing similar symptoms/problems - I have seen a few threads complaining about goto not working as expected.

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17256 Posts

Posted - Oct 17 2007 :  07:54:07 AM  Show Profile  Reply with Quote
The demo code has been very helpful, thank you It is always good to find out why things are not working correctly.

The using namespace statements make sense to me, but given what you want to achieve I would be tempted to either leave off the namespace (since you are always using it) or to place the namespace at the end of the class header file.

zen is the art of being at one with the two'ness
Go to Top of Page

beylevem
Tomato Guru

102 Posts

Posted - Oct 30 2007 :  3:33:53 PM  Show Profile  Reply with Quote
Another namespace issue:

file1.h:
namespace N1 {
class C1{};
}

class C2{};

file1.cpp:
using namespace N1;
void C1::newFn() {}
void C2::newFn() {}

One is offered refactoring options on C2::newFn, but not on C1::newFn.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17256 Posts

Posted - Oct 30 2007 :  6:38:56 PM  Show Profile  Reply with Quote
I am seeing the same effect here. Thank you for the clear description.

case=5315

zen is the art of being at one with the two'ness
Go to Top of Page

beylevem
Tomato Guru

102 Posts

Posted - Oct 30 2007 :  8:49:07 PM  Show Profile  Reply with Quote
Does the low number on the case number mean that the problem has been reported already?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17256 Posts

Posted - Oct 31 2007 :  12:06:04 PM  Show Profile  Reply with Quote
Good guess, it does, from the case it was this thread:

http://forum.wholetomato.com/forum/topic.asp?TOPIC_ID=5959

With a strangely familiar poster

zen is the art of being at one with the two'ness
Go to Top of Page

beylevem
Tomato Guru

102 Posts

Posted - Oct 31 2007 :  12:42:53 PM  Show Profile  Reply with Quote
dang!

Well. I guess it's still itching there...

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17256 Posts

Posted - Oct 31 2007 :  4:45:33 PM  Show Profile  Reply with Quote
I have bumped the priority on this for you, hopefully this will help.

zen is the art of being at one with the two'ness
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Jun 03 2013 :  1:59:56 PM  Show Profile  Reply with Quote
case=5315 is fixed in build 1940
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2019 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000