support a nixide C API extension
This commit is contained in:
parent
c96289e688
commit
b7e9a69dd8
12 changed files with 96 additions and 12 deletions
0
nixide-sys/libnixide-c/nixide_api_expr.cc
Normal file
0
nixide-sys/libnixide-c/nixide_api_expr.cc
Normal file
12
nixide-sys/libnixide-c/nixide_api_expr.h
Normal file
12
nixide-sys/libnixide-c/nixide_api_expr.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef NIXIDE_API_EXPR_H
|
||||
#define NIXIDE_API_EXPR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // NIXIDE_API_EXPR_H
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#include "nix_api_util_internal.h"
|
||||
#include "nix_api_fetchers_internal.hh"
|
||||
#include <nix_api_util_internal.h>
|
||||
#include <nix_api_fetchers_internal.hh>
|
||||
|
||||
#include "nix/fetchers/fetch-settings.hh"
|
||||
#include <nix/fetchers/fetch-settings.hh>
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
#ifndef NIXIDE_API_FETCHERS_H
|
||||
#define NIXIDE_API_FETCHERS_H
|
||||
|
||||
#include "nix_api_fetchers.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <nix_api_fetchers.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
// #include <string>
|
||||
|
||||
// #include "nix_api_flake.h"
|
||||
#include "nix_api_flake_internal.hh"
|
||||
// #include "nix_api_util.h"
|
||||
#include "nix_api_util_internal.h"
|
||||
// #include "nix_api_expr_internal.h"
|
||||
// #include "nix_api_fetchers_internal.hh"
|
||||
// #include "nix_api_fetchers.h"
|
||||
// #include <nix_api_flake.h>
|
||||
#include <nix_api_flake_internal.hh>
|
||||
// #include <nix_api_util.h>
|
||||
#include <nix_api_util_internal.h>
|
||||
// #include <nix_api_expr_internal.h>
|
||||
// #include <nix_api_fetchers_internal.hh>
|
||||
// #include <nix_api_fetchers.h>
|
||||
|
||||
#include "nix/flake/flake.hh"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef NIXIDE_API_FLAKE_H
|
||||
#define NIXIDE_API_FLAKE_H
|
||||
|
||||
#include "nix_api_flake.h"
|
||||
#include <nix_api_flake.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
|||
30
nixide-sys/libnixide-c/nixide_api_main.cc
Normal file
30
nixide-sys/libnixide-c/nixide_api_main.cc
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include <dlfcn.h>
|
||||
|
||||
#include <nix_api_util.h>
|
||||
#include <nix_api_util_internal.h>
|
||||
|
||||
#include <nix/main/plugin.hh>
|
||||
|
||||
extern "C" {
|
||||
|
||||
nix_err nixide_register_plugin(nix_c_context * context, char * plugin)
|
||||
{
|
||||
if (context)
|
||||
context->last_err_code = NIX_OK;
|
||||
if (plugin == nullptr) {
|
||||
// TODO: should this be `NIX_ERR_RECOVERABLE` or `NIX_ERR_UNKNOWN`?
|
||||
return nix_set_err_msg(context, NIX_ERR_RECOVERABLE, "Plugin is null");
|
||||
}
|
||||
|
||||
void * handle = dlopen("libnixmainc.so", RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (!handle) {
|
||||
return nix_set_err_msg(context, NIX_ERR_UNKNOWN, dlerror());
|
||||
}
|
||||
|
||||
void * sym_addr = dlsym(handle, "pluginSettings");
|
||||
|
||||
try {
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
}
|
||||
17
nixide-sys/libnixide-c/nixide_api_main.h
Normal file
17
nixide-sys/libnixide-c/nixide_api_main.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef NIXIDE_API_MAIN_H
|
||||
#define NIXIDE_API_MAIN_H
|
||||
|
||||
#include <nix_api_main.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // NIXIDE_API_MAIN_H
|
||||
0
nixide-sys/libnixide-c/nixide_api_store.cc
Normal file
0
nixide-sys/libnixide-c/nixide_api_store.cc
Normal file
12
nixide-sys/libnixide-c/nixide_api_store.h
Normal file
12
nixide-sys/libnixide-c/nixide_api_store.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef NIXIDE_API_STORE_H
|
||||
#define NIXIDE_API_STORE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // NIXIDE_API_STORE_H
|
||||
0
nixide-sys/libnixide-c/nixide_api_util.cc
Normal file
0
nixide-sys/libnixide-c/nixide_api_util.cc
Normal file
12
nixide-sys/libnixide-c/nixide_api_util.h
Normal file
12
nixide-sys/libnixide-c/nixide_api_util.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef NIXIDE_API_UTIL_H
|
||||
#define NIXIDE_API_UTIL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // NIXIDE_API_UTIL_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue