summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-06-03 08:08:54 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-06-03 08:08:54 -0700
commit6cb7fdec4cebacda48c5610a45e28ecef16f2ce2 (patch)
treed81a5ffda14c90fd0ff2c148f5d07bd5058ad833
parente538d15b836c6931bbd14b5fb26f57899a3bff54 (diff)
downloadtxr-6cb7fdec4cebacda48c5610a45e28ecef16f2ce2.tar.gz
txr-6cb7fdec4cebacda48c5610a45e28ecef16f2ce2.tar.bz2
txr-6cb7fdec4cebacda48c5610a45e28ecef16f2ce2.zip
ffi: use expressions for bit field width also.
* ffi.c (ffi_type_compile): Evaluate width argument of sbit and ubit type as as expression. * txr.1: Documented.
-rw-r--r--ffi.c2
-rw-r--r--txr.19
2 files changed, 6 insertions, 5 deletions
diff --git a/ffi.c b/ffi.c
index db7ae8cd..84ec6b9f 100644
--- a/ffi.c
+++ b/ffi.c
@@ -2341,7 +2341,7 @@ val ffi_type_compile(val syntax)
ffi_carray_put, ffi_carray_get,
0, 0, 0, eltype);
} else if (sym == sbit_s || sym == ubit_s) {
- val nbits = cadr(syntax);
+ val nbits = ffi_eval_expr(cadr(syntax), nil, nil);
cnum nb = c_num(nbits);
val type = make_ffi_type_builtin(syntax, integer_s, 0, 0,
&ffi_type_void,
diff --git a/txr.1 b/txr.1
index a9ba02de..c0f40cc3 100644
--- a/txr.1
+++ b/txr.1
@@ -53541,9 +53541,9 @@ be extended.
Some constituents of compound type syntax are expressions which evaluate to
integer values: the dimension value for array types, the size for buffers,
-and the value expressions for enumeration constants are such expressions.
-These expressions allow full use of \*(TL. They are evaluated without
-visibility into any apparent surrounding lexical scope.
+the width for bitfields and the value expressions for enumeration constants are
+such expressions. These expressions allow full use of \*(TL. They are
+evaluated without visibility into any apparent surrounding lexical scope.
Some predefined types which are provided are in fact typedef names.
For instance, the
@@ -54453,7 +54453,8 @@ Bitfields of any other type are not supported.
The
.meta width
-parameter of the type indicates the number of bits. It may range from
+parameter of is an expression evaluated in the top-level environment,
+indicates the number of bits. It may range from
zero to the number of bits in the
.code uint
type.