1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-27 21:57:41 +00:00

Update C API to use friendlier functions rather than macros.

Error handling is implemented with setjmp/longjmp so code
can be more concise. This required a very large but straight forward refactor for all
of the libraries.
This commit is contained in:
Calvin Rose
2019-01-05 20:09:03 -05:00
parent 5b62c8e6db
commit b60e3e302a
23 changed files with 1066 additions and 1534 deletions

View File

@@ -23,14 +23,12 @@
#include "line.h"
/* Common */
int janet_line_getter(JanetArgs args) {
JANET_FIXARITY(args, 2);
JANET_CHECK(args, 0, JANET_STRING);
JANET_CHECK(args, 1, JANET_BUFFER);
janet_line_get(
janet_unwrap_string(args.v[0]),
janet_unwrap_buffer(args.v[1]));
JANET_RETURN(args, args.v[0]);
Janet janet_line_getter(int32_t argc, Janet *argv) {
janet_arity(argc, 2, 2);
const uint8_t *str = janet_getstring(argv, 0);
JanetBuffer *buf = janet_getbuffer(argv, 1);
janet_line_get(str, buf);
return argv[0];
}
static void simpleline(JanetBuffer *buffer) {