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

Support other string types #27

Closed
Rantanen opened this issue Dec 13, 2017 · 2 comments
Closed

Support other string types #27

Rantanen opened this issue Dec 13, 2017 · 2 comments
Assignees

Comments

@Rantanen
Copy link
Owner

Rantanen commented Dec 13, 2017

Current plan

https://github.com/Rantanen/intercom-site/blob/master/content/docs/types/strings.md


Legacy thoughts

Currently String is converted to BStr.

It might be more sensible to reduce the automation in this sense. Perhaps use the following mappings:

  • BStr - BSTR
  • OsString - WCHAR* on Windows, char* on Linux.
  • String - char* everywhere. Essentially being std::string compatible.

Eager implement for AsRef/From/etc. on BStr would be needed for this to be sensible.

On Windows BStr would be allocated with SysAllocString while everything else would use the CoTaskMemAlloc APIs. Not sure what the equivalent on Linux would be, if any. The fallback for both systems would be to use the #6 APIs once we get those.

@Rantanen
Copy link
Owner Author

OsString should be BSTR on Windows. This is compatible with APIs expecting WCHAR* as long as they don't take ownership of the memory.

With this change OsString is the preferred string to use when trying to achieve best compatibility with the platform expectations.

The WCHAR* type should be represented with &[u16] or Vec<u16> in the future, as this is the type that std::os::windows::ffi uses for WCHAR*.

@Rantanen Rantanen added this to the Public release milestone Feb 8, 2018
@Rantanen Rantanen self-assigned this Jul 24, 2018
@Rantanen
Copy link
Owner Author

#85 landed a while back, which added CString/&CStr

So in total we now have:

  • BString/&BStr
  • String/&str
  • CString/&CStr

The UString/&UStr variant is missing. We can implement that as the C++ wrapper gets support for that. For now the "native C string" is Rust's built-in CString (just a raw zero terminated char* string).

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

No branches or pull requests

1 participant