1
-----------------------------------------------------------------------
2
-- GtkAda - Ada95 binding for the Gimp Toolkit --
4
-- Copyright (C) 2006, AdaCore --
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. --
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. --
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. --
21
-----------------------------------------------------------------------
24
with GNAT.Strings; use GNAT.Strings;
25
with Interfaces.C; use Interfaces.C;
26
with Interfaces.C.Strings; use Interfaces.C.Strings;
28
package body Gtkada.Bindings is
34
function String_Or_Null
35
(S : String) return Interfaces.C.Strings.chars_ptr is
40
return New_String (S);
48
function To_String_List
49
(C : Interfaces.C.Strings.chars_ptr_array) return String_List
53
while C (size_t (Count)) /= Null_Ptr loop
57
return To_String_List (C, Gint (Count));
64
function To_String_List
65
(C : ICS.chars_ptr_array; N : Gint) return GNAT.Strings.String_List
67
Result : String_List (1 .. Natural (N));
69
for R in Result'Range loop
70
Result (R) := new String'(Value (C (size_t (R) - 1)));
75
----------------------
76
-- From_String_List --
77
----------------------
79
function From_String_List
80
(C : String_List) return Interfaces.C.Strings.chars_ptr_array
82
Result : Interfaces.C.Strings.chars_ptr_array (0 .. C'Length);
85
Result (size_t (S - C'First)) := New_String (C (S).all);
87
Result (Result'Last) := Null_Ptr;
96
(C : chars_ptr_array_access) return ICS.chars_ptr_array
100
while C (Count) /= Null_Ptr loop
105
Result : chars_ptr_array (0 .. Count - 1);
107
for J in Result'Range loop
118
-- function To_Gint_Array
119
-- (Arr : Unbounded_Gint_Array_Access; N : Gint) return Glib.Gint_Array
122
-- if Arr = null then
123
-- return (1 .. 0 => 0);
126
-- Result : Glib.Gint_Array (1 .. Natural (N));
128
-- for R in 0 .. Natural (N - 1) loop
129
-- Result (R + 1) := Arr (R);
134
-- end To_Gint_Array;
136
-----------------------------------
137
-- To_Gint_Array_Zero_Terminated --
138
-----------------------------------
140
function To_Gint_Array_Zero_Terminated
141
(Arr : Gint_Arrays.Unbounded_Array_Access) return Glib.Gint_Array
143
Count : Natural := 0;
145
while Arr (Count) /= 0 loop
150
Result : Gint_Array (1 .. Count);
152
for R in Result'Range loop
153
Result (R) := Arr (R - 1);
157
end To_Gint_Array_Zero_Terminated;
163
-- function To_Point_Array
164
-- (Arr : Unbounded_Points_Array_Access; N : Glib.Gint)
165
-- return Gdk.Types.Gdk_Points_Array
168
-- if Arr = null then
169
-- return (1 .. 0 => (0, 0));
172
-- Result : Gdk_Points_Array (1 .. Natural (N));
174
-- for R in 0 .. Natural (N - 1) loop
175
-- Result (R + 1) := Arr (R);
180
-- end To_Point_Array;
186
-- function To_Atom_Array
187
-- (Arr : Unbounded_Atom_Array_Access; N : Glib.Gint)
188
-- return Gdk.Types.Gdk_Atom_Array
191
-- if Arr = null then
192
-- return (1 .. 0 => Gdk.Types.Gdk_None);
195
-- Result : Gdk_Atom_Array (1 .. Natural (N));
197
-- for R in 0 .. Natural (N - 1) loop
198
-- Result (R + 1) := Arr (R);
203
-- end To_Atom_Array;
209
-- function To_Color_Array
210
-- (Arr : Unbounded_Color_Array_Access; N : Glib.Gint)
211
-- return Gdk.Color.Gdk_Color_Array
214
-- if Arr = null then
215
-- return (1 .. 0 => Null_Color);
218
-- Result : Gdk_Color_Array (1 .. Natural (N));
220
-- for R in 0 .. Natural (N - 1) loop
221
-- Result (R + 1) := Arr (R);
226
-- end To_Color_Array;
232
-- function To_Pspec_Array
233
-- (Arr : Unbounded_Pspec_Array_Access; N : Glib.Gint)
234
-- return Glib.Param_Spec_Array
237
-- if Arr = null then
238
-- return (1 .. 0 => null);
241
-- Result : Param_Spec_Array (1 .. Natural (N));
243
-- for R in 0 .. Natural (N - 1) loop
244
-- Result (R + 1) := Arr (R);
249
-- end To_Pspec_Array;
251
------------------------
252
-- To_Signal_Id_Array --
253
------------------------
255
-- function To_Signal_Id_Array
256
-- (Arr : Unbounded_Signal_Id_Array_Access; N : Glib.Guint)
257
-- return Glib.Object.Signal_Id_Array
260
-- if Arr = null then
261
-- return (1 .. 0 => Null_Signal_Id);
264
-- Result : Signal_Id_Array (1 .. N);
266
-- for R in 0 .. N - 1 loop
267
-- Result (R + 1) := Arr (Natural (R));
272
-- end To_Signal_Id_Array;
278
-- function To_GType_Array
279
-- (Arr : Unbounded_GType_Array_Access; N : Glib.Guint)
280
-- return Glib.GType_Array
283
-- if Arr = null then
284
-- return (1 .. 0 => GType_Invalid);
287
-- Result : GType_Array (1 .. N);
289
-- for R in 0 .. N - 1 loop
290
-- Result (R + 1) := Arr (Natural (R));
295
-- end To_GType_Array;