Author Topic: using namespace  (Read 16473 times)

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
using namespace
« on: April 10, 2013, 08:15:53 pm »
While going through this patch, I noticed that using namespace is only (or at least, seems to be only) parsed in the global scope.  Is this a known problem?  Is it supposed to work (currently)?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: using namespace
« Reply #1 on: April 11, 2013, 02:15:32 am »
While going through this patch, I noticed that using namespace is only (or at least, seems to be only) parsed in the global scope.  Is this a known problem?
Note that parser in batch mode (parsing local files) has no need to handle "using namespace" statements in function bodies.
There is another function:bool ParserThread::ParseBufferForUsingNamespace(const wxString& buffer, wxArrayString& result) which handle local using namespace statements.

Another thing: I think TokenIdxSet is better than "std::vector<int>" in the patch.
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 Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: using namespace
« Reply #2 on: April 11, 2013, 04:36:36 pm »
There is another function:bool ParserThread::ParseBufferForUsingNamespace(const wxString& buffer, wxArrayString& result) which handle local using namespace statements.
Yes, however on line 414, function bodies are skipped.  (I think I have a solution though.)
Code
        else if (token==ParserConsts::opbrace)
        {
            SkipBlock();
        }

Another thing: I think TokenIdxSet is better than "std::vector<int>" in the patch.
Yes (I have a few other local modifications also).

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: using namespace
« Reply #3 on: April 11, 2013, 04:55:10 pm »
Another thing: I think TokenIdxSet is better than "std::vector<int>" in the patch.
Yes. This patch needs a clean-up. I did it in my local copy as well...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: using namespace
« Reply #4 on: April 12, 2013, 04:49:05 pm »
Attached patch includes tidied up version of the previous patch (by p2rkw), and parsing of function bodies for using namespace directives.
Feedback appreciated.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: using namespace
« Reply #5 on: April 13, 2013, 07:12:16 pm »
Committed.

(By the way, I tested a full rebuild of CodeBlocks-unix.cbp on my new computer I just assembled... total time: 39 seconds!!)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: using namespace
« Reply #6 on: April 13, 2013, 08:09:55 pm »
total time: 39 seconds!!)
Really seconds?  :o

Specs please!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: using namespace
« Reply #7 on: April 13, 2013, 09:39:41 pm »
Quote
codeblocks --rebuild CodeBlocks-unix.cbp
-------------- Clean: tinyXML in Code::Blocks wx2.8.x - Unix (compiler: GNU GCC Compiler)---------------
[...]
-------------- Clean: To-do in Code::Blocks wx2.8.x - Unix (compiler: GNU GCC Compiler)---------------
-------------- Build: tinyXML in Code::Blocks wx2.8.x - Unix (compiler: GNU GCC Compiler)---------------
ccache-g++ -Wall -g -fmessage-length=0 -fexceptions -Winvalid-pch -Ulinux -Uunix -fPIC -I/usr/lib64/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_
[...]
Process terminated with status 0 (0 minute(s), 38 second(s))
0 error(s), 0 warning(s) (0 minute(s), 38 second(s))
Core i7 quadcore (8 virtual cores), 32 GB Ram, parallel build with 9 threads, build with ccache, with pure g++/gcc it needs 1 minute 46 seconds .

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: using namespace
« Reply #8 on: April 13, 2013, 10:59:17 pm »
39 seconds was with pure GCC.  Adding ccache reduces my time to 31 seconds.

Specs please!
Dual SSD's in RAID 0, 16 GB RAM, and i7-3970X (hexacore, 12 virtual cores, 4.2 GHz).
« Last Edit: April 13, 2013, 11:02:35 pm by Alpha »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: using namespace
« Reply #9 on: April 15, 2013, 06:48:49 am »
...I won't tell you mine then. :'(
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: using namespace
« Reply #10 on: April 16, 2013, 12:03:46 am »
...I won't tell you mine then. :'(
:D

I am sure you will get a new computer in a year or two with whatever the newest processor architecture will be, that will blow away the rest of our statistics ;).