]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/ada_include/terminal_interface-curses-menus-menu_user_data.adb
ncurses 4.1
[ncurses.git] / Ada95 / ada_include / terminal_interface-curses-menus-menu_user_data.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                           GNAT ncurses Binding                           --
4 --                                                                          --
5 --               Terminal_Interface.Curses.Menus.Menu_User_Data             --
6 --                                                                          --
7 --                                 B O D Y                                  --
8 --                                                                          --
9 --  Version 00.92                                                           --
10 --                                                                          --
11 --  The ncurses Ada95 binding is copyrighted 1996 by                        --
12 --  Juergen Pfeifer, Email: Juergen.Pfeifer@T-Online.de                     --
13 --                                                                          --
14 --  Permission is hereby granted to reproduce and distribute this           --
15 --  binding by any means and for any fee, whether alone or as part          --
16 --  of a larger distribution, in source or in binary form, PROVIDED         --
17 --  this notice is included with any such distribution, and is not          --
18 --  removed from any of its header files. Mention of ncurses and the        --
19 --  author of this binding in any applications linked with it is            --
20 --  highly appreciated.                                                     --
21 --                                                                          --
22 --  This binding comes AS IS with no warranty, implied or expressed.        --
23 ------------------------------------------------------------------------------
24 --  Version Control:
25 --  $Revision: 1.3 $
26 ------------------------------------------------------------------------------
27 with Unchecked_Conversion;
28
29 package body Terminal_Interface.Curses.Menus.Menu_User_Data is
30
31    function To_Address is new
32      Unchecked_Conversion (User_Access,
33                            System.Address);
34    function To_Pointer is new
35      Unchecked_Conversion (System.Address,
36                            User_Access);
37
38    procedure Set_User_Data (Men  : in Menu;
39                             Data : in User_Access)
40    is
41       function Menu_Userptr (Men : Menu) return Ada_User_Wrapper_Access;
42       pragma Import (C, Menu_Userptr, "menu_userptr");
43
44       U : Ada_User_Wrapper_Access := Menu_Userptr (Men);
45    begin
46       if U = null or else U.I = null then
47          raise Menu_Exception;
48       end if;
49       U.U := To_Address (Data);
50    end Set_User_Data;
51
52    procedure Get_User_Data (Men  : in  Menu;
53                             Data : out User_Access)
54    is
55       function Menu_Userptr (Men : Menu) return Ada_User_Wrapper_Access;
56       pragma Import (C, Menu_Userptr, "menu_userptr");
57
58       U : Ada_User_Wrapper_Access := Menu_Userptr (Men);
59    begin
60       if U = null then
61          raise Menu_Exception;
62       else
63          Data := To_Pointer (U.U);
64       end if;
65    end Get_User_Data;
66
67 end Terminal_Interface.Curses.Menus.Menu_User_Data;