mirror of
https://github.com/janet-lang/janet
synced 2024-11-25 17:57:17 +00:00
Update janet_pcall interface
The programmer can now not only get the used fiber, but provide a fiber to reuse if many calls are made in succession.
This commit is contained in:
parent
2ea28f29b0
commit
b14fcb068b
@ -198,6 +198,9 @@ static Janet cfun_io_fread(int32_t argc, Janet *argv) {
|
||||
if (fsize < 0) {
|
||||
janet_panicf("could not get file size of %v", argv[0]);
|
||||
}
|
||||
if (fsize > (INT32_MAX)) {
|
||||
janet_panic("file to large to read into buffer");
|
||||
}
|
||||
fseek(iof->file, 0, SEEK_SET);
|
||||
read_chunk(iof, buffer, (int32_t) fsize);
|
||||
}
|
||||
|
@ -1057,7 +1057,6 @@ static Janet cfun_peg_match(int32_t argc, Janet *argv) {
|
||||
s.captures = janet_array(0);
|
||||
s.scratch = janet_buffer(10);
|
||||
s.tags = janet_buffer(10);
|
||||
|
||||
s.constants = peg->constants;
|
||||
s.bytecode = peg->bytecode;
|
||||
const uint8_t *result = peg_rule(&s, s.bytecode, bytes.bytes + start);
|
||||
|
@ -852,7 +852,12 @@ JanetSignal janet_pcall(
|
||||
const Janet *argv,
|
||||
Janet *out,
|
||||
JanetFiber **f) {
|
||||
JanetFiber *fiber = janet_fiber(fun, 64, argc, argv);
|
||||
JanetFiber *fiber;
|
||||
if (f && *f) {
|
||||
fiber = janet_fiber_reset(*f, fun, argc, argv);
|
||||
} else {
|
||||
fiber = janet_fiber(fun, 64, argc, argv);
|
||||
}
|
||||
if (f) *f = fiber;
|
||||
if (!fiber) {
|
||||
*out = janet_cstringv("arity mismatch");
|
||||
|
Loading…
Reference in New Issue
Block a user