Author Topic: handle define  (Read 7890 times)

Offline blueshake

  • Regular
  • ***
  • Posts: 459
handle define
« 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]
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: handle define
« Reply #1 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]
« Last Edit: July 21, 2009, 05:13:44 am by blueshake »
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: handle define
« Reply #2 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!!!
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: handle define
« Reply #3 on: July 22, 2009, 03:06:08 am »
@ollydgb
thank you for your suggestion.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?