From 38e5d2200b48b86772d6921e1553bf76408e5809 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Thu, 1 Mar 2018 19:45:07 +1100 Subject: Corrected C naming terminology for Fl_Clock_Output --- src/c_fl_clock.cpp | 97 --------------------------------------------- src/c_fl_clock.h | 39 ------------------ src/c_fl_clock_output.cpp | 97 +++++++++++++++++++++++++++++++++++++++++++++ src/c_fl_clock_output.h | 39 ++++++++++++++++++ src/fltk-widgets-clocks.adb | 72 ++++++++++++++++----------------- 5 files changed, 172 insertions(+), 172 deletions(-) delete mode 100644 src/c_fl_clock.cpp delete mode 100644 src/c_fl_clock.h create mode 100644 src/c_fl_clock_output.cpp create mode 100644 src/c_fl_clock_output.h diff --git a/src/c_fl_clock.cpp b/src/c_fl_clock.cpp deleted file mode 100644 index 1c16d75..0000000 --- a/src/c_fl_clock.cpp +++ /dev/null @@ -1,97 +0,0 @@ - - -#include -#include "c_fl_clock.h" -#include "c_fl_type.h" - - - - -class My_Clock : public Fl_Clock { - public: - using Fl_Clock::Fl_Clock; - friend void clock_set_draw_hook(CLOCK c, void * d); - friend void fl_clock_draw(CLOCK c); - friend void clock_set_handle_hook(CLOCK c, void * h); - friend int fl_clock_handle(CLOCK c, int e); - protected: - void draw(); - void real_draw(); - int handle(int e); - int real_handle(int e); - d_hook_p draw_hook; - h_hook_p handle_hook; -}; - -void My_Clock::draw() { - (*draw_hook)(this->user_data()); -} - -void My_Clock::real_draw() { - Fl_Clock::draw(); -} - -int My_Clock::handle(int e) { - return (*handle_hook)(this->user_data(), e); -} - -int My_Clock::real_handle(int e) { - return Fl_Clock::handle(e); -} - -void clock_set_draw_hook(CLOCK c, void * d) { - reinterpret_cast(c)->draw_hook = reinterpret_cast(d); -} - -void fl_clock_draw(CLOCK c) { - reinterpret_cast(c)->real_draw(); -} - -void clock_set_handle_hook(CLOCK c, void * h) { - reinterpret_cast(c)->handle_hook = reinterpret_cast(h); -} - -int fl_clock_handle(CLOCK c, int e) { - return reinterpret_cast(c)->real_handle(e); -} - - - - -CLOCK new_fl_clock(int x, int y, int w, int h, char* label) { - My_Clock *c = new My_Clock(x, y, w, h, label); - return c; -} - -void free_fl_clock(CLOCK c) { - delete reinterpret_cast(c); -} - - - - -int fl_clock_get_hour(CLOCK c) { - return reinterpret_cast(c)->hour(); -} - -int fl_clock_get_minute(CLOCK c) { - return reinterpret_cast(c)->minute(); -} - -int fl_clock_get_second(CLOCK c) { - return reinterpret_cast(c)->second(); -} - - -ulong fl_clock_get_value(CLOCK c) { - return reinterpret_cast(c)->value(); -} - -void fl_clock_set_value(CLOCK c, ulong v) { - reinterpret_cast(c)->value(v); -} - -void fl_clock_set_value2(CLOCK c, int h, int m, int s) { - reinterpret_cast(c)->value(h,m,s); -} - diff --git a/src/c_fl_clock.h b/src/c_fl_clock.h deleted file mode 100644 index 3b93456..0000000 --- a/src/c_fl_clock.h +++ /dev/null @@ -1,39 +0,0 @@ - - -#ifndef FL_CLOCK_GUARD -#define FL_CLOCK_GUARD - - - - -typedef void* CLOCK; - - - - -extern "C" void clock_set_draw_hook(CLOCK c, void * d); -extern "C" void fl_clock_draw(CLOCK c); -extern "C" void clock_set_handle_hook(CLOCK c, void * h); -extern "C" int fl_clock_handle(CLOCK c, int e); - - - - -extern "C" CLOCK new_fl_clock(int x, int y, int w, int h, char* label); -extern "C" void free_fl_clock(CLOCK c); - - - - -extern "C" int fl_clock_get_hour(CLOCK c); -extern "C" int fl_clock_get_minute(CLOCK c); -extern "C" int fl_clock_get_second(CLOCK c); - - -extern "C" ulong fl_clock_get_value(CLOCK c); -extern "C" void fl_clock_set_value(CLOCK c, ulong v); -extern "C" void fl_clock_set_value2(CLOCK c, int h, int m, int s); - - -#endif - diff --git a/src/c_fl_clock_output.cpp b/src/c_fl_clock_output.cpp new file mode 100644 index 0000000..62f5e1b --- /dev/null +++ b/src/c_fl_clock_output.cpp @@ -0,0 +1,97 @@ + + +#include +#include "c_fl_clock_output.h" +#include "c_fl_type.h" + + + + +class My_Clock_Output : public Fl_Clock_Output { + public: + using Fl_Clock_Output::Fl_Clock_Output; + friend void clock_output_set_draw_hook(CLOCK_OUTPUT c, void * d); + friend void fl_clock_output_draw(CLOCK_OUTPUT c); + friend void clock_output_set_handle_hook(CLOCK_OUTPUT c, void * h); + friend int fl_clock_output_handle(CLOCK_OUTPUT c, int e); + protected: + void draw(); + void real_draw(); + int handle(int e); + int real_handle(int e); + d_hook_p draw_hook; + h_hook_p handle_hook; +}; + +void My_Clock_Output::draw() { + (*draw_hook)(this->user_data()); +} + +void My_Clock_Output::real_draw() { + Fl_Clock_Output::draw(); +} + +int My_Clock_Output::handle(int e) { + return (*handle_hook)(this->user_data(), e); +} + +int My_Clock_Output::real_handle(int e) { + return Fl_Clock_Output::handle(e); +} + +void clock_output_set_draw_hook(CLOCK_OUTPUT c, void * d) { + reinterpret_cast(c)->draw_hook = reinterpret_cast(d); +} + +void fl_clock_output_draw(CLOCK_OUTPUT c) { + reinterpret_cast(c)->real_draw(); +} + +void clock_output_set_handle_hook(CLOCK_OUTPUT c, void * h) { + reinterpret_cast(c)->handle_hook = reinterpret_cast(h); +} + +int fl_clock_output_handle(CLOCK_OUTPUT c, int e) { + return reinterpret_cast(c)->real_handle(e); +} + + + + +CLOCK_OUTPUT new_fl_clock_output(int x, int y, int w, int h, char* label) { + My_Clock_Output *c = new My_Clock_Output(x, y, w, h, label); + return c; +} + +void free_fl_clock_output(CLOCK_OUTPUT c) { + delete reinterpret_cast(c); +} + + + + +int fl_clock_output_get_hour(CLOCK_OUTPUT c) { + return reinterpret_cast(c)->hour(); +} + +int fl_clock_output_get_minute(CLOCK_OUTPUT c) { + return reinterpret_cast(c)->minute(); +} + +int fl_clock_output_get_second(CLOCK_OUTPUT c) { + return reinterpret_cast(c)->second(); +} + + +ulong fl_clock_output_get_value(CLOCK_OUTPUT c) { + return reinterpret_cast(c)->value(); +} + +void fl_clock_output_set_value(CLOCK_OUTPUT c, ulong v) { + reinterpret_cast(c)->value(v); +} + +void fl_clock_output_set_value2(CLOCK_OUTPUT c, int h, int m, int s) { + reinterpret_cast(c)->value(h,m,s); +} + diff --git a/src/c_fl_clock_output.h b/src/c_fl_clock_output.h new file mode 100644 index 0000000..6a606a5 --- /dev/null +++ b/src/c_fl_clock_output.h @@ -0,0 +1,39 @@ + + +#ifndef FL_CLOCK_OUTPUT_GUARD +#define FL_CLOCK_OUTPUT_GUARD + + + + +typedef void* CLOCK_OUTPUT; + + + + +extern "C" void clock_output_set_draw_hook(CLOCK_OUTPUT c, void * d); +extern "C" void fl_clock_output_draw(CLOCK_OUTPUT c); +extern "C" void clock_output_set_handle_hook(CLOCK_OUTPUT c, void * h); +extern "C" int fl_clock_output_handle(CLOCK_OUTPUT c, int e); + + + + +extern "C" CLOCK_OUTPUT new_fl_clock_output(int x, int y, int w, int h, char* label); +extern "C" void free_fl_clock_output(CLOCK_OUTPUT c); + + + + +extern "C" int fl_clock_output_get_hour(CLOCK_OUTPUT c); +extern "C" int fl_clock_output_get_minute(CLOCK_OUTPUT c); +extern "C" int fl_clock_output_get_second(CLOCK_OUTPUT c); + + +extern "C" ulong fl_clock_output_get_value(CLOCK_OUTPUT c); +extern "C" void fl_clock_output_set_value(CLOCK_OUTPUT c, ulong v); +extern "C" void fl_clock_output_set_value2(CLOCK_OUTPUT c, int h, int m, int s); + + +#endif + diff --git a/src/fltk-widgets-clocks.adb b/src/fltk-widgets-clocks.adb index da53d11..f409af5 100644 --- a/src/fltk-widgets-clocks.adb +++ b/src/fltk-widgets-clocks.adb @@ -13,75 +13,75 @@ use type package body FLTK.Widgets.Clocks is - procedure clock_set_draw_hook + procedure clock_output_set_draw_hook (W, D : in System.Address); - pragma Import (C, clock_set_draw_hook, "clock_set_draw_hook"); + pragma Import (C, clock_output_set_draw_hook, "clock_output_set_draw_hook"); - procedure clock_set_handle_hook + procedure clock_output_set_handle_hook (W, H : in System.Address); - pragma Import (C, clock_set_handle_hook, "clock_set_handle_hook"); + pragma Import (C, clock_output_set_handle_hook, "clock_output_set_handle_hook"); - function new_fl_clock + function new_fl_clock_output (X, Y, W, H : in Interfaces.C.int; Text : in Interfaces.C.char_array) return System.Address; - pragma Import (C, new_fl_clock, "new_fl_clock"); + pragma Import (C, new_fl_clock_output, "new_fl_clock_output"); - procedure free_fl_clock + procedure free_fl_clock_output (F : in System.Address); - pragma Import (C, free_fl_clock, "free_fl_clock"); + pragma Import (C, free_fl_clock_output, "free_fl_clock_output"); - function fl_clock_get_hour + function fl_clock_output_get_hour (C : in System.Address) return Interfaces.C.int; - pragma Import (C, fl_clock_get_hour, "fl_clock_get_hour"); + pragma Import (C, fl_clock_output_get_hour, "fl_clock_output_get_hour"); - function fl_clock_get_minute + function fl_clock_output_get_minute (C : in System.Address) return Interfaces.C.int; - pragma Import (C, fl_clock_get_minute, "fl_clock_get_minute"); + pragma Import (C, fl_clock_output_get_minute, "fl_clock_output_get_minute"); - function fl_clock_get_second + function fl_clock_output_get_second (C : in System.Address) return Interfaces.C.int; - pragma Import (C, fl_clock_get_second, "fl_clock_get_second"); + pragma Import (C, fl_clock_output_get_second, "fl_clock_output_get_second"); - function fl_clock_get_value + function fl_clock_output_get_value (C : in System.Address) return Interfaces.C.unsigned_long; - pragma Import (C, fl_clock_get_value, "fl_clock_get_value"); + pragma Import (C, fl_clock_output_get_value, "fl_clock_output_get_value"); - procedure fl_clock_set_value + procedure fl_clock_output_set_value (C : in System.Address; V : in Interfaces.C.unsigned_long); - pragma Import (C, fl_clock_set_value, "fl_clock_set_value"); + pragma Import (C, fl_clock_output_set_value, "fl_clock_output_set_value"); - procedure fl_clock_set_value2 + procedure fl_clock_output_set_value2 (C : in System.Address; H, M, S : in Interfaces.C.int); - pragma Import (C, fl_clock_set_value2, "fl_clock_set_value2"); + pragma Import (C, fl_clock_output_set_value2, "fl_clock_output_set_value2"); - procedure fl_clock_draw + procedure fl_clock_output_draw (W : in System.Address); - pragma Import (C, fl_clock_draw, "fl_clock_draw"); + pragma Import (C, fl_clock_output_draw, "fl_clock_output_draw"); - function fl_clock_handle + function fl_clock_output_handle (W : in System.Address; E : in Interfaces.C.int) return Interfaces.C.int; - pragma Import (C, fl_clock_handle, "fl_clock_handle"); + pragma Import (C, fl_clock_output_handle, "fl_clock_output_handle"); @@ -92,7 +92,7 @@ package body FLTK.Widgets.Clocks is if This.Void_Ptr /= System.Null_Address and then This in Clock'Class then - free_fl_clock (This.Void_Ptr); + free_fl_clock_output (This.Void_Ptr); This.Void_Ptr := System.Null_Address; end if; Finalize (Widget (This)); @@ -107,7 +107,7 @@ package body FLTK.Widgets.Clocks is return Clock is begin return This : Clock do - This.Void_Ptr := new_fl_clock + This.Void_Ptr := new_fl_clock_output (Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), @@ -116,8 +116,8 @@ package body FLTK.Widgets.Clocks is fl_widget_set_user_data (This.Void_Ptr, Widget_Convert.To_Address (This'Unchecked_Access)); - clock_set_draw_hook (This.Void_Ptr, Draw_Hook'Address); - clock_set_handle_hook (This.Void_Ptr, Handle_Hook'Address); + clock_output_set_draw_hook (This.Void_Ptr, Draw_Hook'Address); + clock_output_set_handle_hook (This.Void_Ptr, Handle_Hook'Address); end return; end Create; @@ -128,7 +128,7 @@ package body FLTK.Widgets.Clocks is (This : in Clock) return Hour is begin - return Hour (fl_clock_get_hour (This.Void_Ptr)); + return Hour (fl_clock_output_get_hour (This.Void_Ptr)); end Get_Hour; @@ -136,7 +136,7 @@ package body FLTK.Widgets.Clocks is (This : in Clock) return Minute is begin - return Minute (fl_clock_get_minute (This.Void_Ptr)); + return Minute (fl_clock_output_get_minute (This.Void_Ptr)); end Get_Minute; @@ -144,7 +144,7 @@ package body FLTK.Widgets.Clocks is (This : in Clock) return Second is begin - return Second (fl_clock_get_second (This.Void_Ptr)); + return Second (fl_clock_output_get_second (This.Void_Ptr)); end Get_Second; @@ -154,7 +154,7 @@ package body FLTK.Widgets.Clocks is (This : in Clock) return Time_Value is begin - return Time_Value (fl_clock_get_value (This.Void_Ptr)); + return Time_Value (fl_clock_output_get_value (This.Void_Ptr)); end Get_Time; @@ -162,7 +162,7 @@ package body FLTK.Widgets.Clocks is (This : in out Clock; To : in Time_Value) is begin - fl_clock_set_value (This.Void_Ptr, Interfaces.C.unsigned_long (To)); + fl_clock_output_set_value (This.Void_Ptr, Interfaces.C.unsigned_long (To)); end Set_Time; @@ -172,7 +172,7 @@ package body FLTK.Widgets.Clocks is Minutes : in Minute; Seconds : in Second) is begin - fl_clock_set_value2 + fl_clock_output_set_value2 (This.Void_Ptr, Interfaces.C.int (Hours), Interfaces.C.int (Minutes), @@ -185,7 +185,7 @@ package body FLTK.Widgets.Clocks is procedure Draw (This : in out Clock) is begin - fl_clock_draw (This.Void_Ptr); + fl_clock_output_draw (This.Void_Ptr); end Draw; @@ -195,7 +195,7 @@ package body FLTK.Widgets.Clocks is return Event_Outcome is begin return Event_Outcome'Val - (fl_clock_handle (This.Void_Ptr, Event_Kind'Pos (Event))); + (fl_clock_output_handle (This.Void_Ptr, Event_Kind'Pos (Event))); end Handle; -- cgit