Skip to content

Commit 059253f

Browse files
committed
Merge branch 'master' into compile-opt
2 parents 4396f01 + 3441bcb commit 059253f

31 files changed

+709
-262
lines changed

.github/workflows/codeql.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@ jobs:
2727
uses: actions/checkout@v3
2828

2929
- name: Initialize CodeQL
30-
uses: github/codeql-action/init@v2
30+
uses: github/codeql-action/init@v3
3131
with:
3232
languages: ${{ matrix.language }}
3333
queries: +security-and-quality
34+
tools: linked
3435

3536
- name: Autobuild
36-
uses: github/codeql-action/autobuild@v2
37+
uses: github/codeql-action/autobuild@v3
3738

3839
- name: Perform CodeQL Analysis
39-
uses: github/codeql-action/analyze@v2
40+
uses: github/codeql-action/analyze@v3
4041
with:
4142
category: "/language:${{ matrix.language }}"

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
- name: Test the project
3939
shell: cmd
4040
run: build_win test
41+
- name: Test installer build
42+
shell: cmd
43+
run: build_win dist
4144

4245
test-windows-min:
4346
name: Build and test on Windows Minimal build

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
All notable changes to this project will be documented in this file.
33

44
## ??? - Unreleased
5+
- Improve `?` peg special termination behavior
6+
- Add IEEE hex floats to grammar.
7+
- Add buffer peg literal support
8+
- Improve `split` peg special edge case behavior
9+
- Add Arm64 .msi support
10+
- Add `no-reuse` argument to `net/listen` to disable reusing server sockets
11+
- Add `struct/rawget`
12+
- Fix `deep=` and `deep-not=` to better handle degenerate cases with mutable table keys
13+
- Long strings will now dedent on `\r\n` instead of just `\n`.
14+
- Add `ev/to-file` for synchronous resource operations
15+
- Improve `file/open` error message by including path
16+
17+
## 1.37.1 - 2024-12-05
18+
- Fix meson cross compilation
19+
- Update timeout documentation for networking APIs: timeouts raise errors and do not return nil.
20+
- Add `janet_addtimeout_nil(double sec);` to the C API.
521
- Change string hashing.
622
- Fix string equality bug.
723
- Add `assertf`

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ Alternatively, install the package directly with `pkgin install janet`.
207207

208208
To build an `.msi` installer executable, in addition to the above steps, you will have to:
209209

