Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Drop namespaces on generated code in a namespace

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
grandchain Posted - Sep 26 2023 : 06:39:33 AM
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
3   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Sep 29 2023 : 12:44:40 PM
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.
grandchain Posted - Sep 29 2023 : 11:15:59 AM
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
feline Posted - Sep 26 2023 : 10:19:18 AM
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?

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000