changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / lisp/std/pkg.lisp

changeset 692: f51b73f49946
parent: 295ea43ceb2d
child: a36280d2ef4e
author: Richard Westhaver <ellis@rwest.io>
date: Thu, 03 Oct 2024 17:56:11 -0400
permissions: -rw-r--r--
description: std/task and tests
1 ;;; std/pkg.lisp --- Standard Packages
2 
3 ;;
4 
5 ;;; Code:
6 (pkg:defpkg :std-int
7  (:use :cl)
8  (:use-reexport :std/named-readtables :std/defpkg))
9 
10 (in-package :std-int)
11 
12 (defpackage :std/condition
13  (:use :cl)
14  (:export ;; err
15  :std-error :std-error-message
16  :define-error-reporter
17  :deferror
18  :nyi!
19  :required-argument
20  :ignore-some-conditions
21  :simple-style-warning
22  :simple-reader-error
23  :simple-parse-error
24  :simple-program-error
25  :circular-dependency
26  :circular-dependency-items
27  :unknown-argument
28  :unknown-argument-name
29  :unknown-argument-kind
30  :unknown-argument-p
31  :missing-argument
32  :missing-argument-command
33  :missing-argument-p
34  :invalid-argument
35  :invalid-argument-item
36  :invalid-argument-reason
37  :invalid-argument-p
38  :unwind-protect-case
39  :define-simple-error
40  :define-simple-error-reporter
41  :def-simple-error-reporter
42  :std-warning
43  :defwarning
44  :def-simple-warning-reporter
45  :def-warning-reporter))
46 
47 (defpackage :std/sym
48  (:use :cl)
49  (:shadowing-import-from :sb-int
50  :with-unique-names :symbolicate :package-symbolicate :keywordicate :gensymify*
51  :gensymify)
52  (:export
53  :ensure-symbol
54  :format-symbol
55  :make-keyword
56  :make-slot-name
57  :make-gensym
58  :make-gensym-list
59  :with-gensyms
60  :with-unique-names
61  :symbolicate
62  :keywordicate
63  :gensymify
64  :gensymify*))
65 
66 (defpkg :std/list
67  (:use :cl)
68  (:shadowing-import-from :sb-int
69  :ensure-list :recons :memq :assq
70  :ensure-list :proper-list-of-length-p :proper-list-p :singleton-p)
71  (:import-from :std/sym :symb)
72  (:import-from :std/named-readtables :parse-body)
73  (:export
74  :ensure-car
75  :ensure-cons
76  :appendf
77  :nconcf
78  :unionf
79  :nunionf
80  :reversef
81  :nreversef
82  :deletef
83  :flatten
84  :group
85  :let-binding-transform
86  :ensure-list :recons :memq :assq
87  :circular-list :circular-list-p :circular-tree-p :merge!
88  :sort!
89  :set-equal))
90 
91 (defpkg :std/type
92  (:use :cl)
93  (:import-from :std/sym :format-symbol :with-gensyms)
94  (:import-from :std/list :ensure-car)
95  (:export :+default-element-type+
96  :array-index :array-length
97  :negative-integer :non-negative-integer
98  :positive-integer :octet
99  :octet-vector))
100 
101 (defpkg :std/num
102  (:use :cl)
103  (:export
104  ;; num/parse
105  :parse-number
106  :parse-real-number
107  :parse-positive-real-number
108  :invalid-number
109  :invalid-number-value
110  :invalid-number-reason
111  ;; num/float
112  :make-float-converters
113  :encode-float32
114  :decode-float32
115  :encode-float64
116  :decode-float64
117  ;; num/leb128
118  :read-leb128
119  :encode-leb128
120  :decode-leb128
121  :read-uleb128
122  :encode-uleb128
123  :decode-uleb128))
124 
125 (defpkg :std/stream
126  (:use :cl :sb-gray)
127  (:import-from :std/type :non-negative-integer :positive-integer)
128  (:export
129  ;; stream
130  :copy-stream
131  :wrapped-stream
132  :wrapped-character-input-stream
133  :wrapped-character-output-stream
134  :counting-character-input-stream
135  :prefixed-character-output-stream
136  :stream-of :char-count-of :line-count-of :col-count-of
137  :prev-col-count-of :col-index-of :write-prefix
138  :prefix-of))
139 
140 (defpkg :std/array
141  (:use :cl)
142  (:export :copy-array :signed-array-length))
143 
144 (defpkg :std/hash-table
145  (:use :cl)
146  (:nicknames :std/ht)
147  (:export :hash-table-alist
148  :maphash-keys :hash-table-keys
149  :maphash-values :hash-table-values))
150 
151 (defpkg :std/alien
152  (:use :cl :sb-alien)
153  (:import-from :std/sym :symbolicate :with-gensyms)
154  (:export
155  :setfa
156  :copy-c-string
157  :clone-strings
158  :octets-to-alien-array
159  :with-alien-slots
160  :clone-octets-to-alien
161  :octets-to-alien
162  :clone-octets-from-alien
163  :foreign-int-to-integer
164  :foreign-int-to-bool
165  :bool-to-foreign-int
166  :define-alien-enum
167  :define-opaque
168  :shared-object-name
169  :define-alien-loader
170  :c-string-to-string-list
171  :list-all-shared-objects
172  :num-cpus
173  :*cpus*
174  :loff-t
175  :memset))
176 
177 (defpkg :std/mop
178  (:use :cl :sb-mop :sb-pcl)
179  (:import-from :std/sym :symb :make-keyword)
180  (:export :list-slot-values-using-class
181  :list-class-methods :list-class-slots :list-indirect-slot-methods))
182 
183 (defpkg :std/fu
184  (:use :cl)
185  (:import-from :std/sym :make-gensym-list)
186  (:export
187  :ensure-function
188  :ensure-functionf
189  :disjoin
190  :conjoin
191  :compose
192  :multiple-value-compose
193  :curry
194  :rcurry))
195 
196 (defpkg :std/macs
197  (:use :cl)
198  (:import-from :std/sym :symb :mkstr :make-gensym-list :once-only :with-gensyms)
199  (:import-from :std/fu :compose)
200  (:import-from :std/named-readtables :in-readtable :parse-body)
201  (:import-from :std/list :flatten :defmacro!)
202  (:export
203  :named-lambda
204  :nested-loop
205  :g!-symbol-p
206  :defmacro/g!
207  :o!-symbol-p
208  :o!-symbol-to-g!-symbol
209  :defmacro!
210  :defun!
211  :dlambda
212  :until
213  :fact
214  :choose
215  :make-tlist
216  :tlist-left
217  :tlist-right
218  :tlist-empty-p
219  :tlist-add-left
220  :tlist-add-right
221  :tlist-rem-left
222  :tlist-update
223  :build-batcher-sn
224  :sortf
225  :dollar-symbol-p
226  :if-match
227  :when-match
228  :once-only
229  :destructuring-case
230  :destructuring-ccase
231  :destructuring-ecase
232  :when-let
233  :when-let*
234  :if-let
235  :if-let*
236  :if*
237  :define-constant
238  :defvar-unbound
239  :def!
240  :eval-always
241  ;; ana
242  :awhen
243  :acond
244  :alambda
245  :nlet-tail
246  :alet%
247  :alet
248  :acond2
249  :aif
250  :it
251  :%a
252  ;; pan
253  :%p
254  :pandoriclet
255  :pandoriclet-get
256  :pandoriclet-set
257  :get-pandoric
258  :with-pandoric
259  :pandoric-hotpatch
260  :pandoric-recode
261  :plambda
262  :pandoric-eval
263  :with-collectors
264  :collecting
265  :xor))
266 
267 (defpkg :std/thread
268  (:use :cl :sb-thread :sb-concurrency)
269  (:import-from :std/list :flatten)
270  (:use-reexport :sb-thread)
271  (:export
272  :std-thread-error
273  :print-top-level :thread-support-p
274  :find-thread-by-id :thread-id-list
275  :timed-join-thread :kill-thread
276  :wait-for-threads
277  :hang :finish-threads
278  :make-threads :with-threads
279  :thread-count :dump-thread))
280 
281 (defpkg :std/task
282  (:use :cl :std/thread :sb-concurrency)
283  (:import-from :std/thread :%make-thread)
284  (:import-from :std/macs :if-let)
285  (:export
286  :spawn-workers
287  :make-oracle :make-supervisor
288  :oracle :run-task
289  :oracle-id :find-thread
290  :push-job :push-task
291  :push-worker :push-task-result
292  :run-job :run-stage
293  :pop-job :pop-task
294  :workers
295  :tasks
296  :results
297  :kill-workers
298  :kill-worker
299  :join-worker
300  :worker-thread
301  :start-task-worker
302  :start-task-workers
303  :pop-worker :pop-task-result
304  :*task-pool*
305  :*tasks*
306  :*oracles*
307  :*workers*
308  :*jobs*
309  :*stages*
310  :*task*
311  :*task-result*
312  :define-task-kernel
313  :*task-kernel*
314  :default-task-kernel
315  :make-worker
316  :make-workers
317  :run-tasks
318  :run-jobs
319  :worker-count
320  :init-task-pool
321  :make-task-pool
322  :start-task-pool :pause-task-pool
323  :shutdown-task-pool
324  :push-stage :designate-oracle
325  :make-task-pool
326  :task :job :task-pool
327  :stage :task-pool-p
328  :job-tasks :make-job
329  :job-p :task-object
330  :make-task :task-p :task
331  :task-pool-oracle :task-pool-jobs
332  :task-pool-stages
333  :task-pool-workers :task-pool-results
334  :with-task-pool))
335 
336 (defpkg :std/readtable
337  (:use :cl)
338  (:import-from :std/named-readtables :defreadtable)
339  (:import-from :std/fu :curry :rcurry :compose)
340  (:import-from :std/sym :symb)
341  (:import-from :std/list :defmacro!) ;; kludge
342  (:export
343  ;; readtable
344  :|#"-reader|
345  :|#`-reader|
346  :|#f-reader|
347  :|#$-reader|
348  :segment-reader
349  :match-mode-ppcre-lambda-form
350  :subst-mode-ppcre-lambda-form
351  :|#~-reader|
352  :_))
353 
354 (defpkg :std/bit
355  (:use :cl)
356  (:import-from :std/type :octet :octet-vector)
357  (:export
358  :make-bits
359  :sign-bit
360  :different-signs-p
361  :mortify-bits
362  :int-list-bits
363  :aref-bit
364  :make-bit-vector
365  :logbit
366  :bitfield
367  :bitfield-slot-name
368  :bitfield-slot-start
369  :bitfield-slot-end
370  :bitfield-slot-size
371  :bitfield-slot-reader
372  :bitfield-slot-initform
373  :bitfield-slot-pack
374  :bitfield-slot-unpack
375  :parse-atomic-bitfield-slot-specifier
376  :parse-compound-bitfield-slot-specifier
377  :bitfield-slot
378  :bitfield-boolean-slot
379  :bitfield-integer-slot
380  :bitfield-member-slot
381  :define-bitfield
382  :hex-string-to-octet-vector
383  :octet-vector-to-hex-string
384  :octets-to-integer
385  :integer-to-octets
386  :octets-to-integer-le
387  :integer-to-octets-le
388  :read-little-endian
389  :write-little-endian
390  :hexchar-to-int))
391 
392 (defpkg :std/fmt
393  (:use :cl)
394  (:import-from :std/list :group :ensure-cons)
395  (:shadowing-import-from :uiop :println)
396  (:export :printer-status :fmt-row :format-sxhash :iprintln :fmt-tree :println))
397 
398 (defpkg :std/path
399  (:use :cl)
400  (:export
401  :wild-pathname
402  :non-wild-pathname
403  :absolute-pathname
404  :relative-pathname
405  :directory-pathname
406  :symlink-pathname
407  :symlinkp
408  :absolute-directory-pathname
409  :+wildfile+ :+pathsep+ :set-pathname-suffix :*tmp-suffix*
410  :tmpize-pathname))
411 
412 (defpkg :std/os
413  (:use :cl)
414  (:import-from :std/macs :with-gensyms)
415  (:export
416  :list-all-users
417  :list-all-groups
418  :with-umask
419  :with-fd))
420 
421 (defpkg :std/file
422  (:use :cl)
423  (:import-from :std/macs :define-constant :once-only :eval-always)
424  (:import-from :std/stream :copy-stream)
425  (:import-from :std/type :octet :octet-vector :array-index :array-length :+default-element-type+)
426  (:export
427  :tmpfile
428  :file-pathname
429  :with-open-files
430  :write-stream-into-file
431  :write-file-into-stream
432  :file=
433  :file-size
434  :file-size-in-octets
435  :octet-vector=
436  :file-date
437  :file-timestamp
438  :directory-path-p
439  :*hidden-paths*
440  :hidden-path-p
441  :directory-path
442  :find-files
443  :count-file-lines))
444 
445 (defpkg :std/string
446  (:use :cl)
447  (:export
448  :*omit-nulls*
449  :*whitespaces*
450  :string-designator
451  :ssplit
452  :trim
453  :collapse-whitespaces
454  :make-template-parser
455  :string-case))
456 
457 (defpkg :std/seq
458  (:use :cl)
459  (:import-from :sb-int :collect)
460  (:import-from :std/array :signed-array-length)
461  (:export :take :starts-with-subseq :ends-with-subseq
462  :split-sequence :split-sequence-if :split-sequence-if-not))
463 
464 (defpkg :std/sys
465  (:use :cl)
466  (:shadowing-import-from :sb-kernel :get-lisp-obj-address :with-pinned-objects :unbound-marker-p :generation-of)
467  (:shadowing-import-from :sb-vm :list-allocated-objects)
468  (:import-from :sb-impl :*logical-hosts*)
469  (:export
470  :*default-arena-size*
471  :current-lisp-implementation
472  :current-machine
473  :list-package-symbols
474  :package-symbols
475  :package-symbol-names
476  :append-logical-hosts
477  :save-lisp-tree-shake-and-die
478  :save-lisp-and-live
479  :forget-shared-object
480  :forget-shared-objects
481  :compile-lisp))
482 
483 (defpkg :std
484  (:use :cl :sb-unicode :cl-ppcre :sb-mop :sb-c :sb-thread :sb-alien :sb-gray :sb-concurrency)
485  (:use-reexport :std/named-readtables :std/defpkg :std/condition
486  :std/sym :std/list :std/type :std/num
487  :std/stream :std/fu :std/array :std/hash-table
488  :std/alien :std/mop :std/thread :std/task
489  :std/macs :std/bit :std/fmt :std/path
490  :std/os :std/file :std/string :std/seq
491  :std/sys :std/readtable))
492 
493 (defpkg :std-user
494  (:use :cl :cl-user :sb-ext :std
495  :std-int :sb-alien :sb-thread :sb-bsd-sockets
496  :sb-gray :sb-mop :sb-debug))
497 
498 (pkg:define-lisp-package :std)