The bitfield Reference Manual

This is the bitfield Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 04:24:52 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 bitfield

Efficiently represent several finite sets or small integers as a single non-negative integer.

Author

Marco Heisig <>

License

MIT

Source

bitfield.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 bitfield/bitfield.asd

Source

bitfield.asd.

Parent Component

bitfield (system).

ASDF Systems

bitfield.


3.1.2 bitfield/packages.lisp

Source

bitfield.asd.

Parent Component

bitfield (system).

Packages

bitfield.


3.1.3 bitfield/bitfield.lisp

Dependency

packages.lisp (file).

Source

bitfield.asd.

Parent Component

bitfield (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 bitfield

Source

packages.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Macros

Macro: define-bitfield (name &body slots)

Defines an encoding of enumerable properties like booleans,
integers or finite sets as a single non-negative integer.

For a supplied bitfield name NAME, and for some slot definitions of the
form (SLOT-NAME TYPE &KEY INITFORM &ALLOW-OTHER-KEYS), this macro defines
the following functions:

1. A constructor named MAKE-{NAME}, that takes one keyword argument per
SLOT-NAME, similar to the default constructor generated by DEFSTRUCT.
It returns a bitfield whose entries have the values indicated by the
keyword arguments, or the supplied initform.

2. A clone operation named CLONE-{NAME}, that takes an existing bitfield
and one keyword argument per SLOT-NAME. It returns a copy of the
existing bitfield, but where each supplied keyword argument supersedes
the value of the corresponding slot.

3. A reader function named {NAME}-{SLOT-NAME} for each slot.

In addition to these functions, NAME is defined as a suitable subtype of UNSIGNED-BYTE.

This macro supports boolean, integer, and member slots. It is also
possible to add new kinds of slots by defining new subclasses of
BITFIELD-SLOT and the corresponding methods on BITFIELD-SLOT-PACK, BITFIELD-SLOT-UNPACK and PARSE-ATOMIC-BITFIELD-SLOT-SPECIFIER or PARSE-COMPOUND-BITFIELD-SLOT-SPECIFIER.

Example:

(define-bitfield examplebits
(a boolean)
(b (signed-byte 2))
(c (unsigned-byte 3) :initform 1)
(d (integer -100 100))
(e (member foo bar baz)))

(defun examplebits-values (examplebits)
(list
(examplebits-a examplebits)
(examplebits-b examplebits)
(examplebits-c examplebits)
(examplebits-d examplebits)
(examplebits-e examplebits)))

(defparameter *default* (make-examplebits))

(examplebits-values *default*)
;; => (nil 0 1 -100 foo)

(defparameter *explicit* (make-examplebits :a t :b -1 :c 7 :d 42 :e ’baz))

(examplebits-values *explicit*)
;; => (t -1 7 42 baz)

(defparameter *clone* (clone-examplebits *explicit* :a nil :b -1 :c 2 :d -12 :e ’bar))

(examplebits-values *clone*)
;; => (nil -1 2 -12 bar)

Package

bitfield.

Source

bitfield.lisp.


5.1.2 Generic functions

Generic Reader: bitfield-slot-end (bitfield-slot)

Returns the position right after the last bit of this slot in the bitfield.

Package

bitfield.

Source

bitfield.lisp.

Methods
Reader Method: bitfield-slot-end ((bitfield-slot bitfield-slot))

automatically generated reader method

Target Slot

%end.

Generic Reader: bitfield-slot-initform (bitfield-slot)

Returns a form that produces the initial value for that slot.

Package

bitfield.

Source

bitfield.lisp.

Methods
Reader Method: bitfield-slot-initform ((bitfield-slot bitfield-slot))

automatically generated reader method

Target Slot

%initform.

Generic Reader: bitfield-slot-name (bitfield-slot)

Returns a symbol that is the name of the bitfield slot.

Package

bitfield.

Source

bitfield.lisp.

Methods
Reader Method: bitfield-slot-name ((bitfield-slot bitfield-slot))

automatically generated reader method

Target Slot

%name.

Generic Function: bitfield-slot-pack (bitfield-slot value-form)

Takes a form that produces a value and turns it into a form that produces a non-negative integer representing that value.

Package

bitfield.

Source

bitfield.lisp.

Methods
Method: bitfield-slot-pack ((slot bitfield-member-slot) value-form)
Method: bitfield-slot-pack ((slot bitfield-integer-slot) value-form)
Method: bitfield-slot-pack ((slot bitfield-boolean-slot) value-form)
Generic Reader: bitfield-slot-size (bitfield-slot)

Returns an unsigned byte that is the number of distinct states of the slot.

Package

bitfield.

Source

bitfield.lisp.

Methods
Reader Method: bitfield-slot-size ((bitfield-slot bitfield-slot))

automatically generated reader method

Target Slot

%size.

Generic Reader: bitfield-slot-start (bitfield-slot)

Returns the position of the first bit of this slot in the bitfield.

Package

bitfield.

Source

bitfield.lisp.

Methods
Reader Method: bitfield-slot-start ((bitfield-slot bitfield-slot))

automatically generated reader method

Target Slot

%start.

Generic Function: bitfield-slot-unpack (bitfield-slot value-form)

Take a form that produces a value that is encoded as a non-negative integer (as produced by BITFIELD-SLOT-PACK), and turn it into a form that produces the decoded value.

Package

bitfield.

Source

bitfield.lisp.

Methods
Method: bitfield-slot-unpack ((slot bitfield-member-slot) value-form)
Method: bitfield-slot-unpack ((slot bitfield-integer-slot) value-form)
Method: bitfield-slot-unpack ((slot bitfield-boolean-slot) value-form)
Generic Function: parse-atomic-bitfield-slot-specifier (specifier &key initform)

Parses an atomic bitfield slot specifier, i.e., a bitfield slot specifier that is not a list. Returns three values:

1. A designator for a bitfield slot class.

2. The size of the bitfield slot.

3. A list of additional arguments that will be supplied to MAKE-INSTANCE when creating the bitfield slot instance.

Package

bitfield.

Source

bitfield.lisp.

Methods
Method: parse-atomic-bitfield-slot-specifier ((specifier (eql bit)) &key initform)
Method: parse-atomic-bitfield-slot-specifier ((specifier (eql boolean)) &key initform)
Generic Function: parse-compound-bitfield-slot-specifier (specifier arguments &key initform)

Parses a compount bitfield slot specifier, i.e., a bitfield slot specifier that is a list. The SPECIFIER is the CAR of that list and the ARGUMENTS are the CDR of that list. Returns three values:

1. A designator for a bitfield slot class.

2. The size of the bitfield slot.

3. A list of additional arguments that will be supplied to MAKE-INSTANCE when creating the bitfield slot instance.

Package

bitfield.

Source

bitfield.lisp.

Methods
Method: parse-compound-bitfield-slot-specifier ((specifier (eql member)) objects &key initform)
Method: parse-compound-bitfield-slot-specifier ((specifier (eql integer)) bounds &key initform)
Method: parse-compound-bitfield-slot-specifier ((specifier (eql signed-byte)) arguments &key initform)
Method: parse-compound-bitfield-slot-specifier ((specifier (eql unsigned-byte)) arguments &key initform)

5.1.3 Classes

Class: bitfield-boolean-slot
Package

bitfield.

Source

bitfield.lisp.

Direct superclasses

bitfield-slot.

Direct methods
Class: bitfield-integer-slot
Package

bitfield.

Source

bitfield.lisp.

Direct superclasses

bitfield-slot.

Direct methods
Direct slots
Slot: %offset
Type

integer

Initargs

:offset

Readers

bitfield-integer-slot-offset.

Writers

This slot is read-only.

Class: bitfield-member-slot
Package

bitfield.

Source

bitfield.lisp.

Direct superclasses

bitfield-slot.

Direct methods
Direct slots
Slot: %objects
Type

list

Initargs

:objects

Readers

bitfield-member-slot-objects.

Writers

This slot is read-only.

Class: bitfield-slot
Package

bitfield.

Source

bitfield.lisp.

Direct subclasses
Direct methods
Direct slots
Slot: %name
Initargs

:name

Readers

bitfield-slot-name.

Writers

This slot is read-only.

Slot: %initform
Initargs

:initform

Readers

bitfield-slot-initform.

Writers

This slot is read-only.

Slot: %start
Initargs

:start

Readers

bitfield-slot-start.

Writers

This slot is read-only.

Slot: %end
Initargs

:end

Readers

bitfield-slot-end.

Writers

This slot is read-only.

Slot: %size
Initargs

:size

Readers

bitfield-slot-size.

Writers

This slot is read-only.


5.1.4 Types

Type: bitfield ()

A bitfield is a non-negative integer that efficiently encodes information about some booleans, enumerations, or small integers.

Package

bitfield.

Source

bitfield.lisp.


5.2 Internals


5.2.1 Special variables

Special Variable: *bitfield-position*
Package

bitfield.

Source

bitfield.lisp.


5.2.2 Ordinary functions

Function: parse-bitfield-slot (slot)
Package

bitfield.

Source

bitfield.lisp.


5.2.3 Generic functions

Generic Reader: bitfield-integer-slot-offset (object)
Package

bitfield.

Methods
Reader Method: bitfield-integer-slot-offset ((bitfield-integer-slot bitfield-integer-slot))

automatically generated reader method

Source

bitfield.lisp.

Target Slot

%offset.

Generic Reader: bitfield-member-slot-objects (object)
Package

bitfield.

Methods
Reader Method: bitfield-member-slot-objects ((bitfield-member-slot bitfield-member-slot))

automatically generated reader method

Source

bitfield.lisp.

Target Slot

%objects.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   B   D   F   G   M   P  
Index Entry  Section

B
bitfield-integer-slot-offset: Private generic functions
bitfield-integer-slot-offset: Private generic functions
bitfield-member-slot-objects: Private generic functions
bitfield-member-slot-objects: Private generic functions
bitfield-slot-end: Public generic functions
bitfield-slot-end: Public generic functions
bitfield-slot-initform: Public generic functions
bitfield-slot-initform: Public generic functions
bitfield-slot-name: Public generic functions
bitfield-slot-name: Public generic functions
bitfield-slot-pack: Public generic functions
bitfield-slot-pack: Public generic functions
bitfield-slot-pack: Public generic functions
bitfield-slot-pack: Public generic functions
bitfield-slot-size: Public generic functions
bitfield-slot-size: Public generic functions
bitfield-slot-start: Public generic functions
bitfield-slot-start: Public generic functions
bitfield-slot-unpack: Public generic functions
bitfield-slot-unpack: Public generic functions
bitfield-slot-unpack: Public generic functions
bitfield-slot-unpack: Public generic functions

D
define-bitfield: Public macros

F
Function, parse-bitfield-slot: Private ordinary functions

G
Generic Function, bitfield-integer-slot-offset: Private generic functions
Generic Function, bitfield-member-slot-objects: Private generic functions
Generic Function, bitfield-slot-end: Public generic functions
Generic Function, bitfield-slot-initform: Public generic functions
Generic Function, bitfield-slot-name: Public generic functions
Generic Function, bitfield-slot-pack: Public generic functions
Generic Function, bitfield-slot-size: Public generic functions
Generic Function, bitfield-slot-start: Public generic functions
Generic Function, bitfield-slot-unpack: Public generic functions
Generic Function, parse-atomic-bitfield-slot-specifier: Public generic functions
Generic Function, parse-compound-bitfield-slot-specifier: Public generic functions

M
Macro, define-bitfield: Public macros
Method, bitfield-integer-slot-offset: Private generic functions
Method, bitfield-member-slot-objects: Private generic functions
Method, bitfield-slot-end: Public generic functions
Method, bitfield-slot-initform: Public generic functions
Method, bitfield-slot-name: Public generic functions
Method, bitfield-slot-pack: Public generic functions
Method, bitfield-slot-pack: Public generic functions
Method, bitfield-slot-pack: Public generic functions
Method, bitfield-slot-size: Public generic functions
Method, bitfield-slot-start: Public generic functions
Method, bitfield-slot-unpack: Public generic functions
Method, bitfield-slot-unpack: Public generic functions
Method, bitfield-slot-unpack: Public generic functions
Method, parse-atomic-bitfield-slot-specifier: Public generic functions
Method, parse-atomic-bitfield-slot-specifier: Public generic functions
Method, parse-compound-bitfield-slot-specifier: Public generic functions
Method, parse-compound-bitfield-slot-specifier: Public generic functions
Method, parse-compound-bitfield-slot-specifier: Public generic functions
Method, parse-compound-bitfield-slot-specifier: Public generic functions

P
parse-atomic-bitfield-slot-specifier: Public generic functions
parse-atomic-bitfield-slot-specifier: Public generic functions
parse-atomic-bitfield-slot-specifier: Public generic functions
parse-bitfield-slot: Private ordinary functions
parse-compound-bitfield-slot-specifier: Public generic functions
parse-compound-bitfield-slot-specifier: Public generic functions
parse-compound-bitfield-slot-specifier: Public generic functions
parse-compound-bitfield-slot-specifier: Public generic functions
parse-compound-bitfield-slot-specifier: Public generic functions