rust-objc icon indicating copy to clipboard operation
rust-objc copied to clipboard

Consider making objc no_std compatible

Open SSheldon opened this issue 8 years ago • 1 comments

This crate is mainly just a wrapper around the objc runtime dylib, so it shouldn't need much else. If we can make it no_std then it might be usable in more places, perhaps even in the rust compiler itself.

The current std dependencies that aren't part of libcore are:

  • Nul-terminating &str via CString in the runtime module and the declare module
  • Reading the length of a C string via CStr in the runtime module and for Encoding
  • Using a String in Encoding to store dynamically-sized, runtime defined type encodings
  • Allocating a buffer via String when declaring methods to represent their type encodings in the declare module
  • Using a String in the representation of MessageError
  • Implementing the Error trait for MessageError
  • Using the std::os::raw types instead of the libc types in the runtime module and for implementing the Encode trait

SSheldon avatar Feb 05 '17 19:02 SSheldon

Current thoughts on how this could be possible:

  • [ ] #54: create a new string abstraction so nul-terminated strings can be passed to the runtime without us having to modify them and allocate new memory
  • [x] #53: overhaul encoding, maybe make it generic so that it can sometimes be declared without any allocations
  • [ ] break the declare module into a separate crate
  • [ ] convert MessageError into an enum rather than backing it with a String and remove the Error conformance (rust-lang/rust#32500)
  • [ ] switch back to using libc instead of std::os::raw 😕

SSheldon avatar Feb 05 '17 19:02 SSheldon