diff --git a/cpp/README.md b/cpp/README.md index 5e72df84..81122315 100644 --- a/cpp/README.md +++ b/cpp/README.md @@ -85,9 +85,6 @@ cpack --config build/CPackConfig.cmake -C RelWithDebInfo For the first layer of the wrapper, built using Cargo: - `LIBLOOT_VERSION_MAJOR`, `LIBLOOT_VERSION_MINOR` and `LIBLOOT_VERSION_PATCH` are exposed as `extern "C"` `static unsigned int` globals. -- CXX doesn't provide integration between Rust's `Option<_>` and C++'s `std::optional`, so sentinel values are used to communicate the absence of a value in the wrapper's API: - - For `Option<&str>`, `None` is represented using an empty string, which is how it's already done for many metadata object fields in the C++ implementation of libloot. - - For `Option`, `None` is represented using `NaN`, since the C++ implementation of libloot's public API already says that `NaN` values get converted to `None`. - All Rust errors are converted to `::rust::Error` exceptions that have a `what()` string that is the concatenation of the error's display string and all its recursive source error display strings. For some errors the `what()` string also includes some data that is parsed by the wrapper's second layer to differentiate certain error types. For the ABI-compatible second layer of the wrapper, built using CMake: diff --git a/cpp/src/lib.rs b/cpp/src/lib.rs index b975408b..0375ecbe 100644 --- a/cpp/src/lib.rs +++ b/cpp/src/lib.rs @@ -238,6 +238,7 @@ mod ffi { } pub enum EdgeType { + /// A special value that indicates that there is no edge. None, Hardcoded, MasterFlag, @@ -271,7 +272,6 @@ mod ffi { extern "Rust" { pub fn is_some(self: &OptionalMessageContentRef) -> bool; - // Again, these lifetimes are wrong. pub unsafe fn as_ref<'a>(self: &'a OptionalMessageContentRef) -> Result<&'a MessageContent>; } @@ -316,10 +316,8 @@ mod ffi { pub fn clear_loaded_plugins(&mut self); - // The plugin's lifetime is actually less than &Game's, it's only valid so long as the loaded plugin is not overwritten or cleared. pub fn plugin(&self, plugin_name: &str) -> Box; - // The plugin's lifetime is actually less than &Game's, it's only valid so long as the loaded plugin is not overwritten or cleared. pub fn loaded_plugins(&self) -> Vec; pub fn sort_plugins(&self, plugin_names: &[&str]) -> Result>; @@ -454,17 +452,16 @@ mod ffi { pub fn name(&self) -> &str; - // The None case is signalled by NaN. + /// NaN is used to indicate that the header version was not found. pub fn header_version(&self) -> f32; - // The None case is signalled by an empty string (which is not a valid version). + /// An empty string is used to indicate that no version was found. pub fn version(&self) -> &str; pub fn masters(&self) -> Result>; pub fn bash_tags(&self) -> &[String]; - // The None case is signalled by -1, all other values fit in u32. pub fn crc(&self) -> Box; pub fn is_master(&self) -> bool; @@ -497,7 +494,6 @@ mod ffi { pub fn is_some(&self) -> bool; - // Again, these lifetimes are wrong. pub unsafe fn as_ref<'a>(&'a self) -> Result<&'a Plugin>; } @@ -506,7 +502,6 @@ mod ffi { pub fn is_some(&self) -> bool; - // Again, these lifetimes are wrong. pub unsafe fn as_ref<'a>(&'a self) -> Result<&'a u32>; } @@ -527,7 +522,6 @@ mod ffi { pub fn is_some(&self) -> bool; - // Again, these lifetimes are wrong. pub unsafe fn as_ref<'a>(&'a self) -> Result<&'a PluginMetadata>; } @@ -538,6 +532,7 @@ mod ffi { pub fn name(&self) -> &str; + /// An empty string is used to indicate that no group is set. pub fn group(&self) -> &str; pub fn load_after_files(&self) -> &[File];