Author Topic: Please help me fix it, I find the reasons!  (Read 18171 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Please help me fix it, I find the reasons!
« on: May 31, 2009, 06:15:08 pm »
I found that VC compiler auto-complete function can not be used for it.
Because the VC header files is special, example:
Code
class ATL_NO_VTABLE CHyperLinkImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >
{
public:
LPTSTR m_lpstrLabel;
LPTSTR m_lpstrHyperLink;

HCURSOR m_hCursor;
HFONT m_hFont;
HFONT m_hFontNormal;
if remove ATL_NO_VTABLE, it's became:
Code
class CHyperLinkImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >
{
public:

it's work fine!
Have any way to fix it?
Thanks!!

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Please help me fix it, I find the reasons!
« Reply #1 on: May 31, 2009, 08:34:57 pm »
Have any way to fix it?
You can try the CC replacements -> replace ATL_NO_VTABLE with "" (nothing).
Settings -> Editor -> CC & Symbols browser -> Tab "C++ parser" -> Add a "replacement" token.
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 Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Please help me fix it, I find the reasons!
« Reply #2 on: June 01, 2009, 01:54:10 am »
Have any way to fix it?
You can try the CC replacements -> replace ATL_NO_VTABLE with "" (nothing).
Settings -> Editor -> CC & Symbols browser -> Tab "C++ parser" -> Add a "replacement" token.
Thanks!
But i can't add replacement ATL_NO_VTABLE with nothing.


[attachment deleted by admin]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Please help me fix it, I find the reasons!
« Reply #3 on: June 01, 2009, 05:31:55 am »
In the ccoptiondlg.cpp.

Code
bool CCOptionsDlg::ValidateReplacementToken(wxString& from, wxString& to)
{
    wxRegEx re(_T("[A-Za-z_]+[0-9]*[A-Za-z_]*"));
    from.Trim(true).Trim(false);
    to.Trim(true).Trim(false);
    if (!re.Matches(from) || !re.Matches(to))
    {
        cbMessageBox(_("Replacement tokens can only contain alphanumeric characters and underscores..."),
                    _("Error"), wxICON_ERROR);
        return false;
    }
    return true;
}

That's the cause of your problem.
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: Please help me fix it, I find the reasons!
« Reply #4 on: June 01, 2009, 07:31:37 am »
In the ccoptiondlg.cpp.

Code
bool CCOptionsDlg::ValidateReplacementToken(wxString& from, wxString& to)
{
    wxRegEx re(_T("[A-Za-z_]+[0-9]*[A-Za-z_]*"));
    from.Trim(true).Trim(false);
    to.Trim(true).Trim(false);
    if (!re.Matches(from) || !re.Matches(to))
    {
        cbMessageBox(_("Replacement tokens can only contain alphanumeric characters and underscores..."),
                    _("Error"), wxICON_ERROR);
        return false;
    }
    return true;
}

That's the cause of your problem.
Thanks!
I comment this code, and do it ok.
Now, class ATL_NO_VTABLE CHyperLinkImpl : public ATL::CWindowImpl< T, TBase, TWinTraits > is OK!

But, other headers, egg. string winuser.h, i don't know how to make it work.
Code
WINUSERAPI
int
WINAPI
MessageBoxA(
    __in_opt HWND hWnd,
    __in_opt LPCSTR lpText,
    __in_opt LPCSTR lpCaption,
    __in UINT uType);
WINUSERAPI
int
WINAPI
MessageBoxW(
    __in_opt HWND hWnd,
    __in_opt LPCWSTR lpText,
    __in_opt LPCWSTR lpCaption,
    __in UINT uType);
#ifdef UNICODE
#define MessageBox  MessageBoxW
#else
#define MessageBox  MessageBoxA
#endif // !UNICODE

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Please help me fix it, I find the reasons!
« Reply #5 on: June 01, 2009, 08:14:58 am »
I find: if the header file size more than 132KB, CC will not work!!
egg. Shlwapi.h,and CC work fine.

and if cut winuser.h from line 1 to line 8446, so, CC work fine.
Why?
need int to long long?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Please help me fix it, I find the reasons!
« Reply #6 on: June 01, 2009, 03:21:56 pm »
What do you mean by "CC will not work!!"?

It seems the Parser can't recognize the function argument like this:
Code
MessageBoxA(
    __in_opt HWND hWnd,
    __in_opt LPCSTR lpText,
    __in_opt LPCSTR lpCaption,
    __in UINT uType);

The related implementation was in

void ParserThread::HandleFunction(const wxString& name, bool isOperator)

So, you can exam these code carefully to see the reason. :D
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: 9694
Re: Please help me fix it, I find the reasons!
« Reply #7 on: June 02, 2009, 08:08:11 am »
Code
MessageBoxA(
    __in_opt HWND hWnd,
    __in_opt LPCSTR lpText,
    __in_opt LPCSTR lpCaption,
    __in UINT uType);
Try replacing this "__in_opt" and alike with "empty", too... ;-) :lol: :lol: :lol:
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 Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Please help me fix it, I find the reasons!
« Reply #8 on: June 02, 2009, 09:05:46 am »
Code
MessageBoxA(
    __in_opt HWND hWnd,
    __in_opt LPCSTR lpText,
    __in_opt LPCSTR lpCaption,
    __in UINT uType);
Try replacing this "__in_opt" and alike with "empty", too... ;-) :lol: :lol: :lol:

It does not parameters question, it is the analysis of the header file is too large, it can not be fully analyzed with CC.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Please help me fix it, I find the reasons!
« Reply #9 on: June 27, 2009, 04:28:25 pm »
Hi, all.

Today, I'm thinking how to refactor the replacement function in

In Tokenizer.cpp GetToken() function
Code
    inline const wxString& ThisOrReplacement(const wxString& str) const
    {
        ConfigManagerContainer::StringToStringMap::const_iterator it = s_Replacements.find(str);
        if (it != s_Replacements.end())
            return it->second;
        return str;
    }

I think this function is some kind too simple. At least, it can do a search, then a replacement.

 (I have exam the code in ctags and its manual, especially in it's code to do Macro replacement)
Here
http://ctags.sourceforge.net/ctags.html#OPERATIONAL%20DETAILS

Quote
−I identifier−list

Specifies a list of identifiers which are to be specially handled while parsing C and C++ source files. This option is specifically provided to handle special cases arising through the use of preprocessor macros.

When the identifiers listed are simple identifiers, these identifiers will be ignored during parsing of the source files.

If an identifier is suffixed with a ’+’ character, ctags will also ignore any parenthesis-enclosed argument list which may immediately follow the identifier in the source files.

If two identifiers are separated with the ’=’ character, the first identifiers is replaced by the second identifiers for parsing purposes.


So, at least, we can do the same thing like in Ctags.

In the option.c of Ctags source code, there are the related codes to doing identifier replacement.

Code
/*  Determines whether or not "name" should be ignored, per the ignore list.
 */
extern boolean isIgnoreToken (
const char *const name, boolean *const pIgnoreParens,
const char **const replacement)
{
boolean result = FALSE;

if (Option.ignore != NULL)
{
const size_t nameLen = strlen (name);
unsigned int i;

if (pIgnoreParens != NULL)
*pIgnoreParens = FALSE;

for (i = 0  ;  i < stringListCount (Option.ignore)  ;  ++i)
{
vString *token = stringListItem (Option.ignore, i);

if (strncmp (vStringValue (token), name, nameLen) == 0)
{
const size_t tokenLen = vStringLength (token);

if (nameLen == tokenLen)
{
result = TRUE;
break;
}
else if (tokenLen == nameLen + 1  &&
vStringChar (token, tokenLen - 1) == '+')
{
result = TRUE;
if (pIgnoreParens != NULL)
*pIgnoreParens = TRUE;
break;
}
else if (vStringChar (token, nameLen) == '=')
{
if (replacement != NULL)
*replacement = vStringValue (token) + nameLen + 1;
break;
}
}
}
}
return result;
}

Here is what we can do in our Code completion code:

Code
    inline const wxString& ThisOrReplacement(const wxString& str) const
    {
        ConfigManagerContainer::StringToStringMap::const_iterator it = s_Replacements.find(str);
        if (it != s_Replacements.end()){

            //Here we should example the "it->second"
            // if it is a "=new_token" string, the current_token should be replaced by "new_token"
            // if it is a "-" , the current string should be ignored, then we should return next token
            // if it is a "+",  the next "parenthesis-enclosed argument list" should be ignored
            // if it match any other pre-defined string grama, we will do other thing , eg, expand the current   token to two tokens...
            //......
            //return it->second;
        }
        return str;
    }


Any Comments?









« Last Edit: June 27, 2009, 04:31:16 pm by 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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Please help me fix it, I find the reasons!
« Reply #10 on: July 02, 2009, 08:00:54 am »
@loaden:

I copy a large header from "Visual studio C++ header folder" which named "WINUSER.h" (232KB)

And I paste to the root of my test project folder, and renamed to "testWINUSER.h"

Then create a simple project

Code
#include "testWINUSER.H"
int main()
{
    UserHandleGrantA  //code completion works fine!
    return 0;
}

And every thing works fine..  At least the last function declaration in that header file is

Code
BOOL UserHandleGrantAccess(
    HANDLE hUserHandle,
    HANDLE hJob);


And code completion works fine! This means the totally 232K files were parsed, not break in the middle. :D

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 blueshake

  • Regular
  • ***
  • Posts: 459
Re: Please help me fix it, I find the reasons!
« Reply #11 on: July 23, 2009, 01:35:01 pm »
I do a patch for this ,class CHyperLinkImpl can be parsed correctly  now.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Please help me fix it, I find the reasons!
« Reply #12 on: July 23, 2009, 01:39:14 pm »
I do a patch for this ,class CHyperLinkImpl can be parsed correctly  now.
where can I find this 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 Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Please help me fix it, I find the reasons!
« Reply #13 on: July 23, 2009, 01:50:17 pm »

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Please help me fix it, I find the reasons!
« Reply #14 on: July 24, 2009, 05:21:31 am »
Thanks to ollydbg!
[removed non-english content]

It's seems have other reason, but not the file size.
It's maybe: max allowed matches. by default, it's be 16340, now i change the value to : 100000
« Last Edit: July 24, 2009, 11:40:17 am by MortenMacFly »

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: Please help me fix it, I find the reasons!
« Reply #15 on: July 24, 2009, 06:25:50 am »
Quote
It's maybe: max allowed matches. by default, it's be 16340, now i change the value to : 100000
It happened when you type some letters which  is not English sometimes . :)
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?