0
|
1 |
"{ Package: 'stx:goodies/ring' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Smalltalk }"
|
|
4 |
|
|
5 |
Object subclass:#RGDefinition
|
|
6 |
instanceVariableNames:'annotations name'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'Ring-Core-Kernel'
|
|
10 |
!
|
|
11 |
|
|
12 |
RGDefinition comment:'I am the root class of the Ring meta-model.
A Ring definition has a name, can be annotated and knows its environment'
|
|
13 |
!
|
|
14 |
|
|
15 |
!RGDefinition class methodsFor:'instance creation'!
|
|
16 |
|
|
17 |
new
|
|
18 |
"return an initialized instance"
|
|
19 |
|
|
20 |
^ self basicNew initialize.
|
|
21 |
! !
|
|
22 |
|
|
23 |
!RGDefinition class methodsFor:'annotations'!
|
|
24 |
|
|
25 |
authorKey
|
|
26 |
|
|
27 |
^#author
|
|
28 |
!
|
|
29 |
|
|
30 |
fullNameKey
|
|
31 |
|
|
32 |
^#fullName
|
|
33 |
!
|
|
34 |
|
|
35 |
timeStampKey
|
|
36 |
|
|
37 |
^#timestamp
|
|
38 |
! !
|
|
39 |
|
|
40 |
!RGDefinition class methodsFor:'class initialization'!
|
|
41 |
|
|
42 |
named: aName
|
|
43 |
|
|
44 |
^self new
|
|
45 |
name: aName asSymbol;
|
|
46 |
yourself
|
|
47 |
! !
|
|
48 |
|
|
49 |
!RGDefinition methodsFor:'accessing'!
|
|
50 |
|
|
51 |
environment
|
|
52 |
"If the receiver has not namespace assigned the default is used"
|
|
53 |
"self class environment = Smalltalk globals"
|
|
54 |
|
|
55 |
^ self annotationNamed: #environment ifAbsent: [ self class environment ]
|
|
56 |
!
|
|
57 |
|
|
58 |
environment: namespace
|
|
59 |
|
|
60 |
namespace = self class environment
|
|
61 |
ifFalse:[ self annotationNamed: #environment put: namespace ]
|
|
62 |
!
|
|
63 |
|
|
64 |
fullName
|
|
65 |
|
|
66 |
^self name
|
|
67 |
!
|
|
68 |
|
|
69 |
name
|
|
70 |
|
|
71 |
^name
|
|
72 |
!
|
|
73 |
|
|
74 |
name: anObject
|
|
75 |
"a symbol or a string should be expected"
|
|
76 |
|
|
77 |
name:= anObject
|
|
78 |
!
|
|
79 |
|
|
80 |
rootEnvironment
|
|
81 |
"Retrieves the runtime environment of an RGObject"
|
|
82 |
"If the receiver is defined in an RGContainer the runtime environment is the one associated to its container"
|
|
83 |
| parent |
|
|
84 |
|
|
85 |
parent:= self environment.
|
|
86 |
[ parent isRingObject ]
|
|
87 |
whileTrue:[ parent:= parent environment ].
|
|
88 |
|
|
89 |
^parent
|
|
90 |
! !
|
|
91 |
|
|
92 |
!RGDefinition methodsFor:'annotations'!
|
|
93 |
|
|
94 |
annotationNamed: annotationName
|
|
95 |
"Answer the value of the annotation named <annotationName>, or
|
|
96 |
nil if the annotation is not defined for the receiver."
|
|
97 |
|
|
98 |
^ self
|
|
99 |
annotationNamed: annotationName
|
|
100 |
ifAbsent: [ nil ]
|
|
101 |
!
|
|
102 |
|
|
103 |
annotationNamed: annotationName ifAbsent: exceptionBlock
|
|
104 |
"Answer the value of the annotation named <annotationName>. If the
|
|
105 |
annotation is not defined for the receiver, answer the result of
|
|
106 |
evaluating the <exceptionBlock>."
|
|
107 |
|
|
108 |
self hasAnnotations
|
|
109 |
ifFalse: [ ^exceptionBlock value ].
|
|
110 |
|
|
111 |
^self annotations
|
|
112 |
at: annotationName
|
|
113 |
ifAbsent: [ exceptionBlock value ]
|
|
114 |
!
|
|
115 |
|
|
116 |
annotationNamed: annotationName ifAbsentPut: blockValue
|
|
117 |
|
|
118 |
^self annotations
|
|
119 |
at: annotationName
|
|
120 |
ifAbsentPut: blockValue
|
|
121 |
!
|
|
122 |
|
|
123 |
annotationNamed: annotationName put: value
|
|
124 |
|
|
125 |
self annotations
|
|
126 |
at: annotationName
|
|
127 |
put: value
|
|
128 |
!
|
|
129 |
|
|
130 |
annotationNames
|
|
131 |
|
|
132 |
self hasAnnotations
|
|
133 |
ifFalse:[ ^OrderedCollection new ].
|
|
134 |
^annotations keys
|
|
135 |
!
|
|
136 |
|
|
137 |
annotations
|
|
138 |
|
|
139 |
^annotations ifNil:[ annotations:= IdentityDictionary new ]
|
|
140 |
!
|
|
141 |
|
|
142 |
hasAnnotationNamed: annotationName
|
|
143 |
"Answer <true> if the receiver contains the annotation named <annotationName>. "
|
|
144 |
|
|
145 |
self hasAnnotations
|
|
146 |
ifFalse:[ ^false ].
|
|
147 |
^annotations includesKey: annotationName
|
|
148 |
!
|
|
149 |
|
|
150 |
hasAnnotations
|
|
151 |
|
|
152 |
^annotations notNil
|
|
153 |
!
|
|
154 |
|
|
155 |
removeAnnotationNamed: annotationName
|
|
156 |
"Remove the annotation named <annotationName>. Fails quietly if there
|
|
157 |
is no annotation with the given name."
|
|
158 |
|
|
159 |
(self hasAnnotationNamed: annotationName)
|
|
160 |
ifTrue:[ annotations removeKey: annotationName ]
|
|
161 |
! !
|
|
162 |
|
|
163 |
!RGDefinition methodsFor:'converting'!
|
|
164 |
|
|
165 |
asRingDefinition
|
|
166 |
^ self
|
|
167 |
! !
|
|
168 |
|
|
169 |
!RGDefinition methodsFor:'testing types'!
|
|
170 |
|
|
171 |
isAccess
|
|
172 |
|
|
173 |
^false
|
|
174 |
!
|
|
175 |
|
|
176 |
isComment
|
|
177 |
|
|
178 |
^false
|
|
179 |
!
|
|
180 |
|
|
181 |
isGlobalVariable
|
|
182 |
|
|
183 |
^false
|
|
184 |
!
|
|
185 |
|
|
186 |
isInheritance
|
|
187 |
|
|
188 |
^false
|
|
189 |
!
|
|
190 |
|
|
191 |
isInvocation
|
|
192 |
|
|
193 |
^false
|
|
194 |
!
|
|
195 |
|
|
196 |
isMethod
|
|
197 |
|
|
198 |
^false
|
|
199 |
!
|
|
200 |
|
|
201 |
isNamespace
|
|
202 |
|
|
203 |
^false
|
|
204 |
!
|
|
205 |
|
|
206 |
isOrganization
|
|
207 |
|
|
208 |
^false
|
|
209 |
!
|
|
210 |
|
|
211 |
isPackage
|
|
212 |
|
|
213 |
^false
|
|
214 |
!
|
|
215 |
|
|
216 |
isPool
|
|
217 |
|
|
218 |
^false
|
|
219 |
!
|
|
220 |
|
|
221 |
isReference
|
|
222 |
|
|
223 |
^false
|
|
224 |
!
|
|
225 |
|
|
226 |
isRingObject
|
|
227 |
|
|
228 |
^true
|
|
229 |
!
|
|
230 |
|
|
231 |
isSlice
|
|
232 |
|
|
233 |
^false
|
|
234 |
!
|
|
235 |
|
|
236 |
isVariable
|
|
237 |
|
|
238 |
^false
|
|
239 |
! !
|
|
240 |
|