-
Notifications
You must be signed in to change notification settings - Fork 2
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
Rework ffi with new logging
, error handling
and some improvements in arch and safe
#10
base: main
Are you sure you want to change the base?
Conversation
logging
and some improvements in arch and safelogging
and some improvements in arch and safe
It also may solve #2 issue |
- use more debug logs - use more high-level types - fix useless code in ffi bindings - add function to work with error data (incomplete) - improve `doublets`, `platform-data` to make it compatible with new changes
logging
and some improvements in arch and safelogging
, error handling
and some improvements in arch and safe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a little review
tracing::error!("SOMETHING IS SERIOUSLY WRONG!!!"); | ||
tracing::warn!("important informational messages; might indicate an error"); | ||
tracing::info!("general informational messages relevant to users"); | ||
tracing::debug!("diagnostics used for internal debugging of a library or application"); | ||
tracing::trace!("very verbose diagnostic events"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move logs out unsafe
context. It's confusing
unsafe { | ||
let handler = &mut *(ctx as *mut F); | ||
(*handler)(before, after); | ||
Flow::Continue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsafe
context is too long
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsafe { | |
let handler = &mut *(ctx as *mut F); | |
(*handler)(before, after); | |
Flow::Continue | |
} | |
let handler = unsafe { &mut *(ctx as *mut F) }; | |
(*handler)(before, after); | |
Flow::Continue |
unsafe fn magic_create<F>(ptr: *mut c_void, handler: F) | ||
where | ||
F: FnMut(Link<u64>, Link<u64>), | ||
{ | ||
let ctx = &mut (ptr, handler); | ||
let _ = create(ptr, null(), 0, ctx as *mut _ as *mut _, create_cb::<F>); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could supplement this example almost to the level of real use
let path = CString::new("doublets.links").unwrap(); | ||
let mut store = doublets_create_united_store_u64( | ||
path.as_ptr(), | ||
Constants::from(LinksConstants::external()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add ffi functions to create external/internal
constants
if *ctx % 2 == 0 { | ||
print!("{str}"); | ||
} else { | ||
eprint!("{str}"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference between print
and eprint
is not noticeable. Use something more different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More panic!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bro, panic abort my example :(
doublets-ffi/src/store.rs
Outdated
|
||
fn place_error<T: LinkType>(err: Error<T>) { | ||
// It can be very expensive to handle each error | ||
debug!(op_error = % err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
op_error
? Think of something better
- Fix forgotten `each` in moder style - Rename `DoubletsErrorKind` to `DoubletsResultKind` (it must contain `Continue`/`Break`) - improve error handling for create store (and fix example)
- Fix forgotten `each` in moder style - Rename `DoubletsErrorKind` to `DoubletsResultKind` (it must contain `Continue`/`Break`) - improve error handling for create store (and fix example)
- use modern syntax: ```rust #[ffi::specialize_for( types( u8 => "u8", u16 => "uint16", u32 => "uint", u64 => "ll", ), name = "...*", )] ``` - add warnings handler - use more beautiful code
…plementation - fix ffi build
add `.gitignore` with `.cargo`
- `Fallible<T, E>` can't drop without generics (can impl manually dropping by C++)
No description provided.