Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Several improvements to Code Completion plugin
Huki:
Yes, the m_PeekAvailable may be true in some cases, eg:
--- Code: ---In DoParse():
PeekToken(); // sets m_PeekAvailable to true
[...]
ReplaceBufferText(); // m_PeekAvailable is true, so call PeekToken() and update m_PeekToken
--- End code ---
My patch makes sure that m_PeekAvailable is not true if we are already inside PeekToken(), so a useless recursive call is avoided. i.e.,
--- Code: ---PeekToken():
-> DoGetToken():
-> ReplaceMacro():
-> ReplaceBufferText(); // no need for recursive call to PeekToken() as we are already going to
// update m_PeekToken after returning from DoGetToken()
-> DoGetToken(); // recurse DoGetToken()
-> m_PeekAvailable = true; // got m_PeekToken, now set this to true
--- End code ---
--- Quote from: ollydbg on August 27, 2014, 10:01:55 am ---Question: what happens about old way (without your patch), do we enter a infinite recursive call to PeekToken()?
--- End quote ---
I don't think there is an infinite recursive call, but generally PeekToken and GetToken are not supposed to recurse, because they update class variables (GetToken() updates Undo__ vars and PeekToken() updates Save__ vars), so a recursive call would overwrite these values, which is bad. So we should first get the peek token (i.e., m_PeekToken = DoGetToken(); ), then set m_PeekAvailable = true;
SteelRat:
Code completion ignores code like this:
--- Code: ---#if defined(TOUCHSCREEN)
void InputManager::ConvertTouch(sf::Event& event)
{
...
}
#endif
--- End code ---
Parser does not understand "final" correctly?
An checkboxes in "Editor->Code complition->C++ parser" "Parse preproceccor..." "Parse macros..." are not saving their state. They are checked always.
ollydbg:
--- Quote from: Huki on August 27, 2014, 11:45:51 am ---Yes, the m_PeekAvailable may be true in some cases, eg:
--- Code: ---In DoParse():
PeekToken(); // sets m_PeekAvailable to true
[...]
ReplaceBufferText(); // m_PeekAvailable is true, so call PeekToken() and update m_PeekToken
--- End code ---
My patch makes sure that m_PeekAvailable is not true if we are already inside PeekToken(), so a useless recursive call is avoided. i.e.,
--- Code: ---PeekToken():
-> DoGetToken():
-> ReplaceMacro():
-> ReplaceBufferText(); // no need for recursive call to PeekToken() as we are already going to
// update m_PeekToken after returning from DoGetToken()
-> DoGetToken(); // recurse DoGetToken()
-> m_PeekAvailable = true; // got m_PeekToken, now set this to true
--- End code ---
--- Quote from: ollydbg on August 27, 2014, 10:01:55 am ---Question: what happens about old way (without your patch), do we enter a infinite recursive call to PeekToken()?
--- End quote ---
I don't think there is an infinite recursive call, but generally PeekToken and GetToken are not supposed to recurse, because they update class variables (GetToken() updates Undo__ vars and PeekToken() updates Save__ vars), so a recursive call would overwrite these values, which is bad. So we should first get the peek token (i.e., m_PeekToken = DoGetToken(); ), then set m_PeekAvailable = true;
--- End quote ---
Hi, Huki, very clear explanation. I have committed your patch to trunk now with some comments added. Thank you very much for the contribution. :)
ollydbg:
--- Quote from: SteelRat on August 27, 2014, 07:28:51 pm ---Code completion ignores code like this:
--- Code: ---#if defined(TOUCHSCREEN)
void InputManager::ConvertTouch(sf::Event& event)
{
...
}
#endif
--- End code ---
--- End quote ---
I just test a minimal sample code
--- Code: ---#define TOUCHSCREEN 1
#if defined(TOUCHSCREEN)
void InputManager::ConvertTouch(sf::Event& event)
{
}
#endif
--- End code ---
It works fine here, I can see the member function symbols in code completion plugin's symbol browser tree.
--- Code: ---Parser does not understand "final" correctly?
--- End code ---
Yeah, you can write a feature request in Sourceforge as I can see.
--- Quote ---An checkboxes in "Editor->Code complition->C++ parser" "Parse preproceccor..." "Parse macros..." are not saving their state. They are checked always.
--- End quote ---
Works fine here. (WinXP, latest nightly build C::B)
SteelRat:
Thanks, I'll try other ways or with new .conf file.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version