Menu

working with references

Help
2010-03-07
2013-04-24
  • Pavel Eroshenko

    Pavel Eroshenko - 2010-03-07

    Hello,

    I have a function:
    void GetStringValues(std::string& result, std::string& property)
    that fills values "result" and "property".
    How can I call this function using VOLE?

     
  • Matt Wilson

    Matt Wilson - 2010-03-07

    Hi

    I'm not able to understand what you're doing clearly enough from the information you've given.

    VOLE drives COM Automation servers from C++; from your post it seems you're trying to drive a C++ function, which you can obviously just call directly from C++.

    If you post a fuller question, I'm sure we can answer.

    Matt

     
  • Pavel Eroshenko

    Pavel Eroshenko - 2010-03-08

    Hello again.
    I'm trying to convert my code from COM to VOLE
    Original I have:
    MyClass* mClass = new MyClass();
    …..
    std::string result, property;
    mClass->GetStringValues(result, property);
    std::cout<<result<<std::endl<<property;

    Now, if I write
    object *mClass = ….
    ….
    mClass->invoke_method_v(L"GetStringValues", &result, &property);
    it will not work as it was supposed.
    So my question is how to do it correct.

     
  • Matt Wilson

    Matt Wilson - 2010-03-09

    Sorry, but the code sample you've given is still just plain-old-C++. It's insufficient to make a guess from that to what you're really doing. Can you provide some actual COM code that we can discuss?

    Matt

     
  • Pavel Eroshenko

    Pavel Eroshenko - 2010-03-16

    Sorry for not making myself clear in the previous posts. Here's a bit of an actual code:

    //Initialize COM Library
    hResult = CoInitializeEx(NULL,COINIT_APARTMENTTHREADED);
    //Create instance of core object
    hResult = CoCreateInstance(CLSID_CoreAut,NULL,CLSCTX_ALL,IID_ICoreAut,(void**)&g_pCore);
    //Create instnce of trade desk object
    hResult = g_pCore->CreateTradeDesk(L"trader",(IDispatch**)&g_pTradeDesk);

    VARIANT vOrderID,vDI;
    hResult = g_pTradeDesk->CreateEntryOrder(bstrAccountID,bstrSymbol,bIsBuy,iLots,nPrice,nStop,nLimit,0,&vOrderID,&vDI);

    The CreateEntryOrder method takes the vOrderID and vDI parameters by reference and alters their values.

    Is it possible to have this method called using VOLE?

    Thanks!

     
  • Matt Wilson

    Matt Wilson - 2010-03-16

    Ah, I see. You're after  parameters.

    No, alas VOLE does not (yet) support them.

    Of course, now you've raised it my mind is filling with ideas …

    Matt

     
  • Duncan McQueen

    Duncan McQueen - 2010-03-16

    Anything that can be done to egg on the inclusion of this?  I could see a lot of value in some of my projects if VOLE allowed this.

     
  • Matt Wilson

    Matt Wilson - 2010-03-16

    Unfortunately, I am pretty snowed with multiple commercial commitments at the moment, some of which will, thankfully, soon be complete.

    It all depends on your timescales. But if you can't/don't want to wait, your options boil down to:
    * engaging me to write a proprietary extension for your exclusive use
    * sponsor the development of the new feature to the library
    * contribute the new feature

    Either of the first two will, of course, move you (close) to the head of my work queue. The third will, equally obviously, require a lot of work from you.

    I apologise that I can't be more FOSS at this point, but I'm just too busy.

    All the best

    Matt

     
  • Duncan McQueen

    Duncan McQueen - 2010-03-17

    How much would it cost to sponsor the development?

     
  • Matt Wilson

    Matt Wilson - 2010-03-21

    I've been giving it some thought, and doing some experimentation, and it seems that the reason I'd never known of out / in-out parameters being supported by type-library marshalling is that they're not. They are not, therefore, available to late-binding clients (except, perhaps, where custom marshalling is implemented), such as VBScript, Ruby, and VOLE.

    Consider the following IDL:

    interface IClass1
      : IDispatch
    {
      [id(1), helpstring("method Method1")]
      HRESULT Method1([in] VARIANT a0, [out, retval] VARIANT* a1);
      [id(2), helpstring("method Method2")]
      HRESULT Method2([in] VARIANT a0, [out] VARIANT* a1, [out, retval] VARIANT* a2);
      [id(3), helpstring("method Method3")]
      HRESULT Method3([in] long l0, [in, out] VARIANT* v1, [out, retval] VARIANT* r);
    };
    

    Assume a class implementing this interface, that changes each of the out/in-out parameters. If you connect a class exposing this interface via early binding, such as VB or C++, then you can indeed see the changed values. However, if you connect via VBS, Ruby or VOLE, only the  changes can be seen, and that's via the special treatment of  by Automation.

    So, in order to consider a sponsored implementation, you'd need to precisely specify what functionality you're looking for. If it's along the lines of the scenario I've described, then we might have to look beyond type-library marshalling. Once you've given me more information, I can consider (i) whether it's possible, and (ii) how much effort that might take, and therefore how much I'd be looking for sponsorship assistance.

    HTH

    Matt

     
  • Duncan McQueen

    Duncan McQueen - 2010-04-02

    Maybe I don't understand the question, but my exact scenario is above:

    hResult = g_pTradeDesk->CreateEntryOrder(bstrAccountID,bstrSymbol,bIsBuy,iLots,nPrice,nStop,nLimit,0,&vOrderID,&vDI);

    The CreateEntryOrder method takes the vOrderID and vDI parameters by reference and alters their values.

    so basic IN/OUT ByRef on a variable - does this answer your question about specifically what I need to have happen?

     
  • Duncan McQueen

    Duncan McQueen - 2010-04-28

    Any additional information I can provide?  I'd love to sponsor the development of the ability to have in/out vars.

     
  • Matt Wilson

    Matt Wilson - 2010-04-29

    Duncan

    Sorry for the lack of response: a vacation and working on some other things (including a new version of VOLE) explain (but do not excuse) my lack of manners.

    I'm very pleased to hear of your desire to sponsor new features, and interested in the challenge. However, I think we probably need to discuss your requirements in quite some detail - I suspect that the thing you're after is impossible via OLE Automation, and would require a different approach entirely - so will send you an email shortly.

    Cheers

    Matt

     
  • Duncan McQueen

    Duncan McQueen - 2010-05-10

    It might be - if in/out is not possible via OLE, then it likely isn't.

     
  • Matt Wilson

    Matt Wilson - 2010-05-13

    That's right. But it may be possible via other means. Check out the STLSoft DL library: I think it's possible that the technology used in the

    dl_call()
    

    could be adapted/enhanced to achieve what you're after with COM dual interfaces

     
  • Duncan McQueen

    Duncan McQueen - 2011-03-16

    Thought I'd revisit this - is your analysis about the lat ebinding that VOLE does will still prevent an in/out return val on a call?  It seems that in my project VOLE does everything else except for those few functions where I have an in/out parameter to the function.

     

Log in to post a comment.