Menu

Passing a Structure in Function argument

2012-06-06
2012-11-29
  • Mustafa Muhammad

    Hi,
    I am new to jInterop, I am using version 2.08
    Can any help me in this issue

    I have defined  a struct in C++

    typedef struct Event
    {
    BSTR strName;
    int aType;
    int bCriteria;
    BSTR strCondition;
    int pDays;
    int pMonths;
    BSTR strMethod;
    int lRefreshRate;
    BSTR ftStartTime;
    BSTR ftEndTime;
    BSTR ftInterval;
    }

    I am passing this structure Array in Function

    HRESULT Add(
                      BSTR m_strFiniteStateMachineName,
    int a_dwEventsCount,
    Event * m_pEvents
                   );

    my Java Code Looks like

    //// Java Code Starts

    JIStruct TransactionEvents = new JIStruct();
    int a = 2,b=5;
    int al=23,bl=12,cl = 23;

    TransactionEvents.addMember(strEventName);
    TransactionEvents.addMember(a);
    TransactionEvents.addMember(b);
    TransactionEvents.addMember(strCondition);
    TransactionEvents.addMember(al);
    TransactionEvents.addMember(bl);
    TransactionEvents.addMember(strAI_MethodName);
    TransactionEvents.addMember(cl);
    TransactionEvents.addMember(ftStartTime);
    TransactionEvents.addMember(ftEndTime);
    TransactionEvents.addMember(ftInterval);

    JIStruct Transactionsarray = new JIStruct;
    Transactionsarray = TransactionEvents;

    JIArray TransactionsJArray = new JIArray(Transactionsarray,true);

    callObject.addInParamAsString(str,JIFlags.FLAG_REPRESENTATION_STRING_BSTR);
           
            callObject.addInParamAsInt(1, JIFlags.FLAG_REPRESENTATION_VT_UINT);
            callObject.addInParamAsArray(TransactionsJArray , JIFlags.FLAG_NULL);

    //// Java Code Ends

    I didn't receive any call in C++. I get Exception."The Stub has received bad data.. "

    Can any one Help me in this issue??

    Best Regards
    Mustafa Muhammad

     
  • Vikram Roopchand

    Hi,

    I think its something to do with the JIFlags in the callObject. Request you to please look at the JITypeInfoImpl and its sister classes on how to call with Structs as params.

    thanks,
    best regards,
    Vikram

     

Log in to post a comment.