deprecate C-STRUCT:, C-UNION:, and old-school struct accessors
parent
80a5bf7138
commit
e85925153c
|
@ -7,10 +7,10 @@ IN: alien.structs.fields
|
||||||
TUPLE: field-spec name offset type reader writer ;
|
TUPLE: field-spec name offset type reader writer ;
|
||||||
|
|
||||||
: reader-word ( class name vocab -- word )
|
: reader-word ( class name vocab -- word )
|
||||||
[ "-" glue ] dip create ;
|
[ "-" glue ] dip create dup make-deprecated ;
|
||||||
|
|
||||||
: writer-word ( class name vocab -- word )
|
: writer-word ( class name vocab -- word )
|
||||||
[ [ swap "set-" % % "-" % % ] "" make ] dip create ;
|
[ [ swap "set-" % % "-" % % ] "" make ] dip create dup make-deprecated ;
|
||||||
|
|
||||||
: <field-spec> ( struct-name vocab type field-name -- spec )
|
: <field-spec> ( struct-name vocab type field-name -- spec )
|
||||||
field-spec new
|
field-spec new
|
||||||
|
|
|
@ -55,12 +55,12 @@ M: struct-type stack-size
|
||||||
[ struct-offsets ] keep
|
[ struct-offsets ] keep
|
||||||
[ [ type>> ] map compute-struct-align ] keep
|
[ [ type>> ] map compute-struct-align ] keep
|
||||||
[ struct-type (define-struct) ] keep
|
[ struct-type (define-struct) ] keep
|
||||||
[ define-field ] each ;
|
[ define-field ] each ; deprecated
|
||||||
|
|
||||||
: define-union ( name members -- )
|
: define-union ( name members -- )
|
||||||
[ expand-constants ] map
|
[ expand-constants ] map
|
||||||
[ [ heap-size ] [ max ] map-reduce ] keep
|
[ [ heap-size ] [ max ] map-reduce ] keep
|
||||||
compute-struct-align f struct-type (define-struct) ;
|
compute-struct-align f struct-type (define-struct) ; deprecated
|
||||||
|
|
||||||
: offset-of ( field struct -- offset )
|
: offset-of ( field struct -- offset )
|
||||||
c-types get at fields>>
|
c-types get at fields>>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
IN: alien.syntax
|
IN: alien.syntax
|
||||||
USING: alien alien.c-types alien.parser alien.structs
|
USING: alien alien.c-types alien.parser alien.structs
|
||||||
help.markup help.syntax ;
|
classes.struct help.markup help.syntax ;
|
||||||
|
|
||||||
HELP: DLL"
|
HELP: DLL"
|
||||||
{ $syntax "DLL\" path\"" }
|
{ $syntax "DLL\" path\"" }
|
||||||
|
@ -55,12 +55,14 @@ HELP: TYPEDEF:
|
||||||
{ $notes "This word differs from " { $link typedef } " in that it runs at parse time, to ensure correct ordering of operations when loading source files. Words defined in source files are compiled before top-level forms are run, so if a source file defines C binding words and uses " { $link typedef } ", the type alias won't be available at compile time." } ;
|
{ $notes "This word differs from " { $link typedef } " in that it runs at parse time, to ensure correct ordering of operations when loading source files. Words defined in source files are compiled before top-level forms are run, so if a source file defines C binding words and uses " { $link typedef } ", the type alias won't be available at compile time." } ;
|
||||||
|
|
||||||
HELP: C-STRUCT:
|
HELP: C-STRUCT:
|
||||||
|
{ $deprecated "New code should use " { $link "classes.struct" } ". See the " { $link POSTPONE: STRUCT: } " word." }
|
||||||
{ $syntax "C-STRUCT: name pairs... ;" }
|
{ $syntax "C-STRUCT: name pairs... ;" }
|
||||||
{ $values { "name" "a new C type name" } { "pairs" "C type / field name string pairs" } }
|
{ $values { "name" "a new C type name" } { "pairs" "C type / field name string pairs" } }
|
||||||
{ $description "Defines a C struct layout and accessor words." }
|
{ $description "Defines a C struct layout and accessor words." }
|
||||||
{ $notes "C type names are documented in " { $link "c-types-specs" } "." } ;
|
{ $notes "C type names are documented in " { $link "c-types-specs" } "." } ;
|
||||||
|
|
||||||
HELP: C-UNION:
|
HELP: C-UNION:
|
||||||
|
{ $deprecated "New code should use " { $link "classes.struct" } ". See the " { $link POSTPONE: UNION-STRUCT: } " word." }
|
||||||
{ $syntax "C-UNION: name members... ;" }
|
{ $syntax "C-UNION: name members... ;" }
|
||||||
{ $values { "name" "a new C type name" } { "members" "a sequence of C types" } }
|
{ $values { "name" "a new C type name" } { "members" "a sequence of C types" } }
|
||||||
{ $description "Defines a new C type sized to fit its largest member." }
|
{ $description "Defines a new C type sized to fit its largest member." }
|
||||||
|
|
|
@ -22,10 +22,10 @@ SYNTAX: TYPEDEF:
|
||||||
scan scan typedef ;
|
scan scan typedef ;
|
||||||
|
|
||||||
SYNTAX: C-STRUCT:
|
SYNTAX: C-STRUCT:
|
||||||
scan current-vocab parse-definition define-struct ;
|
scan current-vocab parse-definition define-struct ; deprecated
|
||||||
|
|
||||||
SYNTAX: C-UNION:
|
SYNTAX: C-UNION:
|
||||||
scan parse-definition define-union ;
|
scan parse-definition define-union ; deprecated
|
||||||
|
|
||||||
SYNTAX: C-ENUM:
|
SYNTAX: C-ENUM:
|
||||||
";" parse-tokens
|
";" parse-tokens
|
||||||
|
|
Loading…
Reference in New Issue