Hello dear Schemers,
i have some trouble with Gambit-C's /c-declare-type/ special form.
Better to say with the logic beyond. There are actually two flavours
of it. The two argument version (called 'alias in _ptree2.scm)
instructs gambit's back-end to handle the type conversions on its own.
The four (resp. five) argument version (called 'c-type in _ptree2.scm)
lets the user gain some control. For this there is a protocol
cummunicating the raw ___SCMOBJs and the actual Ctype's locations.
For many C types one could choose to use either form. That is one
would specify Gambit's conversion/construction c-macros explictly or
let gambit do this. However, this does not hold true for the
(nonnull-)pointer case. Here the communication protocol is
insufficient. Those conversion (C-)macros need two additional
arguments: The release function and the location of the type-checking
chain. But the latter is not known to the programmer.
In my special case this is a problem, as follows. I am working on a
GTK+ binding. Thus is need the type conversion to explicitly check
whether an object belongs to a certain class or not. So i want
something like:
___HIDDEN ___SCMOBJ
scm_to_GtkButtonstar(___SCMOBJ src, GtkButton **dst, ___SCMOBJ typlst_gobject, int idx)
{
___SCMOBJ ___err = ___FIX(___NO_ERR);
GtkObject *obj1;
___BEGIN_CFUN_SCM_TO_NONNULLPOINTER(src, obj1, typlst_gobject, idx)
/* it is an GObject, as reported via Gambit's typechecking,
now we need to pass over to GLibs type checking. */
*dst = CHECK_AND_CAST_GTK_BUTTON(obj1);
if (*btn == NULL) {
___err = ___FIX(___UNKNOWN_ERR);
}
___END_CFUN_SCM_TO_NONNULLPOINTER(src, obj1, typlst_gobject, idx)
return ___err;
}
But for making this work i need to get the typlst_object passed (at
least) (also for the other way round).
I feel i am overlooking something obvious here. The only way (hack)
out i could think of would be to construct a c-function via /c-define/
to get an appropiate (literal, constant!) list for type checking.
Any help?
Regards
Tara