From 1c96c7163a679f1f53625c318139f1a42dcf3c9d Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Mon, 21 Mar 2022 17:47:37 -0500 Subject: [PATCH] Address #926 - enter the event loop from janet_dobytes or janet_dostring. --- CHANGELOG.md | 2 ++ Makefile | 1 + src/core/run.c | 10 +++++++++- src/core/vm.c | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b880c9a4..5f7c4329 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. ## Unreleased - ??? +- C functions `janet_dobytes` and `janet_dostring` will now enter the event loop if it is enabled. +- Fix hashing regression - hash of negative 0 must be the same as positive 0 since they are equal. - The `flycheck` function no longer pollutes the module/cache - Fix quasiquote bug in compiler - Disallow use of `cancel` and `resume` on fibers scheduled or created with `ev/go`, as well as the root diff --git a/Makefile b/Makefile index a60c6e69..72e728b6 100644 --- a/Makefile +++ b/Makefile @@ -238,6 +238,7 @@ build/janet-%.tar.gz: $(JANET_TARGET) \ mkdir -p build/$(JANET_DIST_DIR)/lib/ cp $(JANET_LIBRARY) $(JANET_STATIC_LIBRARY) build/$(JANET_DIST_DIR)/lib/ mkdir -p build/$(JANET_DIST_DIR)/man/man1/ + cp janet.1 build/$(JANET_DIST_DIR)/man/man1/janet.1 mkdir -p build/$(JANET_DIST_DIR)/src/ cp build/c/janet.c build/c/shell.c build/$(JANET_DIST_DIR)/src/ cp CONTRIBUTING.md LICENSE README.md build/$(JANET_DIST_DIR)/ diff --git a/src/core/run.c b/src/core/run.c index 9c0c7e80..5022914d 100644 --- a/src/core/run.c +++ b/src/core/run.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2021 Calvin Rose +* Copyright (c) 2022 Calvin Rose * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -100,6 +100,14 @@ int janet_dobytes(JanetTable *env, const uint8_t *bytes, int32_t len, const char /* Clean up and return errors */ janet_parser_deinit(&parser); if (where) janet_gcunroot(janet_wrap_string(where)); +#ifdef JANET_EV + /* Enter the event loop if we are not already in it */ + if (janet_vm.stack_n == 0) { + janet_gcroot(ret); + janet_loop(); + janet_gcunroot(ret); + } +#endif if (out) *out = ret; return errflags; } diff --git a/src/core/vm.c b/src/core/vm.c index fb8c22f0..ae5f8de0 100644 --- a/src/core/vm.c +++ b/src/core/vm.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2021 Calvin Rose +* Copyright (c) 2022 Calvin Rose * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to