support nix_register_plugin extension
support nix_register_plugin extension
This commit is contained in:
parent
f76658fcfb
commit
eb2a5d0ec2
3 changed files with 10 additions and 2 deletions
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
extern "C" {
|
||||
|
||||
nix_err nixide_register_plugin(nix_c_context * context, char * plugin)
|
||||
nix_err nix_register_plugin(nix_c_context * context, char * plugin)
|
||||
{
|
||||
if (context)
|
||||
context->last_err_code = NIX_OK;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
// NOTE: all plugins should be registered BEFORE `nix_init_plugins` is run
|
||||
nix_err nixide_register_plugin(nix_c_context * context, char * plugin);
|
||||
nix_err nix_register_plugin(nix_c_context * context, char * plugin);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use crate::NixideResult;
|
||||
use crate::errors::ErrorContext;
|
||||
use crate::stdext::AsCPtr as _;
|
||||
use crate::util::wrap;
|
||||
use crate::util::wrappers::AsInnerPtr as _;
|
||||
|
||||
|
|
@ -8,3 +9,10 @@ pub fn load_plugins() -> NixideResult<()> {
|
|||
sys::nix_init_plugins(ctx.as_ptr());
|
||||
})
|
||||
}
|
||||
|
||||
pub fn register_plugin<S: AsRef<str>>(path: S) -> NixideResult<()> {
|
||||
let path_ptr = path.as_ref().into_c_ptr()?;
|
||||
wrap::nix_fn!(|ctx: &ErrorContext| unsafe {
|
||||
sys::nix_register_plugin(ctx.as_ptr(), path_ptr);
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue