Use macro to create classes

This commit is contained in:
Marcus Kammer 2024-10-04 16:35:05 +02:00
parent 62e7885f1d
commit f9736946f7
Signed by: marcuskammer
GPG key ID: C374817BE285268F

View file

@ -140,7 +140,20 @@
,@(loop for name in property-names ,@(loop for name in property-names
collect `(define-property-method ,class-name ,name)))) collect `(define-property-method ,class-name ,name))))
(defclass object (property-container) ()) (defmacro define-extend-class (base-class name)
`(defclass ,name (,base-class) ()))
(defmacro define-extend-classes (base-class &rest class-names)
`(progn
,@ (loop for name in class-names
collect `(define-extend-class ,base-class ,name))))
;;; Core Types
(define-extend-classes property-container
object
link)
(define-property-methods object (define-property-methods object
attachment attachment
attributed-to attributed-to
@ -171,7 +184,6 @@
media-type media-type
duration) duration)
(defclass link (property-container) ())
(define-property-methods link (define-property-methods link
id id
href href
@ -183,7 +195,10 @@
width width
preview) preview)
(defclass activity (object) ()) (define-extend-classes object
activity
collection)
(define-property-methods activity (define-property-methods activity
actor actor
object object
@ -192,7 +207,6 @@
origin origin
instrument) instrument)
(defclass collection (object) ())
(define-property-methods collection (define-property-methods collection
total-items total-items
current current
@ -200,11 +214,13 @@
last-as2 last-as2
items) items)
(defclass ordered-collection (collection) ()) (define-extend-classes collection
ordered-collection
collection-page)
(define-property-methods ordered-collection (define-property-methods ordered-collection
ordered-items) ordered-items)
(defclass collection-page (collection) ())
(define-property-methods collection-page (define-property-methods collection-page
part-of part-of
next next