/[eiffelstudio]/FreeELKS/trunk/library/support/internal.e
ViewVC logotype

Contents of /FreeELKS/trunk/library/support/internal.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91484 - (show annotations)
Thu Jan 25 00:11:12 2007 UTC (13 years ago) by manus_eiffel
File size: 34265 byte(s)
Added required class TYPE for the EiffelStudio compiler.
Added INTERNAL which is needed for the implementation of TYPE and ROUTINE in EiffelStudio.

1 indexing
2 description: "[
3 Access to internal object properties.
4 This class may be used as ancestor by classes needing its facilities.
5 ]"
6 library: "Free implementation of ELKS library"
7 copyright: "Copyright (c) 2005, Eiffel Software and others"
8 license: "Eiffel Forum License v2 (see forum.txt)"
9 date: "$Date$"
10 revision: "$Revision$"
11
12 class
13 INTERNAL
14
15 inherit
16 INTERNAL_HELPER
17
18 feature -- Conformance
19
20 is_instance_of (object: ANY; type_id: INTEGER): BOOLEAN is
21 -- Is `object' an instance of type `type_id'?
22 require
23 object_not_void: object /= Void
24 type_id_nonnegative: type_id >= 0
25 do
26 Result := c_type_conforms_to ({ISE_RUNTIME}.dynamic_type ($object), type_id)
27 end
28
29 type_conforms_to (type1, type2: INTEGER): BOOLEAN is
30 -- Does `type1' conform to `type2'?
31 require
32 type1_nonnegative: type1 >= 0
33 type2_nonnegative: type2 >= 0
34 do
35 Result := c_type_conforms_to (type1, type2)
36 end
37
38 feature -- Creation
39
40 dynamic_type_from_string (class_type: STRING): INTEGER is
41 -- Dynamic type corresponding to `class_type'.
42 -- If no dynamic type available, returns -1.
43 require
44 class_type_not_void: class_type /= Void
45 class_type_not_empty: not class_type.is_empty
46 is_valid_type_string: is_valid_type_string (class_type)
47 local
48 l_cstr: C_STRING
49 l_table: like internal_dynamic_type_string_table
50 l_pre_ecma_status: BOOLEAN
51 do
52 l_table := internal_dynamic_type_string_table
53 l_table.search (class_type)
54 if l_table.found then
55 Result := l_table.found_item
56 else
57 create l_cstr.make (class_type)
58 -- Take into consideration possible pre-ECMA mapping.
59 l_pre_ecma_status := {ISE_RUNTIME}.pre_ecma_mapping_status
60 {ISE_RUNTIME}.set_pre_ecma_mapping (not is_pre_ecma_mapping_disabled)
61 Result := {ISE_RUNTIME}.type_id_from_name (l_cstr.item)
62 {ISE_RUNTIME}.set_pre_ecma_mapping (l_pre_ecma_status)
63 l_table.put (Result, class_type)
64 end
65 ensure
66 dynamic_type_from_string_valid: Result = -1 or Result = none_type or Result >= 0
67 end
68
69 new_instance_of (type_id: INTEGER): ANY is
70 -- New instance of dynamic `type_id'.
71 -- Note: returned object is not initialized and may
72 -- hence violate its invariant.
73 -- `type_id' cannot represent a SPECIAL type, use
74 -- `new_special_any_instance' instead.
75 require
76 type_id_nonnegative: type_id >= 0
77 not_special_type: not is_special_type (type_id)
78 do
79 Result := c_new_instance_of (type_id)
80 ensure
81 not_special_type: not is_special (Result)
82 dynamic_type_set: dynamic_type (Result) = type_id
83 end
84
85 new_special_any_instance (type_id, count: INTEGER): SPECIAL [ANY] is
86 -- New instance of dynamic `type_id' that represents
87 -- a SPECIAL with `count' element. To create a SPECIAL of
88 -- basic type, use `SPECIAL'.
89 require
90 count_valid: count >= 0
91 type_id_nonnegative: type_id >= 0
92 special_type: is_special_any_type (type_id)
93 do
94 create Result.make (count)
95 c_set_dynamic_type ($Result, type_id)
96 ensure
97 special_type: is_special (Result)
98 dynamic_type_set: dynamic_type (Result) = type_id
99 count_set: Result.count = count
100 end
101
102 feature -- Status report
103
104 is_special_any_type (type_id: INTEGER): BOOLEAN is
105 -- Is type represented by `type_id' represent
106 -- a SPECIAL [XX] where XX is a reference type.
107 require
108 type_id_nonnegative: type_id >= 0
109 do
110 Result := c_eif_special_any_type (type_id)
111 end
112
113 is_special_type (type_id: INTEGER): BOOLEAN is
114 -- Is type represented by `type_id' represent
115 -- a SPECIAL [XX] where XX is a reference type
116 -- or a basic type.
117 require
118 type_id_nonnegative: type_id >= 0
119 do
120 Result := c_eif_is_special_type (type_id)
121 end
122
123 is_special (object: ANY): BOOLEAN is
124 -- Is `object' a special object?
125 require
126 object_not_void: object /= Void
127 do
128 Result := c_is_special ($object)
129 end
130
131 is_tuple (object: ANY): BOOLEAN is
132 -- Is `object' a TUPLE object?
133 require
134 object_not_void: object /= Void
135 do
136 Result := c_is_tuple ($object)
137 end
138
139 is_tuple_type (type_id: INTEGER): BOOLEAN is
140 -- Is type represented by `type_id' represent a TUPLE?
141 require
142 type_id_nonnegative: type_id >= 0
143 do
144 Result := c_eif_is_tuple_type (type_id)
145 end
146
147 is_marked (obj: ANY): BOOLEAN is
148 -- Is `obj' marked?
149 require
150 object_exists: obj /= Void
151 do
152 Result := c_is_marked ($obj)
153 end
154
155 feature -- Access
156
157 none_type: INTEGER is -2
158 -- Type ID representation for NONE.
159
160 Pointer_type: INTEGER is 0
161
162 Reference_type: INTEGER is 1
163
164 character_8_type, Character_type: INTEGER is 2
165
166 Boolean_type: INTEGER is 3
167
168 Integer_type, integer_32_type: INTEGER is 4
169
170 Real_type, real_32_type: INTEGER is 5
171
172 Double_type, real_64_type: INTEGER is 6
173
174 Expanded_type: INTEGER is 7
175
176 Bit_type: INTEGER is 8
177
178 Integer_8_type: INTEGER is 9
179
180 Integer_16_type: INTEGER is 10
181
182 Integer_64_type: INTEGER is 11
183
184 character_32_type, Wide_character_type: INTEGER is 12
185
186 natural_8_type: INTEGER is 13
187
188 natural_16_type: INTEGER is 14
189
190 natural_32_type: INTEGER is 15
191
192 natural_64_type: INTEGER is 16
193
194 max_predefined_type: INTEGER is 16
195
196 class_name (object: ANY): STRING is
197 -- Name of the class associated with `object'
198 require
199 object_not_void: object /= Void
200 do
201 Result := object.generator
202 end
203
204 class_name_of_type (type_id: INTEGER): STRING is
205 -- Name of class associated with dynamic type `type_id'.
206 require
207 type_id_nonnegative: type_id >= 0
208 do
209 Result := {ISE_RUNTIME}.c_generator_of_type (type_id)
210 end
211
212 type_name (object: ANY): STRING is
213 -- Name of `object''s generating type (type of which `object'
214 -- is a direct instance).
215 require
216 object_not_void: object /= Void
217 do
218 Result := object.generating_type
219 end
220
221 type_name_of_type (type_id: INTEGER): STRING is
222 -- Name of `type_id''s generating type (type of which `type_id'
223 -- is a direct instance).
224 require
225 type_id_nonnegative: type_id >= 0
226 do
227 Result := {ISE_RUNTIME}.c_generating_type_of_type (type_id)
228 end
229
230 dynamic_type (object: ANY): INTEGER is
231 -- Dynamic type of `object'
232 require
233 object_not_void: object /= Void
234 do
235 Result := {ISE_RUNTIME}.dynamic_type ($object)
236 ensure
237 dynamic_type_nonnegative: Result >= 0
238 end
239
240 generic_count (obj: ANY): INTEGER is
241 -- Number of generic parameter in `obj'.
242 require
243 obj_not_void: obj /= Void
244 do
245 Result := eif_gen_count_with_dftype ({ISE_RUNTIME}.dynamic_type ($obj))
246 end
247
248 generic_count_of_type (type_id: INTEGER): INTEGER is
249 -- Number of generic parameter in `type_id'.
250 require
251 type_id_nonnegative: type_id >= 0
252 do
253 Result := eif_gen_count_with_dftype (type_id)
254 end
255
256 generic_dynamic_type (object: ANY; i: INTEGER): INTEGER is
257 -- Dynamic type of generic parameter of `object' at
258 -- position `i'.
259 require
260 object_not_void: object /= Void
261 object_generic: generic_count (object) > 0
262 i_valid: i > 0 and i <= generic_count (object)
263 do
264 Result := eif_gen_param_id (- 1, {ISE_RUNTIME}.dynamic_type ($object), i)
265 ensure
266 dynamic_type_nonnegative: Result >= 0
267 end
268
269 generic_dynamic_type_of_type (type_id: INTEGER; i: INTEGER): INTEGER is
270 -- Dynamic type of generic parameter of `type_id' at position `i'.
271 require
272 type_id_nonnegative: type_id >= 0
273 type_id_generic: generic_count_of_type (type_id) > 0
274 i_valid: i > 0 and i <= generic_count_of_type (type_id)
275 do
276 Result := eif_gen_param_id (- 1, type_id, i)
277 ensure
278 dynamic_type_nonnegative: Result >= 0
279 end
280
281 field (i: INTEGER; object: ANY): ANY is
282 -- Object attached to the `i'-th field of `object'
283 -- (directly or through a reference)
284 require
285 object_not_void: object /= Void
286 index_large_enough: i >= 1
287 index_small_enough: i <= field_count (object)
288 not_special: not is_special (object)
289 do
290 Result := c_field (i - 1, $object)
291 end
292
293 field_name (i: INTEGER; object: ANY): STRING is
294 -- Name of `i'-th field of `object'
295 require
296 object_not_void: object /= Void
297 index_large_enough: i >= 1
298 index_small_enough: i <= field_count (object)
299 not_special: not is_special (object)
300 do
301 create Result.make_from_c (c_field_name_of_type (i - 1, {ISE_RUNTIME}.dynamic_type ($object)))
302 ensure
303 Result_exists: Result /= Void
304 end
305
306 field_name_of_type (i: INTEGER; type_id: INTEGER): STRING is
307 -- Name of `i'-th field of dynamic type `type_id'.
308 require
309 type_id_nonnegative: type_id >= 0
310 index_large_enough: i >= 1
311 index_small_enought: i <= field_count_of_type (type_id)
312 do
313 create Result.make_from_c (c_field_name_of_type (i - 1, type_id))
314 end
315
316 field_offset (i: INTEGER; object: ANY): INTEGER is
317 -- Offset of `i'-th field of `object'
318 require
319 object_not_void: object /= Void
320 index_large_enough: i >= 1
321 index_small_enough: i <= field_count (object)
322 not_special: not is_special (object)
323 do
324 Result := c_field_offset (i - 1, $object)
325 end
326
327 field_type (i: INTEGER; object: ANY): INTEGER is
328 -- Abstract type of `i'-th field of `object'
329 require
330 object_not_void: object /= Void
331 index_large_enough: i >= 1
332 index_small_enough: i <= field_count (object)
333 do
334 Result := c_field_type_of_type (i - 1, {ISE_RUNTIME}.dynamic_type ($object))
335 ensure
336 field_type_nonnegative: Result >= 0
337 end
338
339 field_type_of_type (i: INTEGER; type_id: INTEGER): INTEGER is
340 -- Abstract type of `i'-th field of dynamic type `type_id'
341 require
342 type_id_nonnegative: type_id >= 0
343 index_large_enough: i >= 1
344 index_small_enough: i <= field_count_of_type (type_id)
345 do
346 Result := c_field_type_of_type (i - 1, type_id)
347 ensure
348 field_type_nonnegative: Result >= 0
349 end
350
351 field_static_type_of_type (i: INTEGER; type_id: INTEGER): INTEGER is
352 -- Static type of declared `i'-th field of dynamic type `type_id'
353 require
354 type_id_nonnegative: type_id >= 0
355 index_large_enough: i >= 1
356 index_small_enough: i <= field_count_of_type (type_id)
357 do
358 Result := c_field_static_type_of_type (i - 1, type_id)
359 ensure
360 field_type_nonnegative: Result >= 0
361 end
362
363 expanded_field_type (i: INTEGER; object: ANY): STRING is
364 -- Class name associated with the `i'-th
365 -- expanded field of `object'
366 require
367 object_not_void: object /= Void
368 index_large_enough: i >= 1
369 index_small_enough: i <= field_count (object)
370 is_expanded: field_type (i, object) = Expanded_type
371 do
372 Result := c_expanded_type (i - 1, $object)
373 ensure
374 Result_exists: Result /= Void
375 end
376
377 character_8_field, character_field (i: INTEGER; object: ANY): CHARACTER_8 is
378 -- CHARACTER_8 value of `i'-th field of `object'
379 require
380 object_not_void: object /= Void
381 index_large_enough: i >= 1
382 index_small_enough: i <= field_count (object)
383 character_8_field: field_type (i, object) = Character_8_type
384 do
385 Result := c_character_8_field (i - 1, $object)
386 end
387
388 character_32_field (i: INTEGER; object: ANY): CHARACTER_32 is
389 -- CHARACTER_32 value of `i'-th field of `object'
390 require
391 object_not_void: object /= Void
392 index_large_enough: i >= 1
393 index_small_enough: i <= field_count (object)
394 character_32_field: field_type (i, object) = Character_32_type
395 do
396 Result := c_character_32_field (i - 1, $object)
397 end
398
399 boolean_field (i: INTEGER; object: ANY): BOOLEAN is
400 -- Boolean value of `i'-th field of `object'
401 require
402 object_not_void: object /= Void
403 index_large_enough: i >= 1
404 index_small_enough: i <= field_count (object)
405 boolean_field: field_type (i, object) = Boolean_type
406 do
407 Result := c_boolean_field (i - 1, $object)
408 end
409
410 natural_8_field (i: INTEGER; object: ANY): NATURAL_8 is
411 -- NATURAL_8 value of `i'-th field of `object'
412 require
413 object_not_void: object /= Void
414 index_large_enough: i >= 1
415 index_small_enough: i <= field_count (object)
416 natural_8_field: field_type (i, object) = natural_8_type
417 do
418 Result := c_natural_8_field (i - 1, $object)
419 end
420
421 natural_16_field (i: INTEGER; object: ANY): NATURAL_16 is
422 -- NATURAL_16 value of `i'-th field of `object'
423 require
424 object_not_void: object /= Void
425 index_large_enough: i >= 1
426 index_small_enough: i <= field_count (object)
427 natural_16_field: field_type (i, object) = natural_16_type
428 do
429 Result := c_natural_16_field (i - 1, $object)
430 end
431
432 natural_32_field (i: INTEGER; object: ANY): NATURAL_32 is
433 -- NATURAL_32 value of `i'-th field of `object'
434 require
435 object_not_void: object /= Void
436 index_large_enough: i >= 1
437 index_small_enough: i <= field_count (object)
438 natural_32_field: field_type (i, object) = natural_32_type
439 do
440 Result := c_natural_32_field (i - 1, $object)
441 end
442
443 natural_64_field (i: INTEGER; object: ANY): NATURAL_64 is
444 -- NATURAL_64 value of `i'-th field of `object'
445 require
446 object_not_void: object /= Void
447 index_large_enough: i >= 1
448 index_small_enough: i <= field_count (object)
449 natural_64_field: field_type (i, object) = natural_64_type
450 do
451 Result := c_natural_64_field (i - 1, $object)
452 end
453
454 integer_8_field (i: INTEGER; object: ANY): INTEGER_8 is
455 -- INTEGER_8 value of `i'-th field of `object'
456 require
457 object_not_void: object /= Void
458 index_large_enough: i >= 1
459 index_small_enough: i <= field_count (object)
460 integer_8_field: field_type (i, object) = Integer_8_type
461 do
462 Result := c_integer_8_field (i - 1, $object)
463 end
464
465 integer_16_field (i: INTEGER; object: ANY): INTEGER_16 is
466 -- INTEGER_16 value of `i'-th field of `object'
467 require
468 object_not_void: object /= Void
469 index_large_enough: i >= 1
470 index_small_enough: i <= field_count (object)
471 integer_16_field: field_type (i, object) = Integer_16_type
472 do
473 Result := c_integer_16_field (i - 1, $object)
474 end
475
476 integer_field, integer_32_field (i: INTEGER; object: ANY): INTEGER is
477 -- INTEGER_32 value of `i'-th field of `object'
478 require
479 object_not_void: object /= Void
480 index_large_enough: i >= 1
481 index_small_enough: i <= field_count (object)
482 integer_32_field: field_type (i, object) = Integer_32_type
483 do
484 Result := c_integer_32_field (i - 1, $object)
485 end
486
487 integer_64_field (i: INTEGER; object: ANY): INTEGER_64 is
488 -- INTEGER_64 value of `i'-th field of `object'
489 require
490 object_not_void: object /= Void
491 index_large_enough: i >= 1
492 index_small_enough: i <= field_count (object)
493 integer_64_field: field_type (i, object) = Integer_64_type
494 do
495 Result := c_integer_64_field (i - 1, $object)
496 end
497
498 real_32_field, real_field (i: INTEGER; object: ANY): REAL is
499 -- Real value of `i'-th field of `object'
500 require
501 object_not_void: object /= Void
502 index_large_enough: i >= 1
503 index_small_enough: i <= field_count (object)
504 real_32_field: field_type (i, object) = real_32_type
505 do
506 Result := c_real_32_field (i - 1, $object)
507 end
508
509 pointer_field (i: INTEGER; object: ANY): POINTER is
510 -- Pointer value of `i'-th field of `object'
511 require
512 object_not_void: object /= Void
513 index_large_enough: i >= 1
514 index_small_enough: i <= field_count (object)
515 pointer_field: field_type (i, object) = Pointer_type
516 do
517 Result := c_pointer_field (i - 1, $object)
518 end
519
520 real_64_field, double_field (i: INTEGER; object: ANY): DOUBLE is
521 -- Double precision value of `i'-th field of `object'
522 require
523 object_not_void: object /= Void
524 index_large_enough: i >= 1
525 index_small_enough: i <= field_count (object)
526 real_64_field: field_type (i, object) = real_64_type
527 do
528 Result := c_real_64_field (i - 1, $object)
529 end
530
531 feature -- Version
532
533 compiler_version: INTEGER is
534 external
535 "C [macro %"eif_project.h%"]"
536 alias
537 "egc_compiler_tag"
538 end
539
540 feature -- Element change
541
542 set_reference_field (i: INTEGER; object: ANY; value: ANY) is
543 require
544 object_not_void: object /= Void
545 index_large_enough: i >= 1
546 index_small_enough: i <= field_count (object)
547 reference_field: field_type (i, object) = Reference_type
548 value_conforms_to_field_static_type:
549 value /= Void implies
550 type_conforms_to (dynamic_type (value),
551 field_static_type_of_type (i, dynamic_type (object)))
552 do
553 c_set_reference_field (i - 1, $object, $value)
554 end
555
556 set_real_64_field, set_double_field (i: INTEGER; object: ANY; value: DOUBLE) is
557 require
558 object_not_void: object /= Void
559 index_large_enough: i >= 1
560 index_small_enough: i <= field_count (object)
561 real_64_field: field_type (i, object) = real_64_type
562 do
563 c_set_real_64_field (i - 1, $object, value)
564 end
565
566 set_character_8_field, set_character_field (i: INTEGER; object: ANY; value: CHARACTER_8) is
567 -- Set character value of `i'-th field of `object' to `value'
568 require
569 object_not_void: object /= Void
570 index_large_enough: i >= 1
571 index_small_enough: i <= field_count (object)
572 character_field: field_type (i, object) = Character_8_type
573 do
574 c_set_character_8_field (i - 1, $object, value)
575 end
576
577 set_character_32_field (i: INTEGER; object: ANY; value: CHARACTER_32) is
578 -- Set character 32 value of `i'-th field of `object' to `value'
579 require
580 object_not_void: object /= Void
581 index_large_enough: i >= 1
582 index_small_enough: i <= field_count (object)
583 character_field: field_type (i, object) = Character_32_type
584 do
585 c_set_character_32_field (i - 1, $object, value)
586 end
587
588 set_boolean_field (i: INTEGER; object: ANY; value: BOOLEAN) is
589 require
590 object_not_void: object /= Void
591 index_large_enough: i >= 1
592 index_small_enough: i <= field_count (object)
593 boolean_field: field_type (i, object) = Boolean_type
594 do
595 c_set_boolean_field (i - 1, $object, value)
596 end
597
598 set_natural_8_field (i: INTEGER; object: ANY; value: NATURAL_8) is
599 require
600 object_not_void: object /= Void
601 index_large_enough: i >= 1
602 index_small_enough: i <= field_count (object)
603 natural_8_field: field_type (i, object) = natural_8_type
604 do
605 c_set_natural_8_field (i - 1, $object, value)
606 end
607
608 set_natural_16_field (i: INTEGER; object: ANY; value: NATURAL_16) is
609 require
610 object_not_void: object /= Void
611 index_large_enough: i >= 1
612 index_small_enough: i <= field_count (object)
613 natural_16_field: field_type (i, object) = natural_16_type
614 do
615 c_set_natural_16_field (i - 1, $object, value)
616 end
617
618 set_natural_32_field (i: INTEGER; object: ANY; value: NATURAL_32) is
619 require
620 object_not_void: object /= Void
621 index_large_enough: i >= 1
622 index_small_enough: i <= field_count (object)
623 natural_32_field: field_type (i, object) = natural_32_type
624 do
625 c_set_natural_32_field (i - 1, $object, value)
626 end
627
628 set_natural_64_field (i: INTEGER; object: ANY; value: NATURAL_64) is
629 require
630 object_not_void: object /= Void
631 index_large_enough: i >= 1
632 index_small_enough: i <= field_count (object)
633 natural_64_field: field_type (i, object) = natural_64_type
634 do
635 c_set_natural_64_field (i - 1, $object, value)
636 end
637
638 set_integer_8_field (i: INTEGER; object: ANY; value: INTEGER_8) is
639 require
640 object_not_void: object /= Void
641 index_large_enough: i >= 1
642 index_small_enough: i <= field_count (object)
643 integer_8_field: field_type (i, object) = Integer_8_type
644 do
645 c_set_integer_8_field (i - 1, $object, value)
646 end
647
648 set_integer_16_field (i: INTEGER; object: ANY; value: INTEGER_16) is
649 require
650 object_not_void: object /= Void
651 index_large_enough: i >= 1
652 index_small_enough: i <= field_count (object)
653 integer_16_field: field_type (i, object) = Integer_16_type
654 do
655 c_set_integer_16_field (i - 1, $object, value)
656 end
657
658 set_integer_field, set_integer_32_field (i: INTEGER; object: ANY; value: INTEGER) is
659 require
660 object_not_void: object /= Void
661 index_large_enough: i >= 1
662 index_small_enough: i <= field_count (object)
663 integer_32_field: field_type (i, object) = Integer_32_type
664 do
665 c_set_integer_32_field (i - 1, $object, value)
666 end
667
668 set_integer_64_field (i: INTEGER; object: ANY; value: INTEGER_64) is
669 require
670 object_not_void: object /= Void
671 index_large_enough: i >= 1
672 index_small_enough: i <= field_count (object)
673 integer_64_field: field_type (i, object) = Integer_64_type
674 do
675 c_set_integer_64_field (i - 1, $object, value)
676 end
677
678 set_real_32_field, set_real_field (i: INTEGER; object: ANY; value: REAL) is
679 require
680 object_not_void: object /= Void
681 index_large_enough: i >= 1
682 index_small_enough: i <= field_count (object)
683 real_32_field: field_type (i, object) = real_32_type
684 do
685 c_set_real_32_field (i - 1, $object, value)
686 end
687
688 set_pointer_field (i: INTEGER; object: ANY; value: POINTER) is
689 require
690 object_not_void: object /= Void
691 index_large_enough: i >= 1
692 index_small_enough: i <= field_count (object)
693 pointer_field: field_type (i, object) = Pointer_type
694 do
695 c_set_pointer_field (i - 1, $object, value)
696 end
697
698 feature -- Measurement
699
700 field_count (object: ANY): INTEGER is
701 -- Number of logical fields in `object'
702 require
703 object_not_void: object /= Void
704 do
705 Result := field_count_of_type ({ISE_RUNTIME}.dynamic_type ($object))
706 end
707
708 field_count_of_type (type_id: INTEGER): INTEGER is
709 -- Number of logical fields in dynamic type `type_id'.
710 require
711 type_id_nonnegative: type_id >= 0
712 external
713 "C macro signature (EIF_INTEGER): EIF_INTEGER use %"eif_internal.h%""
714 alias
715 "ei_count_field_of_type"
716 end
717
718 bit_size (i: INTEGER; object: ANY): INTEGER is
719 -- Size (in bit) of the `i'-th bit field of `object'
720 require
721 object_not_void: object /= Void
722 index_large_enough: i >= 1
723 index_small_enough: i <= field_count (object)
724 is_bit: field_type (i, object) = Bit_type
725 do
726 Result := c_bit_size (i - 1, $object)
727 ensure
728 positive_result: Result > 0
729 end
730
731 physical_size (object: ANY): INTEGER is
732 -- Space occupied by `object' in bytes
733 require
734 object_not_void: object /= Void
735 do
736 Result := c_size ($object)
737 end
738
739 feature -- Marking
740
741 mark (obj: ANY) is
742 -- Mark object `obj'.
743 -- To be thread safe, make sure to call this feature when you
744 -- have the marking lock that you acquire using `lock_marking'.
745 require
746 object_not_void: obj /= Void
747 object_not_marked: not is_marked (obj)
748 do
749 c_mark ($obj)
750 ensure
751 is_marked: is_marked (obj)
752 end
753
754 unmark (obj: ANY) is
755 -- Unmark object `obj'.
756 -- To be thread safe, make sure to call this feature when you
757 -- have the marking lock that you acquire using `lock_marking'.
758 require
759 object_not_void: obj /= Void
760 object_marked: is_marked (obj)
761 do
762 c_unmark ($obj)
763 ensure
764 is_not_marked: not is_marked (obj)
765 end
766
767 lock_marking is
768 -- Get a lock on `mark' and `unmark' routine so that 2 threads cannot `mark' and
769 -- `unmark' at the same time.
770 external
771 "C blocking use %"eif_traverse.h%""
772 alias
773 "eif_lock_marking"
774 end
775
776 unlock_marking is
777 -- Release a lock on `mark' and `unmark', so that another thread can
778 -- use `mark' and `unmark'.
779 external
780 "C use %"eif_traverse.h%""
781 alias
782 "eif_unlock_marking"
783 end
784
785 feature {NONE} -- Cached data
786
787 internal_dynamic_type_string_table: HASH_TABLE [INTEGER, STRING] is
788 -- Table of dynamic type indexed by type name
789 once
790 create Result.make (100)
791 ensure
792 internal_dynamic_type_string_table_not_void: Result /= Void
793 end
794
795 feature {NONE} -- Implementation
796
797 c_is_instance_of (type1: INTEGER; obj: POINTER): BOOLEAN is
798 -- Is `obj' an instance of `type1'?
799 external
800 "C [macro %"eif_macros.h%"]"
801 alias
802 "RTRA"
803 end
804
805 c_field (i: INTEGER; object: POINTER): ANY is
806 -- Object referenced by the `i'-th field of `object'
807 external
808 "C (long, EIF_REFERENCE): EIF_REFERENCE | %"eif_internal.h%""
809 alias
810 "ei_field"
811 end
812
813 c_field_name_of_type (i: INTEGER; type_id: INTEGER): POINTER is
814 -- C pointer to name of `i'-th field of `object'
815 external
816 "C macro signature (EIF_INTEGER, EIF_INTEGER): EIF_POINTER use %"eif_internal.h%""
817 alias
818 "ei_field_name_of_type"
819 end
820
821 c_field_type_of_type (i: INTEGER; type_id: INTEGER): INTEGER is
822 -- Abstract type of `i'-th field of dynamic type `type_id'
823 external
824 "C signature (long, EIF_INTEGER): EIF_INTEGER use %"eif_internal.h%""
825 alias
826 "ei_field_type_of_type"
827 end
828
829 c_field_static_type_of_type (i: INTEGER; type_id: INTEGER): INTEGER is
830 -- Static type of `i'-th field of dynamic type `type_id'
831 external
832 "C signature (long, EIF_INTEGER): EIF_INTEGER use %"eif_internal.h%""
833 alias
834 "ei_field_static_type_of_type"
835 end
836
837 c_expanded_type (i: INTEGER; object: POINTER): STRING is
838 -- Class name of the `i'-th expanded field of `object'
839 external
840 "C (long, EIF_REFERENCE): EIF_REFERENCE | %"eif_internal.h%""
841 alias
842 "ei_exp_type"
843 end
844
845 c_character_8_field (i: INTEGER; object: POINTER): CHARACTER_8 is
846 -- Character value of `i'-th field of `object'
847 external
848 "C macro signature (long, EIF_REFERENCE): EIF_CHARACTER use %"eif_internal.h%""
849 alias
850 "ei_char_field"
851 end
852
853 c_character_32_field (i: INTEGER; object: POINTER): CHARACTER_32 is
854 -- Character value of `i'-th field of `object'
855 external
856 "C macro signature (long, EIF_REFERENCE): EIF_WIDE_CHAR use %"eif_internal.h%""
857 alias
858 "ei_char_32_field"
859 end
860
861 c_boolean_field (i: INTEGER; object: POINTER): BOOLEAN is
862 -- Boolean value of `i'-th field of `object'
863 external
864 "C macro signature (long, EIF_REFERENCE): EIF_BOOLEAN use %"eif_internal.h%""
865 alias
866 "ei_bool_field"
867 end
868
869 c_natural_8_field (i: INTEGER; object: POINTER): NATURAL_8 is
870 -- NATURAL_8 value of `i'-th field of `object'
871 external
872 "C macro signature (long, EIF_REFERENCE): EIF_NATURAL_8 use %"eif_internal.h%""
873 alias
874 "ei_uint_8_field"
875 end
876
877 c_natural_16_field (i: INTEGER; object: POINTER): NATURAL_16 is
878 -- NATURAL_16 value of `i'-th field of `object'
879 external
880 "C macro signature (long, EIF_REFERENCE): EIF_NATURAL_16 use %"eif_internal.h%""
881 alias
882 "ei_uint_16_field"
883 end
884
885 c_natural_32_field (i: INTEGER; object: POINTER): NATURAL_32 is
886 -- NATURAL_32 value of `i'-th field of `object'
887 external
888 "C macro signature (long, EIF_REFERENCE): EIF_NATURAL_32 use %"eif_internal.h%""
889 alias
890 "ei_uint_32_field"
891 end
892
893 c_natural_64_field (i: INTEGER; object: POINTER): NATURAL_64 is
894 -- NATURAL_64 value of `i'-th field of `object'
895 external
896 "C macro signature (long, EIF_REFERENCE): EIF_NATURAL_64 use %"eif_internal.h%""
897 alias
898 "ei_uint_64_field"
899 end
900
901 c_integer_8_field (i: INTEGER; object: POINTER): INTEGER_8 is
902 -- Integer value of `i'-th field of `object'
903 external
904 "C macro signature (long, EIF_REFERENCE): EIF_INTEGER_8 use %"eif_internal.h%""
905 alias
906 "ei_int_8_field"
907 end
908
909 c_integer_16_field (i: INTEGER; object: POINTER): INTEGER_16 is
910 -- Integer value of `i'-th field of `object'
911 external
912 "C macro signature (long, EIF_REFERENCE): EIF_INTEGER_16 use %"eif_internal.h%""
913 alias
914 "ei_int_16_field"
915 end
916
917 c_integer_32_field (i: INTEGER; object: POINTER): INTEGER is
918 -- Integer value of `i'-th field of `object'
919 external
920 "C macro signature (long, EIF_REFERENCE): EIF_INTEGER use %"eif_internal.h%""
921 alias
922 "ei_int_32_field"
923 end
924
925 c_integer_64_field (i: INTEGER; object: POINTER): INTEGER_64 is
926 -- Integer value of `i'-th field of `object'
927 external
928 "C macro signature (long, EIF_REFERENCE): EIF_INTEGER_64 use %"eif_internal.h%""
929 alias
930 "ei_int_64_field"
931 end
932
933 c_real_32_field (i: INTEGER; object: POINTER): REAL is
934 -- Real value of `i'-th field of `object'
935 external
936 "C macro signature (long, EIF_REFERENCE): EIF_REAL use %"eif_internal.h%""
937 alias
938 "ei_float_field"
939 end
940
941 c_pointer_field (i: INTEGER; object: POINTER): POINTER is
942 -- Pointer value of `i'-th field of `object'
943 external
944 "C macro signature (long, EIF_REFERENCE): EIF_POINTER use %"eif_internal.h%""
945 alias
946 "ei_ptr_field"
947 end
948
949 c_real_64_field (i: INTEGER; object: POINTER): DOUBLE is
950 -- Double precision value of `i'-th field of `object'
951 external
952 "C macro signature (long, EIF_REFERENCE): EIF_DOUBLE use %"eif_internal.h%""
953 alias
954 "ei_double_field"
955 end
956
957 c_is_special (object: POINTER): BOOLEAN is
958 -- Is `object' a special object?
959 external
960 "C (EIF_REFERENCE): EIF_BOOLEAN | %"eif_internal.h%""
961 alias
962 "ei_special"
963 end
964
965 c_is_tuple (object: POINTER): BOOLEAN is
966 -- Is `object' a TUPLE object?
967 external
968 "C (EIF_REFERENCE): EIF_BOOLEAN | %"eif_internal.h%""
969 alias
970 "ei_tuple"
971 end
972
973 c_field_offset (i: INTEGER; object: POINTER): INTEGER is
974 -- Offset of `i'-th field of `object'
975 external
976 "C macro signature (long, EIF_REFERENCE): EIF_INTEGER use %"eif_internal.h%""
977 alias
978 "ei_offset"
979 end
980
981 c_bit_size (i: INTEGER; object: POINTER): INTEGER is
982 -- Size (in bit) of the `i'-th bit field of `object'
983 external
984 "C (long, EIF_REFERENCE): EIF_INTEGER | %"eif_internal.h%""
985 alias
986 "ei_bit_size"
987 end
988
989 c_size (object: POINTER): INTEGER is
990 -- Physical size of `object'
991 external
992 "C (EIF_REFERENCE): EIF_INTEGER | %"eif_internal.h%""
993 alias
994 "ei_size"
995 end
996
997 c_set_reference_field (i: INTEGER; object: POINTER; value: POINTER) is
998 external
999 "C macro signature (long, EIF_REFERENCE, EIF_REFERENCE) use %"eif_internal.h%""
1000 alias
1001 "ei_set_reference_field"
1002 end
1003
1004 c_set_real_64_field (i: INTEGER; object: POINTER; value: DOUBLE) is
1005 external
1006 "C macro signature (long, EIF_REFERENCE, EIF_DOUBLE) use %"eif_internal.h%""
1007 alias
1008 "ei_set_double_field"
1009 end
1010
1011 c_set_character_8_field (i: INTEGER; object: POINTER; value: CHARACTER_8) is
1012 external
1013 "C macro signature (long, EIF_REFERENCE, EIF_CHARACTER) use %"eif_internal.h%""
1014 alias
1015 "ei_set_char_field"
1016 end
1017
1018 c_set_character_32_field (i: INTEGER; object: POINTER; value: CHARACTER_32) is
1019 external
1020 "C macro signature (long, EIF_REFERENCE, EIF_CHARACTER) use %"eif_internal.h%""
1021 alias
1022 "ei_set_char_32_field"
1023 end
1024
1025 c_set_boolean_field (i: INTEGER; object: POINTER; value: BOOLEAN) is
1026 external
1027 "C macro signature (long, EIF_REFERENCE, EIF_BOOLEAN) use %"eif_internal.h%""
1028 alias
1029 "ei_set_boolean_field"
1030 end
1031
1032 c_set_natural_8_field (i: INTEGER; object: POINTER; value: NATURAL_8) is
1033 external
1034 "C macro signature (long, EIF_REFERENCE, EIF_NATURAL_8) use %"eif_internal.h%""
1035 alias
1036 "ei_set_natural_8_field"
1037 end
1038
1039 c_set_natural_16_field (i: INTEGER; object: POINTER; value: NATURAL_16) is
1040 external
1041 "C macro signature (long, EIF_REFERENCE, EIF_NATURAL_16) use %"eif_internal.h%""
1042 alias
1043 "ei_set_natural_16_field"
1044 end
1045
1046 c_set_natural_32_field (i: INTEGER; object: POINTER; value: NATURAL_32) is
1047 external
1048 "C macro signature (long, EIF_REFERENCE, EIF_NATURAL_32) use %"eif_internal.h%""
1049 alias
1050 "ei_set_natural_32_field"
1051 end
1052
1053 c_set_natural_64_field (i: INTEGER; object: POINTER; value: NATURAL_64) is
1054 external
1055 "C macro signature (long, EIF_REFERENCE, EIF_NATURAL_64) use %"eif_internal.h%""
1056 alias
1057 "ei_set_natural_64_field"
1058 end
1059
1060 c_set_integer_8_field (i: INTEGER; object: POINTER; value: INTEGER_8) is
1061 external
1062 "C macro signature (long, EIF_REFERENCE, EIF_INTEGER_8) use %"eif_internal.h%""
1063 alias
1064 "ei_set_integer_8_field"
1065 end
1066
1067 c_set_integer_16_field (i: INTEGER; object: POINTER; value: INTEGER_16) is
1068 external
1069 "C macro signature (long, EIF_REFERENCE, EIF_INTEGER_16) use %"eif_internal.h%""
1070 alias
1071 "ei_set_integer_16_field"
1072 end
1073
1074 c_set_integer_32_field (i: INTEGER; object: POINTER; value: INTEGER) is
1075 external
1076 "C macro signature (long, EIF_REFERENCE, EIF_INTEGER) use %"eif_internal.h%""
1077 alias
1078 "ei_set_integer_32_field"
1079 end
1080
1081 c_set_integer_64_field (i: INTEGER; object: POINTER; value: INTEGER_64) is
1082 external
1083 "C macro signature (long, EIF_REFERENCE, EIF_INTEGER_64) use %"eif_internal.h%""
1084 alias
1085 "ei_set_integer_64_field"
1086 end
1087
1088 c_set_real_32_field (i: INTEGER; object: POINTER; value: REAL) is
1089 external
1090 "C macro signature (long, EIF_REFERENCE, EIF_REAL) use %"eif_internal.h%""
1091 alias
1092 "ei_set_float_field"
1093 end
1094
1095 c_set_pointer_field (i: INTEGER; object: POINTER; value: POINTER) is
1096 external
1097 "C macro signature (long, EIF_REFERENCE, EIF_POINTER) use %"eif_internal.h%""
1098 alias
1099 "ei_set_pointer_field"
1100 end
1101
1102 eif_gen_count_with_dftype (type_id: INTEGER): INTEGER is
1103 -- Number of generic parameters of `obj'.
1104 external
1105 "C signature (int16): int use %"eif_gen_conf.h%""
1106 end
1107
1108 eif_gen_param_id (stype: INTEGER; dftype: INTEGER; pos: INTEGER): INTEGER is
1109 -- Type of generic parameter in `obj' at position `pos'.
1110 external
1111 "C (int16, int16, int): EIF_INTEGER | %"eif_gen_conf.h%""
1112 end
1113
1114 c_new_instance_of (type_id: INTEGER): ANY is
1115 -- New instance of dynamic `type_id'.
1116 -- Note: returned object is not initialized and may
1117 -- hence violate its invariant.
1118 -- `type_id' cannot represent a SPECIAL type, use
1119 -- `new_special_any_instance' instead.
1120 external
1121 "C macro use %"eif_macros.h%""
1122 alias
1123 "RTLNSMART"
1124 end
1125
1126 c_set_dynamic_type (obj: POINTER; dtype: INTEGER) is
1127 -- Set `obj' dynamic type to `dtype'.
1128 external
1129 "C signature (EIF_REFERENCE, EIF_INTEGER) use %"eif_internal.h%""
1130 alias
1131 "eif_set_dynamic_type"
1132 end
1133
1134 c_eif_special_any_type (type_id: INTEGER): BOOLEAN is
1135 -- Is type represented by `type_id' represent
1136 -- a SPECIAL [XX] where XX is a reference type.
1137 external
1138 "C signature (EIF_INTEGER): EIF_BOOLEAN use %"eif_internal.h%""
1139 alias
1140 "eif_special_any_type"
1141 end
1142
1143 c_eif_is_special_type (type_id: INTEGER): BOOLEAN is
1144 -- Is type represented by `type_id' represent
1145 -- a SPECIAL [XX] where XX is a reference type or
1146 -- a basic type.
1147 external
1148 "C signature (EIF_INTEGER): BOOLEAN use %"eif_internal.h%""
1149 alias
1150 "eif_is_special_type"
1151 end
1152
1153 c_eif_is_tuple_type (type_id: INTEGER): BOOLEAN is
1154 -- Is type represented by `type_id' represent a TUPLE?
1155 external
1156 "C signature (EIF_INTEGER): BOOLEAN use %"eif_internal.h%""
1157 alias
1158 "eif_is_tuple_type"
1159 end
1160
1161 c_type_conforms_to (type1, type2: INTEGER): BOOLEAN is
1162 -- Does `type1' conform to `type2'?
1163 external
1164 "C signature (int16, int16): EIF_BOOLEAN use %"eif_gen_conf.h%""
1165 alias
1166 "eif_gen_conf"
1167 end
1168
1169 c_is_marked (obj: POINTER): BOOLEAN is
1170 external
1171 "C macro signature (EIF_REFERENCE): EIF_BOOLEAN use %"eif_internal.h%""
1172 alias
1173 "ei_is_marked"
1174 end
1175
1176 c_unmark (obj: POINTER) is
1177 external
1178 "C macro signature (EIF_REFERENCE) use %"eif_internal.h%""
1179 alias
1180 "ei_unmark"
1181 end
1182
1183 c_mark (obj: POINTER) is
1184 external
1185 "C macro signature (EIF_REFERENCE) use %"eif_internal.h%""
1186 alias
1187 "ei_mark"
1188 end
1189
1190 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23