New patches: [change first automatic defbitfield value to 1 Stephen Compall **20060512153832 - make-foreign-bitfield now starts implicit bitfield values at 1. No more special cases for zero. - Document and update bf tests to match. ] < > { hunk ./doc/cffi-manual.texinfo 2300 The @code{defbitfield} macro is used to define foreign types that map lists of symbols to integer values. -If @var{value} is omitted its value will either be @code{0}, if it is -the first entry, or it will be the result of left-shifting the largest -@var{value} so far, specified or omitted, with a single 1-bit in its -binary representation, by one; if there is no such value so far, -@code{1} is used. +If @var{value} is omitted, it will be computed as follows: find the +greatest @var{value} previously used, including those so computed, +with only a single 1-bit in its binary representation (that is, powers +of two), and left-shift it by one. This rule guarantees that a +computed @var{value} cannot clash with previous values, but may clash +with future explicitly specified values. Symbol lists will be automatically converted to values and vice versa when being passed as arguments to or returned from foreign functions, hunk ./doc/cffi-manual.texinfo 2318 @subheading Examples @lisp (defbitfield open-flags - :rdonly ;@lispcmt{#x0000} + (:rdonly #x0000) :wronly ;@lispcmt{#x0001} :rdwr ;@lispcmt{@dots{}} :nonblock hunk ./src/enum.lisp 138 "Makes a new instance of the foreign-bitfield class." (let ((type (make-instance 'foreign-bitfield :name type-name :actual-type (parse-type base-type))) - (last-bit nil)) + (bit-floor 1)) (dolist (pair values) hunk ./src/enum.lisp 140 - (destructuring-bind (symbol &optional (value nil value-p)) + ;; bit-floor rule: find the greatest single-bit int used so far, + ;; and store its left-shift + (destructuring-bind (symbol &optional + (value (prog1 bit-floor + (setf bit-floor (ash bit-floor 1))) + value-p)) (mklist pair) (check-type symbol symbol) hunk ./src/enum.lisp 148 - (if value-p - (check-type value integer) - (setf value (cond ((null last-bit) 0) - ((zerop last-bit) 1) - (t (ash last-bit 1))))) - ;; find the greatest single-bit int used so far, and use its - ;; left-shift - (when (and (or (null last-bit) (> value last-bit)) - (or (zerop value) (single-bit-p value))) - (setf last-bit value)) + (when value-p + (check-type value integer) + (when (and (>= value bit-floor) (single-bit-p value)) + (setf bit-floor (ash value 1)))) (if (gethash symbol (symbol-values type)) (error "A foreign bitfield cannot contain duplicate symbols: ~S." symbol) hunk ./tests/enum.lisp 77 bf1) (defbitfield bf2 - zero one two four hunk ./tests/enum.lisp 82 eight sixteen - thirty-two) + thirty-two + sixty-four) (deftest bitfield.2 (mapcar (lambda (symbol) hunk ./tests/enum.lisp 88 (foreign-bitfield-value 'bf2 (list symbol))) - '(zero one two four eight sixteen thirty-two)) - (0 1 2 4 8 16 32)) + '(one two four eight sixteen thirty-two sixty-four)) + (1 2 4 8 16 32 64)) (defbitfield bf3 (three 3) hunk ./tests/enum.lisp 93 - zero - (seven 7) one hunk ./tests/enum.lisp 94 + (seven 7) + two (eight 8) sixteen) hunk ./tests/enum.lisp 105 (deftest bitfield.3 (mapcar (lambda (symbol) (foreign-bitfield-value 'bf3 (list symbol))) - '(zero one sixteen)) - (0 1 16)) + '(one two sixteen)) + (1 2 16)) (defbitfield bf4 (zero 0) } Context: [defbitfield: explicit initial zero case Stephen Compall **20060511162202 - Provide for counting an initial zero as a pseudo-single-bit. - Test bitfield.4. ] [only single-bits affect defbitfield implicit values Stephen Compall **20060511154221 - Remove a case in which a non-single-bit like 3 could hijack the implicit value computation for defbitfield. - New test bitfield.3 for this behavior. ] [Fix defbitfield bug and new test Luis Oliveira **20060511145035 - Bug fix: when the first value was provided a (< foo nil) comparision would occur. Regresion test: bitfield.1. - New test bitfield.2. ] [implicit defbitfield symbol values Stephen Compall **20060511072106 - Foreign Type Translators: defctype does not create Lisp types; you have to use eql specializers. - enum.lisp: Use reduce in %foreign-bitfield-value. Code a default rule for bitfield symbol values. ] [Make :POINTER a parameterized foreign type. James Bielman **20060507003511 - :POINTER without arguments is a void pointer. - (:POINTER :INT) is a pointer to an :INT. - These nest properly: (:POINTER (:POINTER :INT)). - Pointers are not type checked yet---an optional pointer type checker will be added someday. ] [Bugfix: Quote type arguments to %DEFCFUN-VARARGS. James Bielman **20060507002829] [Recognize OpenMCL/X86-64 and set CFFI features accordingly. James Bielman **20060504173940] [Conditionalize against non-CPU specific word-size features in OpenMCL. James Bielman **20060504021623] [Bugfix: Specialize UNPARSE for UFFI-CHAR in CFFI-UFFI-COMPAT. James Bielman **20060504015421 - Fixes an error when loading FASL files that dumped UFFI-CHAR instead of (UFFI-CHAR :CHAR) using MAKE-LOAD-FORM. - Reported by Ricardo Boccato. ] [More copyright header year updates. James Bielman **20060503064225] [Update copyright year in file headers. James Bielman **20060503063944] [Conditionally set variables for implementations in Makefile. James Bielman **20060503063241 - Allow overriding from the environment as suggest in the comment, which didn't actually work. (eg.: OPENMCL=openmcl64 make test) ] [Add OpenMCL/X86-64 fasl files to 'make clean'. James Bielman **20060503061637] [Make corman's finalizers thread-safe (hopefully) Luis Oliveira **20060424173620] [Add support for finalizers Luis Oliveira **20060424025357 - New functions: finalize and cancel-finalization. - New cffi-"feature": no-finalizers. Only ECL pushes this. - Document new functions. ] [Include stdint.h in libtest.c Luis Oliveira **20060424025320] [Oops, forgot to bump the version number. Luis Oliveira **20060424025119] [TAG 0.9.1 Luis Oliveira **20060418011351] Patch bundle hash: fcf9d58df9b96823ca32253f0fb2251a829419f9