mirror of
https://github.com/janet-lang/janet
synced 2024-11-28 11:09:54 +00:00
Merge branch 'master' into threads-3
This commit is contained in:
commit
36b2f27873
@ -30,6 +30,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- `jpm` will use `CC` and `AR` environment variables when compiling programs.
|
- `jpm` will use `CC` and `AR` environment variables when compiling programs.
|
||||||
- Add `comptime` macro for compile time evaluation.
|
- Add `comptime` macro for compile time evaluation.
|
||||||
- Run `main` functions in scripts if they exist, just like jpm standalone binaries.
|
- Run `main` functions in scripts if they exist, just like jpm standalone binaries.
|
||||||
|
- Add `protect` macro.
|
||||||
- Change marshalling protocol with regard to abstract types.
|
- Change marshalling protocol with regard to abstract types.
|
||||||
- Numerous small bug fixes and usability improvements.
|
- Numerous small bug fixes and usability improvements.
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ install:
|
|||||||
- call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" %platform%
|
- call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" %platform%
|
||||||
- build_win test-install
|
- build_win test-install
|
||||||
- set janet_outname=%appveyor_repo_tag_name%
|
- set janet_outname=%appveyor_repo_tag_name%
|
||||||
- if "%janet_outname%"=="" set janet_outname=v1.5.1
|
- if "%janet_outname%"=="" set janet_outname=v1.6.0
|
||||||
build: off
|
build: off
|
||||||
|
|
||||||
artifacts:
|
artifacts:
|
||||||
|
31
auxbin/jpm
31
auxbin/jpm
@ -221,12 +221,15 @@
|
|||||||
(defn rm
|
(defn rm
|
||||||
"Remove a directory and all sub directories."
|
"Remove a directory and all sub directories."
|
||||||
[path]
|
[path]
|
||||||
|
(try
|
||||||
(if (= (os/stat path :mode) :directory)
|
(if (= (os/stat path :mode) :directory)
|
||||||
(do
|
(do
|
||||||
(each subpath (os/dir path)
|
(each subpath (os/dir path)
|
||||||
(rm (string path sep subpath)))
|
(rm (string path sep subpath)))
|
||||||
(os/rmdir path))
|
(os/rmdir path))
|
||||||
(os/rm path)))
|
(os/rm path))
|
||||||
|
([err f] (unless (string/has-prefix? "No such file or directory" err)
|
||||||
|
(propagate err f)))))
|
||||||
|
|
||||||
(defn copy
|
(defn copy
|
||||||
"Copy a file or directory recursively from one location to another."
|
"Copy a file or directory recursively from one location to another."
|
||||||
@ -238,6 +241,17 @@
|
|||||||
(shell "xcopy" src (if isdir (string dest "\\" end) dest) "/y" "/s" "/e" "/i"))
|
(shell "xcopy" src (if isdir (string dest "\\" end) dest) "/y" "/s" "/e" "/i"))
|
||||||
(shell "cp" "-rf" src dest)))
|
(shell "cp" "-rf" src dest)))
|
||||||
|
|
||||||
|
(defn mkdir
|
||||||
|
"Create a directory if it doesn't exist. If it does exist, do nothing.
|
||||||
|
If we can't create it, give a friendly error. Return true if created, false if
|
||||||
|
existing. Throw an error if we can't create it."
|
||||||
|
[dir]
|
||||||
|
(if (os/mkdir dir)
|
||||||
|
true
|
||||||
|
(if (os/stat dir :mode)
|
||||||
|
false
|
||||||
|
(error (string "Could not create " dir " - this could be a permission issue.")))))
|
||||||
|
|
||||||
#
|
#
|
||||||
# C Compilation
|
# C Compilation
|
||||||
#
|
#
|
||||||
@ -562,9 +576,7 @@ int main(int argc, const char **argv) {
|
|||||||
(def path ((string/split "\n" line) 0))
|
(def path ((string/split "\n" line) 0))
|
||||||
(def path ((string/split "\r" path) 0))
|
(def path ((string/split "\r" path) 0))
|
||||||
(print "removing " path)
|
(print "removing " path)
|
||||||
(try (rm path) ([err]
|
(rm path))
|
||||||
(unless (= err "No such file or directory")
|
|
||||||
(error err)))))
|
|
||||||
(:close f)
|
(:close f)
|
||||||
(print "removing " manifest)
|
(print "removing " manifest)
|
||||||
(rm manifest)
|
(rm manifest)
|
||||||
@ -607,12 +619,13 @@ int main(int argc, const char **argv) {
|
|||||||
(error (string "expected string or table for repository, got " next-repo)))
|
(error (string "expected string or table for repository, got " next-repo)))
|
||||||
(break (install-git next-repo (if recurse (inc recurse) 0))))
|
(break (install-git next-repo (if recurse (inc recurse) 0))))
|
||||||
(def cache (find-cache))
|
(def cache (find-cache))
|
||||||
(os/mkdir cache)
|
(mkdir cache)
|
||||||
(def id (filepath-replace repo))
|
(def id (filepath-replace repo))
|
||||||
(def module-dir (string cache sep id))
|
(def module-dir (string cache sep id))
|
||||||
(var fresh false)
|
(var fresh false)
|
||||||
(when (os/mkdir module-dir)
|
(when (mkdir module-dir)
|
||||||
(set fresh true)
|
(set fresh true)
|
||||||
|
(print "cloning repository " repo " to " module-dir)
|
||||||
(os/execute ["git" "clone" repo module-dir] :p))
|
(os/execute ["git" "clone" repo module-dir] :p))
|
||||||
(def olddir (os/cwd))
|
(def olddir (os/cwd))
|
||||||
(try
|
(try
|
||||||
@ -642,7 +655,7 @@ int main(int argc, const char **argv) {
|
|||||||
(def path (string destdir sep name))
|
(def path (string destdir sep name))
|
||||||
(array/push (dyn :installed-files) path)
|
(array/push (dyn :installed-files) path)
|
||||||
(add-body "install"
|
(add-body "install"
|
||||||
(os/mkdir destdir)
|
(mkdir destdir)
|
||||||
(copy src destdir)))
|
(copy src destdir)))
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -783,12 +796,12 @@ int main(int argc, const char **argv) {
|
|||||||
(setdyn :manifest-dir manifests)
|
(setdyn :manifest-dir manifests)
|
||||||
(setdyn :installed-files installed-files)
|
(setdyn :installed-files installed-files)
|
||||||
|
|
||||||
(rule "./build" [] (os/mkdir "build"))
|
(rule "./build" [] (mkdir "build"))
|
||||||
(phony "build" ["./build"])
|
(phony "build" ["./build"])
|
||||||
|
|
||||||
(phony "manifest" []
|
(phony "manifest" []
|
||||||
(print "generating " manifest "...")
|
(print "generating " manifest "...")
|
||||||
(os/mkdir manifests)
|
(mkdir manifests)
|
||||||
(spit manifest (string (string/join installed-files "\n") "\n")))
|
(spit manifest (string (string/join installed-files "\n") "\n")))
|
||||||
(phony "install" ["uninstall" "build" "manifest"]
|
(phony "install" ["uninstall" "build" "manifest"]
|
||||||
(when (dyn :test)
|
(when (dyn :test)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Version
|
# Version
|
||||||
!define VERSION "1.5.1"
|
!define VERSION "1.6.0"
|
||||||
!define PRODUCT_VERSION "${VERSION}.0"
|
!define PRODUCT_VERSION "${VERSION}.0"
|
||||||
VIProductVersion "${PRODUCT_VERSION}"
|
VIProductVersion "${PRODUCT_VERSION}"
|
||||||
VIFileVersion "${PRODUCT_VERSION}"
|
VIFileVersion "${PRODUCT_VERSION}"
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
project('janet', 'c',
|
project('janet', 'c',
|
||||||
default_options : ['c_std=c99', 'b_lundef=false', 'default_library=both'],
|
default_options : ['c_std=c99', 'b_lundef=false', 'default_library=both'],
|
||||||
version : '1.5.1')
|
version : '1.6.0-dev')
|
||||||
|
|
||||||
# Global settings
|
# Global settings
|
||||||
janet_path = join_paths(get_option('prefix'), get_option('libdir'), 'janet')
|
janet_path = join_paths(get_option('prefix'), get_option('libdir'), 'janet')
|
||||||
|
@ -218,11 +218,21 @@
|
|||||||
f (gensym)
|
f (gensym)
|
||||||
r (gensym)]
|
r (gensym)]
|
||||||
~(let [,f (,fiber/new (fn [] ,body) :ie)
|
~(let [,f (,fiber/new (fn [] ,body) :ie)
|
||||||
,r (resume ,f)]
|
,r (,resume ,f)]
|
||||||
(if (= (,fiber/status ,f) :error)
|
(if (= (,fiber/status ,f) :error)
|
||||||
(do (def ,err ,r) ,(if fib ~(def ,fib ,f)) ,;(tuple/slice catch 1))
|
(do (def ,err ,r) ,(if fib ~(def ,fib ,f)) ,;(tuple/slice catch 1))
|
||||||
,r))))
|
,r))))
|
||||||
|
|
||||||
|
(defmacro protect
|
||||||
|
"Evaluate expressions, while capturing any errors. Evaluates to a tuple
|
||||||
|
of two elements. The first element is true if successful, false if an
|
||||||
|
error, and the second is the return value or error."
|
||||||
|
[& body]
|
||||||
|
(let [f (gensym) r (gensym)]
|
||||||
|
~(let [,f (,fiber/new (fn [] ,;body) :ie)
|
||||||
|
,r (,resume ,f)]
|
||||||
|
[(,not= :error (,fiber/status ,f)) ,r])))
|
||||||
|
|
||||||
(defmacro and
|
(defmacro and
|
||||||
"Evaluates to the last argument if all preceding elements are true, otherwise
|
"Evaluates to the last argument if all preceding elements are true, otherwise
|
||||||
evaluates to false."
|
evaluates to false."
|
||||||
|
@ -27,10 +27,10 @@
|
|||||||
#define JANETCONF_H
|
#define JANETCONF_H
|
||||||
|
|
||||||
#define JANET_VERSION_MAJOR 1
|
#define JANET_VERSION_MAJOR 1
|
||||||
#define JANET_VERSION_MINOR 5
|
#define JANET_VERSION_MINOR 6
|
||||||
#define JANET_VERSION_PATCH 1
|
#define JANET_VERSION_PATCH 0
|
||||||
#define JANET_VERSION_EXTRA ""
|
#define JANET_VERSION_EXTRA "-dev"
|
||||||
#define JANET_VERSION "1.5.1"
|
#define JANET_VERSION "1.6.0-dev"
|
||||||
|
|
||||||
/* #define JANET_BUILD "local" */
|
/* #define JANET_BUILD "local" */
|
||||||
|
|
||||||
|
@ -103,13 +103,15 @@ type janet_opt##name(const Janet *argv, int32_t argc, int32_t n, int32_t dflt_le
|
|||||||
return janet_get##name(argv, n); \
|
return janet_get##name(argv, n); \
|
||||||
}
|
}
|
||||||
|
|
||||||
Janet janet_getmethod(const uint8_t *method, const JanetMethod *methods) {
|
int janet_getmethod(const uint8_t *method, const JanetMethod *methods, Janet *out) {
|
||||||
while (methods->name) {
|
while (methods->name) {
|
||||||
if (!janet_cstrcmp(method, methods->name))
|
if (!janet_cstrcmp(method, methods->name)) {
|
||||||
return janet_wrap_cfunction(methods->cfun);
|
*out = janet_wrap_cfunction(methods->cfun);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
methods++;
|
methods++;
|
||||||
}
|
}
|
||||||
return janet_wrap_nil();
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_GETTER(number, NUMBER, double)
|
DEFINE_GETTER(number, NUMBER, double)
|
||||||
|
@ -36,8 +36,8 @@
|
|||||||
|
|
||||||
#define MAX_INT_IN_DBL 9007199254740992ULL /* 2^53 */
|
#define MAX_INT_IN_DBL 9007199254740992ULL /* 2^53 */
|
||||||
|
|
||||||
static Janet it_s64_get(void *p, Janet key);
|
static int it_s64_get(void *p, Janet key, Janet *out);
|
||||||
static Janet it_u64_get(void *p, Janet key);
|
static int it_u64_get(void *p, Janet key, Janet *out);
|
||||||
|
|
||||||
static void int64_marshal(void *p, JanetMarshalContext *ctx) {
|
static void int64_marshal(void *p, JanetMarshalContext *ctx) {
|
||||||
janet_marshal_abstract(ctx, p);
|
janet_marshal_abstract(ctx, p);
|
||||||
@ -351,18 +351,18 @@ static JanetMethod it_u64_methods[] = {
|
|||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
static Janet it_s64_get(void *p, Janet key) {
|
static int it_s64_get(void *p, Janet key, Janet *out) {
|
||||||
(void) p;
|
(void) p;
|
||||||
if (!janet_checktype(key, JANET_KEYWORD))
|
if (!janet_checktype(key, JANET_KEYWORD))
|
||||||
janet_panicf("expected keyword, got %v", key);
|
return 0;
|
||||||
return janet_getmethod(janet_unwrap_keyword(key), it_s64_methods);
|
return janet_getmethod(janet_unwrap_keyword(key), it_s64_methods, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Janet it_u64_get(void *p, Janet key) {
|
static int it_u64_get(void *p, Janet key, Janet *out) {
|
||||||
(void) p;
|
(void) p;
|
||||||
if (!janet_checktype(key, JANET_KEYWORD))
|
if (!janet_checktype(key, JANET_KEYWORD))
|
||||||
janet_panicf("expected keyword, got %v", key);
|
return 0;
|
||||||
return janet_getmethod(janet_unwrap_keyword(key), it_u64_methods);
|
return janet_getmethod(janet_unwrap_keyword(key), it_u64_methods, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const JanetReg it_cfuns[] = {
|
static const JanetReg it_cfuns[] = {
|
||||||
|
@ -53,7 +53,7 @@ struct IOFile {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int cfun_io_gc(void *p, size_t len);
|
static int cfun_io_gc(void *p, size_t len);
|
||||||
static Janet io_file_get(void *p, Janet);
|
static int io_file_get(void *p, Janet key, Janet *out);
|
||||||
|
|
||||||
JanetAbstractType cfun_io_filetype = {
|
JanetAbstractType cfun_io_filetype = {
|
||||||
"core/file",
|
"core/file",
|
||||||
@ -353,11 +353,11 @@ static JanetMethod io_file_methods[] = {
|
|||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
static Janet io_file_get(void *p, Janet key) {
|
static int io_file_get(void *p, Janet key, Janet *out) {
|
||||||
(void) p;
|
(void) p;
|
||||||
if (!janet_checktype(key, JANET_KEYWORD))
|
if (!janet_checktype(key, JANET_KEYWORD))
|
||||||
janet_panicf("expected keyword, got %v", key);
|
return 0;
|
||||||
return janet_getmethod(janet_unwrap_keyword(key), io_file_methods);
|
return janet_getmethod(janet_unwrap_keyword(key), io_file_methods, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *janet_dynfile(const char *name, FILE *def) {
|
FILE *janet_dynfile(const char *name, FILE *def) {
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
static JANET_THREAD_LOCAL JanetRNG janet_vm_rng = {0, 0, 0, 0, 0};
|
static JANET_THREAD_LOCAL JanetRNG janet_vm_rng = {0, 0, 0, 0, 0};
|
||||||
|
|
||||||
static Janet janet_rng_get(void *p, Janet key);
|
static int janet_rng_get(void *p, Janet key, Janet *out);
|
||||||
|
|
||||||
static void janet_rng_marshal(void *p, JanetMarshalContext *ctx) {
|
static void janet_rng_marshal(void *p, JanetMarshalContext *ctx) {
|
||||||
JanetRNG *rng = (JanetRNG *)p;
|
JanetRNG *rng = (JanetRNG *)p;
|
||||||
@ -196,10 +196,10 @@ static const JanetMethod rng_methods[] = {
|
|||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
static Janet janet_rng_get(void *p, Janet key) {
|
static int janet_rng_get(void *p, Janet key, Janet *out) {
|
||||||
(void) p;
|
(void) p;
|
||||||
if (!janet_checktype(key, JANET_KEYWORD)) janet_panicf("expected keyword method");
|
if (!janet_checktype(key, JANET_KEYWORD)) return 0;
|
||||||
return janet_getmethod(janet_unwrap_keyword(key), rng_methods);
|
return janet_getmethod(janet_unwrap_keyword(key), rng_methods, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get a random number */
|
/* Get a random number */
|
||||||
|
@ -613,7 +613,7 @@ static Janet os_link(int32_t argc, Janet *argv) {
|
|||||||
const char *oldpath = janet_getcstring(argv, 0);
|
const char *oldpath = janet_getcstring(argv, 0);
|
||||||
const char *newpath = janet_getcstring(argv, 1);
|
const char *newpath = janet_getcstring(argv, 1);
|
||||||
int res = ((argc == 3 && janet_getboolean(argv, 2)) ? symlink : link)(oldpath, newpath);
|
int res = ((argc == 3 && janet_getboolean(argv, 2)) ? symlink : link)(oldpath, newpath);
|
||||||
if (res == -1) janet_panic(strerror(errno));
|
if (-1 == res) janet_panicf("%s: %s -> %s", strerror(errno), oldpath, newpath);
|
||||||
return janet_wrap_integer(res);
|
return janet_wrap_integer(res);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -637,7 +637,7 @@ static Janet os_rmdir(int32_t argc, Janet *argv) {
|
|||||||
#else
|
#else
|
||||||
int res = rmdir(path);
|
int res = rmdir(path);
|
||||||
#endif
|
#endif
|
||||||
if (res == -1) janet_panic(strerror(errno));
|
if (-1 == res) janet_panicf("%s: %s", strerror(errno), path);
|
||||||
return janet_wrap_nil();
|
return janet_wrap_nil();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -649,7 +649,7 @@ static Janet os_cd(int32_t argc, Janet *argv) {
|
|||||||
#else
|
#else
|
||||||
int res = chdir(path);
|
int res = chdir(path);
|
||||||
#endif
|
#endif
|
||||||
if (res == -1) janet_panic(strerror(errno));
|
if (-1 == res) janet_panicf("%s: %s", strerror(errno), path);
|
||||||
return janet_wrap_nil();
|
return janet_wrap_nil();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -677,7 +677,7 @@ static Janet os_remove(int32_t argc, Janet *argv) {
|
|||||||
janet_fixarity(argc, 1);
|
janet_fixarity(argc, 1);
|
||||||
const char *path = janet_getcstring(argv, 0);
|
const char *path = janet_getcstring(argv, 0);
|
||||||
int status = remove(path);
|
int status = remove(path);
|
||||||
if (-1 == status) janet_panic(strerror(errno));
|
if (-1 == status) janet_panicf("%s: %s", strerror(errno), path);
|
||||||
return janet_wrap_nil();
|
return janet_wrap_nil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,7 +730,7 @@ static int parsergc(void *p, size_t size) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Janet parserget(void *p, Janet key);
|
static int parserget(void *p, Janet key, Janet *out);
|
||||||
|
|
||||||
static JanetAbstractType janet_parse_parsertype = {
|
static JanetAbstractType janet_parse_parsertype = {
|
||||||
"core/parser",
|
"core/parser",
|
||||||
@ -1055,10 +1055,10 @@ static const JanetMethod parser_methods[] = {
|
|||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
static Janet parserget(void *p, Janet key) {
|
static int parserget(void *p, Janet key, Janet *out) {
|
||||||
(void) p;
|
(void) p;
|
||||||
if (!janet_checktype(key, JANET_KEYWORD)) janet_panicf("expected keyword method");
|
if (!janet_checktype(key, JANET_KEYWORD)) return 0;
|
||||||
return janet_getmethod(janet_unwrap_keyword(key), parser_methods);
|
return janet_getmethod(janet_unwrap_keyword(key), parser_methods, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const JanetReg parse_cfuns[] = {
|
static const JanetReg parse_cfuns[] = {
|
||||||
|
@ -166,50 +166,50 @@ static void *ta_view_unmarshal(JanetMarshalContext *ctx) {
|
|||||||
|
|
||||||
static JanetMethod tarray_view_methods[6];
|
static JanetMethod tarray_view_methods[6];
|
||||||
|
|
||||||
static Janet ta_getter(void *p, Janet key) {
|
static int ta_getter(void *p, Janet key, Janet *out) {
|
||||||
Janet value;
|
|
||||||
size_t index, i;
|
size_t index, i;
|
||||||
JanetTArrayView *array = p;
|
JanetTArrayView *array = p;
|
||||||
if (janet_checktype(key, JANET_KEYWORD))
|
if (janet_checktype(key, JANET_KEYWORD)) {
|
||||||
return janet_getmethod(janet_unwrap_keyword(key), tarray_view_methods);
|
return janet_getmethod(janet_unwrap_keyword(key), tarray_view_methods, out);
|
||||||
|
}
|
||||||
if (!janet_checksize(key)) janet_panic("expected size as key");
|
if (!janet_checksize(key)) janet_panic("expected size as key");
|
||||||
index = (size_t) janet_unwrap_number(key);
|
index = (size_t) janet_unwrap_number(key);
|
||||||
i = index * array->stride;
|
i = index * array->stride;
|
||||||
if (index >= array->size) {
|
if (index >= array->size) {
|
||||||
value = janet_wrap_nil();
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
switch (array->type) {
|
switch (array->type) {
|
||||||
case JANET_TARRAY_TYPE_U8:
|
case JANET_TARRAY_TYPE_U8:
|
||||||
value = janet_wrap_number(array->as.u8[i]);
|
*out = janet_wrap_number(array->as.u8[i]);
|
||||||
break;
|
break;
|
||||||
case JANET_TARRAY_TYPE_S8:
|
case JANET_TARRAY_TYPE_S8:
|
||||||
value = janet_wrap_number(array->as.s8[i]);
|
*out = janet_wrap_number(array->as.s8[i]);
|
||||||
break;
|
break;
|
||||||
case JANET_TARRAY_TYPE_U16:
|
case JANET_TARRAY_TYPE_U16:
|
||||||
value = janet_wrap_number(array->as.u16[i]);
|
*out = janet_wrap_number(array->as.u16[i]);
|
||||||
break;
|
break;
|
||||||
case JANET_TARRAY_TYPE_S16:
|
case JANET_TARRAY_TYPE_S16:
|
||||||
value = janet_wrap_number(array->as.s16[i]);
|
*out = janet_wrap_number(array->as.s16[i]);
|
||||||
break;
|
break;
|
||||||
case JANET_TARRAY_TYPE_U32:
|
case JANET_TARRAY_TYPE_U32:
|
||||||
value = janet_wrap_number(array->as.u32[i]);
|
*out = janet_wrap_number(array->as.u32[i]);
|
||||||
break;
|
break;
|
||||||
case JANET_TARRAY_TYPE_S32:
|
case JANET_TARRAY_TYPE_S32:
|
||||||
value = janet_wrap_number(array->as.s32[i]);
|
*out = janet_wrap_number(array->as.s32[i]);
|
||||||
break;
|
break;
|
||||||
#ifdef JANET_INT_TYPES
|
#ifdef JANET_INT_TYPES
|
||||||
case JANET_TARRAY_TYPE_U64:
|
case JANET_TARRAY_TYPE_U64:
|
||||||
value = janet_wrap_u64(array->as.u64[i]);
|
*out = janet_wrap_u64(array->as.u64[i]);
|
||||||
break;
|
break;
|
||||||
case JANET_TARRAY_TYPE_S64:
|
case JANET_TARRAY_TYPE_S64:
|
||||||
value = janet_wrap_s64(array->as.s64[i]);
|
*out = janet_wrap_s64(array->as.s64[i]);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case JANET_TARRAY_TYPE_F32:
|
case JANET_TARRAY_TYPE_F32:
|
||||||
value = janet_wrap_number_safe(array->as.f32[i]);
|
*out = janet_wrap_number_safe(array->as.f32[i]);
|
||||||
break;
|
break;
|
||||||
case JANET_TARRAY_TYPE_F64:
|
case JANET_TARRAY_TYPE_F64:
|
||||||
value = janet_wrap_number_safe(array->as.f64[i]);
|
*out = janet_wrap_number_safe(array->as.f64[i]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
janet_panicf("cannot get from typed array of type %s",
|
janet_panicf("cannot get from typed array of type %s",
|
||||||
@ -217,7 +217,7 @@ static Janet ta_getter(void *p, Janet key) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ta_setter(void *p, Janet key, Janet value) {
|
static void ta_setter(void *p, Janet key, Janet value) {
|
||||||
@ -450,7 +450,8 @@ static Janet cfun_typed_array_slice(int32_t argc, Janet *argv) {
|
|||||||
JanetArray *array = janet_array(range.end - range.start);
|
JanetArray *array = janet_array(range.end - range.start);
|
||||||
if (array->data) {
|
if (array->data) {
|
||||||
for (int32_t i = range.start; i < range.end; i++) {
|
for (int32_t i = range.start; i < range.end; i++) {
|
||||||
array->data[i - range.start] = ta_getter(src, janet_wrap_number(i));
|
if (!ta_getter(src, janet_wrap_number(i), &array->data[i - range.start]))
|
||||||
|
array->data[i - range.start] = janet_wrap_nil();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
array->count = range.end - range.start;
|
array->count = range.end - range.start;
|
||||||
|
@ -197,7 +197,8 @@ Janet janet_in(Janet ds, Janet key) {
|
|||||||
case JANET_ABSTRACT: {
|
case JANET_ABSTRACT: {
|
||||||
JanetAbstractType *type = (JanetAbstractType *)janet_abstract_type(janet_unwrap_abstract(ds));
|
JanetAbstractType *type = (JanetAbstractType *)janet_abstract_type(janet_unwrap_abstract(ds));
|
||||||
if (type->get) {
|
if (type->get) {
|
||||||
value = (type->get)(janet_unwrap_abstract(ds), key);
|
if (!(type->get)(janet_unwrap_abstract(ds), key, &value))
|
||||||
|
janet_panicf("key %v not found in %v ", key, ds);
|
||||||
} else {
|
} else {
|
||||||
janet_panicf("no getter for %v ", ds);
|
janet_panicf("no getter for %v ", ds);
|
||||||
}
|
}
|
||||||
@ -223,10 +224,13 @@ Janet janet_get(Janet ds, Janet key) {
|
|||||||
return janet_wrap_integer(str[index]);
|
return janet_wrap_integer(str[index]);
|
||||||
}
|
}
|
||||||
case JANET_ABSTRACT: {
|
case JANET_ABSTRACT: {
|
||||||
|
Janet value;
|
||||||
void *abst = janet_unwrap_abstract(ds);
|
void *abst = janet_unwrap_abstract(ds);
|
||||||
JanetAbstractType *type = (JanetAbstractType *)janet_abstract_type(abst);
|
JanetAbstractType *type = (JanetAbstractType *)janet_abstract_type(abst);
|
||||||
if (!type->get) return janet_wrap_nil();
|
if (!type->get) return janet_wrap_nil();
|
||||||
return (type->get)(abst, key);
|
if ((type->get)(abst, key, &value))
|
||||||
|
return value;
|
||||||
|
return janet_wrap_nil();
|
||||||
}
|
}
|
||||||
case JANET_ARRAY:
|
case JANET_ARRAY:
|
||||||
case JANET_TUPLE:
|
case JANET_TUPLE:
|
||||||
@ -304,7 +308,8 @@ Janet janet_getindex(Janet ds, int32_t index) {
|
|||||||
case JANET_ABSTRACT: {
|
case JANET_ABSTRACT: {
|
||||||
JanetAbstractType *type = (JanetAbstractType *)janet_abstract_type(janet_unwrap_abstract(ds));
|
JanetAbstractType *type = (JanetAbstractType *)janet_abstract_type(janet_unwrap_abstract(ds));
|
||||||
if (type->get) {
|
if (type->get) {
|
||||||
value = (type->get)(janet_unwrap_abstract(ds), janet_wrap_integer(index));
|
if (!(type->get)(janet_unwrap_abstract(ds), janet_wrap_integer(index), &value))
|
||||||
|
value = janet_wrap_nil();
|
||||||
} else {
|
} else {
|
||||||
janet_panicf("no getter for %v ", ds);
|
janet_panicf("no getter for %v ", ds);
|
||||||
}
|
}
|
||||||
|
@ -1201,9 +1201,8 @@ Janet janet_mcall(const char *name, int32_t argc, Janet *argv) {
|
|||||||
if (janet_checktype(argv[0], JANET_ABSTRACT)) {
|
if (janet_checktype(argv[0], JANET_ABSTRACT)) {
|
||||||
void *abst = janet_unwrap_abstract(argv[0]);
|
void *abst = janet_unwrap_abstract(argv[0]);
|
||||||
JanetAbstractType *type = (JanetAbstractType *)janet_abstract_type(abst);
|
JanetAbstractType *type = (JanetAbstractType *)janet_abstract_type(abst);
|
||||||
if (!type->get)
|
if (!type->get || !(type->get)(abst, janet_ckeywordv(name), &method))
|
||||||
janet_panicf("abstract value %v does not implement :%s", argv[0], name);
|
janet_panicf("abstract value %v does not implement :%s", argv[0], name);
|
||||||
method = (type->get)(abst, janet_ckeywordv(name));
|
|
||||||
} else if (janet_checktype(argv[0], JANET_TABLE)) {
|
} else if (janet_checktype(argv[0], JANET_TABLE)) {
|
||||||
JanetTable *table = janet_unwrap_table(argv[0]);
|
JanetTable *table = janet_unwrap_table(argv[0]);
|
||||||
method = janet_table_get(table, janet_ckeywordv(name));
|
method = janet_table_get(table, janet_ckeywordv(name));
|
||||||
|
@ -328,6 +328,14 @@ typedef struct JanetRange JanetRange;
|
|||||||
typedef struct JanetRNG JanetRNG;
|
typedef struct JanetRNG JanetRNG;
|
||||||
typedef Janet(*JanetCFunction)(int32_t argc, Janet *argv);
|
typedef Janet(*JanetCFunction)(int32_t argc, Janet *argv);
|
||||||
|
|
||||||
|
/* String and other aliased pointer types */
|
||||||
|
typedef const uint8_t *JanetString;
|
||||||
|
typedef const uint8_t *JanetSymbol;
|
||||||
|
typedef const uint8_t *JanetKeyword;
|
||||||
|
typedef const Janet *JanetTuple;
|
||||||
|
typedef const JanetKV *JanetStruct;
|
||||||
|
typedef void *JanetAbstract;
|
||||||
|
|
||||||
/* Basic types for all Janet Values */
|
/* Basic types for all Janet Values */
|
||||||
typedef enum JanetType {
|
typedef enum JanetType {
|
||||||
JANET_NUMBER,
|
JANET_NUMBER,
|
||||||
@ -822,8 +830,8 @@ struct JanetFuncDef {
|
|||||||
|
|
||||||
/* Various debug information */
|
/* Various debug information */
|
||||||
JanetSourceMapping *sourcemap;
|
JanetSourceMapping *sourcemap;
|
||||||
const uint8_t *source;
|
JanetString source;
|
||||||
const uint8_t *name;
|
JanetString name;
|
||||||
|
|
||||||
int32_t flags;
|
int32_t flags;
|
||||||
int32_t slotcount; /* The amount of stack space required for the function */
|
int32_t slotcount; /* The amount of stack space required for the function */
|
||||||
@ -899,7 +907,7 @@ struct JanetAbstractType {
|
|||||||
const char *name;
|
const char *name;
|
||||||
int (*gc)(void *data, size_t len);
|
int (*gc)(void *data, size_t len);
|
||||||
int (*gcmark)(void *data, size_t len);
|
int (*gcmark)(void *data, size_t len);
|
||||||
Janet(*get)(void *data, Janet key);
|
int (*get)(void *data, Janet key, Janet *out);
|
||||||
void (*put)(void *data, Janet key, Janet value);
|
void (*put)(void *data, Janet key, Janet value);
|
||||||
void (*marshal)(void *p, JanetMarshalContext *ctx);
|
void (*marshal)(void *p, JanetMarshalContext *ctx);
|
||||||
void *(*unmarshal)(JanetMarshalContext *ctx);
|
void *(*unmarshal)(JanetMarshalContext *ctx);
|
||||||
@ -1090,7 +1098,7 @@ enum JanetAssembleStatus {
|
|||||||
};
|
};
|
||||||
struct JanetAssembleResult {
|
struct JanetAssembleResult {
|
||||||
JanetFuncDef *funcdef;
|
JanetFuncDef *funcdef;
|
||||||
const uint8_t *error;
|
JanetString error;
|
||||||
enum JanetAssembleStatus status;
|
enum JanetAssembleStatus status;
|
||||||
};
|
};
|
||||||
JANET_API JanetAssembleResult janet_asm(Janet source, int flags);
|
JANET_API JanetAssembleResult janet_asm(Janet source, int flags);
|
||||||
@ -1106,12 +1114,12 @@ enum JanetCompileStatus {
|
|||||||
};
|
};
|
||||||
struct JanetCompileResult {
|
struct JanetCompileResult {
|
||||||
JanetFuncDef *funcdef;
|
JanetFuncDef *funcdef;
|
||||||
const uint8_t *error;
|
JanetString error;
|
||||||
JanetFiber *macrofiber;
|
JanetFiber *macrofiber;
|
||||||
JanetSourceMapping error_mapping;
|
JanetSourceMapping error_mapping;
|
||||||
enum JanetCompileStatus status;
|
enum JanetCompileStatus status;
|
||||||
};
|
};
|
||||||
JANET_API JanetCompileResult janet_compile(Janet source, JanetTable *env, const uint8_t *where);
|
JANET_API JanetCompileResult janet_compile(Janet source, JanetTable *env, JanetString where);
|
||||||
|
|
||||||
/* Get the default environment for janet */
|
/* Get the default environment for janet */
|
||||||
JANET_API JanetTable *janet_core_env(JanetTable *replacements);
|
JANET_API JanetTable *janet_core_env(JanetTable *replacements);
|
||||||
@ -1129,7 +1137,7 @@ JANET_API void janet_debug_break(JanetFuncDef *def, int32_t pc);
|
|||||||
JANET_API void janet_debug_unbreak(JanetFuncDef *def, int32_t pc);
|
JANET_API void janet_debug_unbreak(JanetFuncDef *def, int32_t pc);
|
||||||
JANET_API void janet_debug_find(
|
JANET_API void janet_debug_find(
|
||||||
JanetFuncDef **def_out, int32_t *pc_out,
|
JanetFuncDef **def_out, int32_t *pc_out,
|
||||||
const uint8_t *source, int32_t line, int32_t column);
|
JanetString source, int32_t line, int32_t column);
|
||||||
|
|
||||||
/* RNG */
|
/* RNG */
|
||||||
JANET_API JanetRNG *janet_default_rng(void);
|
JANET_API JanetRNG *janet_default_rng(void);
|
||||||
@ -1154,7 +1162,7 @@ JANET_API void janet_buffer_ensure(JanetBuffer *buffer, int32_t capacity, int32_
|
|||||||
JANET_API void janet_buffer_setcount(JanetBuffer *buffer, int32_t count);
|
JANET_API void janet_buffer_setcount(JanetBuffer *buffer, int32_t count);
|
||||||
JANET_API void janet_buffer_extra(JanetBuffer *buffer, int32_t n);
|
JANET_API void janet_buffer_extra(JanetBuffer *buffer, int32_t n);
|
||||||
JANET_API void janet_buffer_push_bytes(JanetBuffer *buffer, const uint8_t *string, int32_t len);
|
JANET_API void janet_buffer_push_bytes(JanetBuffer *buffer, const uint8_t *string, int32_t len);
|
||||||
JANET_API void janet_buffer_push_string(JanetBuffer *buffer, const uint8_t *string);
|
JANET_API void janet_buffer_push_string(JanetBuffer *buffer, JanetString string);
|
||||||
JANET_API void janet_buffer_push_cstring(JanetBuffer *buffer, const char *cstring);
|
JANET_API void janet_buffer_push_cstring(JanetBuffer *buffer, const char *cstring);
|
||||||
JANET_API void janet_buffer_push_u8(JanetBuffer *buffer, uint8_t x);
|
JANET_API void janet_buffer_push_u8(JanetBuffer *buffer, uint8_t x);
|
||||||
JANET_API void janet_buffer_push_u16(JanetBuffer *buffer, uint16_t x);
|
JANET_API void janet_buffer_push_u16(JanetBuffer *buffer, uint16_t x);
|
||||||
@ -1172,35 +1180,35 @@ JANET_API void janet_buffer_push_u64(JanetBuffer *buffer, uint64_t x);
|
|||||||
#define janet_tuple_sm_column(t) (janet_tuple_head(t)->sm_column)
|
#define janet_tuple_sm_column(t) (janet_tuple_head(t)->sm_column)
|
||||||
#define janet_tuple_flag(t) (janet_tuple_head(t)->gc.flags)
|
#define janet_tuple_flag(t) (janet_tuple_head(t)->gc.flags)
|
||||||
JANET_API Janet *janet_tuple_begin(int32_t length);
|
JANET_API Janet *janet_tuple_begin(int32_t length);
|
||||||
JANET_API const Janet *janet_tuple_end(Janet *tuple);
|
JANET_API JanetTuple janet_tuple_end(Janet *tuple);
|
||||||
JANET_API const Janet *janet_tuple_n(const Janet *values, int32_t n);
|
JANET_API JanetTuple janet_tuple_n(const Janet *values, int32_t n);
|
||||||
JANET_API int janet_tuple_equal(const Janet *lhs, const Janet *rhs);
|
JANET_API int janet_tuple_equal(JanetTuple lhs, JanetTuple rhs);
|
||||||
JANET_API int janet_tuple_compare(const Janet *lhs, const Janet *rhs);
|
JANET_API int janet_tuple_compare(JanetTuple lhs, JanetTuple rhs);
|
||||||
|
|
||||||
/* String/Symbol functions */
|
/* String/Symbol functions */
|
||||||
#define janet_string_head(s) ((JanetStringHead *)((char *)s - offsetof(JanetStringHead, data)))
|
#define janet_string_head(s) ((JanetStringHead *)((char *)s - offsetof(JanetStringHead, data)))
|
||||||
#define janet_string_length(s) (janet_string_head(s)->length)
|
#define janet_string_length(s) (janet_string_head(s)->length)
|
||||||
#define janet_string_hash(s) (janet_string_head(s)->hash)
|
#define janet_string_hash(s) (janet_string_head(s)->hash)
|
||||||
JANET_API uint8_t *janet_string_begin(int32_t length);
|
JANET_API uint8_t *janet_string_begin(int32_t length);
|
||||||
JANET_API const uint8_t *janet_string_end(uint8_t *str);
|
JANET_API JanetString janet_string_end(uint8_t *str);
|
||||||
JANET_API const uint8_t *janet_string(const uint8_t *buf, int32_t len);
|
JANET_API JanetString janet_string(const uint8_t *buf, int32_t len);
|
||||||
JANET_API const uint8_t *janet_cstring(const char *cstring);
|
JANET_API JanetString janet_cstring(const char *cstring);
|
||||||
JANET_API int janet_string_compare(const uint8_t *lhs, const uint8_t *rhs);
|
JANET_API int janet_string_compare(JanetString lhs, JanetString rhs);
|
||||||
JANET_API int janet_string_equal(const uint8_t *lhs, const uint8_t *rhs);
|
JANET_API int janet_string_equal(JanetString lhs, JanetString rhs);
|
||||||
JANET_API int janet_string_equalconst(const uint8_t *lhs, const uint8_t *rhs, int32_t rlen, int32_t rhash);
|
JANET_API int janet_string_equalconst(JanetString lhs, const uint8_t *rhs, int32_t rlen, int32_t rhash);
|
||||||
JANET_API const uint8_t *janet_description(Janet x);
|
JANET_API JanetString janet_description(Janet x);
|
||||||
JANET_API const uint8_t *janet_to_string(Janet x);
|
JANET_API JanetString janet_to_string(Janet x);
|
||||||
JANET_API void janet_to_string_b(JanetBuffer *buffer, Janet x);
|
JANET_API void janet_to_string_b(JanetBuffer *buffer, Janet x);
|
||||||
JANET_API void janet_description_b(JanetBuffer *buffer, Janet x);
|
JANET_API void janet_description_b(JanetBuffer *buffer, Janet x);
|
||||||
#define janet_cstringv(cstr) janet_wrap_string(janet_cstring(cstr))
|
#define janet_cstringv(cstr) janet_wrap_string(janet_cstring(cstr))
|
||||||
#define janet_stringv(str, len) janet_wrap_string(janet_string((str), (len)))
|
#define janet_stringv(str, len) janet_wrap_string(janet_string((str), (len)))
|
||||||
JANET_API const uint8_t *janet_formatc(const char *format, ...);
|
JANET_API JanetString janet_formatc(const char *format, ...);
|
||||||
JANET_API void janet_formatb(JanetBuffer *bufp, const char *format, va_list args);
|
JANET_API void janet_formatb(JanetBuffer *bufp, const char *format, va_list args);
|
||||||
|
|
||||||
/* Symbol functions */
|
/* Symbol functions */
|
||||||
JANET_API const uint8_t *janet_symbol(const uint8_t *str, int32_t len);
|
JANET_API JanetSymbol janet_symbol(const uint8_t *str, int32_t len);
|
||||||
JANET_API const uint8_t *janet_csymbol(const char *str);
|
JANET_API JanetSymbol janet_csymbol(const char *str);
|
||||||
JANET_API const uint8_t *janet_symbol_gen(void);
|
JANET_API JanetSymbol janet_symbol_gen(void);
|
||||||
#define janet_symbolv(str, len) janet_wrap_symbol(janet_symbol((str), (len)))
|
#define janet_symbolv(str, len) janet_wrap_symbol(janet_symbol((str), (len)))
|
||||||
#define janet_csymbolv(cstr) janet_wrap_symbol(janet_csymbol(cstr))
|
#define janet_csymbolv(cstr) janet_wrap_symbol(janet_csymbol(cstr))
|
||||||
|
|
||||||
@ -1217,12 +1225,12 @@ JANET_API const uint8_t *janet_symbol_gen(void);
|
|||||||
#define janet_struct_hash(t) (janet_struct_head(t)->hash)
|
#define janet_struct_hash(t) (janet_struct_head(t)->hash)
|
||||||
JANET_API JanetKV *janet_struct_begin(int32_t count);
|
JANET_API JanetKV *janet_struct_begin(int32_t count);
|
||||||
JANET_API void janet_struct_put(JanetKV *st, Janet key, Janet value);
|
JANET_API void janet_struct_put(JanetKV *st, Janet key, Janet value);
|
||||||
JANET_API const JanetKV *janet_struct_end(JanetKV *st);
|
JANET_API JanetStruct janet_struct_end(JanetKV *st);
|
||||||
JANET_API Janet janet_struct_get(const JanetKV *st, Janet key);
|
JANET_API Janet janet_struct_get(JanetStruct st, Janet key);
|
||||||
JANET_API JanetTable *janet_struct_to_table(const JanetKV *st);
|
JANET_API JanetTable *janet_struct_to_table(JanetStruct st);
|
||||||
JANET_API int janet_struct_equal(const JanetKV *lhs, const JanetKV *rhs);
|
JANET_API int janet_struct_equal(JanetStruct lhs, JanetStruct rhs);
|
||||||
JANET_API int janet_struct_compare(const JanetKV *lhs, const JanetKV *rhs);
|
JANET_API int janet_struct_compare(JanetStruct lhs, JanetStruct rhs);
|
||||||
JANET_API const JanetKV *janet_struct_find(const JanetKV *st, Janet key);
|
JANET_API const JanetKV *janet_struct_find(JanetStruct st, Janet key);
|
||||||
|
|
||||||
/* Table functions */
|
/* Table functions */
|
||||||
JANET_API JanetTable *janet_table(int32_t capacity);
|
JANET_API JanetTable *janet_table(int32_t capacity);
|
||||||
@ -1233,9 +1241,9 @@ JANET_API Janet janet_table_get_ex(JanetTable *t, Janet key, JanetTable **which)
|
|||||||
JANET_API Janet janet_table_rawget(JanetTable *t, Janet key);
|
JANET_API Janet janet_table_rawget(JanetTable *t, Janet key);
|
||||||
JANET_API Janet janet_table_remove(JanetTable *t, Janet key);
|
JANET_API Janet janet_table_remove(JanetTable *t, Janet key);
|
||||||
JANET_API void janet_table_put(JanetTable *t, Janet key, Janet value);
|
JANET_API void janet_table_put(JanetTable *t, Janet key, Janet value);
|
||||||
JANET_API const JanetKV *janet_table_to_struct(JanetTable *t);
|
JANET_API JanetStruct janet_table_to_struct(JanetTable *t);
|
||||||
JANET_API void janet_table_merge_table(JanetTable *table, JanetTable *other);
|
JANET_API void janet_table_merge_table(JanetTable *table, JanetTable *other);
|
||||||
JANET_API void janet_table_merge_struct(JanetTable *table, const JanetKV *other);
|
JANET_API void janet_table_merge_struct(JanetTable *table, JanetStruct other);
|
||||||
JANET_API JanetKV *janet_table_find(JanetTable *t, Janet key);
|
JANET_API JanetKV *janet_table_find(JanetTable *t, Janet key);
|
||||||
JANET_API JanetTable *janet_table_clone(JanetTable *table);
|
JANET_API JanetTable *janet_table_clone(JanetTable *table);
|
||||||
|
|
||||||
@ -1257,13 +1265,13 @@ JANET_API const JanetKV *janet_dictionary_next(const JanetKV *kvs, int32_t cap,
|
|||||||
#define janet_abstract_type(u) (janet_abstract_head(u)->type)
|
#define janet_abstract_type(u) (janet_abstract_head(u)->type)
|
||||||
#define janet_abstract_size(u) (janet_abstract_head(u)->size)
|
#define janet_abstract_size(u) (janet_abstract_head(u)->size)
|
||||||
JANET_API void *janet_abstract_begin(const JanetAbstractType *type, size_t size);
|
JANET_API void *janet_abstract_begin(const JanetAbstractType *type, size_t size);
|
||||||
JANET_API void *janet_abstract_end(void *);
|
JANET_API JanetAbstract janet_abstract_end(void *abstractTemplate);
|
||||||
JANET_API void *janet_abstract(const JanetAbstractType *type, size_t size); /* begin and end in one call */
|
JANET_API JanetAbstract janet_abstract(const JanetAbstractType *type, size_t size); /* begin and end in one call */
|
||||||
|
|
||||||
/* Native */
|
/* Native */
|
||||||
typedef void (*JanetModule)(JanetTable *);
|
typedef void (*JanetModule)(JanetTable *);
|
||||||
typedef JanetBuildConfig(*JanetModconf)(void);
|
typedef JanetBuildConfig(*JanetModconf)(void);
|
||||||
JANET_API JanetModule janet_native(const char *name, const uint8_t **error);
|
JANET_API JanetModule janet_native(const char *name, JanetString *error);
|
||||||
|
|
||||||
/* Marshaling */
|
/* Marshaling */
|
||||||
JANET_API void janet_marshal(
|
JANET_API void janet_marshal(
|
||||||
@ -1305,7 +1313,7 @@ JANET_API JanetBuffer *janet_pretty(JanetBuffer *buffer, int depth, int flags, J
|
|||||||
JANET_API int janet_equals(Janet x, Janet y);
|
JANET_API int janet_equals(Janet x, Janet y);
|
||||||
JANET_API int32_t janet_hash(Janet x);
|
JANET_API int32_t janet_hash(Janet x);
|
||||||
JANET_API int janet_compare(Janet x, Janet y);
|
JANET_API int janet_compare(Janet x, Janet y);
|
||||||
JANET_API int janet_cstrcmp(const uint8_t *str, const char *other);
|
JANET_API int janet_cstrcmp(JanetString str, const char *other);
|
||||||
JANET_API Janet janet_in(Janet ds, Janet key);
|
JANET_API Janet janet_in(Janet ds, Janet key);
|
||||||
JANET_API Janet janet_get(Janet ds, Janet key);
|
JANET_API Janet janet_get(Janet ds, Janet key);
|
||||||
JANET_API Janet janet_getindex(Janet ds, int32_t index);
|
JANET_API Janet janet_getindex(Janet ds, int32_t index);
|
||||||
@ -1343,7 +1351,7 @@ typedef enum {
|
|||||||
JANET_API void janet_def(JanetTable *env, const char *name, Janet val, const char *documentation);
|
JANET_API void janet_def(JanetTable *env, const char *name, Janet val, const char *documentation);
|
||||||
JANET_API void janet_var(JanetTable *env, const char *name, Janet val, const char *documentation);
|
JANET_API void janet_var(JanetTable *env, const char *name, Janet val, const char *documentation);
|
||||||
JANET_API void janet_cfuns(JanetTable *env, const char *regprefix, const JanetReg *cfuns);
|
JANET_API void janet_cfuns(JanetTable *env, const char *regprefix, const JanetReg *cfuns);
|
||||||
JANET_API JanetBindingType janet_resolve(JanetTable *env, const uint8_t *sym, Janet *out);
|
JANET_API JanetBindingType janet_resolve(JanetTable *env, JanetSymbol sym, Janet *out);
|
||||||
JANET_API void janet_register(const char *name, JanetCFunction cfun);
|
JANET_API void janet_register(const char *name, JanetCFunction cfun);
|
||||||
|
|
||||||
/* Get values from the core environment. */
|
/* Get values from the core environment. */
|
||||||
@ -1364,7 +1372,7 @@ JANET_API Janet janet_resolve_core(const char *name);
|
|||||||
|
|
||||||
JANET_NO_RETURN JANET_API void janet_panicv(Janet message);
|
JANET_NO_RETURN JANET_API void janet_panicv(Janet message);
|
||||||
JANET_NO_RETURN JANET_API void janet_panic(const char *message);
|
JANET_NO_RETURN JANET_API void janet_panic(const char *message);
|
||||||
JANET_NO_RETURN JANET_API void janet_panics(const uint8_t *message);
|
JANET_NO_RETURN JANET_API void janet_panics(JanetString message);
|
||||||
JANET_NO_RETURN JANET_API void janet_panicf(const char *format, ...);
|
JANET_NO_RETURN JANET_API void janet_panicf(const char *format, ...);
|
||||||
JANET_API void janet_dynprintf(const char *name, FILE *dflt_file, const char *format, ...);
|
JANET_API void janet_dynprintf(const char *name, FILE *dflt_file, const char *format, ...);
|
||||||
#define janet_printf(...) janet_dynprintf("out", stdout, __VA_ARGS__)
|
#define janet_printf(...) janet_dynprintf("out", stdout, __VA_ARGS__)
|
||||||
@ -1374,17 +1382,17 @@ JANET_NO_RETURN JANET_API void janet_panic_abstract(Janet x, int32_t n, const Ja
|
|||||||
JANET_API void janet_arity(int32_t arity, int32_t min, int32_t max);
|
JANET_API void janet_arity(int32_t arity, int32_t min, int32_t max);
|
||||||
JANET_API void janet_fixarity(int32_t arity, int32_t fix);
|
JANET_API void janet_fixarity(int32_t arity, int32_t fix);
|
||||||
|
|
||||||
JANET_API Janet janet_getmethod(const uint8_t *method, const JanetMethod *methods);
|
JANET_API int janet_getmethod(JanetKeyword method, const JanetMethod *methods, Janet *out);
|
||||||
|
|
||||||
JANET_API double janet_getnumber(const Janet *argv, int32_t n);
|
JANET_API double janet_getnumber(const Janet *argv, int32_t n);
|
||||||
JANET_API JanetArray *janet_getarray(const Janet *argv, int32_t n);
|
JANET_API JanetArray *janet_getarray(const Janet *argv, int32_t n);
|
||||||
JANET_API const Janet *janet_gettuple(const Janet *argv, int32_t n);
|
JANET_API JanetTuple janet_gettuple(const Janet *argv, int32_t n);
|
||||||
JANET_API JanetTable *janet_gettable(const Janet *argv, int32_t n);
|
JANET_API JanetTable *janet_gettable(const Janet *argv, int32_t n);
|
||||||
JANET_API const JanetKV *janet_getstruct(const Janet *argv, int32_t n);
|
JANET_API JanetStruct janet_getstruct(const Janet *argv, int32_t n);
|
||||||
JANET_API const uint8_t *janet_getstring(const Janet *argv, int32_t n);
|
JANET_API JanetString janet_getstring(const Janet *argv, int32_t n);
|
||||||
JANET_API const char *janet_getcstring(const Janet *argv, int32_t n);
|
JANET_API const char *janet_getcstring(const Janet *argv, int32_t n);
|
||||||
JANET_API const uint8_t *janet_getsymbol(const Janet *argv, int32_t n);
|
JANET_API JanetSymbol janet_getsymbol(const Janet *argv, int32_t n);
|
||||||
JANET_API const uint8_t *janet_getkeyword(const Janet *argv, int32_t n);
|
JANET_API JanetKeyword janet_getkeyword(const Janet *argv, int32_t n);
|
||||||
JANET_API JanetBuffer *janet_getbuffer(const Janet *argv, int32_t n);
|
JANET_API JanetBuffer *janet_getbuffer(const Janet *argv, int32_t n);
|
||||||
JANET_API JanetFiber *janet_getfiber(const Janet *argv, int32_t n);
|
JANET_API JanetFiber *janet_getfiber(const Janet *argv, int32_t n);
|
||||||
JANET_API JanetFunction *janet_getfunction(const Janet *argv, int32_t n);
|
JANET_API JanetFunction *janet_getfunction(const Janet *argv, int32_t n);
|
||||||
@ -1407,12 +1415,12 @@ JANET_API uint64_t janet_getflags(const Janet *argv, int32_t n, const char *flag
|
|||||||
|
|
||||||
/* Optionals */
|
/* Optionals */
|
||||||
JANET_API double janet_optnumber(const Janet *argv, int32_t argc, int32_t n, double dflt);
|
JANET_API double janet_optnumber(const Janet *argv, int32_t argc, int32_t n, double dflt);
|
||||||
JANET_API const Janet *janet_opttuple(const Janet *argv, int32_t argc, int32_t n, const Janet *dflt);
|
JANET_API JanetTuple janet_opttuple(const Janet *argv, int32_t argc, int32_t n, JanetTuple dflt);
|
||||||
JANET_API const JanetKV *janet_optstruct(const Janet *argv, int32_t argc, int32_t n, const JanetKV *dflt);
|
JANET_API JanetStruct janet_optstruct(const Janet *argv, int32_t argc, int32_t n, JanetStruct dflt);
|
||||||
JANET_API const uint8_t *janet_optstring(const Janet *argv, int32_t argc, int32_t n, const uint8_t *dflt);
|
JANET_API JanetString janet_optstring(const Janet *argv, int32_t argc, int32_t n, JanetString dflt);
|
||||||
JANET_API const char *janet_optcstring(const Janet *argv, int32_t argc, int32_t n, const char *dflt);
|
JANET_API const char *janet_optcstring(const Janet *argv, int32_t argc, int32_t n, const char *dflt);
|
||||||
JANET_API const uint8_t *janet_optsymbol(const Janet *argv, int32_t argc, int32_t n, const uint8_t *dflt);
|
JANET_API JanetSymbol janet_optsymbol(const Janet *argv, int32_t argc, int32_t n, JanetString dflt);
|
||||||
JANET_API const uint8_t *janet_optkeyword(const Janet *argv, int32_t argc, int32_t n, const uint8_t *dflt);
|
JANET_API JanetKeyword janet_optkeyword(const Janet *argv, int32_t argc, int32_t n, JanetString dflt);
|
||||||
JANET_API JanetFiber *janet_optfiber(const Janet *argv, int32_t argc, int32_t n, JanetFiber *dflt);
|
JANET_API JanetFiber *janet_optfiber(const Janet *argv, int32_t argc, int32_t n, JanetFiber *dflt);
|
||||||
JANET_API JanetFunction *janet_optfunction(const Janet *argv, int32_t argc, int32_t n, JanetFunction *dflt);
|
JANET_API JanetFunction *janet_optfunction(const Janet *argv, int32_t argc, int32_t n, JanetFunction *dflt);
|
||||||
JANET_API JanetCFunction janet_optcfunction(const Janet *argv, int32_t argc, int32_t n, JanetCFunction dflt);
|
JANET_API JanetCFunction janet_optcfunction(const Janet *argv, int32_t argc, int32_t n, JanetCFunction dflt);
|
||||||
@ -1422,7 +1430,7 @@ JANET_API int32_t janet_optnat(const Janet *argv, int32_t argc, int32_t n, int32
|
|||||||
JANET_API int32_t janet_optinteger(const Janet *argv, int32_t argc, int32_t n, int32_t dflt);
|
JANET_API int32_t janet_optinteger(const Janet *argv, int32_t argc, int32_t n, int32_t dflt);
|
||||||
JANET_API int64_t janet_optinteger64(const Janet *argv, int32_t argc, int32_t n, int64_t dflt);
|
JANET_API int64_t janet_optinteger64(const Janet *argv, int32_t argc, int32_t n, int64_t dflt);
|
||||||
JANET_API size_t janet_optsize(const Janet *argv, int32_t argc, int32_t n, size_t dflt);
|
JANET_API size_t janet_optsize(const Janet *argv, int32_t argc, int32_t n, size_t dflt);
|
||||||
JANET_API void *janet_optabstract(const Janet *argv, int32_t argc, int32_t n, const JanetAbstractType *at, void *dflt);
|
JANET_API JanetAbstract janet_optabstract(const Janet *argv, int32_t argc, int32_t n, const JanetAbstractType *at, JanetAbstract dflt);
|
||||||
|
|
||||||
/* Mutable optional types specify a size default, and construct a new value if none is provided */
|
/* Mutable optional types specify a size default, and construct a new value if none is provided */
|
||||||
JANET_API JanetBuffer *janet_optbuffer(const Janet *argv, int32_t argc, int32_t n, int32_t dflt_len);
|
JANET_API JanetBuffer *janet_optbuffer(const Janet *argv, int32_t argc, int32_t n, int32_t dflt_len);
|
||||||
@ -1442,7 +1450,7 @@ JANET_API void janet_marshal_int64(JanetMarshalContext *ctx, int64_t value);
|
|||||||
JANET_API void janet_marshal_byte(JanetMarshalContext *ctx, uint8_t value);
|
JANET_API void janet_marshal_byte(JanetMarshalContext *ctx, uint8_t value);
|
||||||
JANET_API void janet_marshal_bytes(JanetMarshalContext *ctx, const uint8_t *bytes, size_t len);
|
JANET_API void janet_marshal_bytes(JanetMarshalContext *ctx, const uint8_t *bytes, size_t len);
|
||||||
JANET_API void janet_marshal_janet(JanetMarshalContext *ctx, Janet x);
|
JANET_API void janet_marshal_janet(JanetMarshalContext *ctx, Janet x);
|
||||||
JANET_API void janet_marshal_abstract(JanetMarshalContext *ctx, void *abstract);
|
JANET_API void janet_marshal_abstract(JanetMarshalContext *ctx, JanetAbstract abstract);
|
||||||
|
|
||||||
JANET_API void janet_unmarshal_ensure(JanetMarshalContext *ctx, size_t size);
|
JANET_API void janet_unmarshal_ensure(JanetMarshalContext *ctx, size_t size);
|
||||||
JANET_API size_t janet_unmarshal_size(JanetMarshalContext *ctx);
|
JANET_API size_t janet_unmarshal_size(JanetMarshalContext *ctx);
|
||||||
@ -1451,7 +1459,7 @@ JANET_API int64_t janet_unmarshal_int64(JanetMarshalContext *ctx);
|
|||||||
JANET_API uint8_t janet_unmarshal_byte(JanetMarshalContext *ctx);
|
JANET_API uint8_t janet_unmarshal_byte(JanetMarshalContext *ctx);
|
||||||
JANET_API void janet_unmarshal_bytes(JanetMarshalContext *ctx, uint8_t *dest, size_t len);
|
JANET_API void janet_unmarshal_bytes(JanetMarshalContext *ctx, uint8_t *dest, size_t len);
|
||||||
JANET_API Janet janet_unmarshal_janet(JanetMarshalContext *ctx);
|
JANET_API Janet janet_unmarshal_janet(JanetMarshalContext *ctx);
|
||||||
JANET_API void *janet_unmarshal_abstract(JanetMarshalContext *ctx, size_t size);
|
JANET_API JanetAbstract janet_unmarshal_abstract(JanetMarshalContext *ctx, size_t size);
|
||||||
|
|
||||||
JANET_API void janet_register_abstract_type(const JanetAbstractType *at);
|
JANET_API void janet_register_abstract_type(const JanetAbstractType *at);
|
||||||
JANET_API const JanetAbstractType *janet_get_abstract_type(Janet key);
|
JANET_API const JanetAbstractType *janet_get_abstract_type(Janet key);
|
||||||
|
Loading…
Reference in New Issue
Block a user