/[eiffelstudio]/trunk/eweasel/tests/valid068/any.e
ViewVC logotype

Contents of /trunk/eweasel/tests/valid068/any.e

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23