/[eiffelstudio]/FreeELKS/trunk/library/kernel/any.e
ViewVC logotype

Contents of /FreeELKS/trunk/library/kernel/any.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91424 - (show annotations)
Tue Oct 26 18:39:32 2004 UTC (15 years, 2 months ago) by manus_eiffel
File size: 9435 byte(s)
Initial revision

1 indexing
2
3 description: "[
4 Project-wide universal properties.
5 This class is an ancestor to all developer-written classes.
6 ANY may be customized for individual projects or teams.
7 ]"
8
9 status: "See notice at end of class"
10 date: "$Date$"
11 revision: "$Revision$"
12
13 class
14 ANY
15
16 feature -- Customization
17
18 feature -- Access
19
20 frozen generator: STRING is
21 -- Name of current object's generating class
22 -- (base class of the type of which it is a direct instance)
23 external
24 "built_in"
25 end
26
27 frozen generating_type: STRING is
28 -- Name of current object's generating type
29 -- (type of which it is a direct instance)
30 external
31 "built_in"
32 end
33
34 feature -- Status report
35
36 frozen conforms_to (other: ANY): BOOLEAN is
37 -- Does type of current object conform to type
38 -- of `other' (as per Eiffel: The Language, chapter 13)?
39 require
40 other_not_void: other /= Void
41 external
42 "built_in"
43 end
44
45 frozen same_type (other: ANY): BOOLEAN is
46 -- Is type of current object identical to type of `other'?
47 require
48 other_not_void: other /= Void
49 external
50 "built_in"
51 ensure
52 definition: Result = (conforms_to (other) and
53 other.conforms_to (Current))
54 end
55
56 feature -- Comparison
57
58 is_equal (other: like Current): BOOLEAN is
59 -- Is `other' attached to an object considered
60 -- equal to current object?
61 require
62 other_not_void: other /= Void
63 do
64 Result := standard_is_equal (other)
65 ensure
66 symmetric: Result implies other.is_equal (Current)
67 consistent: standard_is_equal (other) implies Result
68 end
69
70 frozen standard_is_equal (other: like Current): BOOLEAN is
71 -- Is `other' attached to an object of the same type
72 -- as current object, and field-by-field identical to it?
73 require
74 other_not_void: other /= Void
75 external
76 "built_in"
77 ensure
78 same_type: Result implies same_type (other)
79 symmetric: Result implies other.standard_is_equal (Current)
80 end
81
82 frozen equal (some: ANY; other: like some): BOOLEAN is
83 -- Are `some' and `other' either both void or attached
84 -- to objects considered equal?
85 do
86 if some = Void then
87 Result := other = Void
88 else
89 Result := other /= Void and then
90 some.is_equal (other)
91 end
92 ensure
93 definition: Result = (some = Void and other = Void) or else
94 ((some /= Void and other /= Void) and then
95 some.is_equal (other))
96 end
97
98 frozen standard_equal (some: ANY; other: like some): BOOLEAN is
99 -- Are `some' and `other' either both void or attached to
100 -- field-by-field identical objects of the same type?
101 -- Always uses default object comparison criterion.
102 do
103 if some = Void then
104 Result := other = Void
105 else
106 Result := other /= Void and then
107 some.standard_is_equal (other)
108 end
109 ensure
110 definition: Result = (some = Void and other = Void) or else
111 ((some /= Void and other /= Void) and then
112 some.standard_is_equal (other))
113 end
114
115 frozen is_deep_equal (other: like Current): BOOLEAN is
116 -- Are `Current' and `other' attached to isomorphic object structures?
117 external
118 "built_in"
119 ensure
120 shallow_implies_deep: standard_is_equal (other) implies Result
121 same_type: Result implies same_type (other)
122 symmetric: Result implies other.is_deep_equal (Current)
123 end
124
125 frozen deep_equal (some: ANY; other: like some): BOOLEAN is
126 -- Are `some' and `other' either both void
127 -- or attached to isomorphic object structures?
128 do
129 if some = Void then
130 Result := other = Void
131 else
132 Result := other /= Void and then some.is_deep_equal (other)
133 end
134 ensure
135 shallow_implies_deep: standard_equal (some, other) implies Result
136 both_or_none_void: (some = Void) implies (Result = (other = Void))
137 same_type: (Result and (some /= Void)) implies some.same_type (other)
138 symmetric: Result implies deep_equal (other, some)
139 end
140
141 feature -- Duplication
142
143 frozen twin: like Current is
144 -- New object equal to `Current'
145 -- `twin' calls `copy'; to change copying/twining semantics, redefine `copy'.
146 do
147 Result := standard_twin
148 ensure
149 twin_not_void: Result /= Void
150 is_equal: Result.is_equal (Current)
151 end
152
153 copy (other: like Current) is
154 -- Update current object using fields of object attached
155 -- to `other', so as to yield equal objects.
156 require
157 other_not_void: other /= Void
158 type_identity: same_type (other)
159 do
160 standard_copy (other)
161 ensure
162 is_equal: is_equal (other)
163 end
164
165 frozen standard_copy (other: like Current) is
166 -- Copy every field of `other' onto corresponding field
167 -- of current object.
168 require
169 other_not_void: other /= Void
170 type_identity: same_type (other)
171 external
172 "built_in"
173 ensure
174 is_standard_equal: standard_is_equal (other)
175 end
176
177 frozen clone (other: ANY): like other is
178 -- Void if `other' is void; otherwise new object
179 -- equal to `other'
180 --
181 -- For non-void `other', `clone' calls `copy';
182 -- to change copying/cloning semantics, redefine `copy'.
183 obsolete
184 "Use `twin' instead."
185 do
186 if other /= Void then
187 Result := other.twin
188 end
189 ensure
190 equal: equal (Result, other)
191 end
192
193 frozen standard_clone (other: ANY): like other is
194 -- Void if `other' is void; otherwise new object
195 -- field-by-field identical to `other'.
196 -- Always uses default copying semantics.
197 obsolete
198 "Use `standard_twin' instead."
199 do
200 if other /= Void then
201 Result := other.standard_twin
202 end
203 ensure
204 equal: standard_equal (Result, other)
205 end
206
207 frozen standard_twin: like Current is
208 -- New object field-by-field identical to `other'.
209 -- Always uses default copying semantics.
210 external
211 "built_in"
212 ensure
213 standard_twin_not_void: Result /= Void
214 equal: standard_equal (Result, Current)
215 end
216
217 frozen deep_twin: like Current is
218 -- New object structure recursively duplicated from Current.
219 external
220 "built_in"
221 ensure
222 deep_equal: deep_equal (Current, Result)
223 end
224
225 frozen deep_clone (other: ANY): like other is
226 -- Void if `other' is void: otherwise, new object structure
227 -- recursively duplicated from the one attached to `other'
228 obsolete
229 "Use `deep_twin' instead."
230 do
231 if other /= Void then
232 Result := other.deep_twin
233 end
234 ensure
235 deep_equal: deep_equal (other, Result)
236 end
237
238 frozen deep_copy (other: like Current) is
239 -- Effect equivalent to that of:
240 -- `copy' (`other' . `deep_twin')
241 require
242 other_not_void: other /= Void
243 do
244 copy (other.deep_twin)
245 ensure
246 deep_equal: deep_equal (Current, other)
247 end
248
249 feature {NONE} -- Retrieval
250
251 frozen internal_correct_mismatch is
252 -- Called from runtime to perform a proper dynamic dispatch on `correct_mismatch'
253 -- from MISMATCH_CORRECTOR.
254 local
255 l_corrector: MISMATCH_CORRECTOR
256 l_msg: STRING
257 l_exc: EXCEPTIONS
258 do
259 l_corrector ?= Current
260 if l_corrector /= Void then
261 l_corrector.correct_mismatch
262 else
263 create l_msg.make_from_string ("Mismatch: ")
264 create l_exc
265 l_msg.append (generating_type)
266 l_exc.raise_retrieval_exception (l_msg)
267 end
268 end
269
270 feature -- Output
271
272 io: STD_FILES is
273 -- Handle to standard file setup
274 once
275 create Result
276 Result.set_output_default
277 end
278
279 out: STRING is
280 -- New string containing terse printable representation
281 -- of current object
282 do
283 Result := tagged_out
284 end
285
286 frozen tagged_out: STRING is
287 -- New string containing terse printable representation
288 -- of current object
289 external
290 "built_in"
291 end
292
293 print (some: ANY) is
294 -- Write terse external representation of `some'
295 -- on standard output.
296 do
297 if some /= Void then
298 io.put_string (some.out)
299 end
300 end
301
302 feature -- Platform
303
304 Operating_environment: OPERATING_ENVIRONMENT is
305 -- Objects available from the operating system
306 once
307 create Result
308 end
309
310 feature {NONE} -- Initialization
311
312 default_create is
313 -- Process instances of classes with no creation clause.
314 -- (Default: do nothing.)
315 do
316 end
317
318 feature -- Basic operations
319
320 default_rescue is
321 -- Process exception for routines with no Rescue clause.
322 -- (Default: do nothing.)
323 do
324 end
325
326 frozen do_nothing is
327 -- Execute a null action.
328 do
329 end
330
331 frozen default: like Current is
332 -- Default value of object's type
333 do
334 end
335
336 frozen default_pointer: POINTER is
337 -- Default value of type `POINTER'
338 -- (Avoid the need to write `p'.`default' for
339 -- some `p' of type `POINTER'.)
340 do
341 ensure
342 -- Result = Result.default
343 end
344
345 invariant
346 reflexive_equality: standard_is_equal (Current)
347 reflexive_conformance: conforms_to (Current)
348
349 indexing
350
351 library: "[
352 EiffelBase: Library of reusable components for Eiffel.
353 ]"
354
355 status: "[
356 Copyright 1986-2001 Interactive Software Engineering (ISE).
357 For ISE customers the original versions are an ISE product
358 covered by the ISE Eiffel license and support agreements.
359 ]"
360
361 license: "[
362 EiffelBase may now be used by anyone as FREE SOFTWARE to
363 develop any product, public-domain or commercial, without
364 payment to ISE, under the terms of the ISE Free Eiffel Library
365 License (IFELL) at http://eiffel.com/products/base/license.html.
366 ]"
367
368 source: "[
369 Interactive Software Engineering Inc.
370 ISE Building
371 360 Storke Road, Goleta, CA 93117 USA
372 Telephone 805-685-1006, Fax 805-685-6869
373 Electronic mail <info@eiffel.com>
374 Customer support http://support.eiffel.com
375 ]"
376
377 info: "[
378 For latest info see award-winning pages: http://eiffel.com
379 ]"
380
381 end -- class ANY

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23