Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

Is it possible for the parser to support newlib prototypes?

<< < (12/12)

Huki:

--- Quote from: ollydbg on April 10, 2015, 03:26:27 am ---Do you think we need to remove the "*" from the "m_FullType"?

--- End quote ---
It was the only way I could fix the "typedef foo1foo1Ptr)" tooltip bug, but now you have found the real source of the bug in Token::DisplayName(), so we don't have to  remove the "*" anymore (see below).


--- Quote from: ollydbg on April 10, 2015, 03:26:27 am ---Question is:
What does the below code's purpose?

--- Code: ---        if (result.Find('*', true) != wxNOT_FOUND)
        {
            result.RemoveLast();
            return result << m_Name << _T(")") <<  GetFormattedArgs();
        }

--- End code ---

--- End quote ---

In HandleTypedef, we support 2 cases of typedef'd function pointers, and in each case the type is stored as below:

--- Code: ---typedef void (*dMessageFunction)(int errnum, const char *msg, va_list ap);
// --> type is stored as: (*)

typedef void (MyClass::*Function)(int);
// --> type is stored as: (MyClass::*)

--- End code ---

Then in Token::DisplayName() this type is taken as "result". So the code below removes the last ')' and adds the m_Name:

--- Code: ---        // result is "typedef void (*)", m_Name is "Function"
        if (result.Find('*', true) != wxNOT_FOUND)
        {
            result.RemoveLast(); // result is "typedef void (*"
            return result << m_Name << _T(")") <<  GetFormattedArgs(); // we return "typedef void (*Function) (args)"
        }

--- End code ---

So the bug occurs when we test for "if (result.Find('*', true) != wxNOT_FOUND)", but the typedef is not a function pointer (it could be a struct pointer).
A way to fix it is to ensure we really have ')' as the last char. I suggest changing the test like this:

--- Code: ---if (result.Find('*', true) != wxNOT_FOUND && result.Last() == ')')
--- End code ---

Then my previous hack to clear m_PointerOrRef is not required.. :) I quickly tested it and it's working: I get "typedef foo1* foo1Ptr" as expected.

ollydbg:
Hi, Huki, thanks for the detailed explanation, the modified patches is in trunk now. (I also added two test cases for our CCTest project)

Navigation

[0] Message Index

[*] Previous page

Go to full version