-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add debugging environment for valgrind, refactored the code a bit, fi…
…rst attempt for MetaCallFuture, vscode debugging in process.
- Loading branch information
Showing
25 changed files
with
275 additions
and
143 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,6 @@ include/ | |
|
||
# Not ignore .vscode | ||
!.vscode | ||
|
||
# Ignore .env file autogenerated by CMake | ||
.vscode/.env |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::{ | ||
bindings::{metacall_destroy, metacall_initialize, metacall_is_initialized}, | ||
types::MetaCallInitError, | ||
}; | ||
use std::{ffi::c_int, ptr}; | ||
|
||
pub struct MetaCallDestroy(unsafe extern "C" fn() -> c_int); | ||
|
||
impl Drop for MetaCallDestroy { | ||
fn drop(&mut self) { | ||
let code = unsafe { self.0() }; | ||
|
||
if code != 0 { | ||
panic!("MetaCall failed to destroy with code: {}", code) | ||
} | ||
} | ||
} | ||
|
||
/// Initializes MetaCall. Always remember to store the output in a variable to avoid instant drop. | ||
/// For example: ... | ||
/// ``` | ||
/// // Initialize metacall at the top of your main function before loading your codes or | ||
/// // calling any function. | ||
/// let _metacall = metacall::initialize().unwrap(); | ||
/// | ||
/// | ||
/// ``` | ||
pub fn initialize() -> Result<MetaCallDestroy, MetaCallInitError> { | ||
let code = unsafe { metacall_initialize() }; | ||
|
||
if code != 0 { | ||
return Err(MetaCallInitError::new(code)); | ||
} | ||
|
||
Ok(MetaCallDestroy(metacall_destroy)) | ||
} | ||
|
||
pub fn is_initialized() -> bool { | ||
let initialized = unsafe { metacall_is_initialized(ptr::null_mut()) }; | ||
|
||
if initialized == 0 { | ||
return true; | ||
} | ||
|
||
false | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.