File: mop.impure-cload.lisp

package info (click to toggle)
sbcl 1%3A0.9.16.0-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 19,960 kB
  • ctags: 16,537
  • sloc: lisp: 231,164; ansic: 19,558; asm: 2,539; sh: 1,925; makefile: 308
file content (59 lines) | stat: -rw-r--r-- 1,889 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
54
55
56
57
58
59
;;;; miscellaneous side-effectful tests of the MOP

;;;; This software is part of the SBCL system. See the README file for
;;;; more information.
;;;;
;;;; While most of SBCL is derived from the CMU CL system, the test
;;;; files (like this one) were written from scratch after the fork
;;;; from CMU CL.
;;;;
;;;; This software is in the public domain and is provided with
;;;; absolutely no warranty. See the COPYING and CREDITS files for
;;;; more information.

;;;; Note that the MOP is not in an entirely supported state.
;;;; However, this seems a good a way as any of ensuring that we have
;;;; no regressions.

(defpackage "MOP-TEST"
  (:use "CL" "SB-MOP"))

(in-package "MOP-TEST")

;;; A distilled test case from cmucl-imp for Kevin Rosenberg's
;;; hyperobject.  Fix from Gerd Moellmann.
(defclass hyperobject-class (standard-class)
  ((user-name :initarg :user-name :type string :initform nil
              :accessor user-name
              :documentation "User name for class")))

(defclass hyperobject-dsd (standard-direct-slot-definition)
  ())

(defclass hyperobject-esd (standard-effective-slot-definition)
  ((vc :initform 42)))

(defmethod validate-superclass ((class hyperobject-class)
                                (superclass standard-class))
  t)

(defmethod compute-effective-slot-definition :around
    ((cl hyperobject-class) name dsds)
  (let ((ia (sb-pcl::compute-effective-slot-definition-initargs cl dsds)))
    (apply #'make-instance 'hyperobject-esd ia)))

(defmethod (setf slot-value-using-class) :around
    (new-value (cl hyperobject-class) obj (slot hyperobject-esd))
  (format t "~s ~s ~s~%" cl obj slot)
  (slot-value slot 'vc))

(defclass hyperobject ()
  ()
  (:metaclass hyperobject-class))

(defclass person (hyperobject)
  ((name :initarg :name :accessor person-name))
  (:metaclass hyperobject-class))


(eval '(make-instance 'person :name t))