[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] anonymous enums
From: |
Kon Lovett |
Subject: |
Re: [Chicken-users] anonymous enums |
Date: |
Fri, 13 Jul 2007 21:31:23 -0700 |
On Jul 12, 2007, at 1:29 PM, Martin DeMello wrote:
Could someone give me an example of wrapping and using an anonymous c
enum? The manual isn't too clear on that point.
'define-foreign-enum' needs a defined type identifier, so anonymous
enums won't work. I use 'foreign-value' or 'define-foreign-variable',
depending on the context.
Ex:
(define-macro (foreign-mask-set? ?bits ?c-nam)
`(not (zero? (bitwise-and ,?bits (foreign-value ,?c-nam unsigned-
integer32)))) )
(foreign-mask-set? sab "sessionIsRoot")
Here 'sab' is some integer and 'sessionIsRoot' is the ident of some
elm of an anon enum. A bit(s) not zero test. In this case the value
of 'sessionIsRoot' is only used once. (MacOS X frameworks use a lot
of anonymous enums.)
Ex:
(define-foreign-variable c-sessionIsRoot unsigned-integer32
"sessionIsRoot")
Here a compilation unit local Scheme variable 'c-sessionIsRoot' is
created that "shadows" the C identifier 'sessionIsRoot'. (In this
case do not "(set! c-sessionIsRoot ..)" since the C compiler will not
like.) In this case I assume that the value of 'sessionIsRoot' is
only used > once so repeating "(foreign-value sessionIsRoot unsigned-
integer32)" is a pain .
NOTE: there is nothing special about the use of 'unsigned-integer32'
as the type above. I am assuming all 32 bits are significant.
HTH,
Kon
martin
_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users