diff --git a/TODO.md b/TODO.md deleted file mode 100644 index ffeff7f..0000000 --- a/TODO.md +++ /dev/null @@ -1,24 +0,0 @@ -- [ ] rename `AsInnerPtr::as_ptr` to `AsInnerPtr::as_mut_ptr` - -- [ ] add NixError::from_nonnull that replaces calls to NonNull::new(...).ok_or(...) -- [ ] replace all `use nixide_sys as sys;` -> `use crate::sys;` -- [ ] store NonNull pointers in structs! -- [ ] improve documentation situation on context.rs - -- [ ] rename `as_ptr()` to `as_inner_ptr()` or `inner_ptr()`? -- [ ] ^^^ this fn should be added to a trait (maybe just `trait NixStructWrapper : AsPtr { ... }`) -- [ ] ^^^ also make `as_ptr()` public - -- [ ] add mutexs and make the library thread safe!! - -- [ ] grep all `self.inner.as_ptr()` calls and replace them with `self.as_ptr()` - - -- [ ] `ErrorContext::peak` should return `Result<(), NixideError>` **not** `Option` -- [ ] `self.expect_type` should instead be a macro to preserve the trace macro location - -- [ ] make `Value` an enum instead because like duhh - -- [ ] ensure we're always calling `ctx.peak()` unless it's ACTUALLY not necessary - -- [ ] replace *most* calls to `ErrorContext::peak()` with `ErrorContext::pop()` diff --git a/nixide/src/errors/context.rs b/nixide/src/errors/context.rs index 87d4b8e..0f53046 100644 --- a/nixide/src/errors/context.rs +++ b/nixide/src/errors/context.rs @@ -182,8 +182,6 @@ impl ErrorContext { /// of `nix_c_context` must be careful to check the `last_err_code` regularly. pub fn clear(&mut self) { unsafe { - // NOTE: previous nixops4 used the line: (maybe for compatability with old versions?) - // sys::nix_set_err_msg(self.inner.as_ptr(), sys::nix_err_NIX_OK, c"".as_ptr()); sys::nix_clear_err(self.as_ptr()); } } @@ -351,7 +349,7 @@ impl ErrorContext { impl Drop for ErrorContext { fn drop(&mut self) { unsafe { - sys::nix_c_context_free(self.inner.as_ptr()); + sys::nix_c_context_free(self.as_ptr()); } } } diff --git a/nixide/src/expr/evalstate.rs b/nixide/src/expr/evalstate.rs index 304409a..1c6bb28 100644 --- a/nixide/src/expr/evalstate.rs +++ b/nixide/src/expr/evalstate.rs @@ -97,9 +97,8 @@ impl EvalState { impl Drop for EvalState { fn drop(&mut self) { - // SAFETY: We own the state and it's valid until drop unsafe { - sys::nix_state_free(self.inner.as_ptr()); + sys::nix_state_free(self.as_ptr()); } } } diff --git a/nixide/src/expr/evalstatebuilder.rs b/nixide/src/expr/evalstatebuilder.rs index 82908dc..c289fbd 100644 --- a/nixide/src/expr/evalstatebuilder.rs +++ b/nixide/src/expr/evalstatebuilder.rs @@ -77,9 +77,8 @@ impl EvalStateBuilder { impl Drop for EvalStateBuilder { fn drop(&mut self) { - // SAFETY: We own the builder and it's valid until drop unsafe { - sys::nix_eval_state_builder_free(self.inner.as_ptr()); + sys::nix_eval_state_builder_free(self.as_ptr()); } } } diff --git a/nixide/src/store/mod.rs b/nixide/src/store/mod.rs index 63f347c..420d807 100644 --- a/nixide/src/store/mod.rs +++ b/nixide/src/store/mod.rs @@ -129,7 +129,7 @@ impl Store { sys::nix_store_realise( ctx.as_ptr(), - self.inner.as_ptr(), + self.as_ptr(), path.as_ptr(), (*state).inner_ptr() as *mut c_void, Some(callback), @@ -173,7 +173,7 @@ impl Store { |callback, userdata: *mut __UserData, ctx: &ErrorContext| unsafe { sys::nix_store_get_version( ctx.as_ptr(), - self.inner.as_ptr(), + self.as_ptr(), Some(callback), userdata as *mut c_void, ) @@ -187,7 +187,7 @@ impl Store { |callback, userdata: *mut __UserData, ctx: &ErrorContext| unsafe { sys::nix_store_get_uri( ctx.as_ptr(), - self.inner.as_ptr(), + self.as_ptr(), Some(callback), userdata as *mut c_void, ) @@ -200,7 +200,7 @@ impl Store { |callback, userdata: *mut __UserData, ctx: &ErrorContext| unsafe { sys::nix_store_get_storedir( ctx.as_ptr(), - self.inner.as_ptr(), + self.as_ptr(), Some(callback), userdata as *mut c_void, ) @@ -242,7 +242,7 @@ impl Store { impl Drop for Store { fn drop(&mut self) { unsafe { - sys::nix_store_free(self.inner.as_ptr()); + sys::nix_store_free(self.as_ptr()); } } } diff --git a/nixide/src/store/path.rs b/nixide/src/store/path.rs index e5894f3..d037c0e 100644 --- a/nixide/src/store/path.rs +++ b/nixide/src/store/path.rs @@ -71,7 +71,7 @@ impl StorePath { /// pub fn name(&self) -> NixideResult { wrap::nix_string_callback!(|callback, userdata: *mut __UserData, _| unsafe { - sys::nix_store_path_name(self.inner.as_ptr(), Some(callback), userdata as *mut c_void); + sys::nix_store_path_name(self.as_ptr(), Some(callback), userdata as *mut c_void); // NOTE: nix_store_path_name doesn't return nix_err, so we force it to return successfully // XXX: NOTE: now `nix_string_callback` is a macro this isn't necessary // sys::nix_err_NIX_OK