GithubHelp home page GithubHelp logo

Future of this crate about com-rs HOT 6 OPEN

rylev avatar rylev commented on June 2, 2024 3
Future of this crate

from com-rs.

Comments (6)

demberto avatar demberto commented on June 2, 2024 3

You probably should remove the note in the README saying this crate is in heavy development, the last commit to this repo was 8 months ago

from com-rs.

MarijnS95 avatar MarijnS95 commented on June 2, 2024

@rylev has any progress been made towards answering this question?

from com-rs.

rylev avatar rylev commented on June 2, 2024

Progress has been made, but a resolution has not been come to. We are certainly still looking to improve this crate in the short term, but the relationship with the windows crate is still not very clear.

from com-rs.

MarijnS95 avatar MarijnS95 commented on June 2, 2024

Thanks @rylev! I'll wait for that then before making a move, but would it help to detail my (arguably niche) use-case?

from com-rs.

rylev avatar rylev commented on June 2, 2024

Absolutely!

from com-rs.

MarijnS95 avatar MarijnS95 commented on June 2, 2024

@rylev Thanks! Besides using windows-rs to call into Windows APIs in a nice way, we have this niche use-case of DXC that natively compiles to Linux and Windows as library and exposes COM objects through a DxcCreateInstance(class_id, r_iid, ppv). We are currently using the ancient com_rs crate to describe the COM interfaces by hand and call into them, but the resulting API is as raw as C++ and this crate requires libuuid.

We hence started looking into and have a working port with com-rs back in the day, but this stagnated right as windows-rs got announced which seems to be superior to com_rs and com-rs in almost every way:

  • Newer, and supposedly integrating with or superseding com-rs (but that seems to be backtracked on now);
  • Bindings are fully autogenerated: DXC headers are already processed in win32metadata;
  • Bindings are much more pretty: pointer-returns are wrapped in Result, riid+ppv pairs are "hidden" behind a template argument, array pointer+count are rewritten to accept slices, refcounting is handled on Drop, et cetera;

This actually works for us (implementation is a little dated tohugh), but with one major caveat: windows-rs doesn't support Linux without some modifications. Most notably:

  • Error handling calls into unimplemented!() Windows functions (cannot be linked on Linux) such as SetLastError and GetErrorInfo;
  • String handling is provided by windows-rs (which is nice!) but is only written for 16-bit wide-chars. Linux used 32-bit wchars. I've written some patches to utilize widestring (see the linked DXC proof of concept) but that obviously didn't get accepted, though I am open to write a native implementation.

All in all I don't see any reason for us to use com-rs, given that we can get 32-bit WCHAR support behind a #[cfg(not(windows))] and some shims (bare-bones default implementations) for those few functions that may be called when errors are handled. We're probably only interested in a pretty string for some well-known values (E_NOINTERFACE) when formatting/unwrapping results.

from com-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.