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