Use macro to create classes
This commit is contained in:
parent
62e7885f1d
commit
f9736946f7
1 changed files with 22 additions and 6 deletions
28
src/as2.lisp
28
src/as2.lisp
|
@ -140,7 +140,20 @@
|
|||
,@(loop for name in property-names
|
||||
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
|
||||
attachment
|
||||
attributed-to
|
||||
|
@ -171,7 +184,6 @@
|
|||
media-type
|
||||
duration)
|
||||
|
||||
(defclass link (property-container) ())
|
||||
(define-property-methods link
|
||||
id
|
||||
href
|
||||
|
@ -183,7 +195,10 @@
|
|||
width
|
||||
preview)
|
||||
|
||||
(defclass activity (object) ())
|
||||
(define-extend-classes object
|
||||
activity
|
||||
collection)
|
||||
|
||||
(define-property-methods activity
|
||||
actor
|
||||
object
|
||||
|
@ -192,7 +207,6 @@
|
|||
origin
|
||||
instrument)
|
||||
|
||||
(defclass collection (object) ())
|
||||
(define-property-methods collection
|
||||
total-items
|
||||
current
|
||||
|
@ -200,11 +214,13 @@
|
|||
last-as2
|
||||
items)
|
||||
|
||||
(defclass ordered-collection (collection) ())
|
||||
(define-extend-classes collection
|
||||
ordered-collection
|
||||
collection-page)
|
||||
|
||||
(define-property-methods ordered-collection
|
||||
ordered-items)
|
||||
|
||||
(defclass collection-page (collection) ())
|
||||
(define-property-methods collection-page
|
||||
part-of
|
||||
next
|
||||
|
|
Loading…
Add table
Reference in a new issue