Common Lisp Package: USERIAL

README:

FUNCTION

Public

BUFFER-ADD-BYTE (BYTE)

Add the given BYTE to the BUFFER

BUFFER-ADVANCE (&OPTIONAL (AMOUNT 1))

Advances the BUFFER by AMOUNT bytes

BUFFER-CAPACITY

Returns the current capacity of the BUFFER

SETFBUFFER-CAPACITY (NEW-CAPACITY)

Sets the capacity of the BUFFER to NEW-CAPACITY

BUFFER-GET-BYTE

Get a byte from the BUFFER

BUFFER-LENGTH

Returns the current length of the BUFFER

SETFBUFFER-LENGTH (NEW-LENGTH)

Sets the length of the BUFFER to NEW-LENGTH

BUFFER-REWIND

Rewind the BUFFER to the beginning

MAKE-BUFFER (&OPTIONAL (INITIAL-CAPACITY +DEFAULT-BUFFER-CAPACITY+))

Create an empty BUFFER of a given INITIAL-CAPACITY

SERIALIZE

Method used to serialize a VALUE of given TYPE into BUFFER

UNSERIALIZE

Method used to unserialize a value of given TYPE from BUFFER

UNSERIALIZE-LIST* (TYPES)

UNSERIALIZE a list of types from the given BUFFER into a list. For example: (MAPCAR #'PRINC (UNSERIALIZE-LIST* '(:UINT8 :INT16) :BUFFER BUFFER))

Undocumented

GET-BUFFER

PEEK (TYPE &REST REST &KEY &ALLOW-OTHER-KEYS)

Private

BUFFER-EXPAND-IF-NEEDED (&OPTIONAL (AMOUNT 1))

Expand the BUFFER if needed to accomodate EXPAND-BY more bytes

GET-SYMS-TYPES-PLACES (TYPE-PLACE-LIST &OPTIONAL VARS TYPES PLACES)

Take a list like (:UINT AA :STRING BB :COW CC) and return three lists, the third the list (AA BB CC), the second the list (:UINT :STRING :COW), and the first a list of #'GENSYM symbols as long as the other lists are.

QUOTE-2 (AA BB)

Take two parameters and return them as a quoted list.

SEPARATE-DOCSTRING-AND-DECLS (BODY &OPTIONAL DOCSTRING DECLS)

Take a body form and return two values. The first value is a list of the docstring and any introductory DECLARE forms in the body and the second value is the rest of the body.

Undocumented

ARGIFY (ITEM)

GOT-ARG (ITEM)

IT-OR-THIRD (ITEM)

KEY-FOR-KEY (KEY-CONS)

PLUCK-APART-KEYED-LAMBDA-LIST (LLIST)

RETRIEVE-FROM-UNTIL (START UNTIL LLIST)

RETRIEVE-PAIRED-UNTIL (UNTIL LLIST RESULT)

RETRIEVE-UNTIL (UNTIL LLIST RESULT)

SERIALIZE-KEY (ITEM)

SERIALIZE-OPT (ITEM)

SERIALIZE-REQ (ITEM)

SYM-FOR-KEY (KEY-CONS)

SYM-FOR-OPT (OPT-CONS)

MACRO

Public

MAKE-ACCESSOR-SERIALIZER ((TYPE VALUE FACTORY &KEY LAYER) &REST FIELDS)

Make a serialize/unserialize pair with given TYPE using the FACTORY form when a new instance is needed where FIELDS is a list of key/accessor values. For example: (defstruct person name (age 0)) (make-accessor-serializer (:person person buffer (make-person)) :string person-name :uint8 person-age)

MAKE-BITFIELD-SERIALIZER (TYPE (&REST CHOICES) &KEY LAYER)

Create serialize/unserialize methods keyed by TYPE where the CHOICES can either be specified singly or as a list.

MAKE-ENUM-SERIALIZER (TYPE (&REST CHOICES) &KEY LAYER (MINIMUM-BYTES 0))

Create serialize/unserialize methods keyed by TYPE where the possible values are given by CHOICES

MAKE-FLOAT-SERIALIZER (KEY TYPE BYTES ENCODER DECODER &KEY LAYER)

Make serialize/unserialize routines for floating-point type TYPE dispatched by KEY with the given number of BYTES and an ENCODER/DECODER pair.

MAKE-INT-SERIALIZER (KEY BYTES &KEY LAYER)

Make SERIALIZE/UNSERIALIZE methods for a signed-int of BYTES bytes in length dispatched by KEY.

MAKE-LIST-SERIALIZER (TYPE ELEMENT-TYPE &KEY LAYER)

Make a serialize/unserialize pair for the key TYPE where each element is serialized with the key ELEMENT-TYPE.

MAKE-SLOT-SERIALIZER ((TYPE VALUE FACTORY &KEY LAYER) &REST FIELDS)

Make a serialize/unserialize pair with given TYPE using the FACTORY form when a new instance is needed where FIELDS is a list of key/slot values. For example: (defstruct person name (age 0)) (make-slot-serializer (:person person buffer (make-person)) :string name :uint8 age)

MAKE-UINT-SERIALIZER (KEY BYTES &KEY LAYER)

Make SERIALIZE/UNSERIALIZE methods for an unsigned-int of BYTES bytes in length dispatched by KEY.

SERIALIZE* (&REST TYPE-VALUE-PAIRS)

SERIALIZE a list of TYPE + VALUE into BUFFER returning the final BUFFER. For example: (SERIALIZE* :UINT8 5 :INT16 -10)

UNSERIALIZE* (&REST TYPE-PLACE-PLIST)

UNSERIALIZE a list of TYPE + PLACE from the given BUFFER and execute the body. For example: (LET (AA BB) (UNSERIALIZE* :UINT8 AA :INT16 BB) (LIST AA BB))

UNSERIALIZE-LET* ((&REST TYPE-VAR-PLIST) &BODY BODY)

UNSERIALIZE a list of TYPE + VARIABLE-NAME from the given BUFFER and execute the body. For example: (UNSERIALIZE-LET* (:UINT8 AA :INT16 BB) (LIST AA BB))

WITH-BUFFER (BUFFER &BODY BODY)

Macro to do a BODY of statements with the given BUFFER as default.

Undocumented

DEFINE-SERIALIZER ((KEY VALUE &KEY LAYER EXTRA) &BODY BODY)

DEFINE-SERIALIZING-FUNCALL ((BUFFER-FUNC FUNC &KEY LAYER) (&REST KEYED-LAMBDA-LIST) &BODY BODY)

DEFINE-UNSERIALIZER ((KEY &KEY LAYER EXTRA) &BODY BODY)

MAKE-ALIAS-SERIALIZER (IS-KEY WAS-KEY &KEY LAYER)

MAKE-GLOBAL-VARIABLE-SERIALIZER ((KEY VALUE-KEY &KEY LAYER) &REST GLOBAL-VARS)

MAKE-KEY-ACCESSOR-SERIALIZER ((KEY VAR TYPE-GETTER-VAR-LIST FINDER-FORM &KEY LAYER EXTRA) &REST TYPE-ACCESSOR-PAIRS)

MAKE-KEY-SLOT-SERIALIZER ((KEY VAR TYPE-GETTER-VAR-LIST FINDER-FORM &KEY LAYER EXTRA) &REST TYPE-SLOT-PAIRS)

MAKE-SIMPLE-SERIALIZER ((TYPE VALUE FACTORY &KEY LAYER EXTRA) &REST PAIRS)

MAKE-VECTOR-SERIALIZER (TYPE ELEMENT-TYPE LENGTH &KEY LAYER)

SERIALIZE-ACCESSORS* (OBJECT &REST TYPE-ACCESSOR-PLIST)

SERIALIZE-SLOTS* (OBJECT &REST TYPE-SLOT-PLIST)

UNSERIALIZE-ACCESSORS* (OBJECT &REST TYPE-ACCESSOR-PLIST)

UNSERIALIZE-SLOTS* (OBJECT &REST TYPE-SLOT-PLIST)

WITH-PEEK-BUFFER (NIL &BODY BODY)

Private

UNROLL-ADD-BYTES (VALUE-FORM BYTES)

Added BYTES bytes from the VALUE-FORM (most-significant byte first)

UNROLL-GET-BYTES (BYTES)

Get BYTES bytes (most-significant byte first)

Undocumented

MAKE-KEY-*-SERIALIZER (SERIALIZE-IT UNSERIALIZE-IT (KEY VAR TYPE-GETTER-VAR-LIST FINDER-FORM &KEY LAYER EXTRA) &REST TYPE-*-PAIRS)

TWOS-COMPLEMENT (VAL BYTES)

GENERIC-FUNCTION

Private

Undocumented

=LAYERED-FUNCTION-DEFINER-FOR-SERIALIZE= (LAYER-ARG0 TYPE VALUE &KEY (END (LENGTH VALUE)) (START 0) &ALLOW-OTHER-KEYS)

=LAYERED-FUNCTION-DEFINER-FOR-UNSERIALIZE= (LAYER-ARG79 TYPE &KEY (END (LENGTH OUTPUT)) (START 0) OUTPUT &ALLOW-OTHER-KEYS)

VARIABLE

Private

Undocumented

*BUFFER*

CONSTANT

Private

Undocumented

+DEFAULT-BUFFER-CAPACITY+

+DEFAULT-BUFFER-EXPAND+