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