File: raw-vector.thb

package info (click to toggle)
theme-d 7.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,036 kB
  • sloc: lisp: 9,625; sh: 5,321; makefile: 715; ansic: 477
file content (53 lines) | stat: -rw-r--r-- 1,999 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
;; -*-theme-d-*-

;; Copyright (C) 2025 Tommi Höynälänmaa
;; Distributed under GNU Lesser General Public License version 3,
;; see file doc/LGPL-3.

(define-body (standard-library raw-vector)

  (add-method raw-vector-ref
    (prim-proc vector-ref (<raw-vector> <integer>) <object> pure))

  (add-method raw-vector-set!
    (prim-proc vector-set! (<raw-vector> <integer> <object>) <none> nonpure))

  (add-method raw-vector-length
    (unchecked-prim-proc vector-length (<raw-vector>) <integer> pure))

  (add-method raw-vector
    (prim-proc vector ((rest <object>)) <raw-vector> pure))

  (add-method make-raw-vector
    (prim-proc make-vector (<integer> <object>) <raw-vector> pure))
    
  (add-method raw-vector->list
    (prim-proc vector->list (<raw-vector>) <list> pure))

  (add-param-method-alt _vector-raw-contents (%type)
    (prim-proc _vector-raw-contents
               ((:vector %type)) <raw-vector> pure))

  ;; We may use target procedure _vector-raw-contents for mutable vectors,
  ;; too.
  (add-param-method-alt _mutable-vector-raw-contents (%type)
    (prim-proc _vector-raw-contents
               ((:mutable-vector %type)) <raw-vector> pure))

  ;; The result type is checked by the Scheme procedure.
  (define-param-proc-alt _vector-with-raw-contents0 (%type)
    (unchecked-prim-proc _vector-with-raw-contents0
                         (<object> <raw-vector>) (:vector %type) pure))

  (define-param-proc _vector-with-raw-contents (%type)
      (((rv <raw-vector>)) (:vector %type) pure)
    ((param-proc-instance _vector-with-raw-contents0 %type) %type rv))

  (define-param-proc-alt _mutable-vector-with-raw-contents0 (%type)
    (unchecked-prim-proc _mutable-vector-with-raw-contents0
                         (<object> <raw-vector>) (:mutable-vector %type) pure))

  (define-param-proc _mutable-vector-with-raw-contents (%type)
      (((rv <raw-vector>)) (:mutable-vector %type) pure)
    ((param-proc-instance _mutable-vector-with-raw-contents0 %type) %type rv)))