Confusion again.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Confusion again.

Ming Cheng
My C++ source code:

void initPluginAgentMsgCopy(PFO_PluginAgent& );

class CPlImplMsgCopy : public QFIXFLEX_NMSP::CPluginImplBase<CPlImplMsgCopy>
{
public:
    CPlImplMsgCopy() : m_pMgr(NULL), m_bDoRecovery(false)
    {
    }
    ~CPlImplMsgCopy()
    {
        if (NULL != m_pMgr)
        {
            delete m_pMgr;
            m_pMgr = NULL;
        }
    }

    static const std::string& name()
    {
        static const std::string s_name("MSGCOPY");
        return s_name;
    }
}


My Java processing code:

private static void processFuncName(IIndex index, IASTName funcName) {
        // find bindings for name
        try {
            index.acquireReadLock();
            IBinding binding = funcName.resolveBinding();
            if (binding != null) {
                display(binding.getName());
                IIndexBinding[] bindings= index.findBindings(binding.getName().toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
                display("bindings=" + bindings.length);
                for (IIndexBinding b : bindings) {
                    if (binding instanceof IFunction) {
                        outputReferences(index, binding);
                    } else {
                         
                        display("non IFunction");
                    }
                }
            }
        } catch (CoreException e) {
            log.error(e.getMessage());
        } catch (InterruptedException e) {
            log.error(e.getMessage());
        } finally {
            index.releaseReadLock();
        }
    }

initPluginAgentMsgCopy() will come to outputReferences() but CPlImplMsgCopy() /name().

display("bindings=" + bindings.length); does show these 3 (initPluginAgentMsgCopy() /CPlImplMsgCopy() /name() binding size are 1.

Thanks.

_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: Confusion again.

Ming Cheng
I know when my program parses my C++ src, it came to my function:

private static int visit(IIndex index, ICPPASTFunctionDeclarator cppFunctionDeclarator) {
        display("Visiting ICPPASTFunctionDeclarator: " + cppFunctionDeclarator.getRawSignature());
        //display(cppName.getBinding().getName());
        IBinding b = CPPVisitor.createBinding(cppFunctionDeclarator.getName());
        if (b != null)
            processFuncName(index, b);
        else {
            display("failed to find IBinding");
        }
        return PROCESS_CONTINUE;
    }



However processFuncName() prompts "non IFunction":

private static void processFuncName(IIndex index, IBinding b) {
        try {
                    if (b instanceof IFunction) {
                        outputReferences(index, b);
                    } else if (b instanceof IProblemBinding) {
                        display("IProblemBinding");
                    } else if (b instanceof ICPPUnknownBinding) {
                        display("ICPPUnknownBinding");
                    }  else {    
                        display("non IFunction");
                    }
        } catch (CoreException e) {
            log.error(e.getMessage());
        } 
    }

Where did it go wrong?

Thanks.

From: Ming Cheng
Sent: Monday, March 2, 2020 10:32 AM
To: [hidden email] <[hidden email]>
Subject: Confusion again.
 
My C++ source code:

void initPluginAgentMsgCopy(PFO_PluginAgent& );

class CPlImplMsgCopy : public QFIXFLEX_NMSP::CPluginImplBase<CPlImplMsgCopy>
{
public:
    CPlImplMsgCopy() : m_pMgr(NULL), m_bDoRecovery(false)
    {
    }
    ~CPlImplMsgCopy()
    {
        if (NULL != m_pMgr)
        {
            delete m_pMgr;
            m_pMgr = NULL;
        }
    }

    static const std::string& name()
    {
        static const std::string s_name("MSGCOPY");
        return s_name;
    }
}


My Java processing code:

private static void processFuncName(IIndex index, IASTName funcName) {
        // find bindings for name
        try {
            index.acquireReadLock();
            IBinding binding = funcName.resolveBinding();
            if (binding != null) {
                display(binding.getName());
                IIndexBinding[] bindings= index.findBindings(binding.getName().toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
                display("bindings=" + bindings.length);
                for (IIndexBinding b : bindings) {
                    if (binding instanceof IFunction) {
                        outputReferences(index, binding);
                    } else {
                         
                        display("non IFunction");
                    }
                }
            }
        } catch (CoreException e) {
            log.error(e.getMessage());
        } catch (InterruptedException e) {
            log.error(e.getMessage());
        } finally {
            index.releaseReadLock();
        }
    }

initPluginAgentMsgCopy() will come to outputReferences() but CPlImplMsgCopy() /name().

display("bindings=" + bindings.length); does show these 3 (initPluginAgentMsgCopy() /CPlImplMsgCopy() /name() binding size are 1.

Thanks.

_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: Confusion again.

Nathan Ridge
There are two interfaces named IFunction in the CDT code:

1. org.eclipse.cdt.core.dom.ast.IFunction
2. org.eclipse.cdt.core.model.IFunction

IBindings are of the first kind (dom.ast), is that the one you're checking for?

Also, there is a public API to get the binding for a name:

  cppFunctionDeclarator.getName().resolveBinding()

(i.e. there is no need to use the private class CPPVisitor).

Hope that helps,
Nate

________________________________________
From: [hidden email] <[hidden email]> on behalf of Ming Cheng <[hidden email]>
Sent: March 4, 2020 1:42 AM
To: [hidden email]
Subject: Re: [cdt-dev] Confusion again.

I know when my program parses my C++ src, it came to my function:

private static int visit(IIndex index, ICPPASTFunctionDeclarator cppFunctionDeclarator) {
        display("Visiting ICPPASTFunctionDeclarator: " + cppFunctionDeclarator.getRawSignature());
        //display(cppName.getBinding().getName());
        IBinding b = CPPVisitor.createBinding(cppFunctionDeclarator.getName());
        if (b != null)
            processFuncName(index, b);
        else {
            display("failed to find IBinding");
        }
        return PROCESS_CONTINUE;
    }

[cid:b54bb5c2-64d7-478f-b883-35d44a5e5d17]

However processFuncName() prompts "non IFunction":

private static void processFuncName(IIndex index, IBinding b) {
        try {
                    if (b instanceof IFunction) {
                        outputReferences(index, b);
                    } else if (b instanceof IProblemBinding) {
                        display("IProblemBinding");
                    } else if (b instanceof ICPPUnknownBinding) {
                        display("ICPPUnknownBinding");
                    }  else {
                        display("non IFunction");
                    }
        } catch (CoreException e) {
            log.error(e.getMessage());
        }
    }

Where did it go wrong?

Thanks.
________________________________
From: Ming Cheng
Sent: Monday, March 2, 2020 10:32 AM
To: [hidden email] <[hidden email]>
Subject: Confusion again.

My C++ source code:

void initPluginAgentMsgCopy(PFO_PluginAgent& );

class CPlImplMsgCopy : public QFIXFLEX_NMSP::CPluginImplBase<CPlImplMsgCopy>
{
public:
    CPlImplMsgCopy() : m_pMgr(NULL), m_bDoRecovery(false)
    {
    }
    ~CPlImplMsgCopy()
    {
        if (NULL != m_pMgr)
        {
            delete m_pMgr;
            m_pMgr = NULL;
        }
    }

    static const std::string& name()
    {
        static const std::string s_name("MSGCOPY");
        return s_name;
    }
}


My Java processing code:

private static void processFuncName(IIndex index, IASTName funcName) {
        // find bindings for name
        try {
            index.acquireReadLock();
            IBinding binding = funcName.resolveBinding();
            if (binding != null) {
                display(binding.getName());
                IIndexBinding[] bindings= index.findBindings(binding.getName().toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
                display("bindings=" + bindings.length);
                for (IIndexBinding b : bindings) {
                    if (binding instanceof IFunction) {
                        outputReferences(index, binding);
                    } else {

                        display("non IFunction");
                    }
                }
            }
        } catch (CoreException e) {
            log.error(e.getMessage());
        } catch (InterruptedException e) {
            log.error(e.getMessage());
        } finally {
            index.releaseReadLock();
        }
    }

initPluginAgentMsgCopy() will come to outputReferences() but CPlImplMsgCopy() /name().

display("bindings=" + bindings.length); does show these 3 (initPluginAgentMsgCopy() /CPlImplMsgCopy() /name() binding size are 1.

Thanks.

_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/cdt-dev

Outlook-tdpby013.png (11K) Download Attachment