Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
typedef parse problem(branch version )
blueshake:
codes like this can not be parsed .SubCls1,SubCls2 can not be recognized .
--- Code: ---#include <iostream>
#include <map>
using namespace std;
typedef class MyClass
{
int x;
int y;
}SubCls1,SubCls2;
int main()
{
SubCls1 cls;
cout << "Hello world!" << endl;
return 0;
}
--- End code ---
here is the patch.
--- Code: ---Index: parserthread.cpp
===================================================================
--- parserthread.cpp (revision 5696)
+++ parserthread.cpp (working copy)
@@ -1256,12 +1256,19 @@
// no vars are defined on a typedef, only types
// In the former example, aa is not part of the typedef.
if (m_ParsingTypedef)
+ {
+ m_Str.Clear();
+ ReadClsNames(newToken->m_Name);
+// m_ParsingTypedef = false;
break;
-
- m_Str = newToken->m_Name;
- ReadVarNames();
- m_Str.Clear();
- break;
+ }
+ else
+ {
+ m_Str = newToken->m_Name;
+ ReadVarNames();
+ m_Str.Clear();
+ break;
+ }
}
else if (next==ParserConsts::opbrace)
{
@@ -1295,12 +1302,19 @@
// no vars are defined on a typedef, only types
// In the former example, aa is not part of the typedef.
if (m_ParsingTypedef)
+ {
+ m_Str.Clear();
+ ReadClsNames(newToken->m_Name);
+// m_ParsingTypedef = false;
break;
-
- m_Str = newToken->m_Name;
- ReadVarNames();
- m_Str.Clear();
- break;
+ }
+ else
+ {
+ m_Str = newToken->m_Name;
+ ReadVarNames();
+ m_Str.Clear();
+ break;
+ }
}
else if (next==ParserConsts::semicolon) // forward decl; we don't care
break;
@@ -1719,3 +1735,36 @@
tdef->m_ActualType = ancestor + args;
}
}
+void ParserThread::ReadClsNames(wxString& ancestor)
+{
+ while (1)
+ {
+ wxString current = m_Tokenizer.GetToken();
+
+ if (current.IsEmpty())
+ break;
+ if (current==ParserConsts::comma)
+ continue;
+ else if (current==ParserConsts::semicolon)
+ {
+ m_Tokenizer.UngetToken();
+ break;
+ }
+ else if (wxIsalpha(current.GetChar(0)))
+ {
+// if ( m_Filename == _T("F:\\fortest\\main.cpp"))
+// Manager::Get()->GetLogManager()->DebugLog(F(_T("Adding variable '%s' as '%s' to '%s'"), current.c_str(), m_Str.c_str(), (m_pLastParent?m_pLastParent->m_Name.c_str():_T("<no-parent>"))));
+ Token* newToken = DoAddToken(tkClass, current, m_Tokenizer.GetLineNumber());
+ if (!newToken)
+ break;
+ else
+ {
+ wxString tempAncestor = ancestor;
+ newToken->m_AncestorsString = tempAncestor;
+ }
+
+ }
+ else // unexpected
+ break;
+ }
+}
Index: parserthread.h
===================================================================
--- parserthread.h (revision 5696)
+++ parserthread.h (working copy)
@@ -89,6 +89,7 @@
void HandlePreprocessorBlocks(const wxString& preproc);
void HandleNamespace();
void ReadVarNames();
+ void ReadClsNames(wxString& ancestor);
void HandleClass(EClassType ct);
void HandleFunction(const wxString& name, bool isOperator = false);
void HandleEnum();
--- End code ---
by the way ,Ihave not test it completely .welcome to test and report bugs .
[attachment deleted by admin]
ollydbg:
I tested this patch, and it works great!!!
By the way, I need to manually patch in my local copy.
Thanks to the "Block select mode in editor", I can delete many "+" at a once. :D (use ALT + mouse drag).
ollydbg:
Any dev can test this patch?
I have write the description of this patch in wiki page, see here:
Handing class and typdef
Thanks.
By the way, I'm considering enrich the multiply match dialog. I think we should add another column about FileList, Or, we can do it like "threadSearch result tree".
MortenMacFly:
--- Quote from: ollydbg on July 31, 2009, 04:31:10 am ---Any dev can test this patch?
--- End quote ---
I am already on it... don't worry. Looks good so far.
ollydbg:
--- Quote from: MortenMacFly on July 31, 2009, 08:16:12 am ---
--- Quote from: ollydbg on July 31, 2009, 04:31:10 am ---Any dev can test this patch?
--- End quote ---
I am already on it... don't worry. Looks good so far.
--- End quote ---
Nice to hear! Thanks.
Navigation
[0] Message Index
[#] Next page
Go to full version