User forums > Using Code::Blocks

Code completion does not solve STDMETHOD macro for COM interfaces

<< < (2/4) > >>

GPBeta:
Thank you so much for the debugging so that I can try to find out some ways to have it a hot fix.

--- Code: ---[debug]$3 = {m_FullType = L"virtual HRESULT STDMETHODCALLTYPE m", m_BaseType = L"m", m_Name = L"STDMETHOD", m_Args = L"(m)"
--- End code ---
According to the debug info, m_FullType contains the m_Name, then parsing process interrupt.
So I replaced the macro in the sample:

--- Code: ---#define STDMETHOD(m) virtual HRESULT STDMETHODCALLTYPE m
#define STDMETHOD_(t,m) virtual t STDMETHODCALLTYPE m

--- End code ---
with this code:

--- Code: ---#define STDMETHOD(m) virtual HRESULT __stdcall m
#define STDMETHOD_(t,m) virtual t __stdcall m

--- End code ---
Now the m_Name("STDMETHOD") does not match any sub strings in m_FullType("virtual HRESULT __stdcall m"),
but it doesn't seem to be any help to code completion expending STDMETHOD or STDMETHOD_ macro, any ideas?

Huki:

--- Quote from: ollydbg on September 21, 2014, 04:41:28 pm ---Here have a code snippet:

--- Code: ---bool Tokenizer::GetMacroExpandedText(const Token* tk, wxString& expandedText)
{
    // e.g. "#define AAA AAA" and usage "AAA(x)"
    if (!tk || tk->m_Name == tk->m_FullType)
        return false;

    // sanity check if we have such macro definition that #define AAA(x,y) x+y+AAA
    // if a macro name exists in its definition, it will cause a infinite expansion loop
    if (tk->m_FullType.Find(tk->m_Name) != wxNOT_FOUND)
        return false;

--- End code ---
Here, the macro definition token tk is:

--- Code: ---[debug]> p *tk
[debug]$3 = {m_FullType = L"virtual HRESULT STDMETHODCALLTYPE m", m_BaseType = L"m", m_Name = L"STDMETHOD", m_Args = L"(m)",
--- End code ---
Now, I see that m_FullType contains the m_Name, so we just stop expansion, and return false to avoid infinite recursive call :(
--- End quote ---
Yes, we are using m_FullType.Find() to see if m_Name is a sub-string of m_FullType, so it doesn't see any difference between STDMETHOD and STDMETHODCALLTYPE.  ::)

A quick way to fix it is to just disable this test. We have macro replacement limited to s_MaxRepeatReplaceCount, so we won't get infinite replacement loop anyway. So if m_FullType contains m_Name we assume the user knows what he is doing and we just try to continue expansion.

Huki:

--- Quote from: GPBeta on September 21, 2014, 07:22:52 pm ---Thank you so much for the debugging so that I can try to find out some ways to have it a hot fix.

--- Code: ---[debug]$3 = {m_FullType = L"virtual HRESULT STDMETHODCALLTYPE m", m_BaseType = L"m", m_Name = L"STDMETHOD", m_Args = L"(m)"
--- End code ---
According to the debug info, m_FullType contains the m_Name, then parsing process interrupt.
So I replaced the macro in the sample:

--- Code: ---#define STDMETHOD(m) virtual HRESULT STDMETHODCALLTYPE m
#define STDMETHOD_(t,m) virtual t STDMETHODCALLTYPE m

--- End code ---
with this code:

--- Code: ---#define STDMETHOD(m) virtual HRESULT __stdcall m
#define STDMETHOD_(t,m) virtual t __stdcall m

--- End code ---
Now the m_Name("STDMETHOD") does not match any sub strings in m_FullType("virtual HRESULT __stdcall m"),
but it doesn't seem to be any help to code completion expending STDMETHOD or STDMETHOD_ macro, any ideas?

--- End quote ---
After replacing STDMETHODCALLTYPE with __stdcall I get the correct results with code completion. See below:



ollydbg:

--- Quote from: GPBeta on September 21, 2014, 07:22:52 pm ---...
but it doesn't seem to be any help to code completion expending STDMETHOD or STDMETHOD_ macro, any ideas?

--- End quote ---
You need a patch by Huki, see: Re: Is it possible for the parser to support newlib prototypes?


--- Quote from: Huki on September 21, 2014, 08:45:11 pm ---...
After replacing STDMETHODCALLTYPE with __stdcall I get the correct results with code completion. See below:





--- End quote ---
I can get expected function shown in the suggestion list. But in my suggestion list, I see a lot of global namespace tokens, not sure why those global tokens were shown, need time to debug.
EDIT: issue fixed since I was disable the smart sense option of CC. I get the same suggestion list as Huki now.  ;)

GPBeta:

--- Quote from: Huki on September 21, 2014, 08:45:11 pm ---
--- Quote from: GPBeta on September 21, 2014, 07:22:52 pm ---Thank you so much for the debugging so that I can try to find out some ways to have it a hot fix.

--- Code: ---[debug]$3 = {m_FullType = L"virtual HRESULT STDMETHODCALLTYPE m", m_BaseType = L"m", m_Name = L"STDMETHOD", m_Args = L"(m)"
--- End code ---
According to the debug info, m_FullType contains the m_Name, then parsing process interrupt.
So I replaced the macro in the sample:

--- Code: ---#define STDMETHOD(m) virtual HRESULT STDMETHODCALLTYPE m
#define STDMETHOD_(t,m) virtual t STDMETHODCALLTYPE m

--- End code ---
with this code:

--- Code: ---#define STDMETHOD(m) virtual HRESULT __stdcall m
#define STDMETHOD_(t,m) virtual t __stdcall m

--- End code ---
Now the m_Name("STDMETHOD") does not match any sub strings in m_FullType("virtual HRESULT __stdcall m"),
but it doesn't seem to be any help to code completion expending STDMETHOD or STDMETHOD_ macro, any ideas?

--- End quote ---
After replacing STDMETHODCALLTYPE with __stdcall I get the correct results with code completion. See below:





--- End quote ---

Thanks for the help Huki, but CC is still not going to parse it unless removing the __stdcall from macro definition:

--- Code: ---#define STDMETHOD(m) virtual HRESULT __stdcall m
#define STDMETHOD_(t,m) virtual t __stdcall m

--- End code ---

Maybe I should try about the patch ollydbg referred and compile it myself?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version