Skip to content

Commit c27a722

Browse files
authored
[200_21] bump: goldfish 17.11.26 (#2828)
1 parent 4927cdd commit c27a722

File tree

10 files changed

+1673
-78
lines changed

10 files changed

+1673
-78
lines changed

TeXmacs/plugins/goldfish/goldfish/liii/hash-table.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
hash-table-size hash-table-keys hash-table-values hash-table-entries
2828
hash-table-find hash-table-count hash-table-fold
2929
hash-table-for-each hash-table-map->list
30-
hash-table->alist
30+
hash-table->alist hash-table-copy
3131
)
3232
(begin
3333
) ; end of begin

TeXmacs/plugins/goldfish/goldfish/liii/hashlib.scm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@
1414
; under the License.
1515
;
1616
(define-library (liii hashlib)
17-
(export md5 sha1 sha256)
17+
(export md5 sha1 sha256
18+
md5-by-file sha1-by-file sha256-by-file)
1819
(begin
1920

2021
(define (md5 str) (g_md5 str))
2122
(define (sha1 str) (g_sha1 str))
2223
(define (sha256 str) (g_sha256 str))
2324

25+
(define (md5-by-file path) (g_md5-by-file path))
26+
(define (sha1-by-file path) (g_sha1-by-file path))
27+
(define (sha256-by-file path) (g_sha256-by-file path))
28+
2429
) ; end of begin
2530
) ; end of define-library

TeXmacs/plugins/goldfish/goldfish/liii/http.scm

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
(import (liii hash-table)
88
(liii alist))
99
(export http-head http-get http-post http-ok?
10-
http-stream-get http-stream-post)
10+
http-stream-get http-stream-post
11+
http-async-get http-async-post http-async-head http-poll http-wait-all)
1112
(begin
1213

1314
(define (http-ok? r)
@@ -65,6 +66,43 @@
6566
(g_http-stream-post url params data '(("Content-Type" . "text/plain")) proxy userdata callback))
6667
(else (g_http-stream-post url params data headers proxy userdata callback))))
6768

69+
;; Async HTTP API wrapper functions
70+
71+
(define* (http-async-get url callback (params '()) (headers '()) (proxy '()))
72+
(when (not (alist? params))
73+
(type-error params "is not a association list"))
74+
(when (not (alist? proxy))
75+
(type-error proxy "is not a association list"))
76+
(when (not (procedure? callback))
77+
(type-error callback "is not a procedure"))
78+
(g_http-async-get url params headers proxy callback))
79+
80+
(define* (http-async-post url callback (params '()) (data "") (headers '()) (proxy '()))
81+
(when (not (alist? params))
82+
(type-error params "is not a association list"))
83+
(when (not (alist? proxy))
84+
(type-error proxy "is not a association list"))
85+
(when (not (procedure? callback))
86+
(type-error callback "is not a procedure"))
87+
(cond ((and (string? data) (> (string-length data) 0) (null? headers))
88+
(g_http-async-post url params data '(("Content-Type" . "text/plain")) proxy callback))
89+
(else (g_http-async-post url params data headers proxy callback))))
90+
91+
(define* (http-async-head url callback (params '()) (headers '()) (proxy '()))
92+
(when (not (alist? params))
93+
(type-error params "is not a association list"))
94+
(when (not (alist? proxy))
95+
(type-error proxy "is not a association list"))
96+
(when (not (procedure? callback))
97+
(type-error callback "is not a procedure"))
98+
(g_http-async-head url params headers proxy callback))
99+
100+
(define (http-poll)
101+
(g_http-poll))
102+
103+
(define* (http-wait-all (timeout -1))
104+
(g_http-wait-all timeout))
105+
68106
) ; end of begin
69107
) ; end of define-library
70108

TeXmacs/plugins/goldfish/goldfish/scheme/time.scm

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,26 @@
1515
;
1616

1717
(define-library (scheme time)
18-
(export current-second current-jiffy jiffies-per-second)
18+
(import (only (scheme base) let-values s7-round))
19+
(export current-second current-jiffy jiffies-per-second
20+
get-time-of-day monotonic-nanosecond
21+
system-clock-resolution steady-clock-resolution)
1922
(begin
2023

2124
(define (jiffies-per-second) 1000000)
2225

23-
(define (current-second) (g_current-second))
26+
(define get-time-of-day g_get-time-of-day)
27+
(define monotonic-nanosecond g_monotonic-nanosecond)
28+
(define system-clock-resolution g_system-clock-resolution)
29+
(define steady-clock-resolution g_steady-clock-resolution)
30+
31+
(define (current-second)
32+
(let-values (((sec usec) (get-time-of-day)))
33+
(+ sec (exact->inexact (/ usec 1000000)))))
2434

2535
(define (current-jiffy)
26-
(round (* (current-second) (jiffies-per-second))))
36+
;; NOTE: use the s7-round to ensure that a natural number is returned.
37+
(s7-round (* (current-second) (jiffies-per-second))))
2738

2839
) ; end of begin
2940
) ; end of define-library

TeXmacs/plugins/goldfish/goldfish/srfi/srfi-125.scm

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
hash-table-update! hash-table-update!/default hash-table-pop! hash-table-clear!
2323
hash-table-size hash-table-keys hash-table-values hash-table-entries hash-table-find
2424
hash-table-count hash-table-fold hash-table-for-each hash-table-map->list
25-
hash-table->alist)
25+
hash-table->alist hash-table-copy)
2626
(begin
2727

2828
(define (assert-hash-table-type ht f)
@@ -148,4 +148,14 @@
148148

149149
(define hash-table->alist
150150
(typed-lambda ((ht hash-table?))
151-
(append-map (lambda (x) (list (car x) (cdr x))) (map values ht))))))
151+
(append-map (lambda (x) (list (car x) (cdr x))) (map values ht))))
152+
153+
(define hash-table-copy
154+
(typed-lambda ((ht hash-table?) . rest)
155+
(let ((new-ht (make-hash-table))
156+
(mutable? (if (null? rest) #t (car rest))))
157+
(hash-table-for-each
158+
(lambda (k v)
159+
(hash-table-set! new-ht k v))
160+
ht)
161+
new-ht)))))

0 commit comments

Comments
 (0)