-
Notifications
You must be signed in to change notification settings - Fork 2
/
idef-macros.lisp
58 lines (42 loc) · 1.59 KB
/
idef-macros.lisp
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
;;; idef-macros --- interface definition macros
(in-package :clorb)
;;;; A Global Repository
(defvar *idef-repository*
(make-instance 'repository))
(add-repository *internal-interface-repository* '*idef-repository*)
(defun lookup-name (name)
(lookup-name-in *idef-repository* name))
(defmethod gen-idef ((name string))
(gen-idef (lookup-name name)))
;;;; Macro for IDEF definitions
(defmacro idef-definitions (&body forms)
`(idef-read ',forms *idef-repository*))
(defmacro idef-code (&body forms)
(let ((repository (make-instance 'repository)))
(idef-read forms repository)
(let* ((target (make-instance 'all-target))
(code (target-code repository target)))
(make-progn*
(make-progn
(loop for package in (slot-value target 'packages)
unless (member package *stub-code-ignored-packages*)
collect (make-target-ensure-package package target)))
code))))
;;;; Creating a servant class
(defmacro define-servant (name scoped-name &key id)
"Creates an auto-servant class for an interface.
This class can be used almost as a skeleton class generated by an
IDL-compiler."
`(progn
(defclass ,NAME (auto-servant)
())
,@(if id
`((defmethod servant-interface-id ((servant ,name))
,id)))
(defmethod servant-interface ((servant ,name))
(or (ignore-errors (lookup-name ,scoped-name))
(call-next-method)))))
(defmacro require-idl (name &key file)
`(eval-when (:load-toplevel :execute)
(unless (lookup-name-in *idef-repository* ,name nil)
(load ,file))))