blob: 96adc07984497bf55be7832398cb877c8f57d7fc (
plain)
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; Syntax: ANSI-Common-Lisp; Base: 10 -*-
(declaim (optimize (speed 0) (safety 3) (debug 3)))
(in-package #:music-dispensary)
;; ========================================================================== ;;
(defclass generic-form (rest-service)
((name :initarg :name
:initform nil
:accessor name)
(http-method :initarg :http-method
:initform "POST"
:accessor http-method)
(action :initarg :action
:initform nil
:accessor action)
(form-fields :initarg :form-fields
:initform nil
:accessor form-fields))
(:documentation ""))
(defclass form-field (base-service)
((name :initarg :name
:initform nil
:accessor name)
(label :initarg :label
:initform nil
:accessor label)
(field-type :initarg :field-type
:initform nil
:accessor field-type))
(:documentation ""))
(defmacro define-generic-form-constructor ((form-class name action) fields)
`(defmethod initialize-instance :after ((,form-class ,form-class) &key)
(setf (name ,form-class) ,name)
(setf (action ,form-class) ,action)
(setf (form-fields ,form-class)
(mapcar (lambda (form)
(make-instance 'form-field
:name (getf form :name)
:label (getf form :label)
:field-type (getf form :field-type)))
,fields))))
|