Author Topic: wxGetApp not in the list CC  (Read 7498 times)

Offline Borr

  • Multiple posting newcomer
  • *
  • Posts: 29
wxGetApp not in the list CC
« on: October 22, 2010, 06:33:40 am »
wxGetApp not in the list CC. Maybe we should try to look at the Eclipse parser algorithm?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5277
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: wxGetApp not in the list CC
« Reply #1 on: October 22, 2010, 07:18:31 am »
wxGetApp not in the list CC.

confirmed trunk rev 6736.

Just noticed that:

In my D:\code\wxWidgets-2.8.11\include\wx\app.h
The declaration is like:
Code: [Select]
// this macro can be used multiple times and just allows you to use wxGetApp()
// function
#define DECLARE_APP(appname) extern appname& wxGetApp();

But once the cc's parser meets a extern keyword, it will just skip the later statement.

see the source code: parserthread.cpp line 716
Code: [Select]
           else if (token == ParserConsts::kw_extern)
            {
                // check for "C", "C++"
                m_Str = m_Tokenizer.GetToken();
                if (m_Str == ParserConsts::kw_C || m_Str == ParserConsts::kw_CPP)
                {
                    m_Tokenizer.GetToken(); // "eat" {
                    DoParse(); // time for recursion ;)
                }
                else
                {
                    // do nothing, just skip keyword "extern", otherwise uncomment:
                    //SkipToOneOfChars(ParserConsts::semicolon); // skip externs
                    m_Tokenizer.UngetToken();
                }
                m_Str.Clear();
            }

So, the solution is:
some times, we will meet many instants of extern forward declaration. shall we add them to the TokensTree??? any good ideas???

Quote
Maybe we should try to look at the Eclipse parser algorithm?
I'm interested in any parsers, but did you give more directions.
I have no idea about Eclipse parser.
Does it a Jave parser? or some one has familiar with it? Does it do a full C++ grammar match? macro expansion?  include expansion?

ollydbg.



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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12911
    • Travis build status
Re: wxGetApp not in the list CC
« Reply #2 on: October 22, 2010, 08:57:46 am »
... Maybe we should try to look at the Eclipse parser algorithm? ...

Looking at the source code of Eclipse is just a waste of time (I've tried it).
They have buried the useful parts in too many abstractions and patterns, and other "cool" java enterprise s**t.
It is impossible to understand it, unless you're java programmer or you have plenty of time to waste.

Looking at the code of clang will be way more useful :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5277
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: wxGetApp not in the list CC
« Reply #3 on: October 23, 2010, 04:14:12 am »
... Maybe we should try to look at the Eclipse parser algorithm? ...

Looking at the source code of Eclipse is just a waste of time (I've tried it).
They have buried the useful parts in too many abstractions and patterns, and other "cool" java enterprise s**t.
It is impossible to understand it, unless you're java programmer or you have plenty of time to waste.

Looking at the code of clang will be way more useful :)

thank you.
I have found that there is a minimal tutorial, see here:
http://amnoid.de/tmp/clangtut/tut.html

this is a step to step tutorial to build a lexer -> preprocesser -> parser. Nice.

But it seems not C++ grammar...
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: 5277
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: wxGetApp not in the list CC
« Reply #4 on: October 23, 2010, 05:01:45 am »
by the way:
from this wiki:
Clang - Wikipedia, the free encyclopedia

Quote
On June 7, 2010, Apple announced the preview of Xcode 4.0, which includes Clang C++ support as well as direct integration of Clang into the Xcode 4 IDE. This integration provides Xcode with precise code completion, indexing (cross referencing), on the fly detection of errors and warnings, as well as a new Fix It feature, which uses Clang to automatically corrects errors in the code.

On June 10, 2010, Clang/LLVM became an integral part of FreeBSD. While the default compiler being used is still GCC, it's expected that Clang will replace GCC as a default compiler in the future[19].

sounds Clang is powerful !!!
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: wxGetApp not in the list CC
« Reply #5 on: October 23, 2010, 04:24:07 pm »
wxGetApp not in the list CC. Maybe we should try to look at the Eclipse parser algorithm?
You should add this statement.
Code: [Select]
DECLARE_APP(yourApp)Works well in here. :lol:
« Last Edit: October 23, 2010, 05:59:17 pm by Loaden »

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: wxGetApp not in the list CC
« Reply #6 on: October 23, 2010, 06:12:13 pm »
Yes it works, but it should not be needed, if IMPLEMENT_APP is used, because it implicitely calls DECLARE_APP, but it might be to deep in macro-replacement.
Using DECLARE_APP multiple times should be okay, but it's not intuitive to do it this way.

Offline Borr

  • Multiple posting newcomer
  • *
  • Posts: 29
Re: wxGetApp not in the list CC
« Reply #7 on: November 10, 2010, 02:25:13 pm »
СС with Qt Creator powerful too