-
Notifications
You must be signed in to change notification settings - Fork 2
/
clorb-ifr-info.lisp
200 lines (164 loc) · 6.54 KB
/
clorb-ifr-info.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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
(in-package :clorb)
(defun symbol-ifr-parent-id (symbol)
(let ((parent (get symbol 'ifr-parent)))
(if parent (symbol-ifr-id parent) "")))
(defun ifr-version (symbol)
(get symbol 'ifr-version "1.0"))
(defun ifr-kind (symbol)
(case (get-properties (symbol-plist symbol) '(ifr-result ifr-type ifr-bases))
(ifr-result :dk_operation)
(ifr-type :dk_attribute)
(ifr-bases :dk_interface)
(otherwise
(let ((tc (get symbol 'typecode)))
(when tc
(case (typecode-kind tc)
(:tk_alias :dk_alias)
(:tk_except :dk_exception)
(:tk_struct :dk_struct)
(:tk_enum :dk_enum)
(:tk_value_box :dk_valuebox)
(:tk_value :dk_value)))))))
(defmethod generate-ifr-description ((tc except-typecode) symbol)
(corba:exceptiondescription
:name (op:name tc)
:id (op:id tc)
:version (ifr-version symbol)
:defined_in (symbol-ifr-parent-id symbol)
:type tc))
(defmethod generate-ifr-description ((tc objref-typecode) symbol)
(let (opdesc atdesc)
(labels ((operations-and-attributes (symbol)
(loop for sym in (get symbol 'ifr-contents)
for kind = (ifr-kind sym)
when (eq kind :dk_operation)
do (push (ifr-description sym) opdesc)
when (eq kind :dk_attribute)
do (push (ifr-description sym) atdesc))
(mapc #'operations-and-attributes (get symbol 'ifr-bases))))
(operations-and-attributes symbol)
(corba:interfacedef/fullinterfacedescription
:name (or (get symbol 'ifr-name) (op:name tc))
:id (symbol-ifr-id symbol)
:defined_in ""
:version (ifr-version symbol)
:operations opdesc
:attributes atdesc
:base_interfaces (mapcar #'symbol-ifr-id (get symbol 'ifr-bases))
:type (symbol-typecode symbol)))))
(defmethod generate-ifr-description ((tc null) symbol)
;; For Contained that hasn't got a TypeCode:
;; ModuleDef, OperationDef, AttributeDef
(multiple-value-bind (indicator value)
(get-properties (symbol-plist symbol) '(ifr-result ifr-type))
(case indicator
(ifr-result ; it's an operation
(CORBA:OperationDescription
:id (symbol-ifr-id symbol)
:name (get symbol 'ifr-name)
:version (ifr-version symbol)
:defined_in (symbol-ifr-parent-id symbol)
:result value
:mode (get symbol 'ifr-mode)
:parameters (loop for (param-name param-mode param-type) in (get symbol 'ifr-params)
collect (corba:parameterdescription
:name param-name
:type param-type
:mode param-mode))
:exceptions (mapcar #'ifr-description (get symbol 'ifr-exceptions))))
(ifr-type ; it's an attribute
(CORBA:AttributeDescription
:id (symbol-ifr-id symbol)
:name (get symbol 'ifr-name)
:version (ifr-version symbol)
:defined_in (symbol-ifr-parent-id symbol)
:mode (get symbol 'ifr-mode)
:type value))
((nil)
(error "Can't generate a description for ~S" symbol)))))
;;;; interface ExceptionDef : Contained, Container
;;; readonly attribute TypeCode type;
;;; attribute StructMemberSeq members;
;; EXPERIMENTAL - IFR-objects that are adapters for (get information
;; from) description structs.
(defclass desc-exceptiondef (CORBA:ExceptionDef)
((desc :initarg :description :accessor description)))
#| #<EXCEPTIONDESCRIPTION
:NAME "InvalidTypeForEncoding"
:ID "IDL:omg.org/IOP/Codec/InvalidTypeForEncoding:1.0"
:DEFINED_IN "IDL:omg.org/IOP/Codec:1.0"
:VERSION "1.0"
:TYPE #<EXCEPT-TYPECODE "InvalidTypeForEncoding" #x651B106>>
|#
;;; readonly attribute TypeCode type;
(define-method op:type ((obj desc-exceptiondef)) (op:type (description obj)))
;;; attribute StructMemberSeq members;
(define-method op:members ((obj desc-exceptiondef))
(let* ((tc (op:type (description obj)))
(n (op:member_count tc)))
(loop for i from 0 below n
collect (let ((name (op:member_name tc i))
(mtc (op:member_type tc i)))
(CORBA:StructMember
:name name
:type mtc
:type_def nil)))))
;;; CONTAINED
;;; // read/write interface
;;; attribute RepositoryId id;
(define-method op:id ((obj desc-exceptiondef)) (op:id (description obj)))
;;; attribute Identifier name;
(define-method op:name ((obj desc-exceptiondef)) (op:name (description obj)))
;;; attribute VersionSpec version;
(define-method op:version ((obj desc-exceptiondef)) (op:version (description obj)))
;;; // read interface
;;; readonly attribute Container defined_in;
;;; readonly attribute ScopedName absolute_name;
;;; readonly attribute Repository containing_repository;
;;; struct Description {
;;; DefinitionKind kind;
;;; any value;
;;; };
;;; Description describe ();
(define-method op:describe
((obj desc-exceptiondef))
(corba:contained/description
:kind :dk_exception
:value (description obj)))
;;; CONTAINER
;;; Contained lookup(in ScopedName search_name);
;;; ContainedSeq contents(in DefinitionKind limit_type,
;;; in boolean exclude_inherited);
;;; ContainedSeq lookup_name(in Identifier search_name,
;;; in long levels_to_search,
;;; in DefinitionKind limit_type,
;;; in boolean exclude_inherited );
;;; struct Description {
;;; Contained contained_object;
;;; DefinitionKind kind;
;;; any value;
;;; };
;;; typedef sequence<Description> DescriptionSeq;
;;; DescriptionSeq describe_contents(in DefinitionKind limit_type,
;;; in boolean exclude_inherited,
;;; in long max_returned_objs);
;;; interface IRObject {
;;; // read interface
;;; readonly attribute DefinitionKind def_kind;
(define-method op:def_kind ((obj desc-exceptiondef)) :dk_exception)
;;; // write interface
;;; void destroy ();
(define-method op:destroy ((obj desc-exceptiondef)) nil)
#|
(CORBA:IDL "clorb:idl;interface_repository.idl"
:output "clorb:src;y-ifr-base.lisp"
:package-decl nil
:eval nil
:exclude '("::CORBA::TypeCode")
:skeleton nil)
(CORBA:IDL "clorb:idl;CosNaming.idl"
:output "clorb:src;y-cosnaming.lisp"
:package-decl t
:eval nil
:skeleton nil)
|#