Changeset 38863 in project


Ignore:
Timestamp:
08/21/20 16:46:26 (5 weeks ago)
Author:
Kon Lovett
Message:

dup slot storage

Location:
release/5/coops-utils/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/5/coops-utils/trunk/coops-extras.scm

    r38400 r38863  
    1313(import (chicken base))
    1414(import (chicken type))
    15 (import (only (srfi 1) cons* remove))
     15(import (only (srfi 1) list-copy cons* remove))
    1616(import (only coops-introspection check-instance))
    1717(import coops)
     
    6262(: slot-values (coops-instance (list-of symbol) #!optional list -> list))
    6363;
    64 (define (slot-values x slots #!optional (base '()))
     64(define (slot-values obj slots #!optional (base '()))
    6565  (foldl
    6666    (lambda (ls slot)
    67       (if (slot-initialized? x slot)  ;per Jun 19, '17 email from Sandra Snan
    68         (plist-cons slot (slot-value x slot) ls)
     67      (if (slot-initialized? obj slot)  ;per Jun 19, '17 email from Sandra Snan
     68        (plist-cons slot (slot-value obj slot) ls)
    6969        ls ) )
    7070    base
     
    7474;
    7575(define (shadowed-initforms obj initforms #!optional (class (class-of obj)))
     76  ;shallow copy of the slots - share values but not storage
     77  ;FIXME 1-pass, dup storage & replace new values
    7678  (slot-values
    7779    obj
    78     (remove (cut initslot? <> initforms) (*class-slots class))
     80    (remove (cut initslot? <> initforms) (list-copy (*class-slots class)))
    7981    initforms) )
    8082
  • release/5/coops-utils/trunk/coops-utils.egg

    r38766 r38863  
    33
    44((synopsis "coops utilities")
    5  (version "2.1.3")
     5 (version "2.1.4")
    66 (category oop)
    77 (license "BSD")
    88 (author "[[kon lovett]]")
    99 (dependencies
    10   (srfi-1 "0.1")
    11   (srfi-13 "0.1")
    12   (coops "1.0")
    13   (check-errors "3.1.0"))
     10  srfi-1
     11  srfi-13
     12  check-errors
     13  (coops "1.2"))
    1414 (test-dependencies test)
    1515 (components
  • release/5/coops-utils/trunk/tests/coops-utils-test.scm

    r38761 r38863  
    9090;make-copy
    9191(let ((inst (make-copy s1xy-inst 'y 23)))
    92   (test "make-copy" 23 (slot@ inst y)) )
     92  ;check copy
     93  (test-assert "make-copy" (instance? inst))
     94  (test-assert "make-copy" (instance-of? inst <s1xy>))
     95  (test "make-copy" 23 (slot@ inst y))
     96  (test "make-copy" 1 (slot@ inst x))
     97  ;copy own slots?
     98  (slot@ inst x = 32)
     99  (test "make-copy isolation" 32 (slot@ inst x))
     100  (test "make-copy isolation" 1 (slot@ s1xy-inst x)) )
    93101
    94102(let ()
Note: See TracChangeset for help on using the changeset viewer.