#34 Support IDispatch out parameters

open
nobody
None
5
2007-11-09
2007-11-09
No

Please add support to get a new object (IDispatch) through an in/out parameter.

The concrete problem is described in the following forum thread: http://sourceforge.net/forum/forum.php?thread_id=1861572&forum_id=375946

Thanks.
Tom

Discussion

  • Jason Smith

    Jason Smith - 2007-11-13

    Logged In: YES
    user_id=1895760
    Originator: NO

    I'm still working on validating this, but it looks like something isn't quite working in get/setDispatchRef(). It's on my to-do list.

     
  • Jason Smith

    Jason Smith - 2007-11-13

    Logged In: YES
    user_id=1895760
    Originator: NO

    Checking further, I realized that we don't need code demonstrating this bug/feature. It is simply not implemented!

    putDispatchRef() and putDispatch() call the same darn thing! It's even documented to work that way.

    /**
    * Dispatch and dispatchRef are treated the same This is a cover for
    * putVariantDispatch(). Dispatch and dispatchRef are treated the same
    *
    * @param in
    */
    public void putDispatchRef(Dispatch in) {
    putVariantDispatch(in);
    }

    See? No way to distinguish byref/byval. :-)

    The result is that any Variant you create with Byref == true will in fact end up as Byref == false (type (9) instead of type (9 + 16384)).

     
  • clay_shooter

    clay_shooter - 2007-11-22

    Logged In: YES
    user_id=1189284
    Originator: NO

    Someone has to write the C++ code to add this feature and I'll insert it.

     
  • Jason Smith

    Jason Smith - 2007-11-23

    Logged In: YES
    user_id=1895760
    Originator: NO

    This probably should be listed as a bug. Byref passing is supported for every other type, although it causes JVM crashes for SafeArray/VariantArray. :-)

     
  • Jason Smith

    Jason Smith - 2008-02-05

    Logged In: YES
    user_id=1895760
    Originator: NO

    This one has now been reported from the Scriptom side. Excerpt:

    Hi Jason, Thanks for the info! It seems like a big restriction to me, as there are many API's, such as the COM API in Google Earth, that use a similar method. I'll give your suggestion for creating a DLL wrapper a try, although I have no VB experience, or try another approach.

    Regards --Roland

    Smith, Jason wrote:
    >
    > Roland, this is a limitation of the underlying Jacob library. It has
    > come up before for a few people using Jacob, but I think this is the
    > first time it has come up for Scriptom. We've got a bug report on it
    > (jira), the Jacob team has a bug report on it, and I don't expect it
    > to be fixed soon.
    >
    > The only workaround I can think of at the moment is to write a wrapper
    > DLL that returns the object as the result of a method. You can use
    > Visual Basic .NET to do this. There is an example of writing a
    > COM-enabled DLL using Visual Basic .NET in the Scriptom wiki.
    >

     
  • clay_shooter

    clay_shooter - 2008-02-05

    Logged In: YES
    user_id=1189284
    Originator: NO

    Does anyone have a test program that that could be used to verify it works against some commonly available API/DLL?

     
  • Jason Smith

    Jason Smith - 2008-02-05

    Logged In: YES
    user_id=1895760
    Originator: NO

    If you need, I can send you a VB.net project that will demonstrate the issue. Do you have a test suite that it would be easy to add it to, or are you just looking for a library you can code against? Or several libraries to test against?

     
  • clay_shooter

    clay_shooter - 2008-02-05

    Logged In: YES
    user_id=1189284
    Originator: NO

    I think the answer to your question is "yes". Is there any API in MS Office or Windows itself that requires this feature so that a test could be run against it? The VB.net project would be nice but it needs to run against a common dll so that folks can build against it.

    I haven't even looked at how hard this might be to code.

     
  • Jason Smith

    Jason Smith - 2008-02-06

    Logged In: YES
    user_id=1895760
    Originator: NO

    False alarm. I still don't have a solid example of someone doing this in a well known COM interface, and the rumors that the Google Earth team use bad design are proven false. However, if you look at their documentation (which is written for C++ programmers), you can see how it was pretty easy to misread. The following email excerpt should clear things up.

    And for now, I don't see a major need to add this feature. That is, unless someone is working in the code and figure out how to do it easily.

    Okay, after checking out how they have documented, I think you are trying to call it wrong. They've documented the C++ form of the COM interfaces, which always returns an HResult.

    I am assuming you are trying to call GetCamera, not 'considerTerrain', which is an argument passed to GetCamera.

    Open Excel and open the VBA macro editor. Poke around until you figure out how to add a 'reference' to the Google Earth api. Now you can view the whole thing in the Object Browser, which will give you the Visual Basic form of the method calls.

    In short, though, pCamera is an [out,retval], so in script land, that means it is the return value.

    Something like the following code should work.

    def appGE = new ActiveXObject('something.something')
    ActiveXObject camera = appGE.GetCamera(true)

    When in doubt, try to write a little example app using VBA, VB6, or VB.net. The syntax translates very closely to Scriptom syntax.

    What is an HRESULT? That is how C++ returns COM error codes. In Java/Groovy land, we use try/catch and throw mechanisms. :-)

    Please let me know if this works, as I can't install Google Earth at work. I am looking at this from a theoretical viewpoint.

    Jason Smith

    -----Original Message-----
    From: Hochmuth, Roland M
    Sent: Tuesday, February 05, 2008 3:48 PM
    To: Smith, Jason
    Subject: RE: [groovy-user] Using scriptom to return COM object

    Hi Jason, Here are the links for the Google Earth COM API that I found.

    http://earth.google.com/comapi/
    http://services.google.com/earth/earth.idl

    I tried invoking IApplicationGE::considerTerrain(...) as a test

     

Log in to post a comment.