[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
functions which return enumerate types
From: |
John Steele Scott |
Subject: |
functions which return enumerate types |
Date: |
Sat, 09 Sep 2006 12:00:53 +0900 |
User-agent: |
Pan/0.14.2.91 (As She Crawled Across the Table (Debian GNU/Linux)) |
I have used g-wrap to wrap a function which returns an enumerate type. I
wanted to test the return value like so:
(let ((status (cairo-status cr)))
(if (not (eqv? status 'success))
(print-cairo-error status)
(display "OK\n")))
This does not work correctly, because cairo-status is returning the
integer value (i.e. 0), rather than the symbol (i.e. 'success).
Is this a bug?
>From looking at the C code generated by g-wrap, I discovered that there
is a generated function which will convert from the integer
value to the enumeration symbol, which allows a simple workaround:
(let ((status (enum-cairo-status-val->sym (cairo-status cr) #f)))
(if (not (eqv? status 'success))
(print-cairo-error status)
(display "OK\n")))
So that's doable, but it means I need to add an extra layer of wrapping to
cairo-status to get the effect I want.
By the way, what is the second argument to enum-*-val->sym for? I first
assumed that it was for decoding bitset enums, but after some basic
experimentation, this doesn't seem to be the case.
cheers,
John
- functions which return enumerate types,
John Steele Scott <=