/[eiffelstudio]/trunk/eweasel/tests/incr071/memory_structure.e
ViewVC logotype

Contents of /trunk/eweasel/tests/incr071/memory_structure.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 65297 - (show annotations)
Thu Nov 30 20:22:33 2006 UTC (13 years, 3 months ago) by manus
File size: 1374 byte(s)
Moved from trunk/Src/eweasel to trunk/eweasel so that a simple checkout of the source code is not penalized by the lenghty process of checking out all the tests of eweasel.
1 indexing
2 description: "Representation of a memory structure."
3 date: "$Date$"
4 revision: "$Revision$"
5
6 deferred class
7 MEMORY_STRUCTURE
8
9 feature -- Initialization
10
11 make is
12 -- Initialize current with given `structure_size'.
13 local
14 null: POINTER
15 do
16 internal_item := null
17 create managed_pointer.make (structure_size)
18 shared := False
19 ensure
20 not_shared: not shared
21 end
22
23 make_by_pointer (a_ptr: POINTER) is
24 -- Initialize current with `a_ptr'.
25 require
26 a_ptr_not_null: a_ptr /= default_pointer
27 do
28 internal_item := a_ptr
29 managed_pointer := Void
30 shared := True
31 ensure
32 shared: shared
33 end
34
35 feature -- Access
36
37 shared: BOOLEAN
38 -- Is current memory area shared with others?
39
40 item: POINTER is
41 -- Access to memory area.
42 do
43 if shared then
44 Result := internal_item
45 else
46 Result := managed_pointer.item
47 end
48 end
49
50 feature -- Measurement
51
52 structure_size: INTEGER is
53 -- Size to allocate (in bytes)
54 deferred
55 ensure
56 positive_result: Result > 0
57 end
58
59 feature {NONE} -- Implementation
60
61 internal_item: POINTER
62 -- Pointer holding value when shared.
63
64 managed_pointer: MANAGED_POINTER
65 -- Hold memory area in a managed way.
66
67 invariant
68 managed_pointer_valid: not shared implies managed_pointer /= Void
69 internal_item_valid: shared implies internal_item /= default_pointer
70
71 end -- class MEMORY_STRUCTURE

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23