PageRenderTime 22ms CodeModel.GetById 15ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/src/lib/foreign_interface/foreign_dll.e

http://github.com/tybor/Liberty
Specman e | 77 lines | 47 code | 7 blank | 23 comment | 2 complexity | b32214e1d302ec7d0a838d961b1d9a3c MD5 | raw file
 1-- This file is part of a Liberty Eiffel library.
 2-- See the full copyright at the end.
 3--
 4class FOREIGN_DLL
 5
 6create {FOREIGN_DLL_LOADER}
 7   make
 8
 9feature {ANY}
10   filename: FIXED_STRING
11      do
12         Result ::= dso.name
13      end
14
15   function (name: ABSTRACT_STRING; a_parameter_types: TRAVERSABLE[FOREIGN_TYPE]; a_result_type: FOREIGN_TYPE): FOREIGN_AGENT
16      require
17         name /= Void
18      local
19         fn_name: FIXED_STRING
20         p: POINTER
21      do
22         fn_name := name.intern
23         Result := functions.fast_reference_at(fn_name)
24         if Result = Void then
25            p := dso.symbol(fn_name)
26            if p.is_not_null then
27               create {FOREIGN_DLL_FUNCTION} Result.make(p, a_parameter_types, a_result_type)
28            end
29         else
30            check
31               a_parameter_types = Void implies Result.parameter_types = Void
32               a_parameter_types /= Void implies Result.parameter_types /= Void and then Result.parameter_types.is_equal(a_parameter_types)
33               Result.result_type = a_result_type
34            end
35         end
36      end
37
38feature {}
39   make (a_dso: like dso)
40      require
41         a_dso /= Void
42      do
43         dso := a_dso
44         create {HASHED_DICTIONARY[FOREIGN_DLL_FUNCTION, FIXED_STRING]} functions.make
45      ensure
46         dso = a_dso
47      end
48
49feature {FOREIGN_DLL_HANDLER}
50   dso: DYNAMIC_SHARED_OBJECT
51   functions: DICTIONARY[FOREIGN_DLL_FUNCTION, FIXED_STRING]
52
53invariant
54   dso /= Void
55   functions /= Void
56
57end -- class FOREIGN_DLL
58--
59-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
60--
61-- Permission is hereby granted, free of charge, to any person obtaining a copy
62-- of this software and associated documentation files (the "Software"), to deal
63-- in the Software without restriction, including without limitation the rights
64-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
65-- copies of the Software, and to permit persons to whom the Software is
66-- furnished to do so, subject to the following conditions:
67--
68-- The above copyright notice and this permission notice shall be included in
69-- all copies or substantial portions of the Software.
70--
71-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
72-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
73-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
74-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
75-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
76-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
77-- THE SOFTWARE.