Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Wrappers for common types, e.g. BSTR, VARIANT, SAFEARRAY #182

Open
heaths opened this issue Nov 9, 2020 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@heaths
Copy link
Member

heaths commented Nov 9, 2020

While winapi exposes many of these types of functions necessary to use them, there isn't any good support for these types often used in COM. For example, I wrote a BStr (though, I suppose that should be BString to match the Rust naming convention) that exposes just enough of what I need, but this could be expanded considerably to implement From traits and more, and be readily available for use with the com crate. Same for VARIANT and even SAFEARRAY.

@MarijnS95
Copy link
Contributor

If helpful at all, we do a similar thing in hassle-rs (a potential future user of com-rs):

https://github.com/Traverse-Research/hassle-rs/blob/ms-com-rs/src/os.rs
https://github.com/Traverse-Research/hassle-rs/blob/ms-com-rs/src/utils.rs

We'd be happy if these can be moved to a (Windows common) crate as long as types and wrappers are exposed for Linux.

@rylev
Copy link
Contributor

rylev commented Nov 9, 2020

We're working on a solution for this that we hope to be able to share shortly. Stay tuned!

@Bigous
Copy link

Bigous commented Jan 20, 2022

Does this old crate can help?

Or, is there any news? I'm stuck on the IRtdServer interface, that has this idl with SAFEARRAY(VARIANT)* and IRTDUpdateEvent* as parameter:

// TLib :     // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");

// Forward declare all types defined in this typelib
interface IScripRTD;
interface IRTDUpdateEvent;

[
  uuid(A04A3240-D051-4B4C-B004-CA92151F11E5),
  helpstring("ScripRTD Class")
]
coclass ScripRTD {
    [default] interface IScripRTD;
};

[
  odl,
  uuid(EC0E6191-DB51-11D3-8F3E-00C04F3651B8),
  helpstring("IScripRTD Interface"),
  dual,
  nonextensible,
  oleautomation
]
interface IScripRTD : IDispatch {
    [id(0x0000000a)]
    HRESULT ServerStart(
                    [in] IRTDUpdateEvent* callback, 
                    [out, retval] long* result);
    [id(0x0000000b)]
    HRESULT ConnectData(
                    [in] long topicId, 
                    [in] SAFEARRAY(VARIANT)* strings, 
                    [in, out] VARIANT_BOOL* newValues, 
                    [out, retval] VARIANT* values);
    [id(0x0000000c)]
    HRESULT RefreshData(
                    [in, out] long* topicCount, 
                    [out, retval] SAFEARRAY(VARIANT)* data);
    [id(0x0000000d)]
    HRESULT DisconnectData([in] long topicId);
    [id(0x0000000e)]
    HRESULT Heartbeat([out, retval] long* result);
    [id(0x0000000f)]
    HRESULT ServerTerminate();
};

[
  odl,
  uuid(A43788C1-D91B-11D3-8F39-00C04F3651B8),
  dual,
  oleautomation
]
interface IRTDUpdateEvent : IDispatch {
    [id(0x0000000a)]
    HRESULT UpdateNotify();
    [id(0x0000000b), propget]
    HRESULT HeartbeatInterval([out, retval] long* value);
    [id(0x0000000b), propput]
    HRESULT HeartbeatInterval([in] long value);
    [id(0x0000000c)]
    HRESULT Disconnect();
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants