-
Notifications
You must be signed in to change notification settings - Fork 5
/
shampoo-requests.el
155 lines (131 loc) · 4.49 KB
/
shampoo-requests.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
;;; shampoo-requests.el --- Shampoo request builders
;;
;; Copyright (C) 2010 - 2012 Dmitry Matveev <[email protected]>
;;
;; This software is released under terms of the MIT license,
;; please refer to the LICENSE file for details.
(eval-when-compile (require 'cl))
(require 'shampoo-dict)
(require 'shampoo-xml)
(require 'shampoo-utils)
(defun* shampoo-make-login-rq (&key id user encd-pass)
(shampoo-xml
'request
`(:id ,id :type "Login") nil
(list (shampoo-xml
'creds `(:login ,user :magic ,encd-pass)))))
(defun* shampoo-make-namespaces-rq (&key id)
(shampoo-xml
'request
`(:id ,id :type "Namespaces")))
(defun* shampoo-make-classes-rq (&key id ns)
(shampoo-xml
'request
`(:id ,id :type "Classes" :namespace ,ns)))
(defun* shampoo-make-cats-rq (&key id ns class side)
(shampoo-xml
'request
`(:id ,id :type "Categories"
:namespace ,ns :class ,class :side ,side)))
(defun* shampoo-make-class-rq (&key id ns class side)
(shampoo-xml
'request
`(:id ,id :type "Class"
:namespace ,ns :class ,class :side ,side)))
(defun* shampoo-make-methods-rq (&key id ns class category side)
(shampoo-xml
'request
`(:id ,id :type "Methods"
:namespace ,ns :class ,class :category ,category :side ,side)))
(defun* shampoo-make-method-rq (&key id ns class method side)
(shampoo-xml
'request
`(:id ,id :type "MethodSource"
:namespace ,ns :class ,class :side ,side
:method ,(shampoo-escape-xml method))))
(defun* shampoo-make-compile-instance-rq (&key id ss side ns cat desc)
(let* ((inst (shampoo-dict-get :instvars desc))
(clss (shampoo-dict-get :classvars desc))
(pool (shampoo-dict-get :poolvars desc))
(fields
(loop for data in (list inst clss pool)
for type in '(instvar classvar poolvar)
collect (shampoo-wrap-rq-items type data))))
(shampoo-xml
'request
`(:id ,id :type "CompileClass" :superspace ,ss
:side ,side :namespace ,ns
:super ,(shampoo-dict-get :super desc)
:class ,(shampoo-dict-get :name desc)
:category ,cat)
nil
(apply (shampoo-curry 'concatenate 'list) fields))))
(defun* shampoo-make-compile-class-rq (&key id ss side ns desc)
(let* ((inst (shampoo-dict-get :instvars desc)))
(shampoo-xml
'request
`(:id ,id :type "CompileClass" :superspace ,ss
:side ,side :namespace ,ns
:class ,(shampoo-dict-get :name desc))
nil
(shampoo-wrap-rq-items 'instvar inst))))
(defun* shampoo-make-compile-method-rq (&key id ns class side category code)
(shampoo-xml
'request
`(:id ,id :type "CompileMethod"
:namespace ,ns :class ,class :side ,side :category ,category)
code))
(defun* shampoo-make-eval-rq (&key id type code)
(shampoo-xml
'request
`(:id ,id :type ,type)
code))
(defun shampoo-make-rq-item (type value)
(shampoo-xml type nil value))
(defun shampoo-wrap-rq-items (type values)
(mapcar (shampoo-curry 'shampoo-make-rq-item type) values))
(defun* shampoo-make-remove-class-rq (&key id ns class)
(shampoo-xml
'request
`(:id ,id :type "RemoveClass"
:namespace ,ns :class ,class)))
(defun* shampoo-make-remove-method-rq (&key id ns class side method)
(shampoo-xml
'request
`(:id ,id :type "RemoveMethod"
:namespace ,ns :class ,class :side ,side :method ,method)))
(defun* shampoo-make-remove-category-rq
(&key id ns class side category)
(shampoo-xml
'request
`(:id ,id :type "RemoveCategory"
:namespace ,ns :class ,class :side ,side :category ,category)))
(defun* shampoo-make-change-category-rq
(&key id ns class side category method)
(shampoo-xml
'request
`(:id ,id :type "ChangeCategory"
:namespace ,ns :class ,class :side ,side
:category ,category :method ,method)))
(defun* shampoo-make-rename-category-rq
(&key id ns class side from to)
(shampoo-xml
'request
`(:id ,id :type "RenameCategory"
:namespace ,ns :class ,class :side ,side
:from ,from :to ,to)))
(defun* shampoo-make-fileout-namespace-rq (&key id ns split)
(shampoo-xml
'request
`(:id ,id :type "FileOut" :namespace ,ns :splitby ,split)))
(defun* shampoo-make-fileout-class-rq (&key id ns class)
(shampoo-xml
'request
`(:id ,id :type "FileOut" :namespace ,ns :class ,class)))
(defun* shampoo-make-fileout-category-rq (&key id ns cat split)
(shampoo-xml
'request
`(:id ,id :type "FileOut" :namespace ,ns
:category ,cat :splitby ,split)))
(provide 'shampoo-requests)
;;; shampoo-requests.el ends here.