From 3142034d87b39243c139a64e14efebc7bdb64b71 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 3 Jun 2017 08:08:54 -0700 Subject: 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. --- ffi.c | 2 +- txr.1 | 9 +++++---- 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. -- cgit v1.2.3