Author Topic: Solved parsing Opencv pre-function macros  (Read 11690 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Solved parsing Opencv pre-function macros
« on: February 23, 2009, 02:14:18 pm »
Once I have post this message CodeCompletion can't recognize OpenCV function prototype . Now, after reading the CodeCompletion source code and do a lot debugging, I have get an answer to solve this problem.

Here is the patch

Code
Index: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (revision 5469)
+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -593,7 +593,8 @@
                     (!m_pLastParent || m_pLastParent->m_Name != token)) // if func has same name as current scope (class)
                 {
                     m_Str.Clear();
-                    m_Tokenizer.GetToken(); // eat args ()
+                    wxString arg = m_Tokenizer.GetToken(); // eat args ()
+                    m_Str= arg.Mid(1,arg.Len()-2);
                 }
                 else if (peek.GetChar(0) == '(' && m_Options.handleFunctions)
                 {


For example. These is the code
Code
CVAPI(IplImage*) cvLoadImage( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
m_Str = _T("IplImage*") in this situation, so, this became the function type.

By the way, at first, I want use m_Str = "CVAPI(IplImage*)" as the function type. But unluckily, this string can't be correctly recorded, I'm not sure why? :(


Also, you can see the screen shot


[attachment deleted by admin]
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 killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: Solved parsing Opencv pre-function macros
« Reply #1 on: February 23, 2009, 03:44:06 pm »
please also create a patch for this in our patch tracker at berlios. In the forum things can get out of sight too soon ;-)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Solved parsing Opencv pre-function macros
« Reply #2 on: February 23, 2009, 04:07:31 pm »
Done! :D This is my first open source activity. Thanks!
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.