Author Topic: Check macro usage on every identifier like token: issues and discussions  (Read 9706 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4903
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Would you this problem affect the autocompletion, calltip and symbol browser?
Sure, yes. because the macro expansion happens in the lower tokenizer level, so that the high level parserthread only see the expanded tokens.
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4903
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Would you this problem affect the autocompletion, calltip and symbol browser?
Sure, yes. because the macro expansion happens in the lower tokenizer level, so that the high level parserthread only see the expanded tokens.
I take some time to do a simple research, I think macro expansion shouldn't be a problem.
Let me put the example code here again.

Here, I think a good code style is not use the macro definition to give a type a new name, the best way here is using typedef.
So, if we have the code:

Code: [Select]
typedef unsigned char uint8;
void f(uint8 aaa);
Then, the parser still see the "void f(uint8 aaa);"

I see that under MSVC, many types are actually typedef, such as "BOOL", "LPCTSTR".

BTW: I don't see much response about this patches serials :(, so this is a "ping" for further comments, 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9415
BTW: I don't see much response about this patches serials :(, so this is a "ping" for further comments, thanks.
I didn't see there was an update. Unfortunately, all the time you apply patches in trunk this breaks your patch series here. This makes it hard to test... I'll try again with v6 from this thread (hoping its that last version and it applies well on trunk).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9415
I'll try again with v6 from this thread (hoping its that last version and it applies well on trunk).
Well... unfortunately:
Quote
C:\Devel\CodeBlocks\src\plugins\codecompletion\parser\parserthread.cpp: In member function 'void ParserThread::DoParse()':
C:\Devel\CodeBlocks\src\plugins\codecompletion\parser\parserthread.cpp:803:38: error: 'tsSkipNone' was not declared in this scope
                 m_Tokenizer.SetState(tsSkipNone); // don't want to skip equals
...what to do now?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4903
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
I'll try again with v6 from this thread (hoping its that last version and it applies well on trunk).
Well... unfortunately:
Quote
C:\Devel\CodeBlocks\src\plugins\codecompletion\parser\parserthread.cpp: In member function 'void ParserThread::DoParse()':
C:\Devel\CodeBlocks\src\plugins\codecompletion\parser\parserthread.cpp:803:38: error: 'tsSkipNone' was not declared in this scope
                 m_Tokenizer.SetState(tsSkipNone); // don't want to skip equals
...what to do now?
I can simply rebase patches on the trunk and release the new patches, but currently I have build errors, see: Re: exchndl related patch because win32/lib folder is empty in SVN
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4903
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
OK, this is updated git and svn style patches against SVN revision 10373.
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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9415
OK, this is updated git and svn style patches against SVN revision 10373.
Yes, these one seem to work... still compiling...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9415
Re: Check macro usage on every identifier like token: issues and discussions
« Reply #22 on: August 30, 2015, 09:49:58 am »
Yes, these one seem to work... still compiling...
Its broken again after the last commits. I wonder why you don't simply commit these, too? It seems to work for me - I have no hangs whats-o-ever...

Otherwise, mind posting an update here? :-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4903
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Check macro usage on every identifier like token: issues and discussions
« Reply #23 on: August 30, 2015, 10:00:52 am »
Yes, these one seem to work... still compiling...
Its broken again after the last commits. I wonder why you don't simply commit these, too? It seems to work for me - I have no hangs whats-o-ever...
OK, I will commit them, I just want to see it has not regressions. :)
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4903
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Check macro usage on every identifier like token: issues and discussions
« Reply #24 on: August 31, 2015, 02:18:09 am »
Yes, these one seem to work... still compiling...
Its broken again after the last commits. I wonder why you don't simply commit these, too? It seems to work for me - I have no hangs whats-o-ever...
OK, I will commit them, I just want to see it has not regressions. :)
Done. Thanks for everyone!
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 Huki

  • Multiple posting newcomer
  • *
  • Posts: 91
Re: Check macro usage on every identifier like token: issues and discussions
« Reply #25 on: October 25, 2015, 07:58:25 pm »
Hi, I'm back...

Hi, Morten, this is a reply after two months... How time flies.  :(
I think not much people are testing my patch serials. I'm considering what is the time to let those patches into our SVN repo. I don't have a clean plan, maybe, we can let them in, and we may have more testers through nightly build versions.  ;) What's your or other guy's idea?
So far it has been very stable for me. I just checked out the latest revision and found these patches have already made into master.. that's good. :) I found only one regression, due to commit r10230, but this is not related to your cc_macro patches.

Well, I tried to follow Morten's earlier advice. I have now forked Obfuscated's github repo. All my commits are available here, in branch "huki". On the top you can see 3 new bugfixes against the latest master. Now, do you want me to continue posting them in the forum as patches, or should I issue a pull request? (I can create a new branch with those 3 commits.)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4903
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Check macro usage on every identifier like token: issues and discussions
« Reply #26 on: October 26, 2015, 06:05:13 am »
Hi, huki, thanks, and I will clone your branch, and see/test your three commits.
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 Huki

  • Multiple posting newcomer
  • *
  • Posts: 91
Re: Check macro usage on every identifier like token: issues and discussions
« Reply #27 on: October 26, 2015, 07:54:15 pm »
I have added test cases for my fixes (this commit).

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4903
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Check macro usage on every identifier like token: issues and discussions
« Reply #28 on: October 29, 2015, 02:59:14 pm »
I have added test cases for my fixes (this commit).
Thanks, but I think the file "cc_loop_variables.cpp" currently doesn't work under our cctest framework, since the cctest can only test codecompletion in the global scope. In our normal CodeCompletion plugin, we have some other methods to retrieve the scope information.
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4903
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Check macro usage on every identifier like token: issues and discussions
« Reply #29 on: October 29, 2015, 03:22:28 pm »
I see other works on your github branch, which use CC to support the preprocessor of Scintilla's gray out of inactive conditional preprocessor branch. I don't know the details, but it looks like you are explicitly load a dll(shared library) from the sdk or src. My idea is that currently, the SDK.dll is a bridge, and all plugin should implement the interface, I have some simple diagram added days ago in the wiki, see Plugin structure of C::B - CodeBlocks
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.