Create a setter for C-GLOBAL words
parent
0507e6ec53
commit
e28e48beea
|
@ -179,5 +179,16 @@ PREDICATE: alien-callback-type-word < typedef-word
|
|||
swap [ name>> current-library get ] dip
|
||||
'[ _ _ address-of 0 _ alien-value ] ;
|
||||
|
||||
: define-global ( type word -- )
|
||||
: set-global-quot ( type word -- quot )
|
||||
swap [ name>> current-library get ] dip
|
||||
'[ _ _ address-of 0 _ set-alien-value ] ;
|
||||
|
||||
: define-global-getter ( type word -- )
|
||||
[ nip ] [ global-quot ] 2bi (( -- value )) define-declared ;
|
||||
|
||||
: define-global-setter ( type word -- )
|
||||
[ nip name>> "set-" prepend create-in ]
|
||||
[ set-global-quot ] 2bi (( obj -- )) define-declared ;
|
||||
|
||||
: define-global ( type word -- )
|
||||
[ define-global-getter ] [ define-global-setter ] 2bi ;
|
||||
|
|
|
@ -122,7 +122,7 @@ HELP: typedef
|
|||
HELP: C-GLOBAL:
|
||||
{ $syntax "C-GLOBAL: type name" }
|
||||
{ $values { "type" "a C type" } { "name" "a C global variable name" } }
|
||||
{ $description "Defines a new word named " { $snippet "name" } " which accesses a global variable in the current library, set with " { $link POSTPONE: LIBRARY: } "." } ;
|
||||
{ $description "Defines a getter " { $snippet "name" } " and setter " { $snippet "set-name" } " for the global value in the current library, set with " { $link POSTPONE: LIBRARY: } "." } ;
|
||||
|
||||
ARTICLE: "alien.enums" "Enumeration types"
|
||||
"The " { $vocab-link "alien.enums" } " vocab contains the implementation for " { $link POSTPONE: ENUM: } " C types, and provides words for converting between enum singletons and integers. It is possible to dispatch off of members of an enum."
|
||||
|
|
Loading…
Reference in New Issue