210-
5. Install, or otherwise add to your PATH the [WiX 3.11 Toolset](https://github.com/wixtoolset/wix3/releases).
210+
5. Install, or otherwise add to your PATH the [WiX 3.14 Toolset](https://github.com/wixtoolset/wix3/releases).
211211
6. Run `build_win dist`.
212212

213213
Now you should have an `.msi`. You can run `build_win install` to install the `.msi`, or execute the file itself.

build_win.bat

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ exit /b 0
9191

9292
@rem Clean build artifacts
9393
:CLEAN
94-
del *.exe *.lib *.exp
94+
del *.exe *.lib *.exp *.msi *.wixpdb
9595
rd /s /q build
9696
if exist dist (
9797
rd /s /q dist
@@ -138,11 +138,18 @@ if defined APPVEYOR_REPO_TAG_NAME (
138138
set RELEASE_VERSION=%JANET_VERSION%
139139
)
140140
if defined CI (
141-
set WIXBIN="c:\Program Files (x86)\WiX Toolset v3.11\bin\"
141+
set WIXBIN="%WIX%bin\"
142+
echo WIXBIN = %WIXBIN%
142143
) else (
143144
set WIXBIN=
144145
)
145-
%WIXBIN%candle.exe tools\msi\janet.wxs -arch %BUILDARCH% -out build\
146+
147+
set WIXARCH=%BUILDARCH%
148+
if "%WIXARCH%"=="aarch64" (
149+
set WIXARCH=arm64
150+
)
151+
152+
%WIXBIN%candle.exe tools\msi\janet.wxs -arch %WIXARCH% -out build\
146153
%WIXBIN%light.exe "-sice:ICE38" -b tools\msi -ext WixUIExtension build\janet.wixobj -out janet-%RELEASE_VERSION%-windows-%BUILDARCH%-installer.msi
147154
exit /b 0
148155

meson.build

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,23 @@
2020

2121
project('janet', 'c',
2222
default_options : ['c_std=c99', 'build.c_std=c99', 'b_lundef=false', 'default_library=both'],
23-
version : '1.37.0')
23+
version : '1.37.1')
2424

2525
# Global settings
2626
janet_path = join_paths(get_option('prefix'), get_option('libdir'), 'janet')
2727
header_path = join_paths(get_option('prefix'), get_option('includedir'), 'janet')
2828

29-
# Link math library on all systems
29+
# Compilers
3030
cc = meson.get_compiler('c')
31+
native_cc = meson.get_compiler('c', native : true)
32+
33+
# Native deps
34+
native_m_dep = native_cc.find_library('m', required : false)
35+
native_dl_dep = native_cc.find_library('dl', required : false)
36+
native_android_spawn_dep = native_cc.find_library('android-spawn', required : false)
37+
native_thread_dep = dependency('threads', native : true)
38+
39+
# Deps
3140
m_dep = cc.find_library('m', required : false)
3241
dl_dep = cc.find_library('dl', required : false)
3342
android_spawn_dep = cc.find_library('android-spawn', required : false)
@@ -167,11 +176,18 @@ mainclient_src = [
167176
'src/mainclient/shell.c'
168177
]
169178

179+
janet_dependencies = [m_dep, dl_dep, android_spawn_dep]
180+
janet_native_dependencies = [native_m_dep, native_dl_dep, native_android_spawn_dep]
181+
if not get_option('single_threaded')
182+
janet_dependencies += thread_dep
183+
janet_native_dependencies += native_thread_dep
184+
endif
185+
170186
# Build boot binary
171187
janet_boot = executable('janet-boot', core_src, boot_src,
172188
include_directories : incdir,
173189
c_args : '-DJANET_BOOTSTRAP',
174-
dependencies : [m_dep, dl_dep, thread_dep, android_spawn_dep],
190+
dependencies : janet_native_dependencies,
175191
native : true)
176192

177193
# Build janet.c
@@ -184,11 +200,6 @@ janetc = custom_target('janetc',
184200
'JANET_PATH', janet_path
185201
])
186202

187-
janet_dependencies = [m_dep, dl_dep, android_spawn_dep]
188-
if not get_option('single_threaded')
189-
janet_dependencies += thread_dep
190-
endif
191-
192203
# Allow building with no shared library
193204
if cc.has_argument('-fvisibility=hidden')
194205
lib_cflags = ['-fvisibility=hidden']
@@ -234,7 +245,7 @@ if meson.is_cross_build()
234245
endif
235246
janet_nativeclient = executable('janet-native', janetc, mainclient_src,
236247
include_directories : incdir,
237-
dependencies : janet_dependencies,
248+
dependencies : janet_native_dependencies,
238249
c_args : extra_native_cflags,
239250
native : true)
240251
else

src/boot/boot.janet

Lines changed: 67 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@
996996

997997
(defn reduce2
998998
``The 2-argument version of `reduce` that does not take an initialization value.
999-
Instead, the first element of the array is used for initialization.``
999+
Instead, the first element of the array is used for initialization. If `ind` is empty, will evaluate to nil.``
10001000
[f ind]
10011001
(var k (next ind))
10021002
(if (= nil k) (break nil))
@@ -1311,7 +1311,7 @@
13111311
(defdyn *redef* "When set, allow dynamically rebinding top level defs. Will slow generated code and is intended to be used for development.")
13121312
(defdyn *debug* "Enables a built in debugger on errors and other useful features for debugging in a repl.")
13131313
(defdyn *exit* "When set, will cause the current context to complete. Can be set to exit from repl (or file), for example.")
1314-
(defdyn *exit-value* "Set the return value from `run-context` upon an exit. By default, `run-context` will return nil.")
1314+
(defdyn *exit-value* "Set the return value from `run-context` upon an exit.")
13151315
(defdyn *task-id* "When spawning a thread or fiber, the task-id can be assigned for concurrency control.")
13161316

13171317
(defdyn *current-file*
@@ -2219,56 +2219,31 @@
22192219
(map-template :some res pred ind inds)
22202220
res)
22212221

2222-
(defn deep-not=
2223-
``Like `not=`, but mutable types (arrays, tables, buffers) are considered
2224-
equal if they have identical structure. Much slower than `not=`.``
2225-
[x y]
2226-
(def tx (type x))
2227-
(or
2228-
(not= tx (type y))
2229-
(case tx
2230-
:tuple (or (not= (length x) (length y))
2231-
(do
2232-
(var ret false)
2233-
(forv i 0 (length x)
2234-
(def xx (in x i))
2235-
(def yy (in y i))
2236-
(if (deep-not= xx yy)
2237-
(break (set ret true))))
2238-
ret))
2239-
:array (or (not= (length x) (length y))
2240-
(do
2241-
(var ret false)
2242-
(forv i 0 (length x)
2243-
(def xx (in x i))
2244-
(def yy (in y i))
2245-
(if (deep-not= xx yy)
2246-
(break (set ret true))))
2247-
ret))
2248-
:struct (deep-not= (kvs x) (kvs y))
2249-
:table (deep-not= (table/to-struct x) (table/to-struct y))
2250-
:buffer (not= (string x) (string y))
2251-
(not= x y))))
2252-
2253-
(defn deep=
2254-
``Like `=`, but mutable types (arrays, tables, buffers) are considered
2255-
equal if they have identical structure. Much slower than `=`.``
2256-
[x y]
2257-
(not (deep-not= x y)))
2258-
22592222
(defn freeze
22602223
`Freeze an object (make it immutable) and do a deep copy, making
22612224
child values also immutable. Closures, fibers, and abstract types
22622225
will not be recursively frozen, but all other types will.`
22632226
[x]
2264-
(case (type x)
2265-
:array (tuple/slice (map freeze x))
2266-
:tuple (tuple/slice (map freeze x))
2267-
:table (if-let [p (table/getproto x)]
2268-
(freeze (merge (table/clone p) x))
2269-
(struct ;(map freeze (kvs x))))
2270-
:struct (struct ;(map freeze (kvs x)))
2271-
:buffer (string x)
2227+
(def tx (type x))
2228+
(cond
2229+
(or (= tx :array) (= tx :tuple))
2230+
(tuple/slice (map freeze x))
2231+
2232+
(or (= tx :table) (= tx :struct))
2233+
(let [temp-tab @{}]
2234+
# Handle multiple unique keys that freeze. Result should
2235+
# be independent of iteration order.
2236+
(eachp [k v] x
2237+
(def kk (freeze k))
2238+
(def vv (freeze v))
2239+
(def old (get temp-tab kk))
2240+
(def new (if (= nil old) vv (max vv old)))
2241+
(put temp-tab kk new))
2242+
(table/to-struct temp-tab (freeze (getproto x))))
2243+
2244+
(= tx :buffer)
2245+
(string x)
2246+
22722247
x))
22732248

22742249
(defn thaw
@@ -2284,6 +2259,41 @@
22842259
:string (buffer ds)
22852260
ds))
22862261

2262+
(defn deep-not=
2263+
``Like `not=`, but mutable types (arrays, tables, buffers) are considered
2264+
equal if they have identical structure. Much slower than `not=`.``
2265+
[x y]
2266+
(def tx (type x))
2267+
(or
2268+
(not= tx (type y))
2269+
(cond
2270+
(or (= tx :tuple) (= tx :array))
2271+
(or (not= (length x) (length y))
2272+
(do
2273+
(var ret false)
2274+
(forv i 0 (length x)
2275+
(def xx (in x i))
2276+
(def yy (in y i))
2277+
(if (deep-not= xx yy)
2278+
(break (set ret true))))
2279+
ret))
2280+
(or (= tx :struct) (= tx :table))
2281+
(or (not= (length x) (length y))
2282+
(do
2283+
(def rawget (if (= tx :struct) struct/rawget table/rawget))
2284+
(var ret false)
2285+
(eachp [k v] x
2286+
(if (deep-not= (rawget y k) v) (break (set ret true))))
2287+
ret))
2288+
(= tx :buffer) (not= 0 (- (length x) (length y)) (memcmp x y))
2289+
(not= x y))))
2290+
2291+
(defn deep=
2292+
``Like `=`, but mutable types (arrays, tables, buffers) are considered
2293+
equal if they have identical structure. Much slower than `=`.``
2294+
[x y]
2295+
(not (deep-not= x y)))
2296+
22872297
(defn macex
22882298
``Expand macros completely.
22892299
`on-binding` is an optional callback for whenever a normal symbolic binding
@@ -2335,17 +2345,11 @@
23352345

23362346
(defmacro short-fn
23372347
```
2338-
Shorthand for `fn`. Arguments are given as `$n`, where `n` is the 0-indexed
2339-
argument of the function. `$` is also an alias for the first (index 0) argument.
2340-
The `$&` symbol will make the anonymous function variadic if it appears in the
2341-
body of the function, and can be combined with positional arguments.
2342-
2343-
Example usage:
2344-
2345-
(short-fn (+ $ $)) # A function that doubles its arguments.
2346-
(short-fn (string $0 $1)) # accepting multiple args.
2347-
|(+ $ $) # use pipe reader macro for terse function literals.
2348-
|(+ $&) # variadic functions
2348+
Shorthand for `fn`. Arguments are given as `$n`, where `n` is the
2349+
0-indexed argument of the function. `$` is also an alias for the
2350+
first (index 0) argument. The `$&` symbol will make the anonymous
2351+
function variadic if it appears in the body of the function, and
2352+
can be combined with positional arguments.
23492353
```
23502354
[arg &opt name]
23512355
(var max-param-seen -1)
@@ -2665,7 +2669,6 @@
26652669

26662670
(do
26672671
(var pindex 0)
2668-
(var pstatus nil)
26692672
(def len (length buf))
26702673
(when (= len 0)
26712674
(:eof p)
@@ -2855,8 +2858,8 @@
28552858
(when (and (string? pattern) (string/has-prefix? ":sys:/" pattern))
28562859
(set last-index index)
28572860
(array/push copies [(string/replace ":sys:" path pattern) ;(drop 1 entry)])))
2858-
(array/insert mp (+ 1 last-index) ;copies)
2859-
mp)
2861+
(array/insert mp (+ 1 last-index) ;copies)
2862+
mp)
28602863

28612864
(module/add-paths ":native:" :native)
28622865
(module/add-paths "/init.janet" :source)
@@ -3874,8 +3877,8 @@
38743877
(compwhen (dyn 'net/listen)
38753878
(defn net/server
38763879
"Start a server asynchronously with `net/listen` and `net/accept-loop`. Returns the new server stream."
3877-
[host port &opt handler type]
3878-
(def s (net/listen host port type))
3880+
[host port &opt handler type no-reuse]
3881+
(def s (net/listen host port type no-reuse))
38793882
(if handler
38803883
(ev/go (fn [] (net/accept-loop s handler))))
38813884
s))
@@ -4097,7 +4100,7 @@
40974100
(when (empty? b) (buffer/trim b) (os/chmod to perm) (break))
40984101
(file/write fto b)
40994102
(buffer/clear b)))
4100-
(errorf "destination file %s cannot be opened for writing" to))
4103+
(errorf "destination file %s cannot be opened for writing" to))
41014104
(errorf "source file %s cannot be opened for reading" from)))
41024105

