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
 BUG: Incorrect hint in specialized functions
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

thedmd
New Member

2 Posts

Posted - Aug 05 2010 :  6:31:47 PM  Show Profile  Reply with Quote
Hello, I'm testing VA in my development machine. Recently I found that VA do not handle correctly specialized template functions implemented outside of class. Bellow are the screens from editor view and outline view. As you can see marked statement is underlined incorrectly. Also outline view contain an error.

Source code which reveal described behavior is included at the bottom of this post.

VA version: 10.6.1823.0




# include <iostream>

using namespace std;

namespace EState
{
  enum type_t
  {
    FIRST,
    SECOND,
    THIRD
  };
}

class THint
{
public:
  void bar()
  {
  }
};

class TMachine
{
public:
  TMachine();

  ~TMachine();

  void SetState(EState::type_t state);

  EState::type_t GetState() const;

  void UpdateState();

private:
  template <EState::type_t STATE> void Enter() {}
  template <EState::type_t STATE> void Leave() {}
  template <EState::type_t STATE> void Update() {}

  template <> 
  void Enter<EState::FIRST>();

  template <>
  void Leave<EState::FIRST>();

  template <>
  void Update<EState::SECOND>();

  void EnterState(EState::type_t state);

  void LeaveState(EState::type_t state);

  void UpdateState(EState::type_t state);

  THint          mHint;
  EState::type_t mState;
};

TMachine::TMachine()
{
  mState = EState::FIRST;
  EnterState(mState);
}

TMachine::~TMachine()
{
  LeaveState(mState);
}

void TMachine::SetState(EState::type_t state)
{
  LeaveState(mState);
  mState = state;
  EnterState(state);
}

EState::type_t TMachine::GetState() const
{
  return mState;
}

void TMachine::UpdateState()
{
  UpdateState(mState);
}

template <>
void TMachine::Enter<EState::FIRST>()
{
  cout << "Enter \\"first\\" EState." << endl;

  // BUG: type 'this' and wait for hint, you will see FIRST, SECOND and THIRD

  // BUG: incorrect underline
  this->mHint.bar();

  // OK
  mHint.bar();
}

template <>
void TMachine::Leave<EState::FIRST>()
{
  cout << "Leave \\"first\\" EState." << endl;

  // BUG: type 'this' and wait for hint, you will see FIRST, SECOND and THIRD
}

template <>
void TMachine::Update<EState::SECOND>()
{
  cout << "Update \\"second\\" EState." << endl;

  // BUG: type 'this' and wait for hint, you will see FIRST, SECOND and THIRD
}

void TMachine::EnterState(EState::type_t state)
{
  if (state == EState::FIRST)
    Enter<EState::FIRST>();
  else if (state == EState::SECOND)
    Enter<EState::SECOND>();
  else if (state == EState::THIRD)
    Enter<EState::THIRD>();
  else
    cerr << "Invalid state" << endl;
}

void TMachine::LeaveState(EState::type_t state)
{
  if (state == EState::FIRST)
    Leave<EState::FIRST>();
  else if (state == EState::SECOND)
    Leave<EState::SECOND>();
  else if (state == EState::THIRD)
    Leave<EState::THIRD>();
  else
    cerr << "Invalid state" << endl;
}

void TMachine::UpdateState(EState::type_t state)
{
  if (state == EState::FIRST)
    Update<EState::FIRST>();
  else if (state == EState::SECOND)
    Update<EState::SECOND>();
  else if (state == EState::THIRD)
    Update<EState::THIRD>();
  else
    cerr << "Invalid state" << endl;
}

int main()
{
  TMachine obj;

  obj.SetState(EState::SECOND);
  obj.UpdateState();
  obj.UpdateState();
  obj.UpdateState();
  obj.SetState(EState::THIRD);
  obj.UpdateState();
  obj.UpdateState();
  obj.SetState(EState::FIRST);
  obj.UpdateState();

  return 0;
}

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Aug 06 2010 :  5:26:15 PM  Show Profile  Reply with Quote
I am seeing the same effect here. Thank you for the clear description and the full source. I have put in a bug report for this:

case=48428

It seems VA does not like the namespace qualifier. When I remove it, everything seems great:



So for now, "using namespace" (i.e. using namespace EState) might be a suitable workaround.

Edited by - accord on Aug 06 2010 5:37:07 PM
Go to Top of Page

thedmd
New Member

2 Posts

Posted - Aug 08 2010 :  03:32:51 AM  Show Profile  Reply with Quote
Thank you for the hint. I didn't thought about that.
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