Add examples for _enum and _bitmask usage. (Close #1317)

This commit is contained in:
Pedro Caldeira 2016-05-01 18:29:19 +02:00 committed by Vincent St-Amour
parent fdcbe249f9
commit 551ef55535

View File

@ -1510,6 +1510,13 @@ Takes a list of symbols and generates an enumeration type. The
enumeration maps between a symbol in the given @racket[symbols] list and enumeration maps between a symbol in the given @racket[symbols] list and
corresponding integers, counting from @racket[0]. corresponding integers, counting from @racket[0].
To call a foreign function that takes an enum as a parameter simply provide
the symbol of the desiered enum as an argument.
@racketblock[
(code:comment "example sdl call")
(sdl-create-window "title" ... 'SDL_WINDOW_OPENGL)]
The list @racket[symbols] can also set the values of symbols by The list @racket[symbols] can also set the values of symbols by
putting @racket['=] and an exact integer after the symbol. For putting @racket['=] and an exact integer after the symbol. For
example, the list @racket['(x y = 10 z)] maps @racket['x] to example, the list @racket['(x y = 10 z)] maps @racket['x] to
@ -1539,6 +1546,14 @@ of symbols to a number and back, using @racket[bitwise-ior] on the
values of individual symbols, where A single symbol is equivalent to a values of individual symbols, where A single symbol is equivalent to a
list containing just the symbol. list containing just the symbol.
In other words, to call a foreign function that uses bitmask parameters simply call the
procedure with the list of wanted flags.
@racketblock[
(code:comment "example call from curl_global_init in curl.h")
(curl-global-init '(CURL_GLOBAL_SSL CURL_GLOBAL_WIN32))]
When a symbol does not have a given value (via @racket['=] after the When a symbol does not have a given value (via @racket['=] after the
symbol in @racket[symbols]), its value is the next power of 2 greater symbol in @racket[symbols]), its value is the next power of 2 greater
than the previous symbol's assignment (or @racket[1] for the first than the previous symbol's assignment (or @racket[1] for the first