[gtkada] Gdk.Pixbuf patch - inline data
Arnaud Charlet
charlet at adacore.com
Tue Jan 18 11:46:03 CET 2005
> After looking at it (and perhaps I am missing something) I
> find the use of a chars_ptr_array for data which is likely
> (for the foreseeable future) to be pragma Imported from C
> to be a little clumsy (since Chars_Ptr_array is
> unconstrained).
Well the trouble is twofold:
- it is inconsistent with Gdk.Pixmap and the approach used in the other
GtkAda routines.
- it makes it almost impossible or very hard to use this function from Ada
directly.
Although you do not foresee its usage in Ada directly, I do not see any
particular trouble in writing a program that would generate an Ada array
of chars as is done in C.
> Perhaps this is a bit evil but it just seemed to me that
> using an access to an unsigned_char was an easier to use
> approach (for users of the routine). Simply declare an
> aliased variable, pragma import it and pass the 'access of
> it to the new routine.
I do not see why this is easier (actually it looks more complicated
to me) than doing:
Pixbuf : Chars_Ptr_Array (1 .. 0);
pragma Import (C, arrow_xpm, "arrow_xpm");
-- Actual bounds are maintained by the C code directly, and is
And then pass Pixbuf as a parameter to the gdk_pixbuf_new_from_data function.
You could even I guess see whethere the array passed has empty bound or
not to pass -1 or 'Length to the C function, although I tried to find the
gdk_pixbuf_new_from_data or gdk_pixbuf_new_from_inline functions and failed
to find any of them in Gtk+ 2.2 or 2.4, so could you clarify where
this function is defined ? If it is only defined in Gtk+ 2.6, then there's
also the issue of making GtkAda compatible with Gtk+ 2.6 only, which is
probably a little bit early at this stage.
> I am certainly willing to re-work this if someone can
> explain why the Char_Ptr_array is easier to use or lends
> any real additional error checking over this approach.
See above.
Arno
More information about the gtkada
mailing list