~ubuntu-branches/ubuntu/intrepid/libgtkada2/intrepid

« back to all changes in this revision

Viewing changes to src/gtkada-bindings.adb

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna
  • Date: 2008-08-11 09:46:51 UTC
  • mfrom: (6.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20080811094651-9mjd6acwa98ffw5c
Tags: 2.12.0-2ubuntu1
Add lpia to supported architectures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-----------------------------------------------------------------------
 
2
--          GtkAda - Ada95 binding for the Gimp Toolkit              --
 
3
--                                                                   --
 
4
--                     Copyright (C) 2006, 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
with Glib;                 use Glib;
 
24
with GNAT.Strings;         use GNAT.Strings;
 
25
with Interfaces.C;         use Interfaces.C;
 
26
with Interfaces.C.Strings; use Interfaces.C.Strings;
 
27
 
 
28
package body Gtkada.Bindings is
 
29
 
 
30
   --------------------
 
31
   -- String_Or_Null --
 
32
   --------------------
 
33
 
 
34
   function String_Or_Null
 
35
     (S : String) return Interfaces.C.Strings.chars_ptr is
 
36
   begin
 
37
      if S = "" then
 
38
         return Null_Ptr;
 
39
      else
 
40
         return New_String (S);
 
41
      end if;
 
42
   end String_Or_Null;
 
43
 
 
44
   --------------------
 
45
   -- To_String_List --
 
46
   --------------------
 
47
 
 
48
   function To_String_List
 
49
     (C : Interfaces.C.Strings.chars_ptr_array) return String_List
 
50
   is
 
51
      Count : Natural := 0;
 
52
   begin
 
53
      while C (size_t (Count)) /= Null_Ptr loop
 
54
         Count := Count + 1;
 
55
      end loop;
 
56
 
 
57
      return To_String_List (C, Gint (Count));
 
58
   end To_String_List;
 
59
 
 
60
   --------------------
 
61
   -- To_String_List --
 
62
   --------------------
 
63
 
 
64
   function To_String_List
 
65
     (C : ICS.chars_ptr_array; N : Gint) return GNAT.Strings.String_List
 
66
   is
 
67
      Result : String_List (1 .. Natural (N));
 
68
   begin
 
69
      for R in Result'Range loop
 
70
         Result (R) := new String'(Value (C (size_t (R) - 1)));
 
71
      end loop;
 
72
      return Result;
 
73
   end To_String_List;
 
74
 
 
75
   ----------------------
 
76
   -- From_String_List --
 
77
   ----------------------
 
78
 
 
79
   function From_String_List
 
80
     (C : String_List) return Interfaces.C.Strings.chars_ptr_array
 
81
   is
 
82
      Result : Interfaces.C.Strings.chars_ptr_array (0 .. C'Length);
 
83
   begin
 
84
      for S in C'Range loop
 
85
         Result (size_t (S - C'First)) := New_String (C (S).all);
 
86
      end loop;
 
87
      Result (Result'Last) := Null_Ptr;
 
88
      return Result;
 
89
   end From_String_List;
 
90
 
 
91
   ------------------
 
92
   -- To_Chars_Ptr --
 
93
   ------------------
 
94
 
 
95
   function To_Chars_Ptr
 
96
     (C : chars_ptr_array_access) return ICS.chars_ptr_array
 
97
   is
 
98
      Count : size_t := 0;
 
99
   begin
 
100
      while C (Count) /= Null_Ptr loop
 
101
         Count := Count + 1;
 
102
      end loop;
 
103
 
 
104
      declare
 
105
         Result : chars_ptr_array (0 .. Count - 1);
 
106
      begin
 
107
         for J in Result'Range loop
 
108
            Result (J) := C (J);
 
109
         end loop;
 
110
         return Result;
 
111
      end;
 
112
   end To_Chars_Ptr;
 
113
 
 
114
   -------------------
 
115
   -- To_Gint_Array --
 
116
   -------------------
 
117
 
 
118
--     function To_Gint_Array
 
119
--       (Arr : Unbounded_Gint_Array_Access; N : Gint) return Glib.Gint_Array
 
120
--     is
 
121
--     begin
 
122
--        if Arr = null then
 
123
--           return (1 .. 0 => 0);
 
124
--        else
 
125
--           declare
 
126
--              Result : Glib.Gint_Array (1 .. Natural (N));
 
127
--           begin
 
128
--              for R in 0 .. Natural (N - 1) loop
 
129
--                 Result (R + 1) := Arr (R);
 
130
--              end loop;
 
131
--              return Result;
 
132
--           end;
 
133
--        end if;
 
134
--     end To_Gint_Array;
 
135
 
 
136
   -----------------------------------
 
137
   -- To_Gint_Array_Zero_Terminated --
 
138
   -----------------------------------
 
139
 
 
140
   function To_Gint_Array_Zero_Terminated
 
141
     (Arr : Gint_Arrays.Unbounded_Array_Access) return Glib.Gint_Array
 
142
   is
 
143
      Count : Natural := 0;
 
144
   begin
 
145
      while Arr (Count) /= 0 loop
 
146
         Count := Count + 1;
 
147
      end loop;
 
148
 
 
149
      declare
 
150
         Result : Gint_Array (1 .. Count);
 
151
      begin
 
152
         for R in Result'Range loop
 
153
            Result (R) := Arr (R - 1);
 
154
         end loop;
 
155
         return Result;
 
156
      end;
 
157
   end To_Gint_Array_Zero_Terminated;
 
158
 
 
159
   --------------------
 
160
   -- To_Point_Array --
 
161
   --------------------
 
162
 
 
163
--     function To_Point_Array
 
164
--       (Arr : Unbounded_Points_Array_Access; N : Glib.Gint)
 
165
--        return Gdk.Types.Gdk_Points_Array
 
166
--     is
 
167
--     begin
 
168
--        if Arr = null then
 
169
--           return (1 .. 0 => (0, 0));
 
170
--        else
 
171
--           declare
 
172
--              Result : Gdk_Points_Array (1 .. Natural (N));
 
173
--           begin
 
174
--              for R in 0 .. Natural (N - 1) loop
 
175
--                 Result (R + 1) := Arr (R);
 
176
--              end loop;
 
177
--              return Result;
 
178
--           end;
 
179
--        end if;
 
180
--     end To_Point_Array;
 
181
 
 
182
   -------------------
 
183
   -- To_Atom_Array --
 
184
   -------------------
 
185
 
 
186
--     function To_Atom_Array
 
187
--       (Arr : Unbounded_Atom_Array_Access; N : Glib.Gint)
 
188
--        return Gdk.Types.Gdk_Atom_Array
 
189
--     is
 
190
--     begin
 
191
--        if Arr = null then
 
192
--           return (1 .. 0 => Gdk.Types.Gdk_None);
 
193
--        else
 
194
--           declare
 
195
--              Result : Gdk_Atom_Array (1 .. Natural (N));
 
196
--           begin
 
197
--              for R in 0 .. Natural (N - 1) loop
 
198
--                 Result (R + 1) := Arr (R);
 
199
--              end loop;
 
200
--              return Result;
 
201
--           end;
 
202
--        end if;
 
203
--     end To_Atom_Array;
 
204
 
 
205
   --------------------
 
206
   -- To_Color_Array --
 
207
   --------------------
 
208
 
 
209
--     function To_Color_Array
 
210
--       (Arr : Unbounded_Color_Array_Access; N : Glib.Gint)
 
211
--        return Gdk.Color.Gdk_Color_Array
 
212
--     is
 
213
--     begin
 
214
--        if Arr = null then
 
215
--           return (1 .. 0 => Null_Color);
 
216
--        else
 
217
--           declare
 
218
--              Result : Gdk_Color_Array (1 .. Natural (N));
 
219
--           begin
 
220
--              for R in 0 .. Natural (N - 1) loop
 
221
--                 Result (R + 1) := Arr (R);
 
222
--              end loop;
 
223
--              return Result;
 
224
--           end;
 
225
--        end if;
 
226
--     end To_Color_Array;
 
227
 
 
228
   --------------------
 
229
   -- To_Pspec_Array --
 
230
   --------------------
 
231
 
 
232
--     function To_Pspec_Array
 
233
--       (Arr : Unbounded_Pspec_Array_Access; N : Glib.Gint)
 
234
--        return Glib.Param_Spec_Array
 
235
--     is
 
236
--     begin
 
237
--        if Arr = null then
 
238
--           return (1 .. 0 => null);
 
239
--        else
 
240
--           declare
 
241
--              Result : Param_Spec_Array (1 .. Natural (N));
 
242
--           begin
 
243
--              for R in 0 .. Natural (N - 1) loop
 
244
--                 Result (R + 1) := Arr (R);
 
245
--              end loop;
 
246
--              return Result;
 
247
--           end;
 
248
--        end if;
 
249
--     end To_Pspec_Array;
 
250
 
 
251
   ------------------------
 
252
   -- To_Signal_Id_Array --
 
253
   ------------------------
 
254
 
 
255
--     function To_Signal_Id_Array
 
256
--       (Arr : Unbounded_Signal_Id_Array_Access; N : Glib.Guint)
 
257
--        return Glib.Object.Signal_Id_Array
 
258
--     is
 
259
--     begin
 
260
--        if Arr = null then
 
261
--           return (1 .. 0 => Null_Signal_Id);
 
262
--        else
 
263
--           declare
 
264
--              Result : Signal_Id_Array (1 .. N);
 
265
--           begin
 
266
--              for R in 0 .. N - 1 loop
 
267
--                 Result (R + 1) := Arr (Natural (R));
 
268
--              end loop;
 
269
--              return Result;
 
270
--           end;
 
271
--        end if;
 
272
--     end To_Signal_Id_Array;
 
273
 
 
274
   --------------------
 
275
   -- To_GType_Array --
 
276
   --------------------
 
277
 
 
278
--     function To_GType_Array
 
279
--       (Arr : Unbounded_GType_Array_Access; N : Glib.Guint)
 
280
--        return Glib.GType_Array
 
281
--     is
 
282
--     begin
 
283
--        if Arr = null then
 
284
--           return (1 .. 0 => GType_Invalid);
 
285
--        else
 
286
--           declare
 
287
--              Result : GType_Array (1 .. N);
 
288
--           begin
 
289
--              for R in 0 .. N - 1 loop
 
290
--                 Result (R + 1) := Arr (Natural (R));
 
291
--              end loop;
 
292
--              return Result;
 
293
--           end;
 
294
--        end if;
 
295
--     end To_GType_Array;
 
296
 
 
297
end Gtkada.Bindings;