41034106
(defn- copyrf

src/conf/janetconf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
#define JANET_VERSION_MAJOR 1
77
#define JANET_VERSION_MINOR 37
8-
#define JANET_VERSION_PATCH 0
9-
#define JANET_VERSION_EXTRA "-dev"
10-
#define JANET_VERSION "1.37.0-dev"
8+
#define JANET_VERSION_PATCH 1
9+
#define JANET_VERSION_EXTRA ""
10+
#define JANET_VERSION "1.37.1"
1111

1212
/* #define JANET_BUILD "local" */
1313

src/core/capi.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ JANET_NO_RETURN static void janet_top_level_signal(const char *msg) {
6262

6363
void janet_signalv(JanetSignal sig, Janet message) {
6464
if (janet_vm.return_reg != NULL) {
65+
/* Should match logic in janet_call for coercing everything not ok to an error (no awaits, yields, etc.) */
66+
if (janet_vm.coerce_error && sig != JANET_SIGNAL_OK) {
67+
#ifdef JANET_EV
68+
if (NULL != janet_vm.root_fiber && sig == JANET_SIGNAL_EVENT) {
69+
janet_vm.root_fiber->sched_id++;
70+
}
71+
#endif
72+
if (sig != JANET_SIGNAL_ERROR) {
73+
message = janet_wrap_string(janet_formatc("%v coerced from %s to error", message, janet_signal_names[sig]));
74+
}
75+
sig = JANET_SIGNAL_ERROR;
76+
}
6577
*janet_vm.return_reg = message;
6678
if (NULL != janet_vm.fiber) {
6779
janet_vm.fiber->flags |= JANET_FIBER_DID_LONGJUMP;

0 commit comments

Comments
 (0)