[gtkada] Problem writing a librsvg Ada binding
Damien Carbonne
aetdcarbonne at free.fr
Wed Dec 27 23:39:30 CET 2006
Hi,
I'm trying to write a librsvg Ada binding and have a problem with it.
As librsvg depends on glib/gdk, I've used GtkAda for that.
Note: This binding will be available using the same license as GtkAda on
which it depends.
An extract of what is available on C side in rsvg.h is:
/************************************************************/
// ...
typedef struct _RsvgHandle RsvgHandle;
typedef struct RsvgHandlePrivate RsvgHandlePrivate;
typedef struct _RsvgHandleClass RsvgHandleClass;
typedef struct _RsvgDimensionData RsvgDimensionData;
struct _RsvgHandleClass {
GObjectClass parent;
gpointer _abi_padding[15];
};
struct _RsvgHandle {
GObject parent;
RsvgHandlePrivate *priv;
gpointer _abi_padding[15];
};
// ...
void rsvg_init (void);
// ...
/************************************************************/
An extract of what I wrote on Ada side is:
--------------------------------------------------------------
package RSVG is
-- ...
type RSVG_Handle_Record is new Glib.Object.GObject_Record with private;
type RSVG_Handle is access all RSVG_Handle_Record'Class;
-- ...
procedure SRVG_New_From_File
(Handle : out RSVG_Handle;
Filename : String;
Error : out GError);
-- ...
private
-- ...
type RSVG_Handle_Record is new Glib.Object.GObject_Record with null
record;
end RSVG;
--------------------------------------------------------------
The implementation of SRVG_New_From_File is:
--------------------------------------------------------------
procedure SRVG_New_From_File
(Handle : out RSVG_Handle;
Filename : String;
Error : out GError)
is
function Internal (Filename : System.Address; Error : access
GError) return System.Address;
pragma Import (C, Internal, "rsvg_handle_new_from_file");
C_Filename : constant String := Filename & ASCII.nul;
Err : aliased GError;
begin
Handle := new RSVG_Handle_Record;
Set_Object (Handle, Internal (C_Filename'Address, Err'Access));
Error := Err;
end SRVG_New_From_File;
--------------------------------------------------------------
I wrote this by following what is done for Gtk_New in Gtk.Window.
But when I use all this, it fails and I get these messages:
===============================================================
(process:18095): GLib-GObject-CRITICAL **: gtype.c:2240: initialization
assertion failed, use IA__g_type_init() prior to this function
(process:18095): GLib-GObject-CRITICAL **: gtype.c:2240: initialization
assertion failed, use IA__g_type_init() prior to this function
(process:18095): GLib-GObject-CRITICAL **: g_object_new: assertion
`G_TYPE_IS_OBJECT (object_type)' failed
===============================================================
I have not found any procedure that binds g_type_init in GtkAda.
Any help would be appreciated.
Regards
Damien Carbonne
More information about the gtkada
mailing list