[gtk-server] Re: R: Re: R: How to bind varargs functions

  • From: Peter van Eerten <administrator@xxxxxxxxxxxxxx>
  • To: gtk-server@xxxxxxxxxxxxx
  • Date: Wed, 21 Dec 2005 17:51:43 +0100

Hi Leonardo,

From your tracefile I see you are using the call "gtk_list_store_new". Looking
further into this GTK function it appears that the second argument is of a
C-type 'varargs'. This type cannot be converted by the GTK-server and is the
reason for the crash.

Instead, use "gtk_list_store_newv", which, as the GTK documentation states, is
used by language bindings.

The second argument of this GTK function however expects a pointer to an array
of integers. In newLisp I would implement this as follows, using your value for
G_TYPE_STRING:

(set 'arg (address (pack "d" 64))))
(gtk "gtk_list_store_newv" 1 arg)


As you may see, the client language must have the capability to construct a C
pointer. Languages like newLisp and Perl can do that. But I am not sure if this
is also possible with CLisp.

The prototype in the configfile would look like:

GTK_LIB_FUNCTION = gtk_list_store_newv, NONE, WIDGET, 2, LONG, LONG


Best regards
Peter

Citeren Leonardo Cecchi <l.cecchi@xxxxxxxxxxxxxxxxxxxx>:

> Hi Peter.
>
> I tried your solution and I think gtk_server_redefine works perfectly.
> I have another strange issue: gtk-server core dumps where I call the
> redefined gtk_list_store_new.
>
> I attach a file with the communication between gtk-server and the wrapper:
>
> Then the gtk-server goes to core dump.
> 64 is the number for G_TYPE_STRING: i've checked with a c program.
> I'm in windows with gtk-server 2.0.6 and gtk 2.6.7.
> Probably the solution is easy....
> When I've more time I will check on linux in order to see the stack trace.
> Thanks again,
>
> Leonardo
>
>
> -----Messaggio originale-----
> Da: gtk-server-bounce@xxxxxxxxxxxxx [mailto:gtk-server-bounce@xxxxxxxxxxxxx]
> Per conto di Peter van Eerten
> Inviato: mercoledì 21 dicembre 2005 6.31
> A: gtk-server@xxxxxxxxxxxxx
> Oggetto: [gtk-server] Re: R: How to bind varargs functions
>
> Hi Leonardo,
>
> Well, you are completely right there! I have cut and pasted from old code.
> But
> the GTK-server expects the incoming call without commas.
>
> Sorry for the confusion.
>
> Regards
> Peter
>
>
> Citeren Leonardo Cecchi <l.cecchi@xxxxxxxxxxxxxxxxxxxx>:
>
> > Hi Peter,
> >
> > Thanks for the prompt reply!
> > I think I will follow the gtk_server_redefine route and I will redefining
> > the function checking the number of arguments of the calling program.
> >
> > You have written:
> >
> > gtk_server_redefine gtk_list_store_new, NONE, WIDGET, 3, LONG, LONG, LONG
> >
> > but, if I have understood the gtk-server manpage correctly, it should be:
> >
> > gtk_server_redefine gtk_list_store_new NONE WIDGET 3 LONG LONG LONG
> >
> > Where I'm wrong?
> > Thanks,
> >
> > Leonardo
> >
> > -----Messaggio originale-----
> > Da: Peter van Eerten [mailto:turtle@xxxxxx]
> > Inviato: martedì 20 dicembre 2005 19.17
> > A: gtk-server@xxxxxxxxxxxxx
> > Oggetto: Re: [gtk-server] How to bind varargs functions
> >
> > Hi Leonardo,
> >
> > Indeed this is a problem for interpreted programming. During execution the
> > interpreted program must know in advance the amount of columns in order to
> > call
> > the GtkListStore successfully. In the configfile this could look like:
> >
> > GTK_LIB_FUNCTION = gtk_list_store_new, NONE, WIDGET, 2, LONG, LONG
> >
> > Here, we define gtk_list_store as a function with 2 arguments, the latter
> > being
> > the actual type, which is a C number (e.g. G_TYPE_STRING, G_TYPE_INT etc).
> > So
> > the function is using 1 column.
> >
> > But at another instance the same program would like to call GtkListStore
> > with 2
> > columns, for example. Especially for these type of situations the
> GTK-server
> > has
> > a possibility to redefine the GTK function:
> >
> > gtk_server_redefine gtk_list_store_new, NONE, WIDGET, 3, LONG, LONG, LONG
> >
> > As soon the GTK-server encounters this call then from this point on the
> > 'gtk_list_store' will be defined using 2 columns. In case of creating a
> > wrapper,
> > you probably need to catch this function yourself first; then check the
> > amount
> > of columns being used by the client program, then redefine the call, and
> > finally
> > actually realize the GTK function.
> >
> > Another solution is to follow the original design of the GTK server, by
> > presenting an individual configfile for each distributed program. So a
> > particular program can use the definition mentioned in a configfile, while
> > another program can use another definition mentioned in the configfile
> which
> > belongs to this program. (If the configfile resides in the same directory
> as
> > the
> > client program, this file will be used by the GTK-server.)
> >
> > Hope this helps,
> > Peter
> >
> > Citeren Leonardo Cecchi <l.cecchi@xxxxxxxxxxxxxxxxxxxx>:
> >
> > > Hi all,
> > >
> > > I would like to have a list-like component in my Gtk-Server wrapper
> > because
> > > I think it's really useful.
> > >
> > > So I have to bind some functions of the GtkListStore object in order to
> > use
> > > the GtkTreeView component with Gtk-Server.
> > >
> > > In the constructor list I see:
> > >
> > > GtkListStore* gtk_list_store_new            (gint n_columns, ...);
> > > GtkListStore* gtk_list_store_newv           (gint n_columns, GType
> > *types);
> > >
> > > How can I bind one of the two calls without setting a constant number of
> > > columns?
> > > Excuse me if this question has already been answered.
> > >
> > > Thanks in advance,
> > >
> > > Leonardo
> > >
>
> --
> http://www.gtk-server.org
>
>


-- 
http://www.gtk-server.org

Other related posts: