
;; Copyright (C) 2026 Tommi Höynälänmaa

;; Distributed under GNU LGPL.

(define-body (theme-d-intr base utils)


  (import (standard-library string-utilities)
          (standard-library list-utilities)
          (standard-library object-string-conversion))


  (define-simple-proc g-variant-get-string1
      (((gv <g-variant>)) <string> nonpure)
    (car (g-variant-get-string gv)))


  (define-simple-method get-integer-sequence
      (((i-start <integer>) (i-count <integer>))
       (:uniform-list <integer>)
       pure)
    (assert (>= i-count 0))
    (if (equal? i-count 0)
        '()
        (cons i-start (get-integer-sequence (+ i-start 1)
                                            (- i-count 1)))))
  
  (define-simple-method string->symbol-list
      (((str <string>)) (:uniform-list <symbol>) pure)
    (let ((i-len (string-length str)))
      (if (and
           (>= i-len 2)
           (equal? (string-ref str 0) #\()
           (equal? (string-ref str (- i-len 1)) #\)))
          (let* ((l1 (split-string
                      (substring str 1 (- i-len 1))
                      #\space))
                 (l2 (map1 string->symbol l1)))
            l2)
          (raise (make-rte-exception 'string->symbol-list:invalid-argument
                                     (list (cons 'str str)))))))

                                     
  ;; The result type checking is done in the lowlevel procedure.
  (add-method xml->sxml
    (unchecked-prim-proc theme-d-xml->sxml (<string>) <source-expr> nonpure)))
