Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Bug : Encapsulating variable issues

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
Hugh Posted - Sep 12 2019 : 6:34:27 PM
Hi,

I've just tried using Encapsulate Field for the first time, and had a couple of issues with it.

The variable is defined as:

Imath::V3f m_position;


When I click Encapsulate Field, it pops up the window, and the suggested values for the getter and setter are both "Position".

If I go ahead and use the suggestion, here's the code it creates:


    Imath Position() const { return Position(); }
    void Position( Imath val ) { Position( val ); }


There are 2 issues here. First is the fact that these methods are just calling themselves. If I change the names of the getter and setter in the pop up window, it does what it should:


    Imath getPosition() const { return m_position; }
    void setPosition( Imath val ) { m_position = val; }


(note - I just tried doing it with the default values again, and this time it did the right thing. I'm not sure where the first result came from.)

The second issue here is that it hasn't realised that the variable type has a namespace, and has generated code with just the namespace, and not the actual type.

The code that I'd expect to be generated would be:


    Imath::V3f getPosition() const { return m_position; }
    void setPosition( Imath::V3f val ) { m_position = val; }


Thanks
1   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Sep 13 2019 : 08:35:16 AM
Which IDE and version of VA are you using?

Also which language are you using?

I have tested this using VS2017 and VA 2341.2 in C++. Since I need a bit more code to make sense of this, I have set up the following simple test case, in a header file:

namespace ImathFeline
{
	class V3FFeline
	{
	public:
		V3FFeline()	{ }
	};
}
 
class testingEncFieldNamespaced
{
private:
	ImathFeline::V3FFeline m_position;
};

when I then trigger Encapsulate Field on the variable "m_position" I get the following code added to the class:
public:
	ImathFeline::V3FFeline Position() const { return m_position; }
	void Position(ImathFeline::V3FFeline val) { m_position = val; }

which seems correct and sensible, and compiles, which is always a good sanity check.

Am I testing the right sort of thing here? If so, can you please try running the same test, with this code, on your system, and see what happens?

If I am not testing the right thing, can you please tell me what is different / missing in my test?

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