Developer forums (C::B DEVELOPMENT STRICTLY!) > Contributions to C::B
About the Code Completion
pingf:
Hi,
I felt a little disappointed about the C::B's code completion,
e.g.
typedef struct tagABC
{
int a;
int b;
} ABC;
and the completion won't find the ABC's members!
so does the OPENFILENAME ,PAINTSTRUCT.......
however,
e.g.
struct M
{
int a;
int b;
};
M m;
it finds the m's members immediately!
ollydbg:
See this thread.
http://forums.codeblocks.org/index.php/topic,9225.msg65886.html#msg65886
I found this patch haven't applied.
Edit:
I investigate the source code in void ParserThread::HandleTypedef(), in parserthread.cpp. This file needs to be modified to parse C type typedef and struct correctly :D.
ollydbg:
In the beginning, it has these comments.
--- Code: ---void ParserThread::HandleTypedef()
{
// typedefs are handled as tkClass and we put the typedef'd type as the class's
// ancestor. this way, it will work through inheritance.
--- End code ---
The typedef's type as the class's ancestor.
Here is my test code:
--- Code: ---class Ancestor{
public:
int m_aaaa;
int m_bbbb;
};
class Child:public Ancestor {
public:
int m_cccc;
int m_dddd;
};
int main()
{
Child obj;
obj. // works ok! all the four members will be shown.
return 0;
}
--- End code ---
See the screen shot below.
But the code below can't work.
--- Code: ---
typedef class Ancestor{
public:
int m_aaaa;
int m_bbbb;
} Parent;
//typedef class Ancestor Parent;
int main()
{
Parent obj;
obj. //Show nothing! works badly.
return 0;
}
--- End code ---
If the Parent was treated as Ancestor's parents(said by the comments), I think the public member of Ancestor should be shown. So, it can't work though it's inheritance.
[attachment deleted by admin]
pingf:
--- Quote from: ollydbg on March 14, 2009, 03:40:33 am ---See this thread.
http://forums.codeblocks.org/index.php/topic,9225.msg65886.html#msg65886
I found this patch haven't applied.
Edit:
I investigate the source code in void ParserThread::HandleTypedef(), in parserthread.cpp. This file needs to be modified to parse C type typedef and struct correctly :D.
--- End quote ---
THX a lot!
but,How to use the patch? [or install ,compile...whatever]
I'm just a beginner on C::B.
ollydbg:
I'm examining the code.
In the parsethread.cpp line 1570, I enable the output to report a typedef token information.
--- Code: ---Manager::Get()->GetLogManager()->DebugLog(F(_("Adding typedef: name '%s', ancestor: '%s'"), components.front().c_str(), ancestor.c_str()));
--- End code ---
It seems that when I parse the code like this:
--- Code: ---typedef class Ancestor{
public:
int m_aaaa;
int m_bbbb;
} Parent;
--- End code ---
Then the output is like this:
--- Code: ---Adding typedef: name 'Parent', ancestor: ''
--- End code ---
Note that the ancestor is an empty string. This is the reason that code completion can't give the correct tooltips.
If the ancestor is string named "Ancestor", I think the code completion will work ok!
Edit: This has been confirmed, I just tested by assigning the ancestor = _T("Ancestor") , in the line 1564 of parsethread.cpp.
--- Code: --- ancestor << typ;
ancestor = _T("Ancestor");
--- End code ---
then, the tips can show correctly.
I'm trying to solve it, but all the codes are hard to understand(currently no document were supplied), so, it will take times, also, I will enrich the wiki page if I find the solution.
There is another issue: If I try to parse this code
--- Code: ---class Ancestor{
public:
int m_aaaa;
int m_bbbb;
};
typedef class Ancestor Parent;
--- End code ---
Then no typedef token was recognized. :(
Navigation
[0] Message Index
[#] Next page
Go to full version