-
Notifications
You must be signed in to change notification settings - Fork 1
/
px2.psm
46 lines (35 loc) · 1.37 KB
/
px2.psm
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
;; -*- mode: lisp -*-
;; PX2 shortcut macros to reduce noise and save some parens on
;; named get and set (both quiet and loud versions)
(defmacro ? (self member) ;; normal get
`((@ ,self ,member)))
(defmacro ?? (self member) ;; loud get
`((@ ,self get) ',member true))
(defmacro ! (self member value) ;; set
`((@ ,self ,member) ,value))
(defmacro !? (self member value) ;; quiet set
`((@ ,self set) ',member ,value true))
;; Combined @ and ?/?? macros for some more brevity
(defmacro ?@ (self member &rest at-values)
`(@ (? ,self ,member) ,@at-values))
(defmacro ??@ (self member &rest at-values)
`(@ (?? ,self ,member) ,@at-values))
;; PX2 convenience macros for defining Models, Views, Controllers and
;; Containers
(defmacro defmodel (name &rest options)
`(defvar ,name (*Model (create
type ',name
,@options))))
(defmacro defview (name &rest options)
`(defvar ,name (*View (create
type ',name
,@options))))
(defmacro defcontroller (name &rest options)
`(defvar ,name (*Model (create
type ',name
,@options))))
(defmacro defcontainer (name contains &rest options)
`(defvar ,name (*Model (create
type ',name
contains ',contains
,@options))))