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" {
|
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)
|
if (context)
|
||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// NOTE: all plugins should be registered BEFORE `nix_init_plugins` is run
|
// 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
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::NixideResult;
|
use crate::NixideResult;
|
||||||
use crate::errors::ErrorContext;
|
use crate::errors::ErrorContext;
|
||||||
|
use crate::stdext::AsCPtr as _;
|
||||||
use crate::util::wrap;
|
use crate::util::wrap;
|
||||||
use crate::util::wrappers::AsInnerPtr as _;
|
use crate::util::wrappers::AsInnerPtr as _;
|
||||||
|
|
||||||
|
|
@ -8,3 +9,10 @@ pub fn load_plugins() -> NixideResult<()> {
|
||||||
sys::nix_init_plugins(ctx.as_ptr());
|
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