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

 All Forums
 Visual Assist
 Technical Support
 Bug : Encapsulating variable issues
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

New Member

9 Posts

Posted - Sep 12 2019 :  6:34:27 PM  Show Profile  Reply with Quote

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; }


Whole Tomato Software

United Kingdom
16651 Posts

Posted - Sep 13 2019 :  08:35:16 AM  Show Profile  Reply with Quote
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
		V3FFeline()	{ }
class testingEncFieldNamespaced
	ImathFeline::V3FFeline m_position;

when I then trigger Encapsulate Field on the variable "m_position" I get the following code added to the class:
	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?

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:
© 2019 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000