Memory layout of a data structure: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 597: | Line 597: | ||
class RS232_25pin(Structure): |
class RS232_25pin(Structure): |
||
_fields_ = [(__, c_int, 1) for __ in rs232_25pin]</lang> |
_fields_ = [(__, c_int, 1) for __ in rs232_25pin]</lang> |
||
=={{header|Racket}}== |
|||
<lang racket> |
|||
#lang racket |
|||
(require ffi/unsafe) |
|||
(define (_autobitmask l) |
|||
(_bitmask (append* (for/list ([x l] [i (in-naturals)]) `(,x = ,(expt 2 i)))))) |
|||
(define _rs232 (_autobitmask '(CD RD TD DTR SG DSR RTS CTS RI ))) |
|||
;; Usually it will get used when using foreign functions automatically, but |
|||
;; this demonstrates the conversions explicitly |
|||
(require (only-in '#%foreign ctype-scheme->c ctype-c->scheme)) |
|||
((ctype-scheme->c _rs232) '(SG TD RI)) ; -> 276 |
|||
((ctype-c->scheme _rs232) 276) ; -> '(TD SG RI) |
|||
</lang> |
|||
=={{header|REXX}}== |
=={{header|REXX}}== |