doll up ENUM: docs

db4
Joe Groff 2010-04-21 21:33:04 -07:00
parent a00c5170bc
commit 4c7ab0e9a3
3 changed files with 9 additions and 6 deletions

View File

@ -105,7 +105,7 @@ $nl
"Important guidelines for passing data in byte arrays:" "Important guidelines for passing data in byte arrays:"
{ $subsections "byte-arrays-gc" } { $subsections "byte-arrays-gc" }
"C-style enumerated types are supported:" "C-style enumerated types are supported:"
{ $subsections POSTPONE: ENUM: } { $subsections "alien.enums" POSTPONE: ENUM: }
"C types can be aliased for convenience and consistency with native library documentation:" "C types can be aliased for convenience and consistency with native library documentation:"
{ $subsections POSTPONE: TYPEDEF: } { $subsections POSTPONE: TYPEDEF: }
"A utility for defining " { $link "destructors" } " for deallocating memory:" "A utility for defining " { $link "destructors" } " for deallocating memory:"

View File

@ -1,13 +1,13 @@
! Copyright (C) 2010 Erik Charlebois. ! Copyright (C) 2010 Erik Charlebois.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types help.markup help.syntax words ; USING: alien.c-types alien.syntax help.markup help.syntax words ;
IN: alien.enums IN: alien.enums
HELP: define-enum HELP: define-enum
{ $values { $values
{ "word" word } { "base-type" c-type } { "members" "sequence of word and value pairs" } { "word" word } { "base-type" c-type } { "members" "sequence of word and value pairs" }
} }
{ $description "Defines an enum. This is the run-time equivalent of ENUM:." } ; { $description "Defines an enum. This is the run-time equivalent of " { $link POSTPONE: ENUM: } "." } ;
HELP: enum>number HELP: enum>number
{ $values { $values
@ -23,11 +23,14 @@ HELP: number>enum
} }
{ $description "Convert a number to an enum." } ; { $description "Convert a number to an enum." } ;
ARTICLE: "alien.enums" "Alien Enumerations" ARTICLE: "alien.enums" "Enumeration types"
{ $vocab-link "alien.enums" } "The " { $vocab-link "alien.enums" } " vocab contains the implementation for " { $link POSTPONE: ENUM: } " C types, and provides words for converting between enum symbols and integers."
$nl
"Defining enums at run-time:" "Defining enums at run-time:"
{ $subsection define-enum } { $subsection define-enum }
"Conversions between enums and integers:" "Conversions between enums and integers:"
{ $subsections enum>number number>enum } ; { $subsections enum>number number>enum } ;
{ POSTPONE: ENUM: define-enum enum>number number>enum } related-words
ABOUT: "alien.enums" ABOUT: "alien.enums"

View File

@ -72,7 +72,7 @@ HELP: TYPEDEF:
HELP: ENUM: HELP: ENUM:
{ $syntax "ENUM: type words... ;" "ENUM: type < base-type words..." } { $syntax "ENUM: type words... ;" "ENUM: type < base-type words..." }
{ $values { "type" "a name to typedef to int or f" } { "words" "a sequence of word names" } } { $values { "type" "a name to typedef to int or f" } { "words" "a sequence of word names" } }
{ $description "Creates a c-type that boxes and unboxes integer values to singletons. A singleton is defined for each member word. The base c-type can optionally be specified and defaults to " { $snippet "int" } ". A constructor word " { $snippet "<type>" } " is defined for converting from integers to singletons. The generic word " { $link enum>number } " converts from singletons to integers. Enum-typed values are automatically prettyprinted as their singleton words. Unrecognizing enum numbers are kept as numbers." } { $description "Creates a c-type that boxes and unboxes integer values to symbols. A symbol is defined for each member word. The base c-type can optionally be specified and defaults to " { $link int } ". A constructor word " { $snippet "<type>" } " is defined for converting from integers to singletons. The generic word " { $link enum>number } " converts from singletons to integers. Enum-typed values are automatically prettyprinted as their singleton words. Unrecognizing enum numbers are kept as numbers." }
{ $examples { $examples
"Here is an example enumeration definition:" "Here is an example enumeration definition:"
{ $code "ENUM: color_t red { green 3 } blue ;" } { $code "ENUM: color_t red { green 3 } blue ;" }