From df843c7fe48f33d25981d03975e670a3e7159031 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sun, 7 May 2017 12:04:33 +1000 Subject: Further code cleanup --- src/c_fl_button.cpp | 6 ++-- src/c_fl_double_window.cpp | 4 +-- src/c_fl_group.cpp | 18 +++++----- src/c_fl_input.cpp | 2 +- src/c_fl_int_input.cpp | 2 +- src/c_fl_menu.cpp | 6 ++-- src/c_fl_menu_button.cpp | 2 +- src/c_fl_menu_window.cpp | 12 +++---- src/c_fl_single_window.cpp | 4 +-- src/c_fl_text_display.cpp | 34 +++++++++--------- src/c_fl_text_editor.cpp | 12 +++---- src/c_fl_widget.cpp | 42 +++++++++++----------- src/c_fl_window.cpp | 14 ++++---- src/fltk-widgets-boxes.adb | 12 ++++--- src/fltk-widgets-boxes.ads | 3 -- src/fltk-widgets-buttons-enter.adb | 13 ++++--- src/fltk-widgets-buttons-enter.ads | 4 --- src/fltk-widgets-buttons-light-check.adb | 13 ++++--- src/fltk-widgets-buttons-light-check.ads | 4 --- src/fltk-widgets-buttons-light-radio.adb | 13 ++++--- src/fltk-widgets-buttons-light-radio.ads | 4 --- src/fltk-widgets-buttons-light-round-radio.adb | 13 ++++--- src/fltk-widgets-buttons-light-round-radio.ads | 4 --- src/fltk-widgets-buttons-light-round.adb | 13 ++++--- src/fltk-widgets-buttons-light-round.ads | 4 --- src/fltk-widgets-buttons-light.adb | 13 ++++--- src/fltk-widgets-buttons-light.ads | 4 --- src/fltk-widgets-buttons-radio.adb | 13 ++++--- src/fltk-widgets-buttons-radio.ads | 4 --- src/fltk-widgets-buttons-repeat.adb | 13 ++++--- src/fltk-widgets-buttons-repeat.ads | 4 --- src/fltk-widgets-buttons-toggle.adb | 13 ++++--- src/fltk-widgets-buttons-toggle.ads | 4 --- src/fltk-widgets-buttons.adb | 12 ++++--- src/fltk-widgets-buttons.ads | 3 -- ...k-widgets-groups-text_displays-text_editors.adb | 14 +++++--- ...k-widgets-groups-text_displays-text_editors.ads | 4 --- src/fltk-widgets-groups-text_displays.adb | 14 +++++--- src/fltk-widgets-groups-text_displays.ads | 4 --- src/fltk-widgets-groups-windows-double.adb | 14 +++++--- src/fltk-widgets-groups-windows-double.ads | 4 --- src/fltk-widgets-groups-windows-single-menu.adb | 14 +++++--- src/fltk-widgets-groups-windows-single-menu.ads | 4 --- src/fltk-widgets-groups-windows-single.adb | 14 +++++--- src/fltk-widgets-groups-windows-single.ads | 4 --- src/fltk-widgets-groups-windows.adb | 13 ++++--- src/fltk-widgets-groups-windows.ads | 3 -- src/fltk-widgets-groups.adb | 12 ++++--- src/fltk-widgets-groups.ads | 3 -- src/fltk-widgets-inputs-int.adb | 13 ++++--- src/fltk-widgets-inputs-int.ads | 4 --- src/fltk-widgets-inputs.adb | 12 ++++--- src/fltk-widgets-inputs.ads | 3 -- src/fltk-widgets-menus-menu_bars.adb | 13 ++++--- src/fltk-widgets-menus-menu_bars.ads | 4 --- src/fltk-widgets-menus-menu_buttons.adb | 13 ++++--- src/fltk-widgets-menus-menu_buttons.ads | 4 --- src/fltk-widgets-menus.adb | 26 ++++---------- src/fltk-widgets-menus.ads | 7 +--- src/fltk-widgets.adb | 22 +++--------- src/fltk-widgets.ads | 3 +- 61 files changed, 269 insertions(+), 317 deletions(-) diff --git a/src/c_fl_button.cpp b/src/c_fl_button.cpp index 233e4ab..f031ff9 100644 --- a/src/c_fl_button.cpp +++ b/src/c_fl_button.cpp @@ -58,16 +58,16 @@ void free_fl_button(BUTTON b) { int fl_button_get_state(BUTTON b) { - return reinterpret_cast(b)->value(); + return reinterpret_cast(b)->value(); } void fl_button_set_state(BUTTON b, int s) { - reinterpret_cast(b)->value(s); + reinterpret_cast(b)->value(s); } void fl_button_set_only(BUTTON b) { - reinterpret_cast(b)->setonly(); + reinterpret_cast(b)->setonly(); } diff --git a/src/c_fl_double_window.cpp b/src/c_fl_double_window.cpp index ff9a596..d7cab71 100644 --- a/src/c_fl_double_window.cpp +++ b/src/c_fl_double_window.cpp @@ -64,11 +64,11 @@ void free_fl_double_window(DOUBLEWINDOW d) { void fl_double_window_show(DOUBLEWINDOW d) { - reinterpret_cast(d)->show(); + reinterpret_cast(d)->show(); } void fl_double_window_hide(DOUBLEWINDOW d) { - reinterpret_cast(d)->hide(); + reinterpret_cast(d)->hide(); } diff --git a/src/c_fl_group.cpp b/src/c_fl_group.cpp index 4546be0..d02476a 100644 --- a/src/c_fl_group.cpp +++ b/src/c_fl_group.cpp @@ -60,50 +60,50 @@ void free_fl_group(GROUP g) { void fl_group_end(GROUP g) { - reinterpret_cast(g)->end(); + reinterpret_cast(g)->end(); } void fl_group_add(GROUP g, WIDGET item) { - reinterpret_cast(g)->add(reinterpret_cast(item)); + reinterpret_cast(g)->add(reinterpret_cast(item)); } int fl_group_find(GROUP g, WIDGET item) { - return reinterpret_cast(g)->find(reinterpret_cast(item)); + return reinterpret_cast(g)->find(reinterpret_cast(item)); } void fl_group_insert(GROUP g, WIDGET item, int place) { - reinterpret_cast(g)->insert(*(reinterpret_cast(item)), place); + reinterpret_cast(g)->insert(*(reinterpret_cast(item)), place); } void fl_group_remove(GROUP g, WIDGET item) { - reinterpret_cast(g)->remove(reinterpret_cast(item)); + reinterpret_cast(g)->remove(reinterpret_cast(item)); } void fl_group_remove2(GROUP g, int place) { - reinterpret_cast(g)->remove(place); + reinterpret_cast(g)->remove(place); } void fl_group_resizable(GROUP g, WIDGET item) { - reinterpret_cast(g)->resizable(reinterpret_cast(item)); + reinterpret_cast(g)->resizable(reinterpret_cast(item)); } int fl_group_children(GROUP g) { - return reinterpret_cast(g)->children(); + return reinterpret_cast(g)->children(); } void * fl_group_child(GROUP g, int place) { - return reinterpret_cast(g)->child(place); + return reinterpret_cast(g)->child(place); } diff --git a/src/c_fl_input.cpp b/src/c_fl_input.cpp index fde9ea8..526dbd5 100644 --- a/src/c_fl_input.cpp +++ b/src/c_fl_input.cpp @@ -58,6 +58,6 @@ void free_fl_input(INPUT i) { const char * fl_input_get_value(INPUT i) { - return reinterpret_cast(i)->value(); + return reinterpret_cast(i)->value(); } diff --git a/src/c_fl_int_input.cpp b/src/c_fl_int_input.cpp index 45c5bc5..a15d1fb 100644 --- a/src/c_fl_int_input.cpp +++ b/src/c_fl_int_input.cpp @@ -58,6 +58,6 @@ void free_fl_int_input(INT_INPUT i) { const char * fl_int_input_get_value(INT_INPUT i) { - return reinterpret_cast(i)->value(); + return reinterpret_cast(i)->value(); } diff --git a/src/c_fl_menu.cpp b/src/c_fl_menu.cpp index 411f6a0..daff92b 100644 --- a/src/c_fl_menu.cpp +++ b/src/c_fl_menu.cpp @@ -47,17 +47,17 @@ void free_fl_menu(MENU m) { int fl_menu_add(MENU m, const char * t, unsigned long s, void * c, void * u, unsigned long f) { - return reinterpret_cast(m)->add(t, s, reinterpret_cast(c), u, f); + return reinterpret_cast(m)->add(t, s, reinterpret_cast(c), u, f); } const void * fl_menu_find_item(MENU m, const char * t) { - return reinterpret_cast(m)->find_item(t); + return reinterpret_cast(m)->find_item(t); } const void * fl_menu_mvalue(MENU m) { - return reinterpret_cast(m)->mvalue(); + return reinterpret_cast(m)->mvalue(); } diff --git a/src/c_fl_menu_button.cpp b/src/c_fl_menu_button.cpp index b49d1aa..e4b963c 100644 --- a/src/c_fl_menu_button.cpp +++ b/src/c_fl_menu_button.cpp @@ -58,6 +58,6 @@ void free_fl_menu_button(MENUBUTTON m) { void fl_menu_button_type(MENUBUTTON m, unsigned int t) { - reinterpret_cast(m)->type(t); + reinterpret_cast(m)->type(t); } diff --git a/src/c_fl_menu_window.cpp b/src/c_fl_menu_window.cpp index 8445978..e488479 100644 --- a/src/c_fl_menu_window.cpp +++ b/src/c_fl_menu_window.cpp @@ -64,31 +64,31 @@ void free_fl_menu_window(MENUWINDOW m) { void fl_menu_window_show(MENUWINDOW m) { - reinterpret_cast(m)->show(); + reinterpret_cast(m)->show(); } void fl_menu_window_hide(MENUWINDOW m) { - reinterpret_cast(m)->hide(); + reinterpret_cast(m)->hide(); } void fl_menu_window_flush(MENUWINDOW m) { - reinterpret_cast(m)->flush(); + reinterpret_cast(m)->flush(); } void fl_menu_window_set_overlay(MENUWINDOW m) { - reinterpret_cast(m)->set_overlay(); + reinterpret_cast(m)->set_overlay(); } void fl_menu_window_clear_overlay(MENUWINDOW m) { - reinterpret_cast(m)->clear_overlay(); + reinterpret_cast(m)->clear_overlay(); } unsigned int fl_menu_window_overlay(MENUWINDOW m) { - return reinterpret_cast(m)->overlay(); + return reinterpret_cast(m)->overlay(); } diff --git a/src/c_fl_single_window.cpp b/src/c_fl_single_window.cpp index 75fbd67..71eecf5 100644 --- a/src/c_fl_single_window.cpp +++ b/src/c_fl_single_window.cpp @@ -64,11 +64,11 @@ void free_fl_single_window(SINGLEWINDOW w) { void fl_single_window_show(SINGLEWINDOW w) { - reinterpret_cast(w)->show(); + reinterpret_cast(w)->show(); } void fl_single_window_flush(SINGLEWINDOW w) { - reinterpret_cast(w)->flush(); + reinterpret_cast(w)->flush(); } diff --git a/src/c_fl_text_display.cpp b/src/c_fl_text_display.cpp index 694b8c9..dc283f7 100644 --- a/src/c_fl_text_display.cpp +++ b/src/c_fl_text_display.cpp @@ -62,86 +62,86 @@ void free_fl_text_display(TEXTDISPLAY td) { // this actually never gets called, since an access to the text_buffer // object is stored on the Ada side of things TEXTBUFFER fl_text_display_get_buffer(TEXTDISPLAY td) { - return reinterpret_cast(td)->buffer(); + return reinterpret_cast(td)->buffer(); } void fl_text_display_set_buffer(TEXTDISPLAY td, TEXTBUFFER tb) { - reinterpret_cast(td)->buffer(reinterpret_cast(tb)); + reinterpret_cast(td)->buffer(reinterpret_cast(tb)); } int fl_text_display_get_text_color(TEXTDISPLAY td) { - return reinterpret_cast(td)->textcolor(); + return reinterpret_cast(td)->textcolor(); } void fl_text_display_set_text_color(TEXTDISPLAY td, int c) { - reinterpret_cast(td)->textcolor(static_cast(c)); + reinterpret_cast(td)->textcolor(static_cast(c)); } int fl_text_display_get_text_font(TEXTDISPLAY td) { - return reinterpret_cast(td)->textfont(); + return reinterpret_cast(td)->textfont(); } void fl_text_display_set_text_font(TEXTDISPLAY td, int f) { - reinterpret_cast(td)->textfont(static_cast(f)); + reinterpret_cast(td)->textfont(static_cast(f)); } int fl_text_display_get_text_size(TEXTDISPLAY td) { - return reinterpret_cast(td)->textsize(); + return reinterpret_cast(td)->textsize(); } void fl_text_display_set_text_size(TEXTDISPLAY td, int s) { - reinterpret_cast(td)->textsize(static_cast(s)); + reinterpret_cast(td)->textsize(static_cast(s)); } int fl_text_display_get_insert_pos(TEXTDISPLAY td) { - return reinterpret_cast(td)->insert_position(); + return reinterpret_cast(td)->insert_position(); } void fl_text_display_set_insert_pos(TEXTDISPLAY td, int p) { - reinterpret_cast(td)->insert_position(p); + reinterpret_cast(td)->insert_position(p); } void fl_text_display_show_insert_pos(TEXTDISPLAY td) { - reinterpret_cast(td)->show_insert_position(); + reinterpret_cast(td)->show_insert_position(); } void fl_text_display_next_word(TEXTDISPLAY td) { - reinterpret_cast(td)->next_word(); + reinterpret_cast(td)->next_word(); } void fl_text_display_previous_word(TEXTDISPLAY td) { - reinterpret_cast(td)->previous_word(); + reinterpret_cast(td)->previous_word(); } void fl_text_display_wrap_mode(TEXTDISPLAY td, int w, int m) { - reinterpret_cast(td)->wrap_mode(w, m); + reinterpret_cast(td)->wrap_mode(w, m); } int fl_text_display_skip_lines(TEXTDISPLAY td, int s, int l, int p) { - return reinterpret_cast(td)->skip_lines(s, l, p); + return reinterpret_cast(td)->skip_lines(s, l, p); } int fl_text_display_rewind_lines(TEXTDISPLAY td, int s, int l) { - return reinterpret_cast(td)->rewind_lines(s, l); + return reinterpret_cast(td)->rewind_lines(s, l); } void fl_text_display_linenumber_width(TEXTDISPLAY td, int w) { - reinterpret_cast(td)->linenumber_width(w); + reinterpret_cast(td)->linenumber_width(w); } diff --git a/src/c_fl_text_editor.cpp b/src/c_fl_text_editor.cpp index a99774f..156d439 100644 --- a/src/c_fl_text_editor.cpp +++ b/src/c_fl_text_editor.cpp @@ -58,31 +58,31 @@ void free_fl_text_editor(TEXTEDITOR te) { void fl_text_editor_undo(TEXTEDITOR te) { - My_Text_Editor::kf_undo(0, reinterpret_cast(te)); + Fl_Text_Editor::kf_undo(0, reinterpret_cast(te)); } void fl_text_editor_cut(TEXTEDITOR te) { - My_Text_Editor::kf_cut(0, reinterpret_cast(te)); + Fl_Text_Editor::kf_cut(0, reinterpret_cast(te)); } void fl_text_editor_copy(TEXTEDITOR te) { - My_Text_Editor::kf_copy(0, reinterpret_cast(te)); + Fl_Text_Editor::kf_copy(0, reinterpret_cast(te)); } void fl_text_editor_paste(TEXTEDITOR te) { - My_Text_Editor::kf_paste(0, reinterpret_cast(te)); + Fl_Text_Editor::kf_paste(0, reinterpret_cast(te)); } void fl_text_editor_delete(TEXTEDITOR te) { - My_Text_Editor::kf_delete(0, reinterpret_cast(te)); + Fl_Text_Editor::kf_delete(0, reinterpret_cast(te)); } void fl_text_editor_remove_key_binding(TEXTEDITOR te, unsigned int k, unsigned long m) { - reinterpret_cast(te)->remove_key_binding(k, m); + reinterpret_cast(te)->remove_key_binding(k, m); } diff --git a/src/c_fl_widget.cpp b/src/c_fl_widget.cpp index 16c746d..6dab9fa 100644 --- a/src/c_fl_widget.cpp +++ b/src/c_fl_widget.cpp @@ -48,112 +48,112 @@ void free_fl_widget(WIDGET w) { void * fl_widget_get_user_data(WIDGET w) { - return reinterpret_cast(w)->user_data(); + return reinterpret_cast(w)->user_data(); } void fl_widget_set_user_data(WIDGET w, void * d) { - reinterpret_cast(w)->user_data(d); + reinterpret_cast(w)->user_data(d); } int fl_widget_get_box(WIDGET w) { - return reinterpret_cast(w)->box(); + return reinterpret_cast(w)->box(); } void fl_widget_set_box(WIDGET w, int b) { - reinterpret_cast(w)->box(static_cast(b)); + reinterpret_cast(w)->box(static_cast(b)); } const char* fl_widget_get_label(WIDGET w) { - return reinterpret_cast(w)->label(); + return reinterpret_cast(w)->label(); } void fl_widget_set_label(WIDGET w, const char* t) { - reinterpret_cast(w)->copy_label(t); + reinterpret_cast(w)->copy_label(t); } int fl_widget_get_label_font(WIDGET w) { - return reinterpret_cast(w)->labelfont(); + return reinterpret_cast(w)->labelfont(); } void fl_widget_set_label_font(WIDGET w, int f) { - reinterpret_cast(w)->labelfont(static_cast(f)); + reinterpret_cast(w)->labelfont(static_cast(f)); } int fl_widget_get_label_size(WIDGET w) { - return reinterpret_cast(w)->labelsize(); + return reinterpret_cast(w)->labelsize(); } void fl_widget_set_label_size(WIDGET w, int s) { - reinterpret_cast(w)->labelsize(static_cast(s)); + reinterpret_cast(w)->labelsize(static_cast(s)); } int fl_widget_get_label_type(WIDGET w) { - return reinterpret_cast(w)->labeltype(); + return reinterpret_cast(w)->labeltype(); } void fl_widget_set_label_type(WIDGET w, int l) { - reinterpret_cast(w)->labeltype(static_cast(l)); + reinterpret_cast(w)->labeltype(static_cast(l)); } void * fl_widget_get_parent(WIDGET w) { - return reinterpret_cast(w)->parent(); + return reinterpret_cast(w)->parent(); } void fl_widget_set_callback(WIDGET w, void * cb) { - reinterpret_cast(w)->callback(reinterpret_cast(cb)); + reinterpret_cast(w)->callback(reinterpret_cast(cb)); } int fl_widget_get_x(WIDGET w) { - return reinterpret_cast(w)->x(); + return reinterpret_cast(w)->x(); } int fl_widget_get_y(WIDGET w) { - return reinterpret_cast(w)->y(); + return reinterpret_cast(w)->y(); } int fl_widget_get_w(WIDGET w) { - return reinterpret_cast(w)->w(); + return reinterpret_cast(w)->w(); } int fl_widget_get_h(WIDGET w) { - return reinterpret_cast(w)->h(); + return reinterpret_cast(w)->h(); } void fl_widget_size(WIDGET w, int d, int h) { - reinterpret_cast(w)->size(d, h); + reinterpret_cast(w)->size(d, h); } void fl_widget_position(WIDGET w, int x, int y) { - reinterpret_cast(w)->position(x, y); + reinterpret_cast(w)->position(x, y); } void fl_widget_set_image(WIDGET w, void * img) { - reinterpret_cast(w)->image(reinterpret_cast(img)); + reinterpret_cast(w)->image(reinterpret_cast(img)); } diff --git a/src/c_fl_window.cpp b/src/c_fl_window.cpp index eda235a..1413646 100644 --- a/src/c_fl_window.cpp +++ b/src/c_fl_window.cpp @@ -67,36 +67,36 @@ void free_fl_window(WINDOW n) { void fl_window_show(WINDOW n) { - reinterpret_cast(n)->show(); + reinterpret_cast(n)->show(); } void fl_window_hide(WINDOW n) { - reinterpret_cast(n)->hide(); + reinterpret_cast(n)->hide(); } void fl_window_set_label(WINDOW n, char* text) { - reinterpret_cast(n)->copy_label(text); + reinterpret_cast(n)->copy_label(text); } void fl_window_size_range(WINDOW n, int lw, int lh, int hw, int hh, int dw, int dh, int a) { - reinterpret_cast(n)->size_range(lw, lh, hw, hh, dw, dh, a); + reinterpret_cast(n)->size_range(lw, lh, hw, hh, dw, dh, a); } void fl_window_set_icon(WINDOW n, void * img) { - reinterpret_cast(n)->icon(reinterpret_cast(img)); + reinterpret_cast(n)->icon(reinterpret_cast(img)); } void fl_window_set_modal(WINDOW n) { - reinterpret_cast(n)->set_modal(); + reinterpret_cast(n)->set_modal(); } void fl_window_set_non_modal(WINDOW n) { - reinterpret_cast(n)->set_non_modal(); + reinterpret_cast(n)->set_non_modal(); } diff --git a/src/fltk-widgets-boxes.adb b/src/fltk-widgets-boxes.adb index 2efc591..1c8fa5b 100644 --- a/src/fltk-widgets-boxes.adb +++ b/src/fltk-widgets-boxes.adb @@ -35,6 +35,8 @@ package body FLTK.Widgets.Boxes is procedure Draw_Hook (U : in System.Address) is + package Box_Convert is new System.Address_To_Access_Conversions (Box'Class); + Ada_Box : access Box'Class := Box_Convert.To_Pointer (U); begin @@ -56,12 +58,12 @@ package body FLTK.Widgets.Boxes is procedure Finalize (This : in out Box) is begin - Finalize (Widget (This)); - if (This.Void_Ptr /= System.Null_Address) then - if This in Box then - free_fl_box (This.Void_Ptr); - end if; + if This in Box and then + This.Void_Ptr /= System.Null_Address + then + free_fl_box (This.Void_Ptr); end if; + Finalize (Widget (This)); end Finalize; diff --git a/src/fltk-widgets-boxes.ads b/src/fltk-widgets-boxes.ads index baf6b28..8fd5571 100644 --- a/src/fltk-widgets-boxes.ads +++ b/src/fltk-widgets-boxes.ads @@ -26,8 +26,5 @@ private (This : in out Box); - package Box_Convert is new System.Address_To_Access_Conversions (Box'Class); - - end FLTK.Widgets.Boxes; diff --git a/src/fltk-widgets-buttons-enter.adb b/src/fltk-widgets-buttons-enter.adb index 9a441f1..d9575ca 100644 --- a/src/fltk-widgets-buttons-enter.adb +++ b/src/fltk-widgets-buttons-enter.adb @@ -35,6 +35,9 @@ package body FLTK.Widgets.Buttons.Enter is procedure Draw_Hook (U : in System.Address) is + package Enter_Button_Convert is new + System.Address_To_Access_Conversions (Enter_Button'Class); + Ada_Enter_Button : access Enter_Button'Class := Enter_Button_Convert.To_Pointer (U); begin @@ -56,12 +59,12 @@ package body FLTK.Widgets.Buttons.Enter is procedure Finalize (This : in out Enter_Button) is begin - Finalize (Button (This)); - if (This.Void_Ptr /= System.Null_Address) then - if This in Enter_Button then - free_fl_return_button (This.Void_Ptr); - end if; + if This in Enter_Button and then + This.Void_Ptr /= System.Null_Address + then + free_fl_return_button (This.Void_Ptr); end if; + Finalize (Button (This)); end Finalize; diff --git a/src/fltk-widgets-buttons-enter.ads b/src/fltk-widgets-buttons-enter.ads index 915589a..d6c42ac 100644 --- a/src/fltk-widgets-buttons-enter.ads +++ b/src/fltk-widgets-buttons-enter.ads @@ -29,9 +29,5 @@ private (This : in out Enter_Button); - package Enter_Button_Convert is new System.Address_To_Access_Conversions - (Enter_Button'Class); - - end FLTK.Widgets.Buttons.Enter; diff --git a/src/fltk-widgets-buttons-light-check.adb b/src/fltk-widgets-buttons-light-check.adb index 1d72d47..c906a6c 100644 --- a/src/fltk-widgets-buttons-light-check.adb +++ b/src/fltk-widgets-buttons-light-check.adb @@ -35,6 +35,9 @@ package body FLTK.Widgets.Buttons.Light.Check is procedure Draw_Hook (U : in System.Address) is + package Check_Button_Convert is new + System.Address_To_Access_Conversions (Check_Button'Class); + Ada_Check_Button : access Check_Button'Class := Check_Button_Convert.To_Pointer (U); begin @@ -56,12 +59,12 @@ package body FLTK.Widgets.Buttons.Light.Check is procedure Finalize (This : in out Check_Button) is begin - Finalize (Light_Button (This)); - if (This.Void_Ptr /= System.Null_Address) then - if This in Check_Button then - free_fl_check_button (This.Void_Ptr); - end if; + if This in Check_Button and then + This.Void_Ptr /= System.Null_Address + then + free_fl_check_button (This.Void_Ptr); end if; + Finalize (Light_Button (This)); end Finalize; diff --git a/src/fltk-widgets-buttons-light-check.ads b/src/fltk-widgets-buttons-light-check.ads index 13a92ea..e5fe5bc 100644 --- a/src/fltk-widgets-buttons-light-check.ads +++ b/src/fltk-widgets-buttons-light-check.ads @@ -26,9 +26,5 @@ private (This : in out Check_Button); - package Check_Button_Convert is new System.Address_To_Access_Conversions - (Check_Button'Class); - - end FLTK.Widgets.Buttons.Light.Check; diff --git a/src/fltk-widgets-buttons-light-radio.adb b/src/fltk-widgets-buttons-light-radio.adb index 83783b7..c04d628 100644 --- a/src/fltk-widgets-buttons-light-radio.adb +++ b/src/fltk-widgets-buttons-light-radio.adb @@ -35,6 +35,9 @@ package body FLTK.Widgets.Buttons.Light.Radio is procedure Draw_Hook (U : in System.Address) is + package Radio_Light_Button_Convert is new + System.Address_To_Access_Conversions (Radio_Light_Button'Class); + Ada_Radio_Light_Button : access Radio_Light_Button'Class := Radio_Light_Button_Convert.To_Pointer (U); begin @@ -56,12 +59,12 @@ package body FLTK.Widgets.Buttons.Light.Radio is procedure Finalize (This : in out Radio_Light_Button) is begin - Finalize (Light_Button (This)); - if (This.Void_Ptr /= System.Null_Address) then - if This in Radio_Light_Button then - free_fl_radio_light_button (This.Void_Ptr); - end if; + if This in Radio_Light_Button and then + This.Void_Ptr /= System.Null_Address + then + free_fl_radio_light_button (This.Void_Ptr); end if; + Finalize (Light_Button (This)); end Finalize; diff --git a/src/fltk-widgets-buttons-light-radio.ads b/src/fltk-widgets-buttons-light-radio.ads index f702649..0854b57 100644 --- a/src/fltk-widgets-buttons-light-radio.ads +++ b/src/fltk-widgets-buttons-light-radio.ads @@ -26,9 +26,5 @@ private (This : in out Radio_Light_Button); - package Radio_Light_Button_Convert is new System.Address_To_Access_Conversions - (Radio_Light_Button'Class); - - end FLTK.Widgets.Buttons.Light.Radio; diff --git a/src/fltk-widgets-buttons-light-round-radio.adb b/src/fltk-widgets-buttons-light-round-radio.adb index 75e3fcf..8c95122 100644 --- a/src/fltk-widgets-buttons-light-round-radio.adb +++ b/src/fltk-widgets-buttons-light-round-radio.adb @@ -35,6 +35,9 @@ package body FLTK.Widgets.Buttons.Light.Round.Radio is procedure Draw_Hook (U : in System.Address) is + package Radio_Round_Button_Convert is new + System.Address_To_Access_Conversions (Radio_Round_Button'Class); + Ada_Radio_Round_Button : access Radio_Round_Button'Class := Radio_Round_Button_Convert.To_Pointer (U); begin @@ -56,12 +59,12 @@ package body FLTK.Widgets.Buttons.Light.Round.Radio is procedure Finalize (This : in out Radio_Round_Button) is begin - Finalize (Round_Button (This)); - if (This.Void_Ptr /= System.Null_Address) then - if This in Radio_Round_Button then - free_fl_radio_round_button (This.Void_Ptr); - end if; + if This in Radio_Round_Button and then + This.Void_Ptr /= System.Null_Address + then + free_fl_radio_round_button (This.Void_Ptr); end if; + Finalize (Round_Button (This)); end Finalize; diff --git a/src/fltk-widgets-buttons-light-round-radio.ads b/src/fltk-widgets-buttons-light-round-radio.ads index ce875f7..9d8ea69 100644 --- a/src/fltk-widgets-buttons-light-round-radio.ads +++ b/src/fltk-widgets-buttons-light-round-radio.ads @@ -26,9 +26,5 @@ private (This : in out Radio_Round_Button); - package Radio_Round_Button_Convert is new System.Address_To_Access_Conversions - (Radio_Round_Button'Class); - - end FLTK.Widgets.Buttons.Light.Round.Radio; diff --git a/src/fltk-widgets-buttons-light-round.adb b/src/fltk-widgets-buttons-light-round.adb index 941d416..769f556 100644 --- a/src/fltk-widgets-buttons-light-round.adb +++ b/src/fltk-widgets-buttons-light-round.adb @@ -35,6 +35,9 @@ package body FLTK.Widgets.Buttons.Light.Round is procedure Draw_Hook (U : in System.Address) is + package Round_Button_Convert is new + System.Address_To_Access_Conversions (Round_Button'Class); + Ada_Round_Button : access Round_Button'Class := Round_Button_Convert.To_Pointer (U); begin @@ -56,12 +59,12 @@ package body FLTK.Widgets.Buttons.Light.Round is procedure Finalize (This : in out Round_Button) is begin - Finalize (Light_Button (This)); - if (This.Void_Ptr /= System.Null_Address) then - if This in Round_Button then - free_fl_round_button (This.Void_Ptr); - end if; + if This in Round_Button and then + This.Void_Ptr /= System.Null_Address + then + free_fl_round_button (This.Void_Ptr); end if; + Finalize (Light_Button (This)); end Finalize; diff --git a/src/fltk-widgets-buttons-light-round.ads b/src/fltk-widgets-buttons-light-round.ads index 26d6904..28034ed 100644 --- a/src/fltk-widgets-buttons-light-round.ads +++ b/src/fltk-widgets-buttons-light-round.ads @@ -26,9 +26,5 @@ private (This : in out Round_Button); - package Round_Button_Convert is new System.Address_To_Access_Conversions - (Round_Button'Class); - - end FLTK.Widgets.Buttons.Light.Round; diff --git a/src/fltk-widgets-buttons-light.adb b/src/fltk-widgets-buttons-light.adb index 88fa147..e3b1cfd 100644 --- a/src/fltk-widgets-buttons-light.adb +++ b/src/fltk-widgets-buttons-light.adb @@ -35,6 +35,9 @@ package body FLTK.Widgets.Buttons.Light is procedure Draw_Hook (U : in System.Address) is + package Light_Button_Convert is new + System.Address_To_Access_Conversions (Light_Button'Class); + Ada_Light_Button : access Light_Button'Class := Light_Button_Convert.To_Pointer (U); begin @@ -56,12 +59,12 @@ package body FLTK.Widgets.Buttons.Light is procedure Finalize (This : in out Light_Button) is begin - Finalize (Button (This)); - if (This.Void_Ptr /= System.Null_Address) then - if This in Light_Button then - free_fl_light_button (This.Void_Ptr); - end if; + if This in Light_Button and then + This.Void_Ptr /= System.Null_Address + then + free_fl_light_button (This.Void_Ptr); end if; + Finalize (Button (This)); end Finalize; diff --git a/src/fltk-widgets-buttons-light.ads b/src/fltk-widgets-buttons-light.ads index 4e5eef6..8d6e83f 100644 --- a/src/fltk-widgets-buttons-light.ads +++ b/src/fltk-widgets-buttons-light.ads @@ -26,9 +26,5 @@ private (This : in out Light_Button); - package Light_Button_Convert is new System.Address_To_Access_Conversions - (Light_Button'Class); - - end FLTK.Widgets.Buttons.Light; diff --git a/src/fltk-widgets-buttons-radio.adb b/src/fltk-widgets-buttons-radio.adb index 8f0b6eb..2b932c3 100644 --- a/src/fltk-widgets-buttons-radio.adb +++ b/src/fltk-widgets-buttons-radio.adb @@ -35,6 +35,9 @@ package body FLTK.Widgets.Buttons.Radio is procedure Draw_Hook (U : in System.Address) is + package Radio_Button_Convert is new + System.Address_To_Access_Conversions (Radio_Button'Class); + Ada_Radio_Button : access Radio_Button'Class := Radio_Button_Convert.To_Pointer (U); begin @@ -56,12 +59,12 @@ package body FLTK.Widgets.Buttons.Radio is procedure Finalize (This : in out Radio_Button) is begin - Finalize (Button (This)); - if This.Void_Ptr /= System.Null_Address then - if This in Radio_Button then - free_fl_radio_button (This.Void_Ptr); - end if; + if This in Radio_Button and then + This.Void_Ptr /= System.Null_Address + then + free_fl_radio_button (This.Void_Ptr); end if; + Finalize (Button (This)); end Finalize; diff --git a/src/fltk-widgets-buttons-radio.ads b/src/fltk-widgets-buttons-radio.ads index 6fca4fb..fcdb47a 100644 --- a/src/fltk-widgets-buttons-radio.ads +++ b/src/fltk-widgets-buttons-radio.ads @@ -26,9 +26,5 @@ private (This : in out Radio_Button); - package Radio_Button_Convert is new System.Address_To_Access_Conversions - (Radio_Button'Class); - - end FLTK.Widgets.Buttons.Radio; diff --git a/src/fltk-widgets-buttons-repeat.adb b/src/fltk-widgets-buttons-repeat.adb index dd7d0fd..7d0f0bd 100644 --- a/src/fltk-widgets-buttons-repeat.adb +++ b/src/fltk-widgets-buttons-repeat.adb @@ -35,6 +35,9 @@ package body FLTK.Widgets.Buttons.Repeat is procedure Draw_Hook (U : in System.Address) is + package Repeat_Button_Convert is new + System.Address_To_Access_Conversions (Repeat_Button'Class); + Ada_Repeat_Button : access Repeat_Button'Class := Repeat_Button_Convert.To_Pointer (U); begin @@ -56,12 +59,12 @@ package body FLTK.Widgets.Buttons.Repeat is procedure Finalize (This : in out Repeat_Button) is begin - Finalize (Button (This)); - if This.Void_Ptr /= System.Null_Address then - if This in Repeat_Button then - free_fl_repeat_button (This.Void_Ptr); - end if; + if This in Repeat_Button and then + This.Void_Ptr /= System.Null_Address + then + free_fl_repeat_button (This.Void_Ptr); end if; + Finalize (Button (This)); end Finalize; diff --git a/src/fltk-widgets-buttons-repeat.ads b/src/fltk-widgets-buttons-repeat.ads index f5ccda0..e05d85a 100644 --- a/src/fltk-widgets-buttons-repeat.ads +++ b/src/fltk-widgets-buttons-repeat.ads @@ -26,9 +26,5 @@ private (This : in out Repeat_Button); - package Repeat_Button_Convert is new System.Address_To_Access_Conversions - (Repeat_Button'Class); - - end FLTK.Widgets.Buttons.Repeat; diff --git a/src/fltk-widgets-buttons-toggle.adb b/src/fltk-widgets-buttons-toggle.adb index 287a5d4..a228130 100644 --- a/src/fltk-widgets-buttons-toggle.adb +++ b/src/fltk-widgets-buttons-toggle.adb @@ -35,6 +35,9 @@ package body FLTK.Widgets.Buttons.Toggle is procedure Draw_Hook (U : in System.Address) is + package Toggle_Button_Convert is new + System.Address_To_Access_Conversions (Toggle_Button'Class); + Ada_Toggle_Button : access Toggle_Button'Class := Toggle_Button_Convert.To_Pointer (U); begin @@ -56,12 +59,12 @@ package body FLTK.Widgets.Buttons.Toggle is procedure Finalize (This : in out Toggle_Button) is begin - Finalize (Button (This)); - if This.Void_Ptr /= System.Null_Address then - if This in Toggle_Button then - free_fl_toggle_button (This.Void_Ptr); - end if; + if This in Toggle_Button and then + This.Void_Ptr /= System.Null_Address + then + free_fl_toggle_button (This.Void_Ptr); end if; + Finalize (Button (This)); end Finalize; diff --git a/src/fltk-widgets-buttons-toggle.ads b/src/fltk-widgets-buttons-toggle.ads index 7d4262e..256a7f7 100644 --- a/src/fltk-widgets-buttons-toggle.ads +++ b/src/fltk-widgets-buttons-toggle.ads @@ -26,9 +26,5 @@ private (This : in out Toggle_Button); - package Toggle_Button_Convert is new System.Address_To_Access_Conversions - (Toggle_Button'Class); - - end FLTK.Widgets.Buttons.Toggle; diff --git a/src/fltk-widgets-buttons.adb b/src/fltk-widgets-buttons.adb index b1f9d2a..4eb2ffb 100644 --- a/src/fltk-widgets-buttons.adb +++ b/src/fltk-widgets-buttons.adb @@ -49,6 +49,8 @@ package body FLTK.Widgets.Buttons is procedure Draw_Hook (U : in System.Address) is + package Button_Convert is new System.Address_To_Access_Conversions (Button'Class); + Ada_Button : access Button'Class := Button_Convert.To_Pointer (U); begin @@ -70,12 +72,12 @@ package body FLTK.Widgets.Buttons is procedure Finalize (This : in out Button) is begin - Finalize (Widget (This)); - if This.Void_Ptr /= System.Null_Address then - if This in Button then - free_fl_button (This.Void_Ptr); - end if; + if This in Button and then + This.Void_Ptr /= System.Null_Address + then + free_fl_button (This.Void_Ptr); end if; + Finalize (Widget (This)); end Finalize; diff --git a/src/fltk-widgets-buttons.ads b/src/fltk-widgets-buttons.ads index d4b421b..f21fed4 100644 --- a/src/fltk-widgets-buttons.ads +++ b/src/fltk-widgets-buttons.ads @@ -43,8 +43,5 @@ private (This : in out Button); - package Button_Convert is new System.Address_To_Access_Conversions (Button'Class); - - end FLTK.Widgets.Buttons; diff --git a/src/fltk-widgets-groups-text_displays-text_editors.adb b/src/fltk-widgets-groups-text_displays-text_editors.adb index 6555926..2424a7e 100644 --- a/src/fltk-widgets-groups-text_displays-text_editors.adb +++ b/src/fltk-widgets-groups-text_displays-text_editors.adb @@ -61,6 +61,9 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is procedure Draw_Hook (U : in System.Address) is + package Text_Editor_Convert is new + System.Address_To_Access_Conversions (Text_Editor'Class); + Ada_Text_Editor : access Text_Editor'Class := Text_Editor_Convert.To_Pointer (U); begin @@ -82,12 +85,13 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is procedure Finalize (This : in out Text_Editor) is begin - Finalize (Text_Display (This)); - if This.Void_Ptr /= System.Null_Address then - if This in Text_Editor then - free_fl_text_editor (This.Void_Ptr); - end if; + if This in Text_Editor and then + This.Void_Ptr /= System.Null_Address + then + This.Clear; + free_fl_text_editor (This.Void_Ptr); end if; + Finalize (Text_Display (This)); end Finalize; diff --git a/src/fltk-widgets-groups-text_displays-text_editors.ads b/src/fltk-widgets-groups-text_displays-text_editors.ads index 10652fc..504de23 100644 --- a/src/fltk-widgets-groups-text_displays-text_editors.ads +++ b/src/fltk-widgets-groups-text_displays-text_editors.ads @@ -54,9 +54,5 @@ private (This : in out Text_Editor); - package Text_Editor_Convert is new System.Address_To_Access_Conversions - (Text_Editor'Class); - - end FLTK.Widgets.Groups.Text_Displays.Text_Editors; diff --git a/src/fltk-widgets-groups-text_displays.adb b/src/fltk-widgets-groups-text_displays.adb index 155ff5c..d8c58d0 100644 --- a/src/fltk-widgets-groups-text_displays.adb +++ b/src/fltk-widgets-groups-text_displays.adb @@ -119,6 +119,9 @@ package body FLTK.Widgets.Groups.Text_Displays is procedure Draw_Hook (U : in System.Address) is + package Text_Display_Convert is new + System.Address_To_Access_Conversions (Text_Display'Class); + Ada_Text_Display : access Text_Display'Class := Text_Display_Convert.To_Pointer (U); begin @@ -140,12 +143,13 @@ package body FLTK.Widgets.Groups.Text_Displays is procedure Finalize (This : in out Text_Display) is begin - Finalize (Group (This)); - if (This.Void_Ptr /= System.Null_Address) then - if This in Text_Display then - free_fl_text_display (This.Void_Ptr); - end if; + if This in Text_Display and then + This.Void_Ptr /= System.Null_Address + then + This.Clear; + free_fl_text_display (This.Void_Ptr); end if; + Finalize (Group (This)); end Finalize; diff --git a/src/fltk-widgets-groups-text_displays.ads b/src/fltk-widgets-groups-text_displays.ads index bcd8310..66d69de 100644 --- a/src/fltk-widgets-groups-text_displays.ads +++ b/src/fltk-widgets-groups-text_displays.ads @@ -124,9 +124,5 @@ private (This : in out Text_Display); - package Text_Display_Convert is new System.Address_To_Access_Conversions - (Text_Display'Class); - - end FLTK.Widgets.Groups.Text_Displays; diff --git a/src/fltk-widgets-groups-windows-double.adb b/src/fltk-widgets-groups-windows-double.adb index 3fc13a4..fc1c4dd 100644 --- a/src/fltk-widgets-groups-windows-double.adb +++ b/src/fltk-widgets-groups-windows-double.adb @@ -48,6 +48,9 @@ package body FLTK.Widgets.Groups.Windows.Double is procedure Draw_Hook (U : in System.Address) is + package Double_Window_Convert is new + System.Address_To_Access_Conversions (Double_Window'Class); + Ada_Window : access Double_Window'Class := Double_Window_Convert.To_Pointer (U); begin @@ -69,12 +72,13 @@ package body FLTK.Widgets.Groups.Windows.Double is procedure Finalize (This : in out Double_Window) is begin - Finalize (Window (This)); - if This.Void_Ptr /= System.Null_Address then - if This in Double_Window then - free_fl_double_window (This.Void_Ptr); - end if; + if This in Double_Window and then + This.Void_Ptr /= System.Null_Address + then + This.Clear; + free_fl_double_window (This.Void_Ptr); end if; + Finalize (Window (This)); end Finalize; diff --git a/src/fltk-widgets-groups-windows-double.ads b/src/fltk-widgets-groups-windows-double.ads index 3e8be5f..6b7cbb8 100644 --- a/src/fltk-widgets-groups-windows-double.ads +++ b/src/fltk-widgets-groups-windows-double.ads @@ -39,9 +39,5 @@ private (This : in out Double_Window); - package Double_Window_Convert is new System.Address_To_Access_Conversions - (Double_Window'Class); - - end FLTK.Widgets.Groups.Windows.Double; diff --git a/src/fltk-widgets-groups-windows-single-menu.adb b/src/fltk-widgets-groups-windows-single-menu.adb index 9d38a37..08e74e2 100644 --- a/src/fltk-widgets-groups-windows-single-menu.adb +++ b/src/fltk-widgets-groups-windows-single-menu.adb @@ -66,6 +66,9 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is procedure Draw_Hook (U : in System.Address) is + package Menu_Window_Convert is new + System.Address_To_Access_Conversions (Menu_Window'Class); + Ada_Window : access Menu_Window'Class := Menu_Window_Convert.To_Pointer (U); begin @@ -87,12 +90,13 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is procedure Finalize (This : in out Menu_Window) is begin - Finalize (Single_Window (This)); - if This.Void_Ptr /= System.Null_Address then - if This in Menu_Window then - free_fl_menu_window (This.Void_Ptr); - end if; + if This in Menu_Window and then + This.Void_Ptr /= System.Null_Address + then + This.Clear; + free_fl_menu_window (This.Void_Ptr); end if; + Finalize (Single_Window (This)); end Finalize; diff --git a/src/fltk-widgets-groups-windows-single-menu.ads b/src/fltk-widgets-groups-windows-single-menu.ads index 7ca43f9..693bf72 100644 --- a/src/fltk-widgets-groups-windows-single-menu.ads +++ b/src/fltk-widgets-groups-windows-single-menu.ads @@ -53,9 +53,5 @@ private (This : in out Menu_Window); - package Menu_Window_Convert is new System.Address_To_Access_Conversions - (Menu_Window'Class); - - end FLTK.Widgets.Groups.Windows.Single.Menu; diff --git a/src/fltk-widgets-groups-windows-single.adb b/src/fltk-widgets-groups-windows-single.adb index 320ea3c..ea7590c 100644 --- a/src/fltk-widgets-groups-windows-single.adb +++ b/src/fltk-widgets-groups-windows-single.adb @@ -48,6 +48,9 @@ package body FLTK.Widgets.Groups.Windows.Single is procedure Draw_Hook (U : in System.Address) is + package Single_Window_Convert is new + System.Address_To_Access_Conversions (Single_Window'Class); + Ada_Window : access Single_Window'Class := Single_Window_Convert.To_Pointer (U); begin @@ -69,12 +72,13 @@ package body FLTK.Widgets.Groups.Windows.Single is procedure Finalize (This : in out Single_Window) is begin - Finalize (Window (This)); - if This.Void_Ptr /= System.Null_Address then - if This in Single_Window then - free_fl_single_window (This.Void_Ptr); - end if; + if This in Single_Window and then + This.Void_Ptr /= System.Null_Address + then + This.Clear; + free_fl_single_window (This.Void_Ptr); end if; + Finalize (Window (This)); end Finalize; diff --git a/src/fltk-widgets-groups-windows-single.ads b/src/fltk-widgets-groups-windows-single.ads index b598306..22b9b3c 100644 --- a/src/fltk-widgets-groups-windows-single.ads +++ b/src/fltk-widgets-groups-windows-single.ads @@ -39,9 +39,5 @@ private (This : in out Single_Window); - package Single_Window_Convert is new System.Address_To_Access_Conversions - (Single_Window'Class); - - end FLTK.Widgets.Groups.Windows.Single; diff --git a/src/fltk-widgets-groups-windows.adb b/src/fltk-widgets-groups-windows.adb index f217403..54b29c4 100644 --- a/src/fltk-widgets-groups-windows.adb +++ b/src/fltk-widgets-groups-windows.adb @@ -71,6 +71,8 @@ package body FLTK.Widgets.Groups.Windows is procedure Draw_Hook (U : in System.Address) is + package Window_Convert is new System.Address_To_Access_Conversions (Window'Class); + Ada_Window : access Window'Class := Window_Convert.To_Pointer (U); begin @@ -92,12 +94,13 @@ package body FLTK.Widgets.Groups.Windows is procedure Finalize (This : in out Window) is begin - Finalize (Group (This)); - if This.Void_Ptr /= System.Null_Address then - if This in Window then - free_fl_window (This.Void_Ptr); - end if; + if This in Window and then + This.Void_Ptr /= System.Null_Address + then + This.Clear; + free_fl_window (This.Void_Ptr); end if; + Finalize (Group (This)); end Finalize; diff --git a/src/fltk-widgets-groups-windows.ads b/src/fltk-widgets-groups-windows.ads index 5351212..79df6f2 100644 --- a/src/fltk-widgets-groups-windows.ads +++ b/src/fltk-widgets-groups-windows.ads @@ -67,8 +67,5 @@ private (This : in out Window); - package Window_Convert is new System.Address_To_Access_Conversions (Window'Class); - - end FLTK.Widgets.Groups.Windows; diff --git a/src/fltk-widgets-groups.adb b/src/fltk-widgets-groups.adb index 9bcb78f..669e2a8 100644 --- a/src/fltk-widgets-groups.adb +++ b/src/fltk-widgets-groups.adb @@ -73,6 +73,8 @@ package body FLTK.Widgets.Groups is procedure Draw_Hook (U : in System.Address) is + package Group_Convert is new System.Address_To_Access_Conversions (Group'Class); + Ada_Group : access Group'Class := Group_Convert.To_Pointer (U); begin @@ -94,13 +96,13 @@ package body FLTK.Widgets.Groups is procedure Finalize (This : in out Group) is begin - Finalize (Widget (This)); - if This.Void_Ptr /= System.Null_Address then + if This in Group and then + This.Void_Ptr /= System.Null_Address + then This.Clear; - if This in Group then - free_fl_group (This.Void_Ptr); - end if; + free_fl_group (This.Void_Ptr); end if; + Finalize (Widget (This)); end Finalize; diff --git a/src/fltk-widgets-groups.ads b/src/fltk-widgets-groups.ads index a45e836..506843a 100644 --- a/src/fltk-widgets-groups.ads +++ b/src/fltk-widgets-groups.ads @@ -77,9 +77,6 @@ private (This : in out Group); - package Group_Convert is new System.Address_To_Access_Conversions (Group'Class); - - procedure fl_group_end (G : in System.Address); pragma Import (C, fl_group_end, "fl_group_end"); diff --git a/src/fltk-widgets-inputs-int.adb b/src/fltk-widgets-inputs-int.adb index 42cb22b..1b73c6a 100644 --- a/src/fltk-widgets-inputs-int.adb +++ b/src/fltk-widgets-inputs-int.adb @@ -40,6 +40,9 @@ package body FLTK.Widgets.Inputs.Int is procedure Draw_Hook (U : in System.Address) is + package Integer_Input_Convert is new + System.Address_To_Access_Conversions (Integer_Input'Class); + Ada_Input : access Integer_Input'Class := Integer_Input_Convert.To_Pointer (U); begin @@ -61,12 +64,12 @@ package body FLTK.Widgets.Inputs.Int is procedure Finalize (This : in out Integer_Input) is begin - Finalize (Input (This)); - if This.Void_Ptr /= System.Null_Address then - if This in Integer_Input then - free_fl_int_input (This.Void_Ptr); - end if; + if This in Integer_Input and then + This.Void_Ptr /= System.Null_Address + then + free_fl_int_input (This.Void_Ptr); end if; + Finalize (Input (This)); end Finalize; diff --git a/src/fltk-widgets-inputs-int.ads b/src/fltk-widgets-inputs-int.ads index 3f210c0..e8d1184 100644 --- a/src/fltk-widgets-inputs-int.ads +++ b/src/fltk-widgets-inputs-int.ads @@ -31,9 +31,5 @@ private (This : in out Integer_Input); - package Integer_Input_Convert is new System.Address_To_Access_Conversions - (Integer_Input'Class); - - end FLTK.Widgets.Inputs.Int; diff --git a/src/fltk-widgets-inputs.adb b/src/fltk-widgets-inputs.adb index 83420ff..9cf7a74 100644 --- a/src/fltk-widgets-inputs.adb +++ b/src/fltk-widgets-inputs.adb @@ -41,6 +41,8 @@ package body FLTK.Widgets.Inputs is procedure Draw_Hook (U : in System.Address) is + package Input_Convert is new System.Address_To_Access_Conversions (Input'Class); + Ada_Input : access Input'Class := Input_Convert.To_Pointer (U); begin @@ -62,12 +64,12 @@ package body FLTK.Widgets.Inputs is procedure Finalize (This : in out Input) is begin - Finalize (Widget (This)); - if This.Void_Ptr /= System.Null_Address then - if This in Input then - free_fl_input (This.Void_Ptr); - end if; + if This in Input and then + This.Void_Ptr /= System.Null_Address + then + free_fl_input (This.Void_Ptr); end if; + Finalize (Widget (This)); end Finalize; diff --git a/src/fltk-widgets-inputs.ads b/src/fltk-widgets-inputs.ads index a60f524..350ac55 100644 --- a/src/fltk-widgets-inputs.ads +++ b/src/fltk-widgets-inputs.ads @@ -31,8 +31,5 @@ private (This : in out Input); - package Input_Convert is new System.Address_To_Access_Conversions (Input'Class); - - end FLTK.Widgets.Inputs; diff --git a/src/fltk-widgets-menus-menu_bars.adb b/src/fltk-widgets-menus-menu_bars.adb index b367c86..1ca0179 100644 --- a/src/fltk-widgets-menus-menu_bars.adb +++ b/src/fltk-widgets-menus-menu_bars.adb @@ -35,6 +35,9 @@ package body FLTK.Widgets.Menus.Menu_Bars is procedure Draw_Hook (U : in System.Address) is + package Menu_Bar_Convert is new + System.Address_To_Access_Conversions (Menu_Bar'Class); + Ada_Menu_Bar : access Menu_Bar'Class := Menu_Bar_Convert.To_Pointer (U); begin @@ -56,12 +59,12 @@ package body FLTK.Widgets.Menus.Menu_Bars is procedure Finalize (This : in out Menu_Bar) is begin - Finalize (Menu (This)); - if This.Void_Ptr /= System.Null_Address then - if This in Menu_Bar then - free_fl_menu_bar (This.Void_Ptr); - end if; + if This in Menu_Bar and then + This.Void_Ptr /= System.Null_Address + then + free_fl_menu_bar (This.Void_Ptr); end if; + Finalize (Menu (This)); end Finalize; diff --git a/src/fltk-widgets-menus-menu_bars.ads b/src/fltk-widgets-menus-menu_bars.ads index a30ed76..5c5abcc 100644 --- a/src/fltk-widgets-menus-menu_bars.ads +++ b/src/fltk-widgets-menus-menu_bars.ads @@ -26,9 +26,5 @@ private (This : in out Menu_Bar); - package Menu_Bar_Convert is new System.Address_To_Access_Conversions - (Menu_Bar'Class); - - end FLTK.Widgets.Menus.Menu_Bars; diff --git a/src/fltk-widgets-menus-menu_buttons.adb b/src/fltk-widgets-menus-menu_buttons.adb index 3054f63..4fedc08 100644 --- a/src/fltk-widgets-menus-menu_buttons.adb +++ b/src/fltk-widgets-menus-menu_buttons.adb @@ -40,6 +40,9 @@ package body FLTK.Widgets.Menus.Menu_Buttons is procedure Draw_Hook (U : in System.Address) is + package Menu_Button_Convert is new + System.Address_To_Access_Conversions (Menu_Button'Class); + Ada_Menu_Button : access Menu_Button'Class := Menu_Button_Convert.To_Pointer (U); begin @@ -61,12 +64,12 @@ package body FLTK.Widgets.Menus.Menu_Buttons is procedure Finalize (This : in out Menu_Button) is begin - Finalize (Menu (This)); - if This.Void_Ptr /= System.Null_Address then - if This in Menu_Button then - free_fl_menu_button (This.Void_Ptr); - end if; + if This in Menu_Button and then + This.Void_Ptr /= System.Null_Address + then + free_fl_menu_button (This.Void_Ptr); end if; + Finalize (Menu (This)); end Finalize; diff --git a/src/fltk-widgets-menus-menu_buttons.ads b/src/fltk-widgets-menus-menu_buttons.ads index 425a98f..6501d34 100644 --- a/src/fltk-widgets-menus-menu_buttons.ads +++ b/src/fltk-widgets-menus-menu_buttons.ads @@ -35,9 +35,5 @@ private (This : in out Menu_Button); - package Menu_Button_Convert is new System.Address_To_Access_Conversions - (Menu_Button'Class); - - end FLTK.Widgets.Menus.Menu_Buttons; diff --git a/src/fltk-widgets-menus.adb b/src/fltk-widgets-menus.adb index 84e2f61..7e201b5 100644 --- a/src/fltk-widgets-menus.adb +++ b/src/fltk-widgets-menus.adb @@ -25,10 +25,6 @@ package body FLTK.Widgets.Menus is (W, D : in System.Address); pragma Import (C, menu_set_draw_hook, "menu_set_draw_hook"); - procedure fl_menu_draw - (W : in System.Address); - pragma Import (C, fl_menu_draw, "fl_menu_draw"); - function new_fl_menu (X, Y, W, H : in Interfaces.C.int; Text : in Interfaces.C.char_array) @@ -81,6 +77,8 @@ package body FLTK.Widgets.Menus is procedure Draw_Hook (U : in System.Address) is + package Menu_Convert is new System.Address_To_Access_Conversions (Menu'Class); + Ada_Menu : access Menu'Class := Menu_Convert.To_Pointer (U); begin @@ -90,25 +88,15 @@ package body FLTK.Widgets.Menus is - procedure Draw - (This : in out Menu) is - begin - -- this space intentionally left blank - null; - end Draw; - - - - procedure Finalize (This : in out Menu) is begin - Finalize (Widget (This)); - if This.Void_Ptr /= System.Null_Address then - if This in Menu then - free_fl_menu (This.Void_Ptr); - end if; + if This in Menu and then + This.Void_Ptr /= System.Null_Address + then + free_fl_menu (This.Void_Ptr); end if; + Finalize (Widget (This)); end Finalize; diff --git a/src/fltk-widgets-menus.ads b/src/fltk-widgets-menus.ads index 6cc197d..c33c180 100644 --- a/src/fltk-widgets-menus.ads +++ b/src/fltk-widgets-menus.ads @@ -8,8 +8,6 @@ private with System; package FLTK.Widgets.Menus is - -- still abstract, really, because if the Draw procedure isn't - -- overridden it'll call the abstract C++ method type Menu is new Widget with private; @@ -74,7 +72,7 @@ package FLTK.Widgets.Menus is procedure Draw - (This : in out Menu); + (This : in out Menu) is null; private @@ -105,8 +103,5 @@ private Flag_Divider : constant Menu_Flag := 2#10000000#; - package Menu_Convert is new System.Address_To_Access_Conversions (Menu'Class); - - end FLTK.Widgets.Menus; diff --git a/src/fltk-widgets.adb b/src/fltk-widgets.adb index 292f274..d46b1c4 100644 --- a/src/fltk-widgets.adb +++ b/src/fltk-widgets.adb @@ -22,10 +22,6 @@ package body FLTK.Widgets is (W, D : in System.Address); pragma Import (C, widget_set_draw_hook, "widget_set_draw_hook"); - procedure fl_widget_draw - (W : in System.Address); - pragma Import (C, fl_widget_draw, "fl_widget_draw"); - function new_fl_widget (X, Y, W, H : in Interfaces.C.int; Text : in Interfaces.C.char_array) @@ -147,23 +143,13 @@ package body FLTK.Widgets is - procedure Draw - (This : in out Widget) is - begin - -- this space intentionally left blank - null; - end Draw; - - - - procedure Finalize (This : in out Widget) is begin - if This.Void_Ptr /= System.Null_Address then - if This in Widget then - free_fl_widget (This.Void_Ptr); - end if; + if This in Widget and then + This.Void_Ptr /= System.Null_Address + then + free_fl_widget (This.Void_Ptr); end if; end Finalize; diff --git a/src/fltk-widgets.ads b/src/fltk-widgets.ads index c2b863b..56bad0a 100644 --- a/src/fltk-widgets.ads +++ b/src/fltk-widgets.ads @@ -130,7 +130,7 @@ package FLTK.Widgets is procedure Draw - (This : in out Widget); + (This : in out Widget) is null; private @@ -148,7 +148,6 @@ private package Widget_Convert is new System.Address_To_Access_Conversions (Widget'Class); - -- package Callback_Convert is new System.Address_To_Access_Conversions (Widget_Callback); package Callback_Convert is function To_Pointer is new Ada.Unchecked_Conversion (System.Address, Widget_Callback); function To_Address is new Ada.Unchecked_Conversion (Widget_Callback, System.Address); -- cgit