From 5f07a601434e9d96a516d1629a1baf82cb92f1cd Mon Sep 17 00:00:00 2001 From: andersoxie Date: Fri, 21 Mar 2014 10:22:50 +0100 Subject: [PATCH 1/3] Updated to void safety for first review It requires an updated version of the graph library not yet in SVN. In latest version of the graph library was an redesign done that makes this library generate an error when compiling: Error code: VDRD(2) Type error: redeclaration has non-conforming signature. What to do: make sure that redeclaration uses signature (number and types of arguments and result) conforming to that of the original. Class: MA_OBJECT_NODE Redefined feature: model: detachable EG_NODE From: MA_OBJECT_NODE Precursor: model: EG_LINKABLE From: EG_LINKABLE_FIGURE --- .gitignore | 2 +- ma_memory_change_mediator.e | 79 ++++--- ma_memory_state.e | 31 +-- ma_object_snapshot_mediator.e | 258 ++++++++++++----------- ma_references_table.e | 32 +-- ma_route_to_once_searcher.e | 264 +++++++++++++----------- memory_analyzer-safe.ecf | 4 +- memory_analyzer.ecf | 8 +- object_graph/ma_figure_factory.e | 20 +- object_graph/ma_object_graph_mediator.e | 135 +++++++----- object_graph/ma_reference_link.e | 88 ++++---- singletons/ma_icons_singleton.e | 12 +- singletons/ma_shared_pixmap_factory.e | 5 +- singletons/ma_singleton_factory.e | 20 +- widgets/ma_constants_imp.e | 28 ++- widgets/ma_filter_window.e | 23 ++- widgets/ma_grid_check_box_item.e | 21 +- widgets/ma_window.e | 50 ++--- 18 files changed, 598 insertions(+), 482 deletions(-) diff --git a/.gitignore b/.gitignore index 2775a23..aa6ab73 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ - +EIFGENs/ .svn .accurev diff --git a/ma_memory_change_mediator.e b/ma_memory_change_mediator.e index 1545a48..ae0d0b2 100644 --- a/ma_memory_change_mediator.e +++ b/ma_memory_change_mediator.e @@ -189,30 +189,31 @@ feature {NONE} -- Implemention l_int: INTEGER l_item: EV_GRID_LABEL_ITEM l_i: INTEGER - l_grid_data_increased: like grid_data_increased do - from - l_grid_data_increased := grid_data_increased - check attached l_grid_data_increased end -- Implied by precondition `set' - l_grid_data_increased.start - until - l_grid_data_increased.after - loop - if not filter.filter_class (l_grid_data_increased.item_for_iteration.text) then - l_i := l_i + 1 - create l_item.make_with_text (l_grid_data_increased.item_for_iteration.text) - l_item.set_pixmap (icons.object_grid_class_icon) - grid_changed.set_item (1, l_i, l_item) - l_int := l_grid_data_increased.item_for_iteration.nb - create l_item.make_with_text (l_int.out) - if l_int > 0 then - l_item.set_foreground_color (increased_color) - else - l_item.set_foreground_color (decreased_color) + if attached grid_data_increased as l_grid_data_increased then + from + l_grid_data_increased.start + until + l_grid_data_increased.after + loop + if not filter.filter_class (l_grid_data_increased.item_for_iteration.text) then + l_i := l_i + 1 + create l_item.make_with_text (l_grid_data_increased.item_for_iteration.text) + l_item.set_pixmap (icons.object_grid_class_icon) + grid_changed.set_item (1, l_i, l_item) + l_int := l_grid_data_increased.item_for_iteration.nb + create l_item.make_with_text (l_int.out) + if l_int > 0 then + l_item.set_foreground_color (increased_color) + else + l_item.set_foreground_color (decreased_color) + end + grid_changed.set_item (2, l_i, l_item) end - grid_changed.set_item (2, l_i, l_item) + l_grid_data_increased.forth end - l_grid_data_increased.forth + else + check attached_grid_data_increased : false end -- Implied by precondition `set' end end @@ -282,14 +283,21 @@ feature {NONE} -- Implemention handle_pick_item (a_item: EV_GRID_LABEL_ITEM): MA_CLASS_STONE -- User pick a item from grid to filter. + require + a_item_attached : attached a_item + index_equal_1 : a_item.column.index = 1 local l_result: detachable like handle_pick_item do if a_item /= Void and a_item.column.index = 1 then l_result := create {MA_CLASS_STONE}.make (a_item.text) end - check attached l_result end -- FIXME: Implied by ...? - Result := l_result + if attached l_result then + Result := l_result + else + check attached_l_result : false end -- Implied by preconditions + create Result.make ("") -- If preonditions is not satisfied we can return whatever we want. + end end sort_data @@ -299,7 +307,6 @@ feature {NONE} -- Implemention local l_sorter: QUICK_SORTER [like grid_data_increased_row] l_agent_sorter: AGENT_EQUALITY_TESTER [like grid_data_increased_row] - l_grid_data_increased: like grid_data_increased do inspect sorted_column @@ -307,9 +314,11 @@ feature {NONE} -- Implemention when 2 then create l_agent_sorter.make (agent sort_on_count) end create l_sorter.make (l_agent_sorter) - l_grid_data_increased := grid_data_increased - check attached l_grid_data_increased end -- Implied by precondition - l_sorter.sort (l_grid_data_increased) + if attached grid_data_increased as l_grid_data_increased then + l_sorter.sort (l_grid_data_increased) + else + check attached_grid_data_increased : false end -- Implied by precondition + end end sorting_order: BOOLEAN @@ -353,8 +362,11 @@ feature {NONE} -- Implemention l_result: detachable like grid_data_increased_row do check False end -- Anchor type only - check attached l_result end -- Satisfy void-safe compiler - Result := l_result + if attached l_result as l_r then + Result := l_result + else + create Result.default_create + end end grid_data_increased: detachable ARRAYED_LIST [like grid_data_increased_row] @@ -372,8 +384,11 @@ feature {NONE} -- Implemention l_result: detachable like row_data do check False end -- Anchor type only - check attached l_result end -- Satisfy void-safe compiler - Result := l_result + if attached l_result as l_r then + Result := l_result + else + create Result.default_create + end end grid_from_state, grid_to_state: EV_GRID -- Two grid show states. @@ -393,7 +408,7 @@ invariant grid_increased_not_void: grid_changed /= Void grid_data_not_void: grid_data /= Void note - copyright: "Copyright (c) 1984-2013, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/ma_memory_state.e b/ma_memory_state.e index ceac519..03239cd 100644 --- a/ma_memory_state.e +++ b/ma_memory_state.e @@ -48,13 +48,13 @@ feature -- Measurrment item_found_count: INTEGER -- after routine found_type, return the count of founded item require - founded_type_not_void: founded_type /= Void - local - l_item_founded: like item_founded + founded_type_attached: attached founded_type do - l_item_founded := item_founded - check l_item_founded /= Void end -- Implied by precondition - Result := l_item_founded.count_in_system + if attached item_founded as l_item_founded then + Result := l_item_founded.count_in_system + else + check attached_item_founded : false end -- Implied by precondition + end end memory_used_eiffel: INTEGER @@ -167,22 +167,25 @@ feature {NONE} -- Implementation l_result: detachable like state do check False end -- Anchor type only - check l_result /= void end -- Satisfy void-safe compiler - Result := l_result + if attached l_result as l_res then + Result := l_res + else + create Result + end end objects_states: ARRAYED_LIST [like state]; -- the count the objects, first argument is type name, second argument is the object instances count note - copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ - Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA - Telephone 805-685-1006, Fax 805-685-6869 - Website http://www.eiffel.com - Customer support http://support.eiffel.com + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com ]" diff --git a/ma_object_snapshot_mediator.e b/ma_object_snapshot_mediator.e index 10e6bc1..ff66f28 100644 --- a/ma_object_snapshot_mediator.e +++ b/ma_object_snapshot_mediator.e @@ -115,8 +115,11 @@ feature -- Command l_count := l_new_table.item_for_iteration if finding_route_to_once then - check attached l_map end -- Implied by `finding_route_to_once' - add_to_reference_table (l_new_table.key_for_iteration, l_map) + if attached l_map as l_m then + add_to_reference_table (l_new_table.key_for_iteration, l_m) + else + check attached_l_map : false end -- Implied by `finding_route_to_once' + end end -- Compute `l_delta' now. @@ -226,7 +229,6 @@ feature {NONE} -- Implementation local l_sorter: QUICK_SORTER [like row_data] l_agent_sorter: AGENT_EQUALITY_TESTER [like row_data] - l_grid_data: like grid_data do inspect sorted_column @@ -235,17 +237,18 @@ feature {NONE} -- Implementation when 3 then create l_agent_sorter.make (agent sort_on_delta) end create l_sorter.make (l_agent_sorter) - l_grid_data := grid_data - check attached l_grid_data end -- Implied by precondition - l_sorter.sort (l_grid_data) + if attached grid_data as l_grid_data then + l_sorter.sort (l_grid_data) + else + check attached_grid_data : false end -- Implied by precondition + end end update_grid_content -- Fill grid using `grid_data' require - grid_data_not_void: grid_data /= Void + grid_data_not_void: attached grid_data local - l_data: like grid_data l_row_data: like row_data l_item: MA_GRID_LABEL_ITEM i, l_count, l_delta: INTEGER @@ -253,56 +256,58 @@ feature {NONE} -- Implementation l_row: EV_GRID_ROW l_grid: like object_grid do - from - l_data := grid_data - l_grid := object_grid - grid_util.grid_remove_and_clear_all_rows (l_grid) - i := 1 - check attached l_data end -- Implied by precondition `grid_data_not_void' - l_data.start - until - l_data.after - loop - l_row_data := l_data.item_for_iteration - if not filter.filter_class (l_row_data.type_name) then - l_str := l_row_data.type_name - check - l_str_not_void: l_str /= Void - end + if attached grid_data as l_data then + from + l_grid := object_grid + grid_util.grid_remove_and_clear_all_rows (l_grid) + i := 1 + l_data.start + until + l_data.after + loop + l_row_data := l_data.item_for_iteration + if not filter.filter_class (l_row_data.type_name) then + l_str := l_row_data.type_name + check + l_str_not_void: l_str /= Void + end - -- Set type name - create l_item.make_with_text (l_str) - l_item.set_pixmap (icons.object_grid_class_icon) - l_grid.set_item (1, i, l_item) - - -- Set count - l_count := l_row_data.number_of_objects - create l_item.make_with_text (l_count.out) - l_grid.set_item (2, i, l_item) - if l_count >= 1 then - l_row := l_grid.row (i) - l_row.ensure_expandable - l_row.expand_actions.extend (agent on_expand_actions_for_type (l_row_data.type_id, l_row)) - end + -- Set type name + create l_item.make_with_text (l_str) + l_item.set_pixmap (icons.object_grid_class_icon) + l_grid.set_item (1, i, l_item) + + -- Set count + l_count := l_row_data.number_of_objects + create l_item.make_with_text (l_count.out) + l_grid.set_item (2, i, l_item) + if l_count >= 1 then + l_row := l_grid.row (i) + l_row.ensure_expandable + l_row.expand_actions.extend (agent on_expand_actions_for_type (l_row_data.type_id, l_row)) + end - -- Set delta - l_delta := l_row_data.variation_since_last_time - if l_delta /= 0 then - create l_item.make_with_text (l_delta.out) - if l_delta > 0 then - l_item.set_foreground_color (increased_color) - else - l_item.set_foreground_color (decreased_color) + -- Set delta + l_delta := l_row_data.variation_since_last_time + if l_delta /= 0 then + create l_item.make_with_text (l_delta.out) + if l_delta > 0 then + l_item.set_foreground_color (increased_color) + else + l_item.set_foreground_color (decreased_color) + end + l_grid.set_item (3, i, l_item) end - l_grid.set_item (3, i, l_item) + i := i + 1 end - i := i + 1 + l_data.forth end - l_data.forth + -- We launch a collection, so that no bad information is displayed + -- for referers. + system_util.collect + else + check attached_data : false end -- Implied by precondition `grid_data_not_void' end - -- We launch a collection, so that no bad information is displayed - -- for referers. - system_util.collect end on_expand_actions_for_type (a_dynamic_type: INTEGER; a_parent_row: EV_GRID_ROW) @@ -457,85 +462,83 @@ feature {NONE} -- Implementation local l_name, l_field_name: STRING l_int: INTERNAL - l_objects_of_type: detachable ARRAYED_LIST [ANY] l_index: NATURAL l_item: ANY l_referee: detachable ANY l_field_count: INTEGER i: INTEGER - l_object_table: like object_table - l_name_table: like name_table - l_reference_table: like reference_table do create l_int l_name := l_int.type_name_of_type (a_object_id) - l_objects_of_type := a_map.item (a_object_id) - check attached l_objects_of_type end -- Implied by precondition `has' - l_object_table := object_table - check attached l_object_table end -- Implied by precondition `set' - l_reference_table := reference_table - check attached l_reference_table end -- Implied by precondition `set' - from - l_objects_of_type.start - until - l_objects_of_type.after - loop - l_item := l_objects_of_type.item - l_index := l_object_table.index (l_item) - if last_selected_object /= Void and then l_item = last_selected_object then - selected_index := l_index - last_selected_object := Void - end - --| Fixme: we don't know whether it is an once object or not. - l_name_table := name_table - check attached l_name_table end -- Implied by precondition `set' - l_name_table.put (l_name, l_index) - check - not l_name_table.conflict - end - if attached {SPECIAL [detachable ANY]} l_item as l_special then - l_field_name := once "(special_field)" - from - i := l_special.lower - until - i > l_special.upper - loop - l_referee := l_special.item (i) - if l_referee /= Void then - l_reference_table.extend (l_index, l_object_table.index (l_referee), l_field_name) - end - i := i + 1 + if attached a_map.item (a_object_id) as l_objects_of_type and attached object_table as l_object_table and attached reference_table as l_reference_table then + from + l_objects_of_type.start + until + l_objects_of_type.after + loop + l_item := l_objects_of_type.item + l_index := l_object_table.index (l_item) + if last_selected_object /= Void and then l_item = last_selected_object then + selected_index := l_index + last_selected_object := Void end - elseif attached {TUPLE} l_item as l_tuple then - l_field_name := once "(tuple_field)" - from - i := l_tuple.lower - until - i > l_tuple.upper - loop - l_referee := l_tuple.item (i) - if l_referee /= Void then - l_reference_table.extend (l_index, l_object_table.index (l_referee), l_field_name) + --| Fixme: we don't know whether it is an once object or not. + if attached name_table as l_name_table then + l_name_table.put (l_name, l_index) + check + not l_name_table.conflict end - i := i + 1 - end - else - from - l_field_count := l_int.field_count_of_type (a_object_id) - i := 1 - until - i > l_field_count or l_item = Current - loop - l_referee := l_int.field (i, l_item) - if l_referee /= Void then - l_field_name := l_int.field_name (i, l_item) - l_reference_table.extend (l_index, l_object_table.index (l_referee), l_field_name) + if attached {SPECIAL [detachable ANY]} l_item as l_special then + l_field_name := once "(special_field)" + from + i := l_special.lower + until + i > l_special.upper + loop + l_referee := l_special.item (i) + if attached l_referee then + l_reference_table.extend (l_index, l_object_table.index (l_referee), l_field_name) + end + i := i + 1 + end + elseif attached {TUPLE} l_item as l_tuple then + l_field_name := once "(tuple_field)" + from + i := l_tuple.lower + until + i > l_tuple.upper + loop + l_referee := l_tuple.item (i) + if l_referee /= Void then + l_reference_table.extend (l_index, l_object_table.index (l_referee), l_field_name) + end + i := i + 1 + end + else + from + l_field_count := l_int.field_count_of_type (a_object_id) + i := 1 + until + i > l_field_count or l_item = Current + loop + l_referee := l_int.field (i, l_item) + if l_referee /= Void then + l_field_name := l_int.field_name (i, l_item) + l_reference_table.extend (l_index, l_object_table.index (l_referee), l_field_name) + end + i := i + 1 + end end - i := i + 1 + else + check attached_l_name_table : false end -- Implied by precondition `set' end + l_objects_of_type.forth end - l_objects_of_type.forth + else + check attached_objects_of_type : false end -- Implied by precondition `has' + check attached_object_table : false end -- Implied by precondition `set' + check attached_reference_table : false end -- Implied by precondition `set' end end @@ -550,7 +553,6 @@ feature {NONE} -- Implementation l_index: like selected_index l_int: INTERNAL l_once_object_table: like once_object_table - l_object_table: like object_table do create l_int create l_once_object_table.make (100) @@ -563,10 +565,12 @@ feature {NONE} -- Implementation loop l_item := l_obj.item (i) if l_item /= Void then - l_object_table := object_table - check attached l_object_table end -- Implied by precondition `set' - l_index := l_object_table.index (l_item) - l_once_object_table.force (l_index, l_index) + if attached object_table as l_object_table then + l_index := l_object_table.index (l_item) + l_once_object_table.force (l_index, l_index) + else + check attached_l_object_table : false end -- Implied by precondition `set' + end end i := i + 1 end @@ -603,8 +607,12 @@ feature {NONE} -- Fields l_result: detachable like row_data do check False end -- Anchor type only - check attached l_result end -- Satisfy void-safe compiler - Result := l_result + if attached l_result as l_res then + Result := l_res + else + check attached_l_result : false end -- Satisfy void-safe compiler + create Result + end end object_grid: EV_GRID @@ -720,7 +728,7 @@ invariant object_grid_not_void: object_grid /= Void note - copyright: "Copyright (c) 1984-2012, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/ma_references_table.e b/ma_references_table.e index 6e7bad1..77b924d 100644 --- a/ma_references_table.e +++ b/ma_references_table.e @@ -74,14 +74,17 @@ feature -- Element change else l_hash := relations.found_item end - check l_hash /= Void end -- Implied by previous if clause - l_hash.force ([a_referee, data], a_referrer) + if attached l_hash as l_h then + l_h.force ([a_referee, data], a_referrer) + else + check attached_l_hash : false end -- Implied by previous if clause + end end feature -- Removal remove (a_referrer: G; a_referee: H) - -- Remove relation between `'a_referrer' and `a_referee'. + -- Remove relation between `'a_referrer' and `a_referee' if it exists a relation. require a_referrer_not_void: a_referrer /= Void a_referee_not_void: a_referee /= Void @@ -90,10 +93,13 @@ feature -- Removal do if relations.has_key (a_referee) then l_hash := relations.found_item - check l_hash /= Void end -- Implied by `has_key' - l_hash.remove (a_referrer) - if l_hash.is_empty then - relations.remove (a_referee) + if attached l_hash as l_h then + l_h.remove (a_referrer) + if l_h.is_empty then + relations.remove (a_referee) + end + else + check attached_l_hash : false end -- Implied by `has_key' end end end @@ -103,14 +109,14 @@ feature {NONE} -- Implementation relations: HASH_TABLE [like references_by_referee, H]; note - copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ - Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA - Telephone 805-685-1006, Fax 805-685-6869 - Website http://www.eiffel.com - Customer support http://support.eiffel.com + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com ]" end diff --git a/ma_route_to_once_searcher.e b/ma_route_to_once_searcher.e index 13423f9..a6eea30 100644 --- a/ma_route_to_once_searcher.e +++ b/ma_route_to_once_searcher.e @@ -92,63 +92,78 @@ feature {NONE} -- Results init_grid (l_grid) result_panel.extend (l_grid) end - check l_grid /= Void end -- Implied by previous if clause - l_column := l_grid.column_count + 1 - l_route_stack := route_stack - check attached l_route_stack end -- Implied by precondition `set' - l_array := l_route_stack.linear_representation - l_grid.set_row_count_to (l_array.count.max (l_grid.row_count)) - l_grid.set_column_count_to (l_column) - l_grid.column (l_column).set_title ("Route" + l_column.out) - from - l_array.start - until - l_array.after - loop - if not l_array.islast then - l_next_index := l_array [l_array.index + 1] - else - l_last := True - end - if not l_last then - l_reference_table := reference_table - check l_reference_table /= Void end -- Implied by precondition `set' - l_tuple := l_reference_table.references_by_referee (l_next_index).item (l_array.item) - if l_tuple /= Void then - if attached {STRING} l_tuple.data as l_string then - l_field_name := l_string + if attached l_grid as l_l_grid then + l_column := l_l_grid.column_count + 1 + l_route_stack := route_stack + if attached l_route_stack as l_r then + l_array := l_r.linear_representation + l_l_grid.set_row_count_to (l_array.count.max (l_l_grid.row_count)) + l_l_grid.set_column_count_to (l_column) + l_l_grid.column (l_column).set_title ("Route" + l_column.out) + from + l_array.start + until + l_array.after + loop + if not l_array.islast then + l_next_index := l_array [l_array.index + 1] + else + l_last := True + end + if not l_last then + l_reference_table := reference_table + if attached l_reference_table as l_ref then + l_tuple := l_ref.references_by_referee (l_next_index).item (l_array.item) + else + check attached_l_reference_table : false end -- Implied by precondition `set' + end + if l_tuple /= Void then + if attached {STRING} l_tuple.data as l_string then + l_field_name := l_string + else + --|FIXME: 2012/04/06 Shouldn't this be "(unknown)", instead of setting it Void? See review#7644004. + l_field_name := Void + end + else + l_field_name := once "(unknown)" + end else --|FIXME: 2012/04/06 Shouldn't this be "(unknown)", instead of setting it Void? See review#7644004. l_field_name := Void end - else - l_field_name := once "(unknown)" + if l_field_name = Void then + l_field_name := once "" + else + l_field_name := l_field_name.twin + l_field_name.prepend (".") + end + -- Optimization, since we know that only the first object is once object. + if l_array.isfirst then + l_once := once "*" + else + l_once := once "" + end + l_name_table := name_table + if attached l_name_table as l_n then + l_name_table_item := l_n.item (l_array.item) + if attached l_name_table_item as l_name_item then + l_text := l_once + l_array.item.out + once ": {" + l_name_item + once "}" + l_field_name + create l_item.make_with_text (l_text) + l_item.set_tooltip (l_text) + l_l_grid.set_item (l_column, l_array.index, l_item) + l_array.forth + else + check attached_l_name_table_item : false end -- FIXME: Implied by ...? + end + else + check attached_l_name_table : false end -- Implied by precondition `set' + end end else - --|FIXME: 2012/04/06 Shouldn't this be "(unknown)", instead of setting it Void? See review#7644004. - l_field_name := Void - end - if l_field_name = Void then - l_field_name := once "" - else - l_field_name := l_field_name.twin - l_field_name.prepend (".") - end - -- Optimization, since we know that only the first object is once object. - if l_array.isfirst then - l_once := once "*" - else - l_once := once "" + check attached_l_route_stack : false end -- Implied by precondition `set' end - l_name_table := name_table - check l_name_table /= Void end -- Implied by precondition `set' - l_name_table_item := l_name_table.item (l_array.item) - check l_name_table_item /= Void end -- FIXME: Implied by ...? - l_text := l_once + l_array.item.out + once ": {" + l_name_table_item + once "}" + l_field_name - create l_item.make_with_text (l_text) - l_item.set_tooltip (l_text) - l_grid.set_item (l_column, l_array.index, l_item) - l_array.forth + else + check attached_l_grid : false end -- Implied by previous if clause end end @@ -183,13 +198,19 @@ feature {NONE} -- Results inspect a_key.code when {EV_KEY_CONSTANTS}.key_a then l_grid := grid - check l_grid /= Void end -- Implied by precondition `grid_set' - select_all_row (l_grid) + if attached l_grid as l_g then + select_all_row (l_g) + else + check attached_l_grid :false end -- Implied by precondition `grid_set' + end when {EV_KEY_CONSTANTS}.key_c then l_grid := grid - check l_grid /= Void end -- Implied by precondition `grid_set' - if not l_grid.selected_items.is_empty then - copy_selected_items (l_grid) + if attached l_grid as l_g then + if not l_g.selected_items.is_empty then + copy_selected_items (l_g) + end + else + check attached_l_grid : false end -- Implied by precondition `grid_set' end else end @@ -318,15 +339,18 @@ feature {NONE} -- Implementation create l_route_stack.make (1000) route_stack := l_route_stack l_reference_table := reference_table - check l_reference_table /= Void end -- Implied by precondition `set' - create visited_references.make (l_reference_table.referee_count) - if deep_visit_node (start_index) then - -- Found route - check - route_stack_not_empty: not l_route_stack.is_empty + if attached l_reference_table as l_r then + create visited_references.make (l_r.referee_count) + if deep_visit_node (start_index) then + -- Found route + check + route_stack_not_empty: not l_route_stack.is_empty + end + fill_results + remove_last_link_to_once end - fill_results - remove_last_link_to_once + else + check attached_l_reference_table : false end -- Implied by precondition `set' end end @@ -350,61 +374,67 @@ feature {NONE} -- Implementation deep_visit_node (a_referee: like start_index): BOOLEAN -- Deep visit a node, Ture is found once object. require - set: attached reference_table + set: attached reference_table as l_reference_table and then attached l_reference_table.references_by_referee (a_referee) set: attached route_stack set: attached visited_references local - l_all_referrers, l_visited_referrers: HASH_TABLE [TUPLE [like start_index, detachable ANY], like start_index] + l_visited_referrers: HASH_TABLE [TUPLE [like start_index, detachable ANY], like start_index] l_referrer: like start_index l_all_referrers_count: INTEGER - l_visited_references: like visited_references - l_reference_table: like reference_table - l_route_stack: like route_stack do if is_visited (a_referee) then Result := False else - l_route_stack := route_stack - check l_route_stack /= Void end -- Implied by precondition `set' - l_route_stack.put (a_referee) - l_reference_table := reference_table - check l_reference_table /= Void end -- Implied by precondition `set' - l_all_referrers := l_reference_table.references_by_referee (a_referee) - l_all_referrers_count := l_all_referrers.count - if l_all_referrers_count = 0 then - -- We reach the end. No referrer. - if is_once_object (a_referee) then - Result := True - else - Result := False - end - elseif is_once_object (a_referee) then - Result := True - else - l_visited_references := visited_references - check attached l_visited_references end -- Implied by precondition `set' - l_visited_referrers := l_visited_references.references_by_referee (a_referee) - if l_all_referrers_count = l_visited_referrers.count then - -- Go back one - Result := False - l_route_stack.remove - else - from - l_all_referrers.start - until - l_all_referrers.after or Result - loop - l_referrer := l_all_referrers.key_for_iteration - if not l_visited_referrers.has_key (l_referrer) then - l_visited_references.extend (l_referrer, a_referee, Void) - Result := deep_visit_node (l_referrer) + if attached route_stack as l_route_stack then + l_route_stack.put (a_referee) + if attached reference_table as l_reference_table then + if attached l_reference_table.references_by_referee (a_referee) as l_all_referrers then + l_all_referrers_count := l_all_referrers.count + if l_all_referrers_count = 0 then + -- We reach the end. No referrer. + if is_once_object (a_referee) then + Result := True + else + Result := False + end + elseif is_once_object (a_referee) then + Result := True + else + if attached visited_references as l_visited_references then + l_visited_referrers := l_visited_references.references_by_referee (a_referee) + if l_all_referrers_count = l_visited_referrers.count then + -- Go back one + Result := False + l_route_stack.remove + else + from + l_all_referrers.start + until + l_all_referrers.after or Result + loop + l_referrer := l_all_referrers.key_for_iteration + if not l_visited_referrers.has_key (l_referrer) then + l_visited_references.extend (l_referrer, a_referee, Void) + Result := deep_visit_node (l_referrer) + end + l_all_referrers.forth + end + if not Result then + l_route_stack.remove + end + end + else + check attached_l_visited_references : false end -- Implied by precondition `set' + end end - l_all_referrers.forth - end - if not Result then - l_route_stack.remove + else + check attached_l_reference_table_references_by_referee : false end -- Implied by precondition `set' end + else + check attached_l_reference_table : false end -- Implied by precondition `set' end + else + check attached_l_route_stack : false end -- Implied by precondition `set' end end end @@ -434,24 +464,24 @@ feature {NONE} -- Implementation -- Is `a_node' visited? require set: attached route_stack - local - l_route_stack: like route_stack do - l_route_stack := route_stack - check l_route_stack /= Void end -- Implied by precondition `set' - Result := l_route_stack.has (a_node) + if attached route_stack as l_route_stack then + Result := l_route_stack.has (a_node) + else + check attached_route_stack : false end -- Implied by precondition `set' + end end is_once_object (a_object: like start_index): BOOLEAN -- Is `a_object' once? require set: attached once_objects_table - local - l_table: like once_objects_table do - l_table := once_objects_table - check attached l_table end -- Implied by precondition `set' - Result := l_table.has (a_object) + if attached once_objects_table as l_table then + Result := l_table.has (a_object) + else + check attached_l_table : false end -- Implied by precondition `set' + end end route_stack: detachable ARRAYED_STACK [like start_index] @@ -465,7 +495,7 @@ invariant result_panel_not_void: result_panel /= Void note - copyright: "Copyright (c) 1984-2012, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/memory_analyzer-safe.ecf b/memory_analyzer-safe.ecf index 72f0c0e..2111fd3 100644 --- a/memory_analyzer-safe.ecf +++ b/memory_analyzer-safe.ecf @@ -1,5 +1,5 @@ - + Memory analyzer library: Track down your memory usage within your application. Copyright (c) 1984-2006, Eiffel Software and others. @@ -12,7 +12,7 @@ - + diff --git a/memory_analyzer.ecf b/memory_analyzer.ecf index 10ecf93..2daee36 100644 --- a/memory_analyzer.ecf +++ b/memory_analyzer.ecf @@ -1,12 +1,14 @@ - + - Memory analyzer library: Track down your memory usage within your application. Copyright (c) 1984-2006, Eiffel Software and others. Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt). + Memory analyzer library: Track down your memory usage within your application. + Copyright (c) 1984-2006, Eiffel Software and others. + Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt). /\.svn - diff --git a/object_graph/ma_figure_factory.e b/object_graph/ma_figure_factory.e index d4c3baa..366ee67 100644 --- a/object_graph/ma_figure_factory.e +++ b/object_graph/ma_figure_factory.e @@ -39,8 +39,12 @@ feature -- Basic operations l_result: detachable like model_from_xml do check not_implemented: False end - check attached l_result end -- Satisfy void-safe compiler - Result := l_result + if attached l_result as l_r then + Result := l_r + else + check attached_l_result: false end -- Satisfy void-safe compiler + create Result -- If no precondtions or checks are switch on this statement will be executed. However, since it is not implemented according to first check statement it might be that we should remove the feature? + end -- node_name := node.name -- if node_name.is_equal ("ELLIPSE_NODE") then -- create {EG_NODE} Result @@ -63,14 +67,14 @@ feature -- Basic operations end note - copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ - Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA - Telephone 805-685-1006, Fax 805-685-6869 - Website http://www.eiffel.com - Customer support http://support.eiffel.com + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com ]" diff --git a/object_graph/ma_object_graph_mediator.e b/object_graph/ma_object_graph_mediator.e index 9bb3f3b..615e81c 100644 --- a/object_graph/ma_object_graph_mediator.e +++ b/object_graph/ma_object_graph_mediator.e @@ -83,8 +83,12 @@ feature -- Command end objects_already_draw.forth end - check attached l_result end -- FIXME: Implied by ...? - Result := l_result + if attached l_result as l_r then + Result := l_r + else + check attached_l_result : false end -- FIXME: Implied by ...? + create Result.default_create -- FIXME: Since we do not have a (clear) precondition we are not allowed to return like this. Need precondition. + end ensure result_not_void : Result /= Void end @@ -172,26 +176,30 @@ feature -- Command graph.add_node (l_last_drawn_node) fig := world.figure_from_model (l_last_drawn_node) - check attached fig end -- Implied by `l_last_drawn_node' has been just added - fig.set_point_position (ax, ay) - - -- Make new node figure a drop target - fig.set_accept_cursor (accept_node) - fig.set_deny_cursor (deny_node) --- fig.drop_actions.extend (agent on_link_drop (?, last_drawn_node)) - - -- Make new node figure pickable --- fig.set_pebble (create {NODE_STONE}.make (last_drawn_node)) - - fig.pointer_button_release_actions.extend (agent on_select_node) - l_tuple := [a_object, l_last_drawn_node] - check - a_object /= Void - last_drawn_node /= Void + if attached fig as l_fig then + + l_fig.set_point_position (ax, ay) + + -- Make new node figure a drop target + l_fig.set_accept_cursor (accept_node) + l_fig.set_deny_cursor (deny_node) + -- l_fig.drop_actions.extend (agent on_link_drop (?, last_drawn_node)) + + -- Make new node figure pickable + -- l_fig.set_pebble (create {NODE_STONE}.make (last_drawn_node)) + + l_fig.pointer_button_release_actions.extend (agent on_select_node) + l_tuple := [a_object, l_last_drawn_node] + check + a_object /= Void + last_drawn_node /= Void + end + world.update + -- Put the object and the node into the hashtable + objects_already_draw.force (l_tuple, l_fig) + else + check attached_fig : false end -- Implied by `l_last_drawn_node' has been just added end - world.update - -- Put the object and the node into the hashtable - objects_already_draw.force (l_tuple, fig) end on_select_node (a_x: INTEGER; a_y: INTEGER; a_button: INTEGER; a_x_tilt: DOUBLE; a_y_tilt: DOUBLE; a_pressure: DOUBLE; a_screen_x: INTEGER; a_screen_y: INTEGER) @@ -234,6 +242,9 @@ feature -- Implementation for agents find_refers -- Find the refers to current slected node and draw the nodes which refer to it. + require + figures_exists: world.selected_figures.count > 0 + attached_item : attached objects_already_draw.item (world.selected_figures.first) local l_nodes: ARRAYED_LIST [EG_FIGURE] l_node: EG_FIGURE @@ -250,38 +261,50 @@ feature -- Implementation for agents if l_nodes.count > 0 then l_node := l_nodes.first l_item := objects_already_draw.item (l_node) - check attached l_item end -- FIXME: Implied by ...? - l_object := l_item.obj - l_refers := memory.referers (l_object) - from - l_int := 0 - refer_count := l_refers.count - until - l_int = refer_count - loop - if object_already_draw(l_refers.item (l_int)) then - -- add link to two already drawed object - l_link_node := find_draw_node_by_object(l_refers.item (l_int)) - l_item := objects_already_draw.item (l_node) - check attached l_item end -- FIXME: Implied by ...? - l_linkable := l_item.node - check - l_linkable /= Void + if attached l_item as l_i then + l_object := l_i.obj + l_refers := memory.referers (l_object) + from + l_int := 0 + refer_count := l_refers.count + until + l_int = refer_count + loop + if object_already_draw(l_refers.item (l_int)) then + -- add link to two already drawed object + l_link_node := find_draw_node_by_object(l_refers.item (l_int)) + l_item := objects_already_draw.item (l_node) + if attached l_item as l_it then + l_linkable := l_it.node + check + l_linkable /= Void + end + add_link (l_linkable, l_link_node ) + else + check attached_l_item : false end -- FIXME: Implied by that we iterate over the available number of items. + end + else + add_node_random_pos(l_refers.item (l_int)) + l_item := objects_already_draw.item (l_node) + if attached l_item as l_it then + l_linkable := l_it.node + check + l_linkable /= Void + end + l_last_drawn_node := last_drawn_node + if attached l_last_drawn_node as l_last then + add_link (l_linkable, l_last) + else + check attachedl_last_drawn_node : false end -- FIXME: Implied by ...? Can not understand if this is impleied or not. + end + else + check attached_l_item : false end -- Implied by that we iterate over the available number of items. + end end - add_link (l_linkable, l_link_node ) - else - add_node_random_pos(l_refers.item (l_int)) - l_item := objects_already_draw.item (l_node) - check attached l_item end -- FIXME: Implied by ...? - l_linkable := l_item.node - check - l_linkable /= Void - end - l_last_drawn_node := last_drawn_node - check attached l_last_drawn_node end -- FIXME: Implied by ...? - add_link (l_linkable, l_last_drawn_node) + l_int := l_int + 1 end - l_int := l_int + 1 + else + check attached_l_item : false end -- FIXME: Implied by precondition end else create l_info_dlg.make_with_text ("Please select a node first.") @@ -441,6 +464,9 @@ feature {NONE} -- Low Level Logic Implementation once create Result.make end +feature + objects_already_draw: HASH_TABLE [TUPLE [obj: ANY; node: EG_NODE], EG_FIGURE] + -- Objects which is already draw on the graph, ANY is the object which EG_NODE is correspond to feature {NONE} -- Fields @@ -456,13 +482,12 @@ feature {NONE} -- Fields last_drawn_node: detachable EG_NODE --Node which was just drawed - objects_already_draw: HASH_TABLE [TUPLE [obj: ANY; node: EG_NODE], EG_FIGURE] - -- Objects which is already draw on the graph, ANY is the object which EG_NODE is correspond to - object_drawing : EV_FRAME -- Place this class to draw graphics of objects +feature world: EG_FIGURE_WORLD -- World allowing to manipulate the graph. +feature {NONE} model_cell: MA_WORLD_CELL -- Cell allowing to edit the graph. graph: EG_GRAPH @@ -486,7 +511,7 @@ invariant objects_already_draw_has_no_void_item: True-- No Void items in `objects_already_draw' note - copyright: "Copyright (c) 1984-2012, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/object_graph/ma_reference_link.e b/object_graph/ma_reference_link.e index cf5f669..f39ee7f 100644 --- a/object_graph/ma_reference_link.e +++ b/object_graph/ma_reference_link.e @@ -99,50 +99,54 @@ feature -- Element change feature {EG_FIGURE, EG_FIGURE_WORLD} -- Update update + require else + model_attached : attached model -- Some properties may have changed. local p1, p2: EV_COORDINATE an_angle: DOUBLE source_size: EV_RECTANGLE - l_model: like model do - l_model := model - check attached l_model end -- FIXME: Implied by ...? - if not l_model.is_reflexive then - if attached source as l_source and then attached target as l_target then - p1 := line.point_array.item (0) - p2 := line.point_array.item (1) - - p1.set (l_source.port_x, l_source.port_y) - p2.set (l_target.port_x, l_target.port_y) - - an_angle := line_angle (p1.x_precise, p1.y_precise, p2.x_precise, p2.y_precise) - l_source.update_edge_point (p1, an_angle) - an_angle := pi + an_angle - l_target.update_edge_point (p2, an_angle) - elseif attached source as l_source_2 then - p1 := line.point_array.item (0) - p1.set (l_source_2.port_x, l_source_2.port_y) - l_source_2.update_edge_point (p1, 0) - elseif attached target as l_target_2 then - p2 := line.point_array.item (1) - p2.set (l_target_2.port_x, l_target_2.port_y) - l_target_2.update_edge_point (p2, 0) - end - - line.invalidate - line.center_invalidate - if is_label_shown then - name_label.set_point_position (line.x, line.y) + if attached model as l_model then + if not l_model.is_reflexive then + if attached source as l_source and then attached target as l_target then + p1 := line.point_array.item (0) + p2 := line.point_array.item (1) + + p1.set (l_source.port_x, l_source.port_y) + p2.set (l_target.port_x, l_target.port_y) + + an_angle := line_angle (p1.x_precise, p1.y_precise, p2.x_precise, p2.y_precise) + l_source.update_edge_point (p1, an_angle) + an_angle := pi + an_angle + l_target.update_edge_point (p2, an_angle) + elseif attached source as l_source_2 then + p1 := line.point_array.item (0) + p1.set (l_source_2.port_x, l_source_2.port_y) + l_source_2.update_edge_point (p1, 0) + elseif attached target as l_target_2 then + p2 := line.point_array.item (1) + p2.set (l_target_2.port_x, l_target_2.port_y) + l_target_2.update_edge_point (p2, 0) + end + + line.invalidate + line.center_invalidate + if is_label_shown then + name_label.set_point_position (line.x, line.y) + end + else + if attached source as l_source_3 then + source_size := l_source_3.size + reflexive.set_x_y (source_size.right + reflexive.radius1, source_size.top + source_size.height // 2) + end + if is_label_shown then + name_label.set_point_position (reflexive.x + reflexive.radius1, reflexive.y) + end end else - if attached source as l_source_3 then - source_size := l_source_3.size - reflexive.set_x_y (source_size.right + reflexive.radius1, source_size.top + source_size.height // 2) - end - if is_label_shown then - name_label.set_point_position (reflexive.x + reflexive.radius1, reflexive.y) - end + check attached_model : false end -- Implied by precondition model_attached + -- if model is not attached the precondtion is not satisfied and we just ignore the call to update since the behaviour is undefined. end is_update_required := False end @@ -185,14 +189,14 @@ invariant line_not_void: line /= Void note - copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ - Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA - Telephone 805-685-1006, Fax 805-685-6869 - Website http://www.eiffel.com - Customer support http://support.eiffel.com + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com ]" diff --git a/singletons/ma_icons_singleton.e b/singletons/ma_icons_singleton.e index d628f05..2eaaa03 100644 --- a/singletons/ma_icons_singleton.e +++ b/singletons/ma_icons_singleton.e @@ -34,12 +34,18 @@ feature {NONE} -- Implementation pixmap_path: PATH -- Path containing all of the Memory Analyzer icons + require else + attached_pixmap_path : attached internal_pixmap_path local l_result: like internal_pixmap_path do l_result := internal_pixmap_path - check attached l_result end -- FIXME: Implied by ...? - Result := l_result + if attached l_result as l_r then -- + Result := l_r + else + check l_result_attached : false end -- Implied by precondition attached_pixmap_path + create Result.make_empty -- Since the behaviour is undefined when precondition is not satisfied we are allowed to return an empty path + end end internal_pixmap_path: detachable like pixmap_path @@ -263,7 +269,7 @@ feature {NONE} -- Icons' Names -- Icon names note - copyright: "Copyright (c) 1984-2012, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/singletons/ma_shared_pixmap_factory.e b/singletons/ma_shared_pixmap_factory.e index 84256ed..cba5612 100644 --- a/singletons/ma_shared_pixmap_factory.e +++ b/singletons/ma_shared_pixmap_factory.e @@ -100,8 +100,11 @@ feature {NONE} -- Implementation result_compares_objects: Result.object_comparison end + + + note - copyright: "Copyright (c) 1984-2012, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/singletons/ma_singleton_factory.e b/singletons/ma_singleton_factory.e index 4350ce3..d4f0358 100644 --- a/singletons/ma_singleton_factory.e +++ b/singletons/ma_singleton_factory.e @@ -77,8 +77,12 @@ feature -- Singletons l_item: detachable MA_WINDOW do l_item := internal_main_window.item - check attached l_item end -- Implied by precondition - Result := l_item + if attached l_item as l_i then + Result := l_item + else + check l_item_attached : false end -- Implied by precondition + create Result.make ("") -- Since the behaviour is undefined when precondition is not satisfied we are allowed to return an undefined window. + end ensure result_not_void: Result /= Void end @@ -235,14 +239,14 @@ invariant internal_main_window_not_void: internal_main_window /= Void note - copyright: "Copyright (c) 1984-2008, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ - Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA - Telephone 805-685-1006, Fax 805-685-6869 - Website http://www.eiffel.com - Customer support http://support.eiffel.com + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com ]" end diff --git a/widgets/ma_constants_imp.e b/widgets/ma_constants_imp.e index 586a225..67ec217 100644 --- a/widgets/ma_constants_imp.e +++ b/widgets/ma_constants_imp.e @@ -453,8 +453,12 @@ feature -- Access l_item: detachable STRING do l_item := all_constants.item (a_name) - check l_item /= Void end -- Implied by precondition `has_constant' - Result := l_item.twin + if attached l_item as l_i then + Result := l_item.twin + else + check l_item_attached : false end -- Implied by precondition `has_constant' + create Result.make_empty -- Since the behaviour is undefined when precondition is not satisfied we are allowed to return an empty string + end ensure Result_not_void: Result /= Void end @@ -470,8 +474,12 @@ feature -- Access l_item: detachable STRING do l_item := all_constants.item (a_name) - check l_item /= Void end -- Implied by precondition `has_constant' - l_string := l_item.twin + if attached l_item as l_i then + l_string := l_item.twin + else + check l_item_attached : false end -- Implied by precondition `has_constant' + create l_string.make_empty -- Since the behaviour is undefined when precondition is not satisfied we are allowed to return 0 + end check is_integer: l_string.is_integer end @@ -580,14 +588,14 @@ invariant all_constants_not_void: all_constants /= Void note - copyright: "Copyright (c) 1984-2008, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ - Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA - Telephone 805-685-1006, Fax 805-685-6869 - Website http://www.eiffel.com - Customer support http://support.eiffel.com + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com ]" end -- class MA_CONSTANTS_IMP diff --git a/widgets/ma_filter_window.e b/widgets/ma_filter_window.e index 6aeb48d..f231578 100644 --- a/widgets/ma_filter_window.e +++ b/widgets/ma_filter_window.e @@ -184,11 +184,16 @@ feature {NONE} -- Implementation do add_new_row (Void) l_last_row := grid.last_visible_row - check attached l_last_row end -- FIXME: Implied by ...? - if attached {EV_GRID_EDITABLE_ITEM} l_last_row.item (1) as l_item then - l_item.activate + if attached l_last_row as l_last_r then + if attached {EV_GRID_EDITABLE_ITEM} l_last_row.item (1) as l_item then + l_item.activate + else + check not_editable_item: False end + -- FIXMED: Implied by ...? Do we miss a precondition or invariant? + end else - check not_editable_item: False end + check l_last_row_attached : false end + -- FIXME: Implied by ...? Do we miss a precondition or invariant? end end @@ -296,8 +301,12 @@ feature {NONE} -- Implementation l_result: detachable like a_filter_data do check False end -- Anchor type only - check attached l_result end -- Satisfy void-safe compiler - Result := l_result + if attached l_result as l_res then + Result := l_result + else -- Satisfy void-safe compile. Since precondition states false the behaviour is not defined if called without precondition and checks. + check l_result_attached : false end + create Result + end end hash_table_datas_to_arrayed_list_datas: MA_ARRAYED_LIST_STORABLE [like a_filter_data] @@ -354,7 +363,7 @@ invariant grid_not_void: grid /= Void note - copyright: "Copyright (c) 1984-2012, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/widgets/ma_grid_check_box_item.e b/widgets/ma_grid_check_box_item.e index 0c9966d..26019fb 100644 --- a/widgets/ma_grid_check_box_item.e +++ b/widgets/ma_grid_check_box_item.e @@ -21,7 +21,7 @@ feature {NONE} -- Initialization -- Creation method. do create selected_changed_actions - + default_create expose_actions.extend (agent draw_overlay_pixmap) pointer_button_press_actions.force_extend (agent handle_pointer_pressed) @@ -108,8 +108,11 @@ feature {NONE} -- Implementation a_drawable.set_foreground_color (l_row_background_color) else l_parent_2 := parent - check attached l_parent_2 end -- FIXME: Implied by ...? - a_drawable.set_foreground_color (l_parent_2.background_color) + if attached l_parent_2 as l_p then + a_drawable.set_foreground_color (l_p.background_color) + else + check l_parent_2_attached : false end -- FIXME: Implied by ...? -- I have tried to understand if the state of the current instance tells us that this will not happen. Next step would be to define a precondition or invariant. At least the behaviour is not worse than before this change. + end end end a_drawable.fill_rectangle (0, 0, a_drawable.width, a_drawable.height) @@ -242,14 +245,14 @@ invariant selected_changed_actions_not_void: selected_changed_actions /= Void note - copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ - Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA - Telephone 805-685-1006, Fax 805-685-6869 - Website http://www.eiffel.com - Customer support http://support.eiffel.com + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com ]" diff --git a/widgets/ma_window.e b/widgets/ma_window.e index 66ac530..eb1f2b7 100644 --- a/widgets/ma_window.e +++ b/widgets/ma_window.e @@ -60,8 +60,8 @@ feature {NONE} -- Initialization do set_main_window (Current) - attached_timer.actions.extend (agent timer_event) - attached_timer.set_interval (refresh_interval) + timer.actions.extend (agent timer_event) + timer.set_interval (refresh_interval) main_book.drop_actions.extend (agent main_book_drop_pebble) main_book.drop_actions.set_veto_pebble_function (agent main_book_dropable) @@ -84,7 +84,7 @@ feature {NONE} -- Initialization search_route_button.select_actions.extend (agent search_route) ensure then main_window_set: main_window_not_void - timer_action_set: attached_timer.actions.count > 0 + timer_action_set: timer.actions.count > 0 notebook_drop_action_set: main_book.drop_actions.count > 0 update_interval_set_normal: refresh_interval = refresh_interval_normal auto_refresh_button_selected: auto_refresh.is_selected @@ -138,9 +138,9 @@ feature -- Redefine destroy -- Destroy window, clear singleton. do - attached_timer.set_interval (0) - attached_timer.actions.wipe_out - timer := Void + timer.set_interval (0) + timer.actions.wipe_out + timer.set_interval (0) main_book.drop_actions.wipe_out filter_setting.drop_actions.wipe_out show_actions.wipe_out @@ -199,14 +199,14 @@ feature {NONE} -- Implementation for agents -- Enable or disable auto refresh memory graph. do if auto_refresh.is_selected then - attached_timer.set_interval (refresh_interval) + timer.set_interval (refresh_interval) auto_refresh.set_tooltip ("Auto refresh enabled") else - attached_timer.set_interval (0) + timer.set_interval (0) auto_refresh.set_tooltip ("Auto refresh disabled") end ensure then - timer_state_changed: old attached_timer.interval /= attached_timer.interval + timer_state_changed: old timer.interval /= timer.interval auto_refresh_tooltip_changed: old auto_refresh.tooltip /= auto_refresh.tooltip end @@ -221,32 +221,32 @@ feature {NONE} -- Implementation for agents analyze_object_snap.set_finding_route_to_once (False) end ensure then --- timer_state_changed: old attached_timer.interval /= attached_timer.interval +-- timer_state_changed: old timer.interval /= timer.interval auto_refresh_tooltip_changed: old auto_refresh.tooltip /= auto_refresh.tooltip end auto_refresh_change_speed -- Change the refresh speed. do - if attached_timer.interval /= 0 then + if timer.interval /= 0 then inspect refresh_interval when refresh_interval_low then refresh_interval := refresh_interval_normal - attached_timer.set_interval (refresh_interval) + timer.set_interval (refresh_interval) refresh_speed.set_tooltip ("Refresh speed is normal") when refresh_interval_normal then refresh_interval := refresh_interval_hi - attached_timer.set_interval (refresh_interval) + timer.set_interval (refresh_interval) refresh_speed.set_tooltip ("Refresh speed is hi") when refresh_interval_hi then refresh_interval := refresh_interval_low - attached_timer.set_interval (refresh_interval) + timer.set_interval (refresh_interval) refresh_speed.set_tooltip ("Refresh speed is low") end end ensure then - refresh_speed_toollip_changed: attached_timer.interval /= 0 implies old refresh_speed.tooltip /= refresh_speed.tooltip - timer_interval_changed: attached_timer.interval /= 0 implies old attached_timer.interval /= attached_timer.interval + refresh_speed_toollip_changed: timer.interval /= 0 implies old refresh_speed.tooltip /= refresh_speed.tooltip + timer_interval_changed: timer.interval /= 0 implies old timer.interval /= timer.interval end arrange_circle_clicked @@ -436,23 +436,9 @@ feature {NONE} -- Implementation analyze_route_searcher: MA_ROUTE_TO_ONCE_SEARCHER -- Searcher for routes to once object. - timer: detachable EV_TIMEOUT + timer: EV_TIMEOUT -- The timer used for update histogram and history. - attached_timer: EV_TIMEOUT - -- Attached `timer' - require - set: attached timer - local - l_result: like timer - do - l_result := timer - check attached l_result end -- Implied by precondition - Result := l_result - ensure - not_void: attached Result - end - refresh_interval: INTEGER -- The time of interval between refersh. @@ -482,7 +468,7 @@ invariant main_book_has_tab_states_compare: main_book.has (tab_states_compare) note - copyright: "Copyright (c) 1984-2012, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software From 3118903ed67e58aa18e2296f7395259eed35442e Mon Sep 17 00:00:00 2001 From: Conaclos Date: Sat, 22 Mar 2014 14:40:41 +0100 Subject: [PATCH 2/3] Adapt memory analyzer library to both soft and advanced redesign of eiffel graph library, available at "https://github.com/Conaclos/EG-complete-safe". --- object_graph/ma_object_node.e | 19 +++---- object_graph/ma_reference_link.e | 88 ++++++++++++++++---------------- 2 files changed, 51 insertions(+), 56 deletions(-) diff --git a/object_graph/ma_object_node.e b/object_graph/ma_object_node.e index 5329973..3795c5b 100644 --- a/object_graph/ma_object_node.e +++ b/object_graph/ma_object_node.e @@ -21,9 +21,6 @@ inherit create make_with_model -create {MA_OBJECT_NODE} - make_filled - feature {NONE} -- Initialization default_create @@ -60,7 +57,7 @@ feature {NONE} -- Initialization feature -- Access - model: detachable EG_NODE + model: EG_NODE -- Model `Current' is a view for. port_x: INTEGER @@ -178,21 +175,21 @@ feature {NONE} -- Implementation new_filled_list (n: INTEGER): like Current -- New list with `n' elements. do - create Result.make_filled (n) + check unimplemented: False then end end invariant node_figure_not_void: node_figure /= Void note - copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + copyright: "Copyright (c) 1984-2014, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ - Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA - Telephone 805-685-1006, Fax 805-685-6869 - Website http://www.eiffel.com - Customer support http://support.eiffel.com + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com ]" diff --git a/object_graph/ma_reference_link.e b/object_graph/ma_reference_link.e index f39ee7f..2c4ee78 100644 --- a/object_graph/ma_reference_link.e +++ b/object_graph/ma_reference_link.e @@ -12,15 +12,13 @@ inherit EG_LINK_FIGURE redefine default_create, - xml_node_name + xml_node_name, + model end create make_with_model -create {MA_REFERENCE_LINK} - make_filled - feature {NONE} -- Initialization default_create @@ -39,8 +37,8 @@ feature {NONE} -- Initialization require a_model_not_void: a_model /= Void do - default_create model := a_model + default_create initialize if a_model.is_directed then @@ -60,6 +58,10 @@ feature {NONE} -- Initialization feature -- Access + model: EG_LINK + -- + -- Not useful redefinition if the library rely on a graph library with `model' attached. + set_color -- Set the color of the reference line. do @@ -107,46 +109,41 @@ feature {EG_FIGURE, EG_FIGURE_WORLD} -- Update an_angle: DOUBLE source_size: EV_RECTANGLE do - if attached model as l_model then - if not l_model.is_reflexive then - if attached source as l_source and then attached target as l_target then - p1 := line.point_array.item (0) - p2 := line.point_array.item (1) - - p1.set (l_source.port_x, l_source.port_y) - p2.set (l_target.port_x, l_target.port_y) - - an_angle := line_angle (p1.x_precise, p1.y_precise, p2.x_precise, p2.y_precise) - l_source.update_edge_point (p1, an_angle) - an_angle := pi + an_angle - l_target.update_edge_point (p2, an_angle) - elseif attached source as l_source_2 then - p1 := line.point_array.item (0) - p1.set (l_source_2.port_x, l_source_2.port_y) - l_source_2.update_edge_point (p1, 0) - elseif attached target as l_target_2 then - p2 := line.point_array.item (1) - p2.set (l_target_2.port_x, l_target_2.port_y) - l_target_2.update_edge_point (p2, 0) - end - - line.invalidate - line.center_invalidate - if is_label_shown then - name_label.set_point_position (line.x, line.y) - end - else - if attached source as l_source_3 then - source_size := l_source_3.size - reflexive.set_x_y (source_size.right + reflexive.radius1, source_size.top + source_size.height // 2) - end - if is_label_shown then - name_label.set_point_position (reflexive.x + reflexive.radius1, reflexive.y) - end + if not model.is_reflexive then + if attached source as l_source and then attached target as l_target then + p1 := line.point_array.item (0) + p2 := line.point_array.item (1) + + p1.set (l_source.port_x, l_source.port_y) + p2.set (l_target.port_x, l_target.port_y) + + an_angle := line_angle (p1.x_precise, p1.y_precise, p2.x_precise, p2.y_precise) + l_source.update_edge_point (p1, an_angle) + an_angle := pi + an_angle + l_target.update_edge_point (p2, an_angle) + elseif attached source as l_source_2 then + p1 := line.point_array.item (0) + p1.set (l_source_2.port_x, l_source_2.port_y) + l_source_2.update_edge_point (p1, 0) + elseif attached target as l_target_2 then + p2 := line.point_array.item (1) + p2.set (l_target_2.port_x, l_target_2.port_y) + l_target_2.update_edge_point (p2, 0) + end + + line.invalidate + line.center_invalidate + if is_label_shown then + name_label.set_point_position (line.x, line.y) end else - check attached_model : false end -- Implied by precondition model_attached - -- if model is not attached the precondtion is not satisfied and we just ignore the call to update since the behaviour is undefined. + if attached source as l_source_3 then + source_size := l_source_3.size + reflexive.set_x_y (source_size.right + reflexive.radius1, source_size.top + source_size.height // 2) + end + if is_label_shown then + name_label.set_point_position (reflexive.x + reflexive.radius1, reflexive.y) + end end is_update_required := False end @@ -168,7 +165,7 @@ feature {NONE} -- Implementation on_is_directed_change -- `model'.`is_directed' changed. do - if attached model as l_model and then l_model.is_directed then + if model.is_directed then line.enable_end_arrow else line.disable_end_arrow @@ -182,11 +179,12 @@ feature {NONE} -- Implementation new_filled_list (n: INTEGER): like Current -- New list with `n' elements. do - create Result.make_filled (n) + check unimplemented: False then end end invariant line_not_void: line /= Void + mdeol_not_void: model /= Void note copyright: "Copyright (c) 1984-2014, Eiffel Software and others" From 5bee8c5dd4e45365cc7883e65e70071646760d4d Mon Sep 17 00:00:00 2001 From: andersoxie Date: Mon, 21 Apr 2014 14:52:24 +0200 Subject: [PATCH 3/3] Latest updates after review Victorien want to test with latest version of graph library update. --- ma_memory_change_mediator.e | 112 ++++------ ma_memory_state.e | 19 +- ma_object_snapshot_mediator.e | 182 +++++++-------- ma_references_table.e | 30 +-- ma_route_to_once_searcher.e | 284 ++++++++++-------------- object_graph/ma_figure_factory.e | 2 +- object_graph/ma_object_graph_mediator.e | 85 +++---- object_graph/ma_reference_link.e | 2 - singletons/ma_icons_singleton.e | 18 +- singletons/ma_shared_pixmap_factory.e | 1 - singletons/ma_singleton_factory.e | 5 +- widgets/ma_filter_window.e | 16 +- widgets/ma_grid_check_box_item.e | 37 ++- 13 files changed, 319 insertions(+), 474 deletions(-) diff --git a/ma_memory_change_mediator.e b/ma_memory_change_mediator.e index ae0d0b2..02cc908 100644 --- a/ma_memory_change_mediator.e +++ b/ma_memory_change_mediator.e @@ -120,14 +120,16 @@ feature -- Command local l_state_1, l_state_2: MA_MEMORY_STATE l_info_dlg: EV_INFORMATION_DIALOG + l_increased: attached like grid_data_increased do if grid_from_state.has_selected_row then if grid_to_state.has_selected_row then l_state_2 := states.i_th (grid_to_state.selected_rows.first.index) l_state_1 := states.i_th (grid_from_state.selected_rows.first.index) grid_util.grid_remove_and_clear_all_rows (grid_changed) - grid_data_increased := l_state_1.compare (l_state_2) - update_grid_increased_content + l_increased := l_state_1.compare (l_state_2) + grid_data_increased := l_increased + update_grid_increased_content (l_increased) else create l_info_dlg.make_with_text ("Please select a To State from the right grid.") l_info_dlg.show_relative_to_window (main_window) @@ -181,39 +183,33 @@ feature -- Command feature {NONE} -- Implemention - update_grid_increased_content + update_grid_increased_content( a_grid_data_increased : attached like grid_data_increased) -- Show the increased objects in the bottom result grid. - require - set: attached grid_data_increased local l_int: INTEGER l_item: EV_GRID_LABEL_ITEM l_i: INTEGER do - if attached grid_data_increased as l_grid_data_increased then - from - l_grid_data_increased.start - until - l_grid_data_increased.after - loop - if not filter.filter_class (l_grid_data_increased.item_for_iteration.text) then - l_i := l_i + 1 - create l_item.make_with_text (l_grid_data_increased.item_for_iteration.text) - l_item.set_pixmap (icons.object_grid_class_icon) - grid_changed.set_item (1, l_i, l_item) - l_int := l_grid_data_increased.item_for_iteration.nb - create l_item.make_with_text (l_int.out) - if l_int > 0 then - l_item.set_foreground_color (increased_color) - else - l_item.set_foreground_color (decreased_color) - end - grid_changed.set_item (2, l_i, l_item) + from + a_grid_data_increased.start + until + a_grid_data_increased.after + loop + if not filter.filter_class (a_grid_data_increased.item_for_iteration.text) then + l_i := l_i + 1 + create l_item.make_with_text (a_grid_data_increased.item_for_iteration.text) + l_item.set_pixmap (icons.object_grid_class_icon) + grid_changed.set_item (1, l_i, l_item) + l_int := a_grid_data_increased.item_for_iteration.nb + create l_item.make_with_text (l_int.out) + if l_int > 0 then + l_item.set_foreground_color (increased_color) + else + l_item.set_foreground_color (decreased_color) end - l_grid_data_increased.forth + grid_changed.set_item (2, l_i, l_item) end - else - check attached_grid_data_increased : false end -- Implied by precondition `set' + a_grid_data_increased.forth end end @@ -274,36 +270,24 @@ feature {NONE} -- Implemention sorted_column := a_column_index sorting_order := False end - if grid_data_increased /= Void then - sort_data - update_grid_increased_content + if attached grid_data_increased as l_grid_data_increased then + sort_data( l_grid_data_increased) + update_grid_increased_content (l_grid_data_increased) end end end - handle_pick_item (a_item: EV_GRID_LABEL_ITEM): MA_CLASS_STONE - -- User pick a item from grid to filter. - require - a_item_attached : attached a_item - index_equal_1 : a_item.column.index = 1 - local - l_result: detachable like handle_pick_item + + handle_pick_item (a_item: detachable EV_GRID_ITEM): detachable MA_CLASS_STONE + -- User pick an item from grid to filter. do - if a_item /= Void and a_item.column.index = 1 then - l_result := create {MA_CLASS_STONE}.make (a_item.text) - end - if attached l_result then - Result := l_result - else - check attached_l_result : false end -- Implied by preconditions - create Result.make ("") -- If preonditions is not satisfied we can return whatever we want. + if attached {EV_GRID_LABEL_ITEM} a_item as l_label and then l_label.column.index = 1 then + create {MA_CLASS_STONE} Result.make (l_label.text) end end - sort_data + sort_data (a_grid_data_increased : attached like grid_data_increased) -- Sort `grid_data' according to `sorted_column' and `sorting_order'. - require - set: attached grid_data_increased local l_sorter: QUICK_SORTER [like grid_data_increased_row] l_agent_sorter: AGENT_EQUALITY_TESTER [like grid_data_increased_row] @@ -314,11 +298,7 @@ feature {NONE} -- Implemention when 2 then create l_agent_sorter.make (agent sort_on_count) end create l_sorter.make (l_agent_sorter) - if attached grid_data_increased as l_grid_data_increased then - l_sorter.sort (l_grid_data_increased) - else - check attached_grid_data_increased : false end -- Implied by precondition - end + l_sorter.sort (a_grid_data_increased) end sorting_order: BOOLEAN @@ -357,16 +337,11 @@ feature {NONE} -- Implemention -- Anchor type should not called. -- first INTEGER is increased object count, second INTEGER is the increased objects type id require - False - local - l_result: detachable like grid_data_increased_row + not_callable : False do - check False end -- Anchor type only - if attached l_result as l_r then - Result := l_result - else - create Result.default_create - end + check False then end + ensure + for_typing_only : False end grid_data_increased: detachable ARRAYED_LIST [like grid_data_increased_row] @@ -379,16 +354,11 @@ feature {NONE} -- Implemention -- Type for the data inserted in grid -- It is [Object Type Name, Eiffel Memory Used, C Memory Used, TypeId]. require - False - local - l_result: detachable like row_data + not_callable : False do - check False end -- Anchor type only - if attached l_result as l_r then - Result := l_result - else - create Result.default_create - end + check False then end + ensure + for_typing_only : False end grid_from_state, grid_to_state: EV_GRID -- Two grid show states. diff --git a/ma_memory_state.e b/ma_memory_state.e index 03239cd..9693445 100644 --- a/ma_memory_state.e +++ b/ma_memory_state.e @@ -47,14 +47,12 @@ feature -- Measurrment item_found_count: INTEGER -- after routine found_type, return the count of founded item - require - founded_type_attached: attached founded_type do if attached item_founded as l_item_founded then Result := l_item_founded.count_in_system - else - check attached_item_founded : false end -- Implied by precondition end + ensure + item_found_count_non_negative: Result >= 0 end memory_used_eiffel: INTEGER @@ -163,15 +161,12 @@ feature {NONE} -- Implementation state: TUPLE [type_name: STRING; count_in_system: INTEGER] -- [type_name_of_type, number of instances of type_name_of_type present in system] - local - l_result: detachable like state + require + not_callable : False do - check False end -- Anchor type only - if attached l_result as l_res then - Result := l_res - else - create Result - end + check False then end + ensure + for_typing_only : False end objects_states: ARRAYED_LIST [like state]; diff --git a/ma_object_snapshot_mediator.e b/ma_object_snapshot_mediator.e index ff66f28..80e9958 100644 --- a/ma_object_snapshot_mediator.e +++ b/ma_object_snapshot_mediator.e @@ -114,12 +114,8 @@ feature -- Command l_count := l_new_table.item_for_iteration - if finding_route_to_once then - if attached l_map as l_m then - add_to_reference_table (l_new_table.key_for_iteration, l_m) - else - check attached_l_map : false end -- Implied by `finding_route_to_once' - end + if l_map /= Void then + add_to_reference_table (l_new_table.key_for_iteration, l_map) end -- Compute `l_delta' now. @@ -154,15 +150,16 @@ feature -- Command end end - if finding_route_to_once then + if l_map /= Void then memory.collection_on last_selected_object := Void end last_table := l_new_table grid_data := l_data - - update_grid_content + if attached grid_data as l_grid_data then + update_grid_content (l_grid_data) + end end set_finding_route_to_once (a_b: BOOLEAN) @@ -215,17 +212,15 @@ feature {NONE} -- Implementation sorted_column := a_column_index sorting_order := False end - if grid_data /= Void then - sort_data - update_grid_content + if attached grid_data as l_grid_data then + sort_data (l_grid_data) + update_grid_content (l_grid_data) end end end - sort_data + sort_data( a_grid_data : attached like grid_data) -- Sort `grid_data' according to `sorted_column' and `sorting_order'. - require - grid_data_not_void: grid_data /= Void local l_sorter: QUICK_SORTER [like row_data] l_agent_sorter: AGENT_EQUALITY_TESTER [like row_data] @@ -237,17 +232,11 @@ feature {NONE} -- Implementation when 3 then create l_agent_sorter.make (agent sort_on_delta) end create l_sorter.make (l_agent_sorter) - if attached grid_data as l_grid_data then - l_sorter.sort (l_grid_data) - else - check attached_grid_data : false end -- Implied by precondition - end + l_sorter.sort (a_grid_data) end - update_grid_content - -- Fill grid using `grid_data' - require - grid_data_not_void: attached grid_data + update_grid_content ( a_grid_data : attached like grid_data) + -- Fill grid using `a_grid_data' local l_row_data: like row_data l_item: MA_GRID_LABEL_ITEM @@ -256,58 +245,54 @@ feature {NONE} -- Implementation l_row: EV_GRID_ROW l_grid: like object_grid do - if attached grid_data as l_data then - from - l_grid := object_grid - grid_util.grid_remove_and_clear_all_rows (l_grid) - i := 1 - l_data.start - until - l_data.after - loop - l_row_data := l_data.item_for_iteration - if not filter.filter_class (l_row_data.type_name) then - l_str := l_row_data.type_name - check - l_str_not_void: l_str /= Void - end + from + l_grid := object_grid + grid_util.grid_remove_and_clear_all_rows (l_grid) + i := 1 + a_grid_data.start + until + a_grid_data.after + loop + l_row_data := a_grid_data.item_for_iteration + if not filter.filter_class (l_row_data.type_name) then + l_str := l_row_data.type_name + check + l_str_not_void: l_str /= Void + end - -- Set type name - create l_item.make_with_text (l_str) - l_item.set_pixmap (icons.object_grid_class_icon) - l_grid.set_item (1, i, l_item) - - -- Set count - l_count := l_row_data.number_of_objects - create l_item.make_with_text (l_count.out) - l_grid.set_item (2, i, l_item) - if l_count >= 1 then - l_row := l_grid.row (i) - l_row.ensure_expandable - l_row.expand_actions.extend (agent on_expand_actions_for_type (l_row_data.type_id, l_row)) - end + -- Set type name + create l_item.make_with_text (l_str) + l_item.set_pixmap (icons.object_grid_class_icon) + l_grid.set_item (1, i, l_item) + + -- Set count + l_count := l_row_data.number_of_objects + create l_item.make_with_text (l_count.out) + l_grid.set_item (2, i, l_item) + if l_count >= 1 then + l_row := l_grid.row (i) + l_row.ensure_expandable + l_row.expand_actions.extend (agent on_expand_actions_for_type (l_row_data.type_id, l_row)) + end - -- Set delta - l_delta := l_row_data.variation_since_last_time - if l_delta /= 0 then - create l_item.make_with_text (l_delta.out) - if l_delta > 0 then - l_item.set_foreground_color (increased_color) - else - l_item.set_foreground_color (decreased_color) - end - l_grid.set_item (3, i, l_item) + -- Set delta + l_delta := l_row_data.variation_since_last_time + if l_delta /= 0 then + create l_item.make_with_text (l_delta.out) + if l_delta > 0 then + l_item.set_foreground_color (increased_color) + else + l_item.set_foreground_color (decreased_color) end - i := i + 1 + l_grid.set_item (3, i, l_item) end - l_data.forth + i := i + 1 end - -- We launch a collection, so that no bad information is displayed - -- for referers. - system_util.collect - else - check attached_data : false end -- Implied by precondition `grid_data_not_void' + a_grid_data.forth end + -- We launch a collection, so that no bad information is displayed + -- for referers. + system_util.collect end on_expand_actions_for_type (a_dynamic_type: INTEGER; a_parent_row: EV_GRID_ROW) @@ -453,12 +438,8 @@ feature {NONE} -- Implementation add_to_reference_table (a_object_id: INTEGER; a_map: HASH_TABLE [ARRAYED_LIST [ANY], INTEGER_32]) -- Added all referer relations of objects of `a_object_id'. require - tables_created: reference_table /= Void and name_table /= Void a_map_not_void: a_map /= Void has: a_map.has (a_object_id) - set: attached object_table - set: attached name_table - set: attached reference_table local l_name, l_field_name: STRING l_int: INTERNAL @@ -536,16 +517,12 @@ feature {NONE} -- Implementation l_objects_of_type.forth end else - check attached_objects_of_type : false end -- Implied by precondition `has' - check attached_object_table : false end -- Implied by precondition `set' - check attached_reference_table : false end -- Implied by precondition `set' + check has_object: False end end end build_once_object_table -- Record once object in `once_object_table'. - require - set: attached object_table local l_obj: like once_objects i: INTEGER @@ -554,25 +531,23 @@ feature {NONE} -- Implementation l_int: INTERNAL l_once_object_table: like once_object_table do - create l_int - create l_once_object_table.make (100) - once_object_table := l_once_object_table - l_obj := once_objects - from - i := l_obj.lower - until - i > l_obj.upper - loop - l_item := l_obj.item (i) - if l_item /= Void then - if attached object_table as l_object_table then - l_index := l_object_table.index (l_item) - l_once_object_table.force (l_index, l_index) - else - check attached_l_object_table : false end -- Implied by precondition `set' + if attached object_table as l_object_table then + create l_int + create l_once_object_table.make (100) + once_object_table := l_once_object_table + l_obj := once_objects + from + i := l_obj.lower + until + i > l_obj.upper + loop + l_item := l_obj.item (i) + if l_item /= Void then + l_index := l_object_table.index (l_item) + l_once_object_table.force (l_index, l_index) end + i := i + 1 end - i := i + 1 end end @@ -603,18 +578,15 @@ feature {NONE} -- Fields row_data: TUPLE [type_name: STRING; number_of_objects: INTEGER; variation_since_last_time: INTEGER; type_id: INTEGER] -- Type for the data inserted in `output_grid' -- It is [type_name, number_of_objects, variation_since_last_time, type_id]. - local - l_result: detachable like row_data + require + not_callable : False do - check False end -- Anchor type only - if attached l_result as l_res then - Result := l_res - else - check attached_l_result : false end -- Satisfy void-safe compiler - create Result - end + check False then end + ensure + for_typing_only : False end + object_grid: EV_GRID -- the main grid to show object snapshot datas diff --git a/ma_references_table.e b/ma_references_table.e index 77b924d..31918e1 100644 --- a/ma_references_table.e +++ b/ma_references_table.e @@ -67,18 +67,12 @@ feature -- Element change local l_hash: detachable like references_by_referee do - if not relations.has_key (a_referee) then - create l_hash.make (20) - -- Here we prevent extending pairs exsited or with equivalent key and value. - relations.force (l_hash, a_referee) - else - l_hash := relations.found_item - end - if attached l_hash as l_h then - l_h.force ([a_referee, data], a_referrer) - else - check attached_l_hash : false end -- Implied by previous if clause + l_hash := relations.item (a_referee) + if l_hash = Void then + create l_hash.make (20) + relations.force (l_hash, a_referee) end + l_hash.force ([a_referee, data], a_referrer) end feature -- Removal @@ -91,15 +85,11 @@ feature -- Removal local l_hash: detachable like references_by_referee do - if relations.has_key (a_referee) then - l_hash := relations.found_item - if attached l_hash as l_h then - l_h.remove (a_referrer) - if l_h.is_empty then - relations.remove (a_referee) - end - else - check attached_l_hash : false end -- Implied by `has_key' + l_hash := relations.item (a_referee) + if l_hash /= Void then + l_hash.remove (a_referrer) + if l_hash.is_empty then + relations.remove (a_referee) end end end diff --git a/ma_route_to_once_searcher.e b/ma_route_to_once_searcher.e index a6eea30..69361ec 100644 --- a/ma_route_to_once_searcher.e +++ b/ma_route_to_once_searcher.e @@ -40,8 +40,8 @@ feature -- Commands %Please select a start point in Object Grid%N% %and refresh again with Collecting Statics enabled.") l_info_box.show - else - build + elseif attached reference_table as l_reference_table then + build (l_reference_table) end end @@ -84,86 +84,81 @@ feature {NONE} -- Results l_grid: like grid l_route_stack: like route_stack do - if attached grid then - l_grid := grid - else + l_grid := grid + if l_grid = Void then create l_grid grid := l_grid init_grid (l_grid) result_panel.extend (l_grid) end - if attached l_grid as l_l_grid then - l_column := l_l_grid.column_count + 1 - l_route_stack := route_stack - if attached l_route_stack as l_r then - l_array := l_r.linear_representation - l_l_grid.set_row_count_to (l_array.count.max (l_l_grid.row_count)) - l_l_grid.set_column_count_to (l_column) - l_l_grid.column (l_column).set_title ("Route" + l_column.out) - from - l_array.start - until - l_array.after - loop - if not l_array.islast then - l_next_index := l_array [l_array.index + 1] + l_column := l_grid.column_count + 1 + l_route_stack := route_stack + if attached l_route_stack as l_r then + l_array := l_r.linear_representation + l_grid.set_row_count_to (l_array.count.max (l_grid.row_count)) + l_grid.set_column_count_to (l_column) + l_grid.column (l_column).set_title ("Route" + l_column.out) + from + l_array.start + until + l_array.after + loop + if not l_array.islast then + l_next_index := l_array [l_array.index + 1] + else + l_last := True + end + if not l_last then + l_reference_table := reference_table + if attached l_reference_table as l_ref then + l_tuple := l_ref.references_by_referee (l_next_index).item (l_array.item) else - l_last := True + check attached_l_reference_table : false end -- Implied by precondition `set' end - if not l_last then - l_reference_table := reference_table - if attached l_reference_table as l_ref then - l_tuple := l_ref.references_by_referee (l_next_index).item (l_array.item) - else - check attached_l_reference_table : false end -- Implied by precondition `set' - end - if l_tuple /= Void then - if attached {STRING} l_tuple.data as l_string then - l_field_name := l_string - else - --|FIXME: 2012/04/06 Shouldn't this be "(unknown)", instead of setting it Void? See review#7644004. - l_field_name := Void - end + if l_tuple /= Void then + if attached {STRING} l_tuple.data as l_string then + l_field_name := l_string else - l_field_name := once "(unknown)" + --|FIXME: 2012/04/06 Shouldn't this be "(unknown)", instead of setting it Void? See review#7644004. + l_field_name := Void end else - --|FIXME: 2012/04/06 Shouldn't this be "(unknown)", instead of setting it Void? See review#7644004. - l_field_name := Void + l_field_name := once "(unknown)" end - if l_field_name = Void then - l_field_name := once "" - else - l_field_name := l_field_name.twin - l_field_name.prepend (".") - end - -- Optimization, since we know that only the first object is once object. - if l_array.isfirst then - l_once := once "*" - else - l_once := once "" - end - l_name_table := name_table - if attached l_name_table as l_n then - l_name_table_item := l_n.item (l_array.item) - if attached l_name_table_item as l_name_item then - l_text := l_once + l_array.item.out + once ": {" + l_name_item + once "}" + l_field_name - create l_item.make_with_text (l_text) - l_item.set_tooltip (l_text) - l_l_grid.set_item (l_column, l_array.index, l_item) - l_array.forth - else - check attached_l_name_table_item : false end -- FIXME: Implied by ...? - end + else + --|FIXME: 2012/04/06 Shouldn't this be "(unknown)", instead of setting it Void? See review#7644004. + l_field_name := Void + end + if l_field_name = Void then + l_field_name := once "" + else + l_field_name := l_field_name.twin + l_field_name.prepend (".") + end + -- Optimization, since we know that only the first object is once object. + if l_array.isfirst then + l_once := once "*" + else + l_once := once "" + end + l_name_table := name_table + if attached l_name_table as l_n then + l_name_table_item := l_n.item (l_array.item) + if attached l_name_table_item as l_name_item then + l_text := l_once + l_array.item.out + once ": {" + l_name_item + once "}" + l_field_name + create l_item.make_with_text (l_text) + l_item.set_tooltip (l_text) + l_grid.set_item (l_column, l_array.index, l_item) + l_array.forth else - check attached_l_name_table : false end -- Implied by precondition `set' + check attached_l_name_table_item : false end -- FIXME: Implied by ...? end + else + check attached_l_name_table : false end -- Implied by precondition `set' end - else - check attached_l_route_stack : false end -- Implied by precondition `set' end else - check attached_l_grid : false end -- Implied by previous if clause + check attached_l_route_stack : false end -- Implied by precondition `set' end end @@ -188,31 +183,21 @@ feature {NONE} -- Results -- Support Copy. require a_key_not_void: a_key /= Void - grid_set: attached grid local l_env: EV_ENVIRONMENT - l_grid: like grid do - create l_env - if attached l_env.application as l_app and then l_app.ctrl_pressed then - inspect a_key.code - when {EV_KEY_CONSTANTS}.key_a then - l_grid := grid - if attached l_grid as l_g then - select_all_row (l_g) - else - check attached_l_grid :false end -- Implied by precondition `grid_set' - end - when {EV_KEY_CONSTANTS}.key_c then - l_grid := grid - if attached l_grid as l_g then - if not l_g.selected_items.is_empty then - copy_selected_items (l_g) + if attached grid as l_grid then + create l_env + if attached l_env.application as l_app and then l_app.ctrl_pressed then + inspect a_key.code + when {EV_KEY_CONSTANTS}.key_a then + select_all_row (l_grid) + when {EV_KEY_CONSTANTS}.key_c then + if not l_grid.selected_items.is_empty then + copy_selected_items (l_grid) end else - check attached_l_grid : false end -- Implied by precondition `grid_set' end - else end end end @@ -328,29 +313,23 @@ feature {NONE} -- Results feature {NONE} -- Implementation - build + build ( a_reference_table : attached like reference_table) -- Build route. - require - set: attached reference_table local - l_reference_table: like reference_table l_route_stack: like route_stack + l_visited_references : attached like visited_references do create l_route_stack.make (1000) route_stack := l_route_stack - l_reference_table := reference_table - if attached l_reference_table as l_r then - create visited_references.make (l_r.referee_count) - if deep_visit_node (start_index) then - -- Found route - check - route_stack_not_empty: not l_route_stack.is_empty - end - fill_results - remove_last_link_to_once + create l_visited_references.make (a_reference_table.referee_count) + visited_references := l_visited_references + if deep_visit_node (start_index, a_reference_table, l_route_stack, l_visited_references) then + -- Found route + check + route_stack_not_empty: not l_route_stack.is_empty end - else - check attached_l_reference_table : false end -- Implied by precondition `set' + fill_results + remove_last_link_to_once end end @@ -371,70 +350,59 @@ feature {NONE} -- Implementation feature {NONE} -- Implementation - deep_visit_node (a_referee: like start_index): BOOLEAN + deep_visit_node (a_referee: like start_index; + a_reference_table : attached like reference_table; + a_route_stack : attached like route_stack; + a_visited_references : attached like visited_references): BOOLEAN -- Deep visit a node, Ture is found once object. require - set: attached reference_table as l_reference_table and then attached l_reference_table.references_by_referee (a_referee) - set: attached route_stack - set: attached visited_references + set: attached a_reference_table.references_by_referee (a_referee) local l_visited_referrers: HASH_TABLE [TUPLE [like start_index, detachable ANY], like start_index] l_referrer: like start_index l_all_referrers_count: INTEGER do - if is_visited (a_referee) then + if is_visited (a_referee, a_route_stack) then Result := False else - if attached route_stack as l_route_stack then - l_route_stack.put (a_referee) - if attached reference_table as l_reference_table then - if attached l_reference_table.references_by_referee (a_referee) as l_all_referrers then - l_all_referrers_count := l_all_referrers.count - if l_all_referrers_count = 0 then - -- We reach the end. No referrer. - if is_once_object (a_referee) then - Result := True - else - Result := False - end - elseif is_once_object (a_referee) then - Result := True - else - if attached visited_references as l_visited_references then - l_visited_referrers := l_visited_references.references_by_referee (a_referee) - if l_all_referrers_count = l_visited_referrers.count then - -- Go back one - Result := False - l_route_stack.remove - else - from - l_all_referrers.start - until - l_all_referrers.after or Result - loop - l_referrer := l_all_referrers.key_for_iteration - if not l_visited_referrers.has_key (l_referrer) then - l_visited_references.extend (l_referrer, a_referee, Void) - Result := deep_visit_node (l_referrer) - end - l_all_referrers.forth - end - if not Result then - l_route_stack.remove - end - end - else - check attached_l_visited_references : false end -- Implied by precondition `set' - end - end + a_route_stack.put (a_referee) + if attached a_reference_table.references_by_referee (a_referee) as l_all_referrers then + l_all_referrers_count := l_all_referrers.count + if l_all_referrers_count = 0 then + -- We reach the end. No referrer. + if is_once_object (a_referee) then + Result := True else - check attached_l_reference_table_references_by_referee : false end -- Implied by precondition `set' + Result := False end + elseif is_once_object (a_referee) then + Result := True else - check attached_l_reference_table : false end -- Implied by precondition `set' + l_visited_referrers := a_visited_references.references_by_referee (a_referee) + if l_all_referrers_count = l_visited_referrers.count then + -- Go back one + Result := False + a_route_stack.remove + else + from + l_all_referrers.start + until + l_all_referrers.after or Result + loop + l_referrer := l_all_referrers.key_for_iteration + if not l_visited_referrers.has_key (l_referrer) then + a_visited_references.extend (l_referrer, a_referee, Void) + Result := deep_visit_node (l_referrer, a_reference_table, a_route_stack, a_visited_references) + end + l_all_referrers.forth + end + if not Result then + a_route_stack.remove + end + end end else - check attached_l_route_stack : false end -- Implied by precondition `set' + check attached_l_reference_table_references_by_referee : false end -- Implied by precondition `set' end end end @@ -460,27 +428,17 @@ feature {NONE} -- Implementation end end - is_visited (a_node: like start_index): BOOLEAN + is_visited (a_node: like start_index; a_route_stack : attached like route_stack): BOOLEAN -- Is `a_node' visited? - require - set: attached route_stack do - if attached route_stack as l_route_stack then - Result := l_route_stack.has (a_node) - else - check attached_route_stack : false end -- Implied by precondition `set' - end + Result := a_route_stack.has (a_node) end is_once_object (a_object: like start_index): BOOLEAN -- Is `a_object' once? - require - set: attached once_objects_table do if attached once_objects_table as l_table then Result := l_table.has (a_object) - else - check attached_l_table : false end -- Implied by precondition `set' end end diff --git a/object_graph/ma_figure_factory.e b/object_graph/ma_figure_factory.e index 366ee67..a119d8b 100644 --- a/object_graph/ma_figure_factory.e +++ b/object_graph/ma_figure_factory.e @@ -43,7 +43,7 @@ feature -- Basic operations Result := l_r else check attached_l_result: false end -- Satisfy void-safe compiler - create Result -- If no precondtions or checks are switch on this statement will be executed. However, since it is not implemented according to first check statement it might be that we should remove the feature? + create Result end -- node_name := node.name -- if node_name.is_equal ("ELLIPSE_NODE") then diff --git a/object_graph/ma_object_graph_mediator.e b/object_graph/ma_object_graph_mediator.e index 615e81c..ecd18c4 100644 --- a/object_graph/ma_object_graph_mediator.e +++ b/object_graph/ma_object_graph_mediator.e @@ -60,37 +60,25 @@ feature -- Command end end - find_draw_node_by_object (a_object: ANY): EG_NODE + find_draw_node_by_object (a_object: ANY): detachable EG_NODE -- Find in `objects_already_draw' return a EG_NODE which corresponding to object. require a_object_not_void : a_object /= Void local l_obj_with_node : TUPLE [obj: ANY; node: EG_NODE] - l_result: detachable like find_draw_node_by_object do from objects_already_draw.start until - l_result /= Void or objects_already_draw.after + Result /= Void or objects_already_draw.after loop l_obj_with_node := objects_already_draw.item_for_iteration -- Test the address. if l_obj_with_node.obj = a_object then - l_result := l_obj_with_node.node - check - result_not_void: l_result /= Void - end + Result := l_obj_with_node.node end objects_already_draw.forth end - if attached l_result as l_r then - Result := l_r - else - check attached_l_result : false end -- FIXME: Implied by ...? - create Result.default_create -- FIXME: Since we do not have a (clear) precondition we are not allowed to return like this. Need precondition. - end - ensure - result_not_void : Result /= Void end object_already_draw (a_object: ANY): BOOLEAN @@ -251,28 +239,26 @@ feature -- Implementation for agents l_object: ANY l_refers: SPECIAL [ANY] l_int,refer_count: INTEGER - l_link_node: EG_NODE l_linkable: EG_LINKABLE l_info_dlg: EV_INFORMATION_DIALOG l_item: detachable TUPLE [obj: ANY; node: EG_NODE] l_last_drawn_node: like last_drawn_node do l_nodes := world.selected_figures - if l_nodes.count > 0 then - l_node := l_nodes.first - l_item := objects_already_draw.item (l_node) - if attached l_item as l_i then - l_object := l_i.obj - l_refers := memory.referers (l_object) - from - l_int := 0 - refer_count := l_refers.count - until - l_int = refer_count - loop - if object_already_draw(l_refers.item (l_int)) then - -- add link to two already drawed object - l_link_node := find_draw_node_by_object(l_refers.item (l_int)) + l_node := l_nodes.first + l_item := objects_already_draw.item (l_node) + if attached l_item as l_i then + l_object := l_i.obj + l_refers := memory.referers (l_object) + from + l_int := 0 + refer_count := l_refers.count + until + l_int = refer_count + loop + if object_already_draw(l_refers.item (l_int)) then + -- add link to two already drawed object + if attached find_draw_node_by_object(l_refers.item (l_int)) as l_link_node then l_item := objects_already_draw.item (l_node) if attached l_item as l_it then l_linkable := l_it.node @@ -283,32 +269,29 @@ feature -- Implementation for agents else check attached_l_item : false end -- FIXME: Implied by that we iterate over the available number of items. end - else - add_node_random_pos(l_refers.item (l_int)) - l_item := objects_already_draw.item (l_node) - if attached l_item as l_it then - l_linkable := l_it.node - check - l_linkable /= Void - end - l_last_drawn_node := last_drawn_node - if attached l_last_drawn_node as l_last then - add_link (l_linkable, l_last) - else - check attachedl_last_drawn_node : false end -- FIXME: Implied by ...? Can not understand if this is impleied or not. - end + end + else + add_node_random_pos(l_refers.item (l_int)) + l_item := objects_already_draw.item (l_node) + if attached l_item as l_it then + l_linkable := l_it.node + check + l_linkable /= Void + end + l_last_drawn_node := last_drawn_node + if attached l_last_drawn_node as l_last then + add_link (l_linkable, l_last) else - check attached_l_item : false end -- Implied by that we iterate over the available number of items. + check attachedl_last_drawn_node : false end -- FIXME: Implied by ...? end + else + check attached_l_item : false end -- Implied by that we iterate over the available number of items. end - l_int := l_int + 1 end - else - check attached_l_item : false end -- FIXME: Implied by precondition + l_int := l_int + 1 end else - create l_info_dlg.make_with_text ("Please select a node first.") - l_info_dlg.show_relative_to_window (main_window) + check attached_l_item : false end end world.update end diff --git a/object_graph/ma_reference_link.e b/object_graph/ma_reference_link.e index 2c4ee78..987c40f 100644 --- a/object_graph/ma_reference_link.e +++ b/object_graph/ma_reference_link.e @@ -101,8 +101,6 @@ feature -- Element change feature {EG_FIGURE, EG_FIGURE_WORLD} -- Update update - require else - model_attached : attached model -- Some properties may have changed. local p1, p2: EV_COORDINATE diff --git a/singletons/ma_icons_singleton.e b/singletons/ma_icons_singleton.e index 2eaaa03..c027a77 100644 --- a/singletons/ma_icons_singleton.e +++ b/singletons/ma_icons_singleton.e @@ -34,19 +34,13 @@ feature {NONE} -- Implementation pixmap_path: PATH -- Path containing all of the Memory Analyzer icons - require else - attached_pixmap_path : attached internal_pixmap_path - local - l_result: like internal_pixmap_path - do - l_result := internal_pixmap_path - if attached l_result as l_r then -- - Result := l_r - else - check l_result_attached : false end -- Implied by precondition attached_pixmap_path - create Result.make_empty -- Since the behaviour is undefined when precondition is not satisfied we are allowed to return an empty path - end + do + if attached internal_pixmap_path as l_result then + Result := l_result + else + create Result.make_current end + end internal_pixmap_path: detachable like pixmap_path -- Path where have icons image. diff --git a/singletons/ma_shared_pixmap_factory.e b/singletons/ma_shared_pixmap_factory.e index cba5612..da4fc47 100644 --- a/singletons/ma_shared_pixmap_factory.e +++ b/singletons/ma_shared_pixmap_factory.e @@ -82,7 +82,6 @@ feature {NONE} -- Implementation deferred ensure result_not_void: Result /= Void - not_result_is_empty: not Result.is_empty end image_matrix: EV_PIXMAP diff --git a/singletons/ma_singleton_factory.e b/singletons/ma_singleton_factory.e index d4f0358..968b8a4 100644 --- a/singletons/ma_singleton_factory.e +++ b/singletons/ma_singleton_factory.e @@ -73,11 +73,8 @@ feature -- Singletons -- MEMORY_TOOL_WINDOW instance require set: is_main_window_set - local - l_item: detachable MA_WINDOW do - l_item := internal_main_window.item - if attached l_item as l_i then + if attached internal_main_window.item as l_item then Result := l_item else check l_item_attached : false end -- Implied by precondition diff --git a/widgets/ma_filter_window.e b/widgets/ma_filter_window.e index f231578..d19ca47 100644 --- a/widgets/ma_filter_window.e +++ b/widgets/ma_filter_window.e @@ -182,7 +182,7 @@ feature {NONE} -- Implementation local l_last_row: detachable EV_GRID_ROW do - add_new_row (Void) + add_new_row (Void) -- Construct a new row where the first item is editable. l_last_row := grid.last_visible_row if attached l_last_row as l_last_r then if attached {EV_GRID_EDITABLE_ITEM} l_last_row.item (1) as l_item then @@ -296,17 +296,11 @@ feature {NONE} -- Implementation a_filter_data: TUPLE [class_name: STRING; selected: BOOLEAN; description: STRING] -- A anchor, should not be called require - False - local - l_result: detachable like a_filter_data + not_callable : False do - check False end -- Anchor type only - if attached l_result as l_res then - Result := l_result - else -- Satisfy void-safe compile. Since precondition states false the behaviour is not defined if called without precondition and checks. - check l_result_attached : false end - create Result - end + check False then end + ensure + for_typing_only : False end hash_table_datas_to_arrayed_list_datas: MA_ARRAYED_LIST_STORABLE [like a_filter_data] diff --git a/widgets/ma_grid_check_box_item.e b/widgets/ma_grid_check_box_item.e index 26019fb..7dbbfd5 100644 --- a/widgets/ma_grid_check_box_item.e +++ b/widgets/ma_grid_check_box_item.e @@ -94,32 +94,27 @@ feature {NONE} -- Implementation -- Draw the pixmap which represent whether current is selected. require a_drawable_not_void: a_drawable /= Void - local - l_parent_2: detachable EV_CONTAINER do - if is_selected and attached parent as l_parent then - if l_parent.has_focus then - a_drawable.set_foreground_color (l_parent.focused_selection_color) - else - a_drawable.set_foreground_color (l_parent.non_focused_selection_color) - end - else - if attached row.background_color as l_row_background_color then - a_drawable.set_foreground_color (l_row_background_color) + if attached parent as l_parent then + if is_selected then + if l_parent.has_focus then + a_drawable.set_foreground_color (l_parent.focused_selection_color) + else + a_drawable.set_foreground_color (l_parent.non_focused_selection_color) + end else - l_parent_2 := parent - if attached l_parent_2 as l_p then - a_drawable.set_foreground_color (l_p.background_color) + if attached row.background_color as l_row_background_color then + a_drawable.set_foreground_color (l_row_background_color) else - check l_parent_2_attached : false end -- FIXME: Implied by ...? -- I have tried to understand if the state of the current instance tells us that this will not happen. Next step would be to define a precondition or invariant. At least the behaviour is not worse than before this change. + a_drawable.set_foreground_color (l_parent.background_color) end end - end - a_drawable.fill_rectangle (0, 0, a_drawable.width, a_drawable.height) - if internal_selected then - draw_selected (a_drawable) - else - draw_unselected (a_drawable) + a_drawable.fill_rectangle (0, 0, a_drawable.width, a_drawable.height) + if internal_selected then + draw_selected (a_drawable) + else + draw_unselected (a_drawable) + end end end