Re: wrapping primitives in cecil


Subject: Re: wrapping primitives in cecil
From: Craig Chambers (chambers@cs.washington.edu)
Date: Thu Mar 28 2002 - 12:27:10 PST


You can't use Cecil-like expressions within primitive blocks; the code there is
raw C++. You also can't treat a primitive block like an expression; it's just a
sequence of statements.

There are macros that can be used in the C++ body of a prim statement that let
you do things like send messages and return. But for the show method, the
easiest thing to do is to have show first send the w.gtk message in regular
Cecil code, then call a helper method passing the result of the message as an
argument, e.g.

   show (w@widget) { w.show_helper(w.gtk); }
   show_helper (w@widget, gtk) { prim c_++: "gtk_widget_show (gtk);"; }

The RETURN (or some variation, I don't recall exactly what is allowed) macro can
be used to return the result of the gtk_window_new function call. Look at the
existing prim methods to get ideas for what's possible.

-- Craig

Thorsten Seitz wrote:
>
> Hi,
>
> I'm trying to write a small GUI library in Cecil. The library shall use
> GTK+ (a GUI library written in C) internally.
>
> Now comes the big question: how can I wrap a GTK+ primitive object in a
> Cecil object?
> I'd like to do something like:
>
> object Widget;
> field gtk (w@widget);
> show (w@widget) { prim c_++: "gtk_widget_show (w.gtk);"; }
>
> object Window;
> new_window (w@int, h@int): Window {
> object isa Window { gtk := prim c_++: "gtk_window_new (w, h);"; }
> }
>
> This was probably too naive, for it won't work :-)
> The problem in "show" seems to be that w.gtk is not known on the
> primitive level and in "new_window" that the return value is not
> correct.
>
> What would be the correct way to do something like this? I tried to find
> out by looking at the source of motif.cecil, file.cecil etc. but didn't
> come very far.
>
> Thanks for any help!
>
> Best regards
> Thorsten
>
> _______________________________________________
> Cecil mailing list
> Cecil@cs.washington.edu
> http://majordomo.cs.washington.edu/mailman/listinfo/cecil
_______________________________________________
Cecil mailing list
Cecil@cs.washington.edu
http://majordomo.cs.washington.edu/mailman/listinfo/cecil



This archive was generated by hypermail 2b25 : Thu Mar 28 2002 - 12:28:07 PST