PageRenderTime 19ms CodeModel.GetById 16ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/lib/foreign_interface/foreign_parameters.e

http://github.com/tybor/Liberty
Specman e | 80 lines | 51 code | 6 blank | 23 comment | 3 complexity | e95262cf579c8ba79a4e8600f1699a06 MD5 | raw file
 1-- This file is part of a Liberty Eiffel library.
 2-- See the full copyright at the end.
 3--
 4expanded class FOREIGN_PARAMETERS
 5
 6feature {ANY}
 7   set (a_parameters: like parameters)
 8      require
 9         no_voids: a_parameters.for_all(agent (p: FOREIGN_OBJECT): BOOLEAN do Result := p /= Void end (?))
10      do
11         parameters := a_parameters
12      ensure
13         parameters = a_parameters
14      end
15
16   match_types (a_types: TRAVERSABLE[FOREIGN_TYPE]): BOOLEAN
17      local
18         i, offset: INTEGER
19      do
20         if parameters /= Void then
21            from
22               Result := a_types.count = parameters.count
23               offset := a_types.lower - parameters.lower
24               i := parameters.lower
25            until
26               not Result or else i > parameters.upper
27            loop
28               Result := parameters.item(i).match_type(a_types.item(i + offset))
29               i := i + 1
30            end
31         end
32      ensure
33         not_set_is_wrong: parameters = Void implies not Result
34      end
35
36feature {FOREIGN_AGENT}
37   as_arrayed_collection: ARRAYED_COLLECTION[POINTER]
38      local
39         i: INTEGER
40      do
41         if not parameters.is_empty then
42            create {FAST_ARRAY[POINTER]} Result.with_capacity(parameters.count)
43            from
44               i := parameters.lower
45            until
46               i > parameters.upper
47            loop
48               Result.add_last(parameters.item(i).as_pointer)
49               i := i + 1
50            end
51         end
52      end
53
54feature {}
55   parameters: TRAVERSABLE[FOREIGN_OBJECT]
56
57invariant
58   no_voids: parameters /= Void implies parameters.for_all(agent (p: FOREIGN_OBJECT): BOOLEAN do Result := p /= Void end (?))
59
60end -- class FOREIGN_PARAMETERS
61--
62-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
63--
64-- Permission is hereby granted, free of charge, to any person obtaining a copy
65-- of this software and associated documentation files (the "Software"), to deal
66-- in the Software without restriction, including without limitation the rights
67-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
68-- copies of the Software, and to permit persons to whom the Software is
69-- furnished to do so, subject to the following conditions:
70--
71-- The above copyright notice and this permission notice shall be included in
72-- all copies or substantial portions of the Software.
73--
74-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
75-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
76-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
77-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
78-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
79-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
80-- THE SOFTWARE.