public inbox for guile-gtk@sourceware.org
 help / color / mirror / Atom feed
* Converting defs file unto guile-wrap code
@ 2001-05-29 21:14 Ariel Rios
  2001-05-29 22:05 ` Rob Browning
  0 siblings, 1 reply; 2+ messages in thread
From: Ariel Rios @ 2001-05-29 21:14 UTC (permalink / raw)
  To: guile-gtk, Rob Browning

Ok.
I plan to translate defs files unto guile-wrap by
defining macros according to the different define-foo types;

Eg for enums:
;;other functions are omitted

(define-macro (define-enum name in-mod cname val)
  `(define ,name (string-append (enum-do-let ,cname) (enum-do-values
,val) "\t#t)\n")))

ANd when evaluating for example:

guile> (define-enum DirectionType
    (in-module "Gtk")
    (c-name "GtkDirectionType")
    (values 
       '("tab-forward" "GTK_DIR_TAB_FORWARD" 0)
       '("tab-backward" "GTK_DIR_TAB_BACKWARD" 1)
       '("up" "GTK_DIR_UP" 2)
       '("down" "GTK_DIR_DOWN" 3)
       '("left" "GTK_DIR_LEFT" 4)
       '("right" "GTK_DIR_RIGHT" 5)))

guile> (display DirectionType)
(let ((we ((gw:wrap-enumeration mod '<gtk:GtkDirectionType>
	"GtkDirectionType*"
	"const GtkDirectionType*")))
	(gw:enum-add-value! we "tab-forward" 'GTK_DIR_TAB_FORWARD)
	(gw:enum-add-value! we "tab-backward" 'GTK_DIR_TAB_BACKWARD)
	(gw:enum-add-value! we "up" 'GTK_DIR_UP)
	(gw:enum-add-value! we "down" 'GTK_DIR_DOWN)
	(gw:enum-add-value! we "left" 'GTK_DIR_LEFT)
	(gw:enum-add-value! we "right" 'GTK_DIR_RIGHT)
	#t)

Now, Is these the correct approach to follow? It is obviously
a very easy way of doing it.

Any objections? 

Rob, do you think that the current defs format info is enough for
g-wrap?

ariel


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Converting defs file unto guile-wrap code
  2001-05-29 21:14 Converting defs file unto guile-wrap code Ariel Rios
@ 2001-05-29 22:05 ` Rob Browning
  0 siblings, 0 replies; 2+ messages in thread
From: Rob Browning @ 2001-05-29 22:05 UTC (permalink / raw)
  To: Ariel Rios; +Cc: guile-gtk

Ariel Rios <ariel@linuxppc.org> writes:

> Now, Is these the correct approach to follow? It is obviously
> a very easy way of doing it.

It seems OK.  It's probably worth trying, and if you run in to
trouble, it should be quite easy to change to a normal parser.  My
experience has been that sometimes it's a little easier to just deal
with a straightforward parser, but it the job is simple enough, then
macros may be fine.

Anyway, writing a parser later if you need it would be easy:

  (define (compile-defs file-port)
    (let loop ((next-form (read)))
      (cond
        ((eof-object? next-form) ...)
        ((null? next-form) ...)
        ((eq? 'define-enum (car next-form)) ...)
        ...)
      (loop (read))))

or similar...

> Rob, do you think that the current defs format info is enough for
> g-wrap?

I haven't really seen the defs file in detail yet, but I suspect it
is, and if not, then we should be able to either enhance g-wrap, your
translator, or the defs spec to fix the problem.

BTW I've been told to go ahead with the g-wrap CVS module, so I should
be able to commit that this week sometime.  I'll also send you the
current (1/4 finished) info docs right now.

-- 
Rob Browning <rlb@cs.utexas.edu> PGP=E80E0D04F521A094 532B97F5D64E3930

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-05-29 22:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-29 21:14 Converting defs file unto guile-wrap code Ariel Rios
2001-05-29 22:05 ` Rob Browning

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).