Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: blueshake on July 21, 2009, 05:00:39 am

Title: handle define
Post by: blueshake on July 21, 2009, 05:00:39 am
hello :
     I found that the macro tip is a little problem .see the picture in attach .

[attachment deleted by admin]
Title: Re: handle define
Post by: blueshake on July 21, 2009, 05:11:42 am
I know that ollydbg have done work for the macro parse problem ,I apply the patch .but the tip problem
seem still exist .So I do a little work for it .It's better now . :)
Code
Index: parserthread.cpp
===================================================================
--- parserthread.cpp (revision 5696)
+++ parserthread.cpp (working copy)
@@ -978,14 +978,30 @@
     // BLAH_BLAH
     if (!token.IsEmpty())
     {
-        // skip the rest of the #define
-        wxString defVal = token + m_Tokenizer.ReadToEOL();
-
+                // skip the rest of the #define
+       wxString defVal = token + m_Tokenizer.ReadToEOL();
+        wxString para(_T(""));
+        size_t start = defVal.find('(');
+        size_t end = defVal.find(')');
+        //Manager::Get()->GetLogManager()->DebugLog(F(_T("Saving nesting level: %d,%d"), start, end));
         // make sure preprocessor definitions are not going under namespaces or classes!
+        if (start != wxString::npos && end != wxString::npos)
+        {
+            para = defVal.Mid(start, end-start+1);
+            m_Str = defVal.Mid(end + 1);
+            m_Str.Trim(false);
+        }
+        else
+        {
+            m_Str = defVal.substr(token.length());
+            m_Str.Trim(false);
+            //defVal = _T("");
+        }
         Token* oldParent = m_pLastParent;
         m_pLastParent = 0L;
-        DoAddToken(tkPreprocessor, token, lineNr, lineNr, m_Tokenizer.GetLineNumber(), defVal, false, true);
+        DoAddToken(tkPreprocessor, token, lineNr, lineNr, m_Tokenizer.GetLineNumber(), para, false, true);
         m_pLastParent = oldParent;
+        m_Str.Clear();
     }
 }
 

here aa2 is macro .
and the macro can have param tip now .see the picture in attach.

[attachment deleted by admin]
Title: Re: handle define
Post by: ollydbg on July 21, 2009, 01:05:31 pm
I have applied in my local copy(though I had to manually patch these code, because Tortoise refused to patch on a modified parserthread.cpp, so, if the patch is small, you can also post the whole function)

This patch works perfect!!!

Thanks for your contribution!!!
Title: Re: handle define
Post by: blueshake on July 22, 2009, 03:06:08 am
@ollydgb
thank you for your suggestion.