Author Topic: Patch for handle preprocessor - V2 - beta 3  (Read 24803 times)

Offline daniloz

  • Regular
  • ***
  • Posts: 268
Re: Patch for handle preprocessor - beta 2
« Reply #15 on: April 27, 2010, 05:18:53 pm »
@ollydbg
Note: the comment:
/ /NOTE: it actually forces reparsing of workspace

Ok, it seems this is part of some testing or debug or ... ????

I'm grad you have interests to debug and test CC. I would like to do my best to help  :D

My pleasure! Actually, I use C::B for almost an year now and I'm very happy with it, so any help I can bring to you guys is a pleasure for me. By the way, I'm glad you see my questions and "features requests" as a help. I wish I could do more and really get into the code, but right now I really don't have time for that... maybe in the future... :-)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Patch for handle preprocessor - V2 - beta 1
« Reply #16 on: April 30, 2010, 04:43:34 pm »
Version 2 Change Log:
1. Move condition preprocessor handle from ParserThread to Tokenizer class
2. Support parse like this demo:
Code
#define AAA

void test(int testInt1 // some comment
#ifdef AAA // test
, int testInt2)
#else
)
#endif
{
    tes|
};
3. Rewrote SkipXXX functions.
4. Make argument support default value, like (int i, bool b = true)
5. Fixed some bugs.
« Last Edit: April 30, 2010, 04:45:52 pm by Loaden »

Online ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Patch for handle preprocessor - V2 - beta 1
« Reply #17 on: April 30, 2010, 05:41:58 pm »
Version 2 Change Log:
1. Move condition preprocessor handle from ParserThread to Tokenizer class
2. Support parse like this demo:
Code
#define AAA

void test(int testInt1 // some comment
#ifdef AAA // test
, int testInt2)
#else
)
#endif
{
    tes|
};
3. Rewrote SkipXXX functions.
4. Make argument support default value, like (int i, bool b = true)
5. Fixed some bugs.

Nice! You patch is far more better than my original patch of "conditional preprocessor handling" in the Parsertest project ( I original posted in ParserTester for codecompletion plugin)

@morten,
As I have explained in this post: Re: Rewrote the DoParse function.
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 Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Patch for handle preprocessor - V2 - beta 2
« Reply #18 on: May 01, 2010, 06:14:42 am »
V2 - Beta 2 Change Log:
1. Fixed some bugs.
2. Add #undef handle
3. Refactoring Expression

NOTE: If need skip default value, just replace GetArgument with this.
Code
wxString Tokenizer::GetArgument()
{
    wxString arg;
    int nestLevel = 0;
    bool skipEqual = false;
    while (NotEOF())
    {
        while (SkipComment())
            ;

        wxChar ch = CurrentChar();
        if (ch == _T('('))
        {
            ++nestLevel;
            arg.Trim(true);
        }
        else if (ch == _T(')'))
        {
            skipEqual = false;
            --nestLevel;
            arg.Trim(true);
        }

        unsigned int index = m_TokenIndex;
        while (ch == _T('#'))
        {
            if (!HandleConditionPreprocessor())
                break;
            ch = CurrentChar();
        }

        if (ch == _T(','))
        {
            skipEqual = false;
            arg.Trim(true);
            arg.Append(_T(", "));
        }
        else if (ch == _T('='))
            skipEqual = true;
        else if (!skipEqual && ((ch > _T(' ')) || (ch == _T(' ') && arg.Last() != _T(' '))))
            arg.Append(ch);

        if (index == m_TokenIndex)
            MoveToNextChar();

        if (nestLevel == 0)
            break;
    }

    return arg;
}
« Last Edit: May 01, 2010, 11:12:04 am by Loaden »

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Patch for handle preprocessor - V2 - beta 3
« Reply #19 on: May 01, 2010, 07:54:04 pm »
V2 - Beta 3 Change Log:
1. Replace from 'GetArgument' to 'ReadBlock'.
2. Fix bugs.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Patch for handle preprocessor - V2 - beta 3
« Reply #20 on: May 02, 2010, 02:38:51 pm »
V2 - Beta 3 Change Log:
1. Replace from 'GetArgument' to 'ReadBlock'.
2. Fix bugs.
I test "V2 - Beta 3" on ArchLinux,  and seems works well. :D