Rework ffi with new logging, error handling and some improvements in arch and safe#10
Open
uselessgoddess wants to merge 77 commits intomainfrom
Open
Rework ffi with new logging, error handling and some improvements in arch and safe#10uselessgoddess wants to merge 77 commits intomainfrom
logging, error handling and some improvements in arch and safe#10uselessgoddess wants to merge 77 commits intomainfrom
Conversation
logging and some improvements in arch and safelogging and some improvements in arch and safe
Member
Author
|
It also may solve #2 issue |
Mitron57
reviewed
Aug 18, 2022
- 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
uselessgoddess
commented
Aug 18, 2022
Member
Author
uselessgoddess
left a comment
There was a problem hiding this comment.
I did a little review
Comment on lines
+23
to
+27
| 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"); |
Member
Author
There was a problem hiding this comment.
Move logs out unsafe context. It's confusing
Comment on lines
+26
to
+30
| unsafe { | ||
| let handler = &mut *(ctx as *mut F); | ||
| (*handler)(before, after); | ||
| Flow::Continue | ||
| } |
Member
Author
There was a problem hiding this comment.
unsafe context is too long
Member
Author
There was a problem hiding this comment.
Suggested change
| 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 |
Comment on lines
+33
to
+39
| 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>); | ||
| } |
Member
Author
There was a problem hiding this comment.
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()), |
Member
Author
There was a problem hiding this comment.
Add ffi functions to create external/internal constants
Comment on lines
+12
to
+16
| if *ctx % 2 == 0 { | ||
| print!("{str}"); | ||
| } else { | ||
| eprint!("{str}"); | ||
| } |
Member
Author
There was a problem hiding this comment.
The difference between print and eprint is not noticeable. Use something more different
Member
Author
There was a problem hiding this comment.
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); |
Member
Author
There was a problem hiding this comment.
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++)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.