-
Notifications
You must be signed in to change notification settings - Fork 2
/
pjb-object.el
96 lines (85 loc) · 3.23 KB
/
pjb-object.el
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
;;;; -*- mode:emacs-lisp;coding:utf-8 -*-
;;;;******************************************************************************
;;;;FILE: pjb-object.el
;;;;LANGUAGE: emacs lisp
;;;;SYSTEM: emacs
;;;;USER-INTERFACE: emacs
;;;;DESCRIPTION
;;;;
;;;; This is a root class for my classes.
;;;; The main purpose is to implement here compatibility stuff.
;;;;
;;;;AUTHORS
;;;; <PJB> Pascal J. Bourguignon
;;;;MODIFICATIONS
;;;; 2002-09-08 <PJB> Creation.
;;;;BUGS
;;;;LEGAL
;;;; LGPL
;;;;
;;;; Copyright Pascal J. Bourguignon 2002 - 2011
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
;;;; License as published by the Free Software Foundation; either
;;;; version 2 of the License, or (at your option) any later version.
;;;;
;;;; This library is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;;;; Lesser General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU Lesser General Public
;;;; License along with this library; if not, write to the Free Software
;;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
;;;;
;;;;******************************************************************************
(require 'pjb-cl)
(require 'eieio)
(provide 'pjb-object)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(put 'make-instance 'lisp-indent-function 2)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; PjbObject
(defclass PjbObject nil
(;;attributes
(object-id
:initform nil
:initarg :object-id
:accessor object-id
:type (or null string)
:documentation
"The id of this object (eieio has it in its internals, but not CLOS).")
);;end attributes
(:documentation
"This is a root class for my classes.
The main purpose is to implement here compatibility stuff.")
);;PjbObject
(defmacro defmethod* (name &rest things)
"In emacs-24 eieio rejects defmethod with more than one specialization."
(let* ((qualifiers (loop while (and (atom (car things)) (not (null (car things))))
collect (pop things)))
(lambda-list (pop things))
(body things)
(mandatories (loop
while (and lambda-list
(not (member (car lambda-list) '(&optional &rest &body &key &allow-other-keys &aux))))
collect (pop lambda-list)))
(other-parameters lambda-list)
(first-parameter (pop mandatories))
(checks '()))
`(defmethod ,name ,@qualifiers
(,first-parameter
,@(mapcar (lambda (parameter)
(if (listp parameter)
(progn
(push parameter checks)
(first parameter))
parameter))
mandatories)
,@other-parameters)
,@(mapcar (lambda (check)
(cons 'check-type check))
checks)
,@body)))
;;;; THE END ;;;;