mirror of
https://github.com/janet-lang/janet
synced 2024-10-18 16:05:47 +00:00
Stop out better configuration.
This commit is contained in:
parent
a59b5765b6
commit
7ff545bd2e
@ -79,6 +79,7 @@ conf.set('JANET_EV_NO_KQUEUE', not get_option('kqueue'))
|
|||||||
conf.set('JANET_NO_INTERPRETER_INTERRUPT', not get_option('interpreter_interrupt'))
|
conf.set('JANET_NO_INTERPRETER_INTERRUPT', not get_option('interpreter_interrupt'))
|
||||||
conf.set('JANET_NO_FFI', not get_option('ffi'))
|
conf.set('JANET_NO_FFI', not get_option('ffi'))
|
||||||
conf.set('JANET_NO_FFI_JIT', not get_option('ffi_jit'))
|
conf.set('JANET_NO_FFI_JIT', not get_option('ffi_jit'))
|
||||||
|
conf.set('JANET_NO_FILEWATCH', not get_option('filewatch'))
|
||||||
conf.set('JANET_NO_CRYPTORAND', not get_option('cryptorand'))
|
conf.set('JANET_NO_CRYPTORAND', not get_option('cryptorand'))
|
||||||
if get_option('os_name') != ''
|
if get_option('os_name') != ''
|
||||||
conf.set('JANET_OS_NAME', get_option('os_name'))
|
conf.set('JANET_OS_NAME', get_option('os_name'))
|
||||||
|
@ -22,6 +22,7 @@ option('kqueue', type : 'boolean', value : true)
|
|||||||
option('interpreter_interrupt', type : 'boolean', value : true)
|
option('interpreter_interrupt', type : 'boolean', value : true)
|
||||||
option('ffi', type : 'boolean', value : true)
|
option('ffi', type : 'boolean', value : true)
|
||||||
option('ffi_jit', type : 'boolean', value : true)
|
option('ffi_jit', type : 'boolean', value : true)
|
||||||
|
option('filewatch', type : 'boolean', value : true)
|
||||||
|
|
||||||
option('recursion_guard', type : 'integer', min : 10, max : 8000, value : 1024)
|
option('recursion_guard', type : 'integer', min : 10, max : 8000, value : 1024)
|
||||||
option('max_proto_depth', type : 'integer', min : 10, max : 8000, value : 200)
|
option('max_proto_depth', type : 'integer', min : 10, max : 8000, value : 200)
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
/* #define JANET_NO_NET */
|
/* #define JANET_NO_NET */
|
||||||
/* #define JANET_NO_INT_TYPES */
|
/* #define JANET_NO_INT_TYPES */
|
||||||
/* #define JANET_NO_EV */
|
/* #define JANET_NO_EV */
|
||||||
|
/* #define JANET_NO_FILEWATCH */
|
||||||
/* #define JANET_NO_REALPATH */
|
/* #define JANET_NO_REALPATH */
|
||||||
/* #define JANET_NO_SYMLINKS */
|
/* #define JANET_NO_SYMLINKS */
|
||||||
/* #define JANET_NO_UMASK */
|
/* #define JANET_NO_UMASK */
|
||||||
|
@ -456,7 +456,7 @@ JANET_CORE_FN(janet_core_range,
|
|||||||
}
|
}
|
||||||
JanetArray *array = janet_array(int_count);
|
JanetArray *array = janet_array(int_count);
|
||||||
for (int32_t i = 0; i < int_count; i++) {
|
for (int32_t i = 0; i < int_count; i++) {
|
||||||
array->data[i] = janet_wrap_number(start + (double) i * step);
|
array->data[i] = janet_wrap_number((double) start + (double) i * step);
|
||||||
}
|
}
|
||||||
array->count = int_count;
|
array->count = int_count;
|
||||||
return janet_wrap_array(array);
|
return janet_wrap_array(array);
|
||||||
@ -1127,6 +1127,9 @@ static void janet_load_libs(JanetTable *env) {
|
|||||||
#endif
|
#endif
|
||||||
#ifdef JANET_EV
|
#ifdef JANET_EV
|
||||||
janet_lib_ev(env);
|
janet_lib_ev(env);
|
||||||
|
#ifdef JANET_FILEWATCH
|
||||||
|
janet_lib_filewatch(env);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef JANET_NET
|
#ifdef JANET_NET
|
||||||
janet_lib_net(env);
|
janet_lib_net(env);
|
||||||
|
@ -3287,8 +3287,6 @@ void janet_lib_ev(JanetTable *env) {
|
|||||||
janet_register_abstract_type(&janet_channel_type);
|
janet_register_abstract_type(&janet_channel_type);
|
||||||
janet_register_abstract_type(&janet_mutex_type);
|
janet_register_abstract_type(&janet_mutex_type);
|
||||||
janet_register_abstract_type(&janet_rwlock_type);
|
janet_register_abstract_type(&janet_rwlock_type);
|
||||||
|
|
||||||
janet_lib_filewatch(env);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef JANET_EV
|
#ifdef JANET_EV
|
||||||
|
#ifdef JANET_FILEWATCH
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
JanetTable *watch_descriptors;
|
JanetTable *watch_descriptors;
|
||||||
@ -36,9 +37,9 @@ typedef struct {
|
|||||||
} JanetWatcher;
|
} JanetWatcher;
|
||||||
|
|
||||||
#ifdef JANET_LINUX
|
#ifdef JANET_LINUX
|
||||||
|
|
||||||
#include <sys/inotify.h>
|
#include <sys/inotify.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -63,7 +64,8 @@ static const JanetWatchFlagName watcher_flags_linux[] = {
|
|||||||
{"q-overflow", IN_Q_OVERFLOW},
|
{"q-overflow", IN_Q_OVERFLOW},
|
||||||
{"unmount", IN_UNMOUNT},
|
{"unmount", IN_UNMOUNT},
|
||||||
};
|
};
|
||||||
static uint32_t decode_inotify_flags(const Janet *options, int32_t n) {
|
|
||||||
|
static uint32_t decode_watch_flags(const Janet *options, int32_t n) {
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
for (int32_t i = 0; i < n; i++) {
|
for (int32_t i = 0; i < n; i++) {
|
||||||
if (!(janet_checktype(options[i], JANET_KEYWORD))) {
|
if (!(janet_checktype(options[i], JANET_KEYWORD))) {
|
||||||
@ -218,6 +220,43 @@ static void janet_watcher_listen(JanetWatcher *watcher) {
|
|||||||
janet_async_start(watcher->stream, JANET_ASYNC_LISTEN_READ, watcher_callback_read, watcher);
|
janet_async_start(watcher->stream, JANET_ASYNC_LISTEN_READ, watcher_callback_read, watcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Default implementation */
|
||||||
|
|
||||||
|
static uint32_t decode_watch_flags(const Janet *options, int32_t n) {
|
||||||
|
(void) options;
|
||||||
|
(void) n;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void janet_watcher_init(JanetWatcher *watcher, JanetChannel *channel, uint32_t default_flags) {
|
||||||
|
(void) watcher;
|
||||||
|
(void) channel;
|
||||||
|
(void) default_flags;
|
||||||
|
janet_panic("nyi");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void janet_watcher_add(JanetWatcher *watcher, const char *path, uint32_t flags) {
|
||||||
|
(void) watcher;
|
||||||
|
(void) flags;
|
||||||
|
(void) path;
|
||||||
|
janet_panic("nyi");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void janet_watcher_remove(JanetWatcher *watcher, const char *path) {
|
||||||
|
(void) watcher;
|
||||||
|
(void) path;
|
||||||
|
janet_panic("nyi");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void janet_watcher_listen(JanetWatcher *watcher) {
|
||||||
|
(void) watcher;
|
||||||
|
janet_panic("nyi");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/* C Functions */
|
/* C Functions */
|
||||||
|
|
||||||
static int janet_filewatch_mark(void *p, size_t s) {
|
static int janet_filewatch_mark(void *p, size_t s) {
|
||||||
@ -242,7 +281,7 @@ JANET_CORE_FN(cfun_filewatch_make,
|
|||||||
janet_arity(argc, 1, -1);
|
janet_arity(argc, 1, -1);
|
||||||
JanetChannel *channel = janet_getchannel(argv, 0);
|
JanetChannel *channel = janet_getchannel(argv, 0);
|
||||||
JanetWatcher *watcher = janet_abstract(&janet_filewatch_at, sizeof(JanetWatcher));
|
JanetWatcher *watcher = janet_abstract(&janet_filewatch_at, sizeof(JanetWatcher));
|
||||||
uint32_t default_flags = decode_inotify_flags(argv + 1, argc - 1);
|
uint32_t default_flags = decode_watch_flags(argv + 1, argc - 1);
|
||||||
janet_watcher_init(watcher, channel, default_flags);
|
janet_watcher_init(watcher, channel, default_flags);
|
||||||
return janet_wrap_abstract(watcher);
|
return janet_wrap_abstract(watcher);
|
||||||
}
|
}
|
||||||
@ -253,7 +292,7 @@ JANET_CORE_FN(cfun_filewatch_add,
|
|||||||
janet_arity(argc, 2, -1);
|
janet_arity(argc, 2, -1);
|
||||||
JanetWatcher *watcher = janet_getabstract(argv, 0, &janet_filewatch_at);
|
JanetWatcher *watcher = janet_getabstract(argv, 0, &janet_filewatch_at);
|
||||||
const char *path = janet_getcstring(argv, 1);
|
const char *path = janet_getcstring(argv, 1);
|
||||||
uint32_t flags = watcher->default_flags | decode_inotify_flags(argv + 2, argc - 2);
|
uint32_t flags = watcher->default_flags | decode_watch_flags(argv + 2, argc - 2);
|
||||||
janet_watcher_add(watcher, path, flags);
|
janet_watcher_add(watcher, path, flags);
|
||||||
return argv[0];
|
return argv[0];
|
||||||
}
|
}
|
||||||
@ -290,3 +329,4 @@ void janet_lib_filewatch(JanetTable *env) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
@ -190,9 +190,6 @@ void janet_lib_debug(JanetTable *env);
|
|||||||
#ifdef JANET_PEG
|
#ifdef JANET_PEG
|
||||||
void janet_lib_peg(JanetTable *env);
|
void janet_lib_peg(JanetTable *env);
|
||||||
#endif
|
#endif
|
||||||
#ifdef JANET_TYPED_ARRAY
|
|
||||||
void janet_lib_typed_array(JanetTable *env);
|
|
||||||
#endif
|
|
||||||
#ifdef JANET_INT_TYPES
|
#ifdef JANET_INT_TYPES
|
||||||
void janet_lib_inttypes(JanetTable *env);
|
void janet_lib_inttypes(JanetTable *env);
|
||||||
#endif
|
#endif
|
||||||
@ -204,8 +201,10 @@ extern const JanetAbstractType janet_address_type;
|
|||||||
void janet_lib_ev(JanetTable *env);
|
void janet_lib_ev(JanetTable *env);
|
||||||
void janet_ev_mark(void);
|
void janet_ev_mark(void);
|
||||||
int janet_make_pipe(JanetHandle handles[2], int mode);
|
int janet_make_pipe(JanetHandle handles[2], int mode);
|
||||||
|
#ifdef JANET_FILEWATCH
|
||||||
void janet_lib_filewatch(JanetTable *env);
|
void janet_lib_filewatch(JanetTable *env);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#ifdef JANET_FFI
|
#ifdef JANET_FFI
|
||||||
void janet_lib_ffi(JanetTable *env);
|
void janet_lib_ffi(JanetTable *env);
|
||||||
#endif
|
#endif
|
||||||
|
@ -210,6 +210,11 @@ extern "C" {
|
|||||||
#define JANET_EV
|
#define JANET_EV
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Enable or disable the filewatch/ module */
|
||||||
|
#if !defined(JANET_NO_FILEWATCH)
|
||||||
|
#define JANET_FILEWATCH
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Enable or disable networking */
|
/* Enable or disable networking */
|
||||||
#if defined(JANET_EV) && !defined(JANET_NO_NET) && !defined(__EMSCRIPTEN__)
|
#if defined(JANET_EV) && !defined(JANET_NO_NET) && !defined(__EMSCRIPTEN__)
|
||||||
#define JANET_NET
|
#define JANET_NET
|
||||||
|
Loading…
Reference in New Issue
Block a user