From 7734e77dfc7eede1140a25357df94dfa045a3a2f Mon Sep 17 00:00:00 2001 From: bakpakin Date: Sun, 22 Aug 2021 10:23:18 -0500 Subject: [PATCH] Readd the janet_register function. --- src/core/util.c | 5 +++++ src/include/janet.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/core/util.c b/src/core/util.c index c4979ccc..a0230037 100644 --- a/src/core/util.c +++ b/src/core/util.c @@ -545,6 +545,11 @@ void janet_cfuns_ext_prefix(JanetTable *env, const char *regprefix, const JanetR if (env) namebuf_deinit(&nb); } +/* Register a value in the global registry */ +void janet_register(const char *name, JanetCFunction cfun) { + janet_registry_put(cfun, name, NULL, NULL, 0); +} + /* Abstract type introspection */ void janet_register_abstract_type(const JanetAbstractType *at) { diff --git a/src/include/janet.h b/src/include/janet.h index 32e21d1a..0916c1d0 100644 --- a/src/include/janet.h +++ b/src/include/janet.h @@ -1852,6 +1852,9 @@ JANET_API void janet_cfuns_ext_prefix(JanetTable *env, const char *regprefix, co JANET_API void janet_def_sm(JanetTable *env, const char *name, Janet val, const char *documentation, const char *source_file, int32_t source_line); JANET_API void janet_var_sm(JanetTable *env, const char *name, Janet val, const char *documentation, const char *source_file, int32_t source_line); +/* Legacy definition of C functions */ +JANET_API void janet_register(const char *name, JanetCFunction cfun); + /* Allow setting entry name for static libraries */ #ifdef __cplusplus #define JANET_MODULE_PREFIX extern "C"