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

Patch for handle preprocessor - V2 - beta 3

<< < (2/5) > >>

daniloz:

 I am using the handle preprocessor patch and have one question. Here's what I have:

- 2 projects in one workspace
- each project has its own define, for example (-DPROJECT_ONE and -DPROJECT_TWO)
- some source files (.cpp and .h) are shared between both projects, but have some different code for each project using

--- Code: ---#ifdef PROJECT_ONE
    // code for project one
#endif

--- End code ---
or

--- Code: ---#ifdef PROJECT_TWO
    // code for project two
#endif

--- End code ---

My question is now:

- since both PROJECT_ONE and PROJECT_TWO are defined within the workspace, the parser is still parsing both #ifdef's regardless of the active project, right? And I have no advantage in using this patch. Is that correct?

- If so, can it be changed, so only the active project #defines (in the project options) are used??

Thanks a lot...

Loaden:

--- Quote from: daniloz on April 21, 2010, 11:17:58 am ---- since both PROJECT_ONE and PROJECT_TWO are defined within the workspace, the parser is still parsing both #ifdef's regardless of the active project, right? And I have no advantage in using this patch. Is that correct?

--- End quote ---
Not! You can define the macros in project's option, but not in header files.



--- Quote from: daniloz on April 21, 2010, 11:17:58 am ---- If so, can it be changed, so only the active project #defines (in the project options) are used??

--- End quote ---
You can try it.

Loaden:
Beta 2 changed:
Rewrote ParserThread::SkipToNextPreprocessorBlock() and ParserThread::SkipToEndPreprocessorBlock(), make it clear.
AND FIX a bug!
Welcome for test!

daniloz:

--- Quote from: Loaden on April 21, 2010, 04:31:06 pm ---
--- Quote from: daniloz on April 21, 2010, 11:17:58 am ---- since both PROJECT_ONE and PROJECT_TWO are defined within the workspace, the parser is still parsing both #ifdef's regardless of the active project, right? And I have no advantage in using this patch. Is that correct?

--- End quote ---
Not! You can define the macros in project's option, but not in header files.

--- End quote ---
I have them defined in each project's options. In "Project One" I have -DPROJECT_ONE and in "Project Two" I have -DPROJECT_TWO.

Just to clarify, what I'd like to have is the parser to only use the defines from the *active* project. I have lots of project dependent code parts, for example

--- Code: ---#ifdef PROJECT_ONE
  #define SOME_VALUE 1
#endif
#ifdef PROJECT_TWO
  #define SOME_VALUE 2
#endif

--- End code ---
I'd like that the CC shows SOME_VALUE as 1 (in the tip and in the symbols browser) when "Project One" is the active one and 2 when "Project Two" is the active one.


--- Quote from: Loaden on April 21, 2010, 04:31:06 pm ---
--- Quote from: daniloz on April 21, 2010, 11:17:58 am ---- If so, can it be changed, so only the active project #defines (in the project options) are used??

--- End quote ---
You can try it.

--- End quote ---
What I see by enabling the debug log in nativeparser.cpp is that the parser does a batch parsing of all projects in the workspace. In my case, I have messages like

--- Code: ---Add project Project One in parsing queue
...
Add project and current buildtarget defined preprocessor macros:
#define PROJECT_ONE
...
Add project Project Two in parsing queue
...
Add project and current buildtarget defined preprocessor macros:
#define PROJECT_TWO
...
Passing list of files to batch-parser.
Batch-parsing 184 file(s)...
Starting batch parsing...
Parsing stage done (268 total parsed files, 11936 tokens in 0 minute(s), 2.913 seconds).
Updating class browser...
Class browser updated.

--- End code ---


Is it possible to change the CC, so that one the current project is parsed? (maybe that's the right question here)
Since I'm new to the CC, I'm a little bit lost about where to start looking for it...

I know I could have only one project in the workspace at a time and that would solve my problem, but it's so convenient to have both at the same time...

ollydbg:
@daniloz

--- Quote ---Is it possible to change the CC, so that one the current project is parsed? (maybe that's the right question here)
Since I'm new to the CC, I'm a little bit lost about where to start looking for it...
--- End quote ---

I found a code snippet in the nativeparser.cpp, line 511

I just do a search of "in parsing queue", and found that it was here:

--- Code: ---void NativeParser::AddParser(cbProject* project, bool useCache)
{
    if (!project)
        return;

    Manager::Get()->GetLogManager()->DebugLog(F(_T("Add project %s in parsing queue"), project->GetTitle().wx_str()));

    ReparseProject(project);
}
--- End code ---

So, this function only parse files in a single project.

But strange that in the function below: nativeparser.cpp line 606.


--- Code: ---// NOTE: it actually forces reparsing of workspace
void NativeParser::ForceReparseActiveProject()
{
    m_Parser.Clear();
    UpdateClassBrowser();

    ProjectsArray* projects = Manager::Get()->GetProjectManager()->GetProjects();
    for (size_t i = 0; i < projects->GetCount(); ++i)
    {
        AddParser(projects->Item(i), false);
    }
}
--- End code ---

Note: the comment:
/ /NOTE: it actually forces reparsing of workspace

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



Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version