/src/wrappers/glib/library/data_types/iterator_on_g_slist.e

http://github.com/tybor/Liberty · Specman e · 76 lines · 64 code · 12 blank · 0 comment · 5 complexity · 9424c4f56dcd4485e727b4f7dec563b4 MD5 · raw file

  1. indexing
  2. description: "Iterator for G_SLIST."
  3. copyright: "[
  4. Copyright (C) 2006 Paolo Redaelli
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. class ITERATOR_ON_G_SLIST [ITEM->WRAPPER]
  19. inherit
  20. ITERATOR [ITEM]
  21. WRAPPER_HANDLER
  22. insert
  23. GSLIST_EXTERNALS
  24. GSLIST_STRUCT
  25. GLOBAL_CACHE
  26. creation make
  27. feature {} -- Creation
  28. make (a_list: G_SLIST_TRAVERSABLE[ITEM]) is
  29. require
  30. valid_list: a_list /= Void
  31. do
  32. list := a_list
  33. end
  34. feature {} -- Implementation
  35. list: G_SLIST_TRAVERSABLE[ITEM]
  36. current_element: POINTER
  37. feature -- Iterator's features
  38. start is
  39. do
  40. current_element := list.handle
  41. end
  42. is_off: BOOLEAN is
  43. do
  44. Result:=(current_element.is_null)
  45. end
  46. item: ITEM is
  47. local
  48. ptr: POINTER
  49. l: WRAPPER
  50. do
  51. ptr := gslist_struct_get_data (current_element)
  52. if ptr.is_not_null then
  53. l := wrappers.reference_at(ptr)
  54. Result ?= l -- TODO: this tricks the compiler. Combining the line just above and this one seems to fail
  55. if Result = Void then
  56. Result := list.wrapper(ptr)
  57. end
  58. end
  59. end
  60. next is
  61. do
  62. current_element := gslist_struct_get_next (current_element)
  63. end
  64. end