changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / lisp/std/pkg.lisp

changeset 664: 4d8451fe5423
parent: 804b5ee20a46
child: ebe3315b7add
author: Richard Westhaver <ellis@rwest.io>
date: Sun, 22 Sep 2024 01:02:49 -0400
permissions: -rw-r--r--
description: moved web to lib/web, added dat/css
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  :pop-worker :pop-task-result
295  :*task-pool*
296  :*tasks*
297  :*oracles*
298  :*workers*
299  :*jobs*
300  :*stages*
301  :define-task-kernel
302  :*task-kernel*
303  :default-task-kernel
304  :make-worker
305  :make-workers
306  :worker-count
307  :init-task-pool
308  :make-task-pool
309  :start-task-pool :pause-task-pool
310  :shutdown-task-pool
311  :push-stage :designate-oracle
312  :make-task-pool
313  :task :job :task-pool
314  :stage :task-pool-p
315  :job-tasks :make-job
316  :job-p :task-object
317  :make-task :task-p :task
318  :task-pool-oracle :task-pool-jobs
319  :task-pool-stages
320  :task-pool-workers :task-pool-results
321  :with-task-pool))
322 
323 (defpkg :std/readtable
324  (:use :cl)
325  (:import-from :std/named-readtables :defreadtable)
326  (:import-from :std/fu :curry :rcurry :compose)
327  (:import-from :std/sym :symb)
328  (:import-from :std/list :defmacro!) ;; kludge
329  (:export
330  ;; readtable
331  :|#"-reader|
332  :|#`-reader|
333  :|#f-reader|
334  :|#$-reader|
335  :segment-reader
336  :match-mode-ppcre-lambda-form
337  :subst-mode-ppcre-lambda-form
338  :|#~-reader|
339  :_))
340 
341 (defpkg :std/bit
342  (:use :cl)
343  (:import-from :std/type :octet :octet-vector)
344  (:export
345  :make-bits
346  :sign-bit
347  :different-signs-p
348  :mortify-bits
349  :int-list-bits
350  :aref-bit
351  :make-bit-vector
352  :logbit
353  :bitfield
354  :bitfield-slot-name
355  :bitfield-slot-start
356  :bitfield-slot-end
357  :bitfield-slot-size
358  :bitfield-slot-reader
359  :bitfield-slot-initform
360  :bitfield-slot-pack
361  :bitfield-slot-unpack
362  :parse-atomic-bitfield-slot-specifier
363  :parse-compound-bitfield-slot-specifier
364  :bitfield-slot
365  :bitfield-boolean-slot
366  :bitfield-integer-slot
367  :bitfield-member-slot
368  :define-bitfield
369  :hex-string-to-octet-vector
370  :octet-vector-to-hex-string
371  :octets-to-integer
372  :integer-to-octets
373  :octets-to-integer-le
374  :integer-to-octets-le
375  :read-little-endian
376  :write-little-endian
377  :hexchar-to-int))
378 
379 (defpkg :std/fmt
380  (:use :cl)
381  (:import-from :std/list :group :ensure-cons)
382  (:shadowing-import-from :uiop :println)
383  (:export :printer-status :fmt-row :format-sxhash :iprintln :fmt-tree :println))
384 
385 (defpkg :std/path
386  (:use :cl)
387  (:export
388  :wild-pathname
389  :non-wild-pathname
390  :absolute-pathname
391  :relative-pathname
392  :directory-pathname
393  :symlink-pathname
394  :symlinkp
395  :absolute-directory-pathname
396  :+wildfile+ :+pathsep+ :set-pathname-suffix :*tmp-suffix*
397  :tmpize-pathname))
398 
399 (defpkg :std/os
400  (:use :cl)
401  (:import-from :std/macs :with-gensyms)
402  (:export
403  :list-all-users
404  :list-all-groups
405  :with-umask))
406 
407 (defpkg :std/file
408  (:use :cl)
409  (:import-from :std/macs :define-constant :once-only :eval-always)
410  (:import-from :std/stream :copy-stream)
411  (:import-from :std/type :octet :octet-vector :array-index :array-length :+default-element-type+)
412  (:export
413  :tmpfile
414  :file-pathname
415  :with-open-files
416  :write-stream-into-file
417  :write-file-into-stream
418  :file=
419  :file-size
420  :file-size-in-octets
421  :octet-vector=
422  :file-date
423  :file-timestamp
424  :directory-path-p
425  :*hidden-paths*
426  :hidden-path-p
427  :directory-path
428  :find-files
429  :count-file-lines))
430 
431 (defpkg :std/string
432  (:use :cl)
433  (:export
434  :*omit-nulls*
435  :*whitespaces*
436  :string-designator
437  :ssplit
438  :trim
439  :collapse-whitespaces
440  :make-template-parser
441  :string-case))
442 
443 (defpkg :std/seq
444  (:use :cl)
445  (:import-from :sb-int :collect)
446  (:import-from :std/array :signed-array-length)
447  (:export :take :starts-with-subseq :ends-with-subseq
448  :split-sequence :split-sequence-if :split-sequence-if-not))
449 
450 (defpkg :std/sys
451  (:use :cl)
452  (:shadowing-import-from :sb-kernel :get-lisp-obj-address :with-pinned-objects :unbound-marker-p :generation-of)
453  (:shadowing-import-from :sb-vm :list-allocated-objects)
454  (:import-from :sb-impl :*logical-hosts*)
455  (:export
456  :current-lisp-implementation
457  :current-machine
458  :list-package-symbols
459  :package-symbols
460  :package-symbol-names
461  :append-logical-hosts
462  :save-lisp-tree-shake-and-die
463  :save-lisp-and-live
464  :forget-shared-object
465  :forget-shared-objects
466  :compile-lisp))
467 
468 (defpkg :std
469  (:use :cl :sb-unicode :cl-ppcre :sb-mop :sb-c :sb-thread :sb-alien :sb-gray :sb-concurrency)
470  (:use-reexport :std/named-readtables :std/defpkg :std/condition
471  :std/sym :std/list :std/type :std/num
472  :std/stream :std/fu :std/array :std/hash-table
473  :std/alien :std/mop :std/thread :std/task
474  :std/macs :std/bit :std/fmt :std/path
475  :std/os :std/file :std/string :std/seq
476  :std/sys :std/readtable))
477 
478 (defpkg :std-user
479  (:use :cl :cl-user :sb-ext :std
480  :std-int :sb-alien :sb-thread :sb-bsd-sockets
481  :sb-gray :sb-mop :sb-debug))
482 
483 (pkg:define-lisp-package :std)