Eiffel mode

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

MIME types defined: text/x-eiffel.

Created by YNH.