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
 Feature Requests
 Drop namespaces on generated code in a namespace
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

grandchain
Junior Member

United Kingdom
22 Posts

Posted - Sep 26 2023 :  06:39:33 AM  Show Profile  Reply with Quote
Hi,

Almost all our C++ code is in namespaces, and our CPP files have the format


...
namespace MyStuff
{

MyClass::Function1(<args>)
{
    ...
}

...
}   // End of namespace MyStuff


If I declare a function in the header and then use Create Implementation, the implementation includes the namespace, even though it is already within the namespace. So if I were to declare a function Foo(int arg) in MyClass and click on Create Implementation, I would get

MyStuff::MyClass::Foo(int arg)
{
    ...
}


This namespace prefix is unnecessary (although it doesn't actually seem to make Visual Studio complain), takes up space, and we have to remove it manually. It would be better if it were dropped during generation.

Thank you,

Ian

feline
Whole Tomato Software

United Kingdom
18755 Posts

Posted - Sep 26 2023 :  10:19:18 AM  Show Profile  Reply with Quote
This should already work. Here is a very simple test case that I have just tried. In the header file I have the code:

namespace TEST_CREATE_IMP_SPACE_POSITION
{
	class testSpaceCreateImp2
	{
		// test - Create Implementation places function into namespace in cpp file
		void namespaceClassFunction2();
	};
}


and in the matching cpp file I have the empty namespace:

namespace TEST_CREATE_IMP_SPACE_POSITION
{

}


after triggering Create Implementation in the header file, the cpp file becomes:

namespace TEST_CREATE_IMP_SPACE_POSITION
{

	void testSpaceCreateImp2::namespaceClassFunction2()
	{

	}

}


can you please try this simple test case on your system and see what result you get?

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

grandchain
Junior Member

United Kingdom
22 Posts

Posted - Sep 29 2023 :  11:15:59 AM  Show Profile  Reply with Quote
Hi @feline,

Apologies. Having just experienced it again, I realise I was slightly incorrect in my description of the issue.

It affects the return type, if the return type is in the namespace.

For example, I created the very simple header as follows:

namespace foo
{

typedef int RETURN_TYPE;

class C
{
public:
    C();
    virtual ~C();

    RETURN_TYPE bar(int param);
};

}   // end of namespace foo


I created the corresponding .cpp file, added the namespace foo, and then used Create Implementation on the constructor, destructor and bar. Here's the result:

#include "issue.h"

namespace foo
{
// Auto-generated from here...

////////////////////////////////////////////////////////////////////////////////
///
//  Function: C
///
/// @brief
///
/// (no parameters)
///
/// @retval
///
////////////////////////////////////////////////////////////////////////////////
C::C()
{
    // Constructor code here
}

////////////////////////////////////////////////////////////////////////////////
///
//  Function: ~C
///
/// @brief
///
/// (no parameters)
///
/// @retval
///
////////////////////////////////////////////////////////////////////////////////
C::~C()
{

}

////////////////////////////////////////////////////////////////////////////////
///
//  Function: bar
///
/// @brief
///
/// @param  param
/// (no parameters)
///
/// @retval
///
////////////////////////////////////////////////////////////////////////////////
foo::RETURN_TYPE C::bar(int param)
{

}

// ...autogenerated to here

}   // end of namespace foo


Note the return type of C::bar is foo::RETURN_TYPE, although we are already in namespace foo.

Does this clarify?

Thanks,

Ian
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18755 Posts

Posted - Sep 29 2023 :  12:44:40 PM  Show Profile  Reply with Quote
Ah, yes, I see the problem now. This is currently a known bug with Create Implementation:

case=140241

hopefully Create Implementation is still useful enough to live with this problem for now.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000