-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathelsa-structure-slot.el
73 lines (59 loc) · 2.29 KB
/
elsa-structure-slot.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
;;; elsa-structure-slot.el --- Elsa structure slot -*- lexical-binding: t -*-
;; Copyright (C) 2023 Matúš Goljer
;; Author: Matúš Goljer <[email protected]>
;; Maintainer: Matúš Goljer <[email protected]>
;; Version: 0.0.1
;; Created: 10th March 2023
;; Package-requires: ((dash "2.17.0"))
;; Keywords:
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version 3
;; of the License, or (at your option) any later version.
;; This program 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 General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(require 'eieio)
(eval-and-compile (setq eieio-backward-compatibility nil))
(require 'elsa-methods)
(defclass elsa-structure-slot nil
((name
:type symbol
:initarg :name
:accessor elsa-get-name
:documentation "Slot name.")
(initarg
:type (or symbol null)
:initarg :initarg
:initform nil
:documentation "Symbol or keyword used to initialize the slot.")
(type
:type elsa-type
:initarg :type
:accessor elsa-get-type
:documentation "Slot Elsa type."))
:documentation "Data about a slot in interface-like structure.
An interface-like structure is anything that has defined set of keys
and associated values. In elisp, these can be the ad-hoc data
structures such as plists and alists and more structured cases like
`cl-defstruct' and `defclass'.")
(cl-defmethod initialize-instance ((this elsa-structure-slot) &optional slots)
(cl-call-next-method)
(let ((initarg (plist-get slots :initarg))
(name (plist-get slots :name)))
(unless initarg
(oset this initarg name))))
(cl-defmethod cl-print-object ((this elsa-structure-slot) stream)
(princ
(format "#<elsa-structure-slot %s %s %s>"
(oref this name)
(oref this initarg)
(elsa-tostring (oref this type)))
stream))
(provide 'elsa-structure-slot)
;;; elsa-structure-slot.el ends here