1. ----------------------------------------------------------------------- 
  2. --          GtkAda - Ada95 binding for the Gimp Toolkit              -- 
  3. --                                                                   -- 
  4. --                 Copyright (C) 2006-2013, AdaCore                  -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- As a special exception, if other files instantiate generics from  -- 
  22. -- this unit, or you link this unit with other files to produce an   -- 
  23. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  24. -- executable to be covered by the GNU General Public License. This  -- 
  25. -- exception does not however invalidate any other reasons why the   -- 
  26. -- executable file  might be covered by the  GNU Public License.     -- 
  27. ----------------------------------------------------------------------- 
  28.  
  29. --  This is a unit purely internal to GtkAda, to ease binding and avoid code 
  30. --  duplication. 
  31. --  Do not use in your own applications, since the interface might change from 
  32. --  release to release. 
  33. --  See also Gtkada.Types 
  34.  
  35. --  with Gdk.Color; 
  36. --  with Gdk.Types; 
  37. with Glib; 
  38. --  with Glib.Object; 
  39. with Gtkada.C; 
  40. with GNAT.Strings; 
  41. with Interfaces.C.Strings; 
  42.  
  43. package Gtkada.Bindings is 
  44.    package ICS renames Interfaces.C.Strings; 
  45.  
  46.    ------------- 
  47.    -- Strings -- 
  48.    ------------- 
  49.  
  50.    function String_Or_Null (S : String) return ICS.chars_ptr; 
  51.    --  Return Null_Ptr if S is the empty string, or a newly allocated string 
  52.    --  otherwise. This is intended mostly for the binding itself. 
  53.  
  54.    type chars_ptr_array_access 
  55.      is access ICS.chars_ptr_array (Interfaces.C.size_t); 
  56.    pragma Convention (C, chars_ptr_array_access); 
  57.    --  Suitable for a C function that returns a gchar** 
  58.  
  59.    procedure g_strfreev (Str_Array : in out chars_ptr_array_access); 
  60.    --  Thin binding to C function of the same name.  Frees a null-terminated 
  61.    --  array of strings, and the array itself.  If called on a null value, 
  62.    --  simply return. 
  63.  
  64.    function To_String_List 
  65.      (C : ICS.chars_ptr_array) return GNAT.Strings.String_List; 
  66.    --  Converts C into a String_List. Returned value must be freed by caller, 
  67.    --  as well as C. C is NULL terminated. 
  68.  
  69.    function To_String_List 
  70.      (C : ICS.chars_ptr_array; N : Glib.Gint) 
  71.       return GNAT.Strings.String_List; 
  72.    --  Converts C into a String_List. N is the number of elements in C. 
  73.    --  Returned value must be freed by caller, as well as C. 
  74.  
  75.    function From_String_List 
  76.      (C : GNAT.Strings.String_List) return ICS.chars_ptr_array; 
  77.    --  Converts C into a chars_ptr_array. Returned value must be freed by 
  78.    --  caller, as well as C. 
  79.  
  80.    function To_Chars_Ptr 
  81.      (C : chars_ptr_array_access) return ICS.chars_ptr_array; 
  82.    --  Return a bounded array that contains the same strings as C (so you 
  83.    --  shouldn't free C). 'Last applies to the result, whereas it doesn't to C. 
  84.  
  85.    ------------ 
  86.    -- Arrays -- 
  87.    ------------ 
  88.    --  See Gtkada.C for more information. 
  89.    --  The packages that are commented out are instanciated in various, 
  90.    --  possibly duplicated places. This is because of elaboration circularity 
  91.    --  issues. 
  92.  
  93.    package Gint_Arrays is new Gtkada.C.Unbounded_Arrays 
  94.      (Glib.Gint, 0, Natural, Glib.Gint_Array); 
  95. --     package Points_Arrays is new Gtkada.C.Unbounded_Arrays 
  96. --       (Gdk.Types.Gdk_Point, (0, 0), Positive, Gdk.Types.Gdk_Points_Array); 
  97. --     package Atom_Arrays is new Gtkada.C.Unbounded_Arrays 
  98. --       (Gdk.Types.Gdk_Atom, Gdk.Types.Gdk_None, 
  99. --        Natural, Gdk.Types.Gdk_Atom_Array); 
  100.    package Pspec_Arrays is new Gtkada.C.Unbounded_Arrays 
  101.      (Glib.Param_Spec, null, Natural, Glib.Param_Spec_Array); 
  102. --     package Signal_Id_Arrays is new Gtkada.C.Unbounded_Arrays 
  103. --       (Glib.Signal_Id, Glib.Null_Signal_Id, Glib.Guint, 
  104. --        Glib.Object.Signal_Id_Array); 
  105.    package GType_Arrays is new Gtkada.C.Unbounded_Arrays 
  106.      (Glib.GType, Glib.GType_None, Glib.Guint, Glib.GType_Array); 
  107. --     package Color_Arrays is new Gtkada.C.Unbounded_Arrays 
  108. --       (Gdk.Color.Gdk_Color, Gdk.Color.Null_Color, Natural, 
  109. --        Gdk.Color.Gdk_Color_Array); 
  110.  
  111. --     type Unbounded_Gint_Array is array (Natural) of Glib.Gint; 
  112. --     pragma Convention (C, Unbounded_Gint_Array); 
  113. --     type Unbounded_Gint_Array_Access is access Unbounded_Gint_Array; 
  114. --     procedure G_Free (Arr : in out Unbounded_Gint_Array_Access); 
  115. --     function To_Gint_Array 
  116. --       (Arr : Unbounded_Gint_Array_Access; N : Glib.Gint) 
  117. --        return Glib.Gint_Array; 
  118.    function To_Gint_Array_Zero_Terminated 
  119.      (Arr : Gint_Arrays.Unbounded_Array_Access) 
  120.       return Glib.Gint_Array; 
  121.    --  Converts Arr, stopping at the first 0 encountered 
  122.  
  123. --     type Unbounded_Points_Array is array (Natural) of Gdk.Types.Gdk_Point; 
  124. --     pragma Convention (C, Unbounded_Points_Array); 
  125. --     type Unbounded_Points_Array_Access is access Unbounded_Points_Array; 
  126. --     procedure G_Free (Arr : in out Unbounded_Points_Array_Access); 
  127. --     function To_Point_Array 
  128. --       (Arr : Unbounded_Points_Array_Access; N : Glib.Gint) 
  129. --        return Gdk.Types.Gdk_Points_Array; 
  130.  
  131. --     type Unbounded_Atom_Array is array (Natural) of Gdk.Types.Gdk_Atom; 
  132. --     pragma Convention (C, Unbounded_Atom_Array); 
  133. --     type Unbounded_Atom_Array_Access is access Unbounded_Atom_Array; 
  134. --     procedure G_Free (Arr : in out Unbounded_Atom_Array_Access); 
  135. --     function To_Atom_Array 
  136. --       (Arr : Unbounded_Atom_Array_Access; N : Glib.Gint) 
  137. --        return Gdk.Types.Gdk_Atom_Array; 
  138.  
  139. --     type Unbounded_Pspec_Array is array (Natural) of Glib.Param_Spec; 
  140. --     pragma Convention (C, Unbounded_Pspec_Array); 
  141. --     type Unbounded_Pspec_Array_Access is access Unbounded_Pspec_Array; 
  142. --     procedure G_Free (Arr : in out Unbounded_Pspec_Array_Access); 
  143. --     function To_Pspec_Array 
  144. --       (Arr : Unbounded_Pspec_Array_Access; N : Glib.Gint) 
  145. --        return Glib.Param_Spec_Array; 
  146.  
  147. --     type Unbounded_Signal_Id_Array is array (Natural) of Glib.Signal_Id; 
  148. --     pragma Convention (C, Unbounded_Signal_Id_Array); 
  149. --   type Unbounded_Signal_Id_Array_Access is access Unbounded_Signal_Id_Array; 
  150. --     procedure G_Free (Arr : in out Unbounded_Signal_Id_Array_Access); 
  151. --     function To_Signal_Id_Array 
  152. --       (Arr : Unbounded_Signal_Id_Array_Access; N : Glib.Guint) 
  153. --        return Glib.Object.Signal_Id_Array; 
  154.  
  155. --     type Unbounded_GType_Array is array (Natural) of Glib.GType; 
  156. --     pragma Convention (C, Unbounded_GType_Array); 
  157. --     type Unbounded_GType_Array_Access is access Unbounded_GType_Array; 
  158. --     procedure G_Free (Arr : in out Unbounded_GType_Array_Access); 
  159. --     function To_GType_Array 
  160. --       (Arr : Unbounded_GType_Array_Access; N : Glib.Guint) 
  161. --        return Glib.GType_Array; 
  162.  
  163. --     type Unbounded_Color_Array is array (Natural) of Gdk.Color.Gdk_Color; 
  164. --     pragma Convention (C, Unbounded_Color_Array); 
  165. --     type Unbounded_Color_Array_Access is access Unbounded_Color_Array; 
  166. --     procedure G_Free (Arr : in out Unbounded_Color_Array_Access); 
  167. --     function To_Color_Array 
  168. --       (Arr : Unbounded_Color_Array_Access; N : Glib.Gint) 
  169. --        return Gdk.Color.Gdk_Color_Array; 
  170. --     function Convert is new Ada.Unchecked_Conversion 
  171. --       (System.Address, Unbounded_Color_Array_Access); 
  172.  
  173. private 
  174. --   pragma Import (C, g_free, "g_free"); 
  175.    pragma Import (C, g_strfreev, "g_strfreev"); 
  176. end Gtkada.Bindings;