Changeset 40078 in project


Ignore:
Timestamp:
05/06/21 12:09:51 (5 weeks ago)
Author:
felix winkelmann
Message:

mdh: added flush-globals, restricted possible val/index types

Location:
release/5/mdh/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/5/mdh/trunk/libmpscpp.h

    r40054 r40078  
    368368        friend class mstring;
    369369
    370             void Flush();
     370            static void Flush();
    371371            void Transpose(global);
    372372            void Multiply(global, global);
  • release/5/mdh/trunk/mdh.scm

    r40074 r40078  
    44(module mdh (^ ^next ^previous ^data ^count ^kill
    55             global global-name global-free global-kill
    6              global-count global-merge
     6             global-count global-merge flush-globals
    77             global-ref global-set! global-next global-previous global-data
    88             close-globals)
     
    3535
    3636(define closed #f)
     37
     38(define (str x)
     39  (cond ((string? x) x)
     40        ((symbol? x) (symbol->string x))
     41        ((number? x) (number->string x))
     42        (else (error "expected string, symbol or numeric value" x))))
    3743
    3844(define (make-ref g args)
     
    95101
    96102(define (->val x)
    97   (let ((y (->string x)))
     103  (let ((y (str x)))
    98104    (if (>= (string-length y) STR_MAX)
    99105        (error "value or index exceeds maximum allowed length" x)
     
    101107
    102108(define (global name)
    103   (make-global name (%make-global (->string name))))
     109  (make-global name (%make-global (->val name))))
    104110
    105111(define %make-global
     
    195201        (make-ref g ix)
    196202        (let* ((p (global-ptr g))
    197               (val (->string (%get p))))
     203               (val (%get p)))
    198204          (%free p)
    199205          val)))
     
    251257      (data-name d))))
    252258
     259(define (flush-globals)
     260  (foreign-lambda* void () "global::Flush();"))
     261
    253262(implicit-exit-handler close-globals)
    254263
  • release/5/mdh/trunk/tests/a.scm

    r40062 r40078  
    6161(test "order ex 9" "" (global-next go 5))      ; test("5").Order(1)      yields "" (empty string)
    6262
     63(flush-globals)
     64
    6365(test-end)
    6466(test-exit)
Note: See TracChangeset for help on using the changeset viewer.