1. ----------------------------------------------------------------------- 
  2. --          GtkAda - Ada95 binding for the Gimp Toolkit              -- 
  3. --                                                                   -- 
  4. --                 Copyright (C) 2006-2010, 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. -- -- -- -- -- -- -- -- -- -- -- --
  22. ----------------------------------------------------------------------- 
  23.  
  24. --  This is a unit purely internal to GtkAda, to ease binding and avoid code 
  25. --  duplication. 
  26. --  Do not use in your own applications, since the interface might change from 
  27. --  release to release. 
  28. --  See also Gtkada.Types 
  29.  
  30. --  with Gdk.Color; 
  31. --  with Gdk.Types; 
  32. with Glib; 
  33. --  with Glib.Object; 
  34. with Gtkada.C; 
  35. with GNAT.Strings; 
  36. with Interfaces.C.Strings; 
  37.  
  38. package Gtkada.Bindings is 
  39.    package ICS renames Interfaces.C.Strings; 
  40.  
  41.    ------------- 
  42.    -- Strings -- 
  43.    ------------- 
  44.  
  45.    function String_Or_Null (S : String) return ICS.chars_ptr; 
  46.    --  Return Null_Ptr if S is the empty string, or a newly allocated string 
  47.    --  otherwise. This is intended mostly for the binding itself. 
  48.  
  49.    type chars_ptr_array_access 
  50.      is access ICS.chars_ptr_array (Interfaces.C.size_t); 
  51.    pragma Convention (C, chars_ptr_array_access); 
  52.    --  Suitable for a C function that returns a gchar** 
  53.  
  54.    procedure g_strfreev (Str_Array : in out chars_ptr_array_access); 
  55.    --  Thin binding to C function of the same name.  Frees a null-terminated 
  56.    --  array of strings, and the array itself.  If called on a null value, 
  57.    --  simply return. 
  58.  
  59.    function To_String_List 
  60.      (C : ICS.chars_ptr_array) return GNAT.Strings.String_List; 
  61.    --  Converts C into a String_List. Returned value must be freed by caller, 
  62.    --  as well as C. C is NULL terminated. 
  63.  
  64.    function To_String_List 
  65.      (C : ICS.chars_ptr_array; N : Glib.Gint) 
  66.       return GNAT.Strings.String_List; 
  67.    --  Converts C into a String_List. N is the number of elements in C. 
  68.    --  Returned value must be freed by caller, as well as C. 
  69.  
  70.    function From_String_List 
  71.      (C : GNAT.Strings.String_List) return ICS.chars_ptr_array; 
  72.    --  Converts C into a chars_ptr_array. Returned value must be freed by 
  73.    --  caller, as well as C. 
  74.  
  75.    function To_Chars_Ptr 
  76.      (C : chars_ptr_array_access) return ICS.chars_ptr_array; 
  77.    --  Return a bounded array that contains the same strings as C (so you 
  78.    --  shouldn't free C). 'Last applies to the result, whereas it doesn't to C. 
  79.  
  80.    ------------ 
  81.    -- Arrays -- 
  82.    ------------ 
  83.    --  See Gtkada.C for more information. 
  84.    --  The packages that are commented out are instanciated in various, 
  85.    --  possibly duplicated places. This is because of elaboration circularity 
  86.    --  issues. 
  87.  
  88.    package Gint_Arrays is new Gtkada.C.Unbounded_Arrays 
  89.      (Glib.Gint, 0, Natural, Glib.Gint_Array); 
  90. --     package Points_Arrays is new Gtkada.C.Unbounded_Arrays 
  91. --       (Gdk.Types.Gdk_Point, (0, 0), Positive, Gdk.Types.Gdk_Points_Array); 
  92. --     package Atom_Arrays is new Gtkada.C.Unbounded_Arrays 
  93. --       (Gdk.Types.Gdk_Atom, Gdk.Types.Gdk_None, 
  94. --        Natural, Gdk.Types.Gdk_Atom_Array); 
  95.    package Pspec_Arrays is new Gtkada.C.Unbounded_Arrays 
  96.      (Glib.Param_Spec, null, Natural, Glib.Param_Spec_Array); 
  97. --     package Signal_Id_Arrays is new Gtkada.C.Unbounded_Arrays 
  98. --       (Glib.Signal_Id, Glib.Null_Signal_Id, Glib.Guint, 
  99. --        Glib.Object.Signal_Id_Array); 
  100.    package GType_Arrays is new Gtkada.C.Unbounded_Arrays 
  101.      (Glib.GType, Glib.GType_None, Glib.Guint, Glib.GType_Array); 
  102. --     package Color_Arrays is new Gtkada.C.Unbounded_Arrays 
  103. --       (Gdk.Color.Gdk_Color, Gdk.Color.Null_Color, Natural, 
  104. --        Gdk.Color.Gdk_Color_Array); 
  105.  
  106. --     type Unbounded_Gint_Array is array (Natural) of Glib.Gint; 
  107. --     pragma Convention (C, Unbounded_Gint_Array); 
  108. --     type Unbounded_Gint_Array_Access is access Unbounded_Gint_Array; 
  109. --     procedure G_Free (Arr : in out Unbounded_Gint_Array_Access); 
  110. --     function To_Gint_Array 
  111. --       (Arr : Unbounded_Gint_Array_Access; N : Glib.Gint) 
  112. --        return Glib.Gint_Array; 
  113.    function To_Gint_Array_Zero_Terminated 
  114.      (Arr : Gint_Arrays.Unbounded_Array_Access) 
  115.       return Glib.Gint_Array; 
  116.    --  Converts Arr, stopping at the first 0 encountered 
  117.  
  118. --     type Unbounded_Points_Array is array (Natural) of Gdk.Types.Gdk_Point; 
  119. --     pragma Convention (C, Unbounded_Points_Array); 
  120. --     type Unbounded_Points_Array_Access is access Unbounded_Points_Array; 
  121. --     procedure G_Free (Arr : in out Unbounded_Points_Array_Access); 
  122. --     function To_Point_Array 
  123. --       (Arr : Unbounded_Points_Array_Access; N : Glib.Gint) 
  124. --        return Gdk.Types.Gdk_Points_Array; 
  125.  
  126. --     type Unbounded_Atom_Array is array (Natural) of Gdk.Types.Gdk_Atom; 
  127. --     pragma Convention (C, Unbounded_Atom_Array); 
  128. --     type Unbounded_Atom_Array_Access is access Unbounded_Atom_Array; 
  129. --     procedure G_Free (Arr : in out Unbounded_Atom_Array_Access); 
  130. --     function To_Atom_Array 
  131. --       (Arr : Unbounded_Atom_Array_Access; N : Glib.Gint) 
  132. --        return Gdk.Types.Gdk_Atom_Array; 
  133.  
  134. --     type Unbounded_Pspec_Array is array (Natural) of Glib.Param_Spec; 
  135. --     pragma Convention (C, Unbounded_Pspec_Array); 
  136. --     type Unbounded_Pspec_Array_Access is access Unbounded_Pspec_Array; 
  137. --     procedure G_Free (Arr : in out Unbounded_Pspec_Array_Access); 
  138. --     function To_Pspec_Array 
  139. --       (Arr : Unbounded_Pspec_Array_Access; N : Glib.Gint) 
  140. --        return Glib.Param_Spec_Array; 
  141.  
  142. --     type Unbounded_Signal_Id_Array is array (Natural) of Glib.Signal_Id; 
  143. --     pragma Convention (C, Unbounded_Signal_Id_Array); 
  144. --   type Unbounded_Signal_Id_Array_Access is access Unbounded_Signal_Id_Array; 
  145. --     procedure G_Free (Arr : in out Unbounded_Signal_Id_Array_Access); 
  146. --     function To_Signal_Id_Array 
  147. --       (Arr : Unbounded_Signal_Id_Array_Access; N : Glib.Guint) 
  148. --        return Glib.Object.Signal_Id_Array; 
  149.  
  150. --     type Unbounded_GType_Array is array (Natural) of Glib.GType; 
  151. --     pragma Convention (C, Unbounded_GType_Array); 
  152. --     type Unbounded_GType_Array_Access is access Unbounded_GType_Array; 
  153. --     procedure G_Free (Arr : in out Unbounded_GType_Array_Access); 
  154. --     function To_GType_Array 
  155. --       (Arr : Unbounded_GType_Array_Access; N : Glib.Guint) 
  156. --        return Glib.GType_Array; 
  157.  
  158. --     type Unbounded_Color_Array is array (Natural) of Gdk.Color.Gdk_Color; 
  159. --     pragma Convention (C, Unbounded_Color_Array); 
  160. --     type Unbounded_Color_Array_Access is access Unbounded_Color_Array; 
  161. --     procedure G_Free (Arr : in out Unbounded_Color_Array_Access); 
  162. --     function To_Color_Array 
  163. --       (Arr : Unbounded_Color_Array_Access; N : Glib.Gint) 
  164. --        return Gdk.Color.Gdk_Color_Array; 
  165. --     function Convert is new Ada.Unchecked_Conversion 
  166. --       (System.Address, Unbounded_Color_Array_Access); 
  167.  
  168. private 
  169. --   pragma Import (C, g_free, "g_free"); 
  170.    pragma Import (C, g_strfreev, "g_strfreev"); 
  171. end Gtkada.Bindings;