((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/blob-record" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.") (tags "eggs") (toc)) (section 2 "blob-record" (section 3 "Description" (p (tt "blob-record") " defines a macro to perform conversion between Scheme records and their representation as " (int-link "byte-blob" "byte blobs") ".") (p "The syntax of a record-type definition is loosely based on SRFI-9:") (pre "<record type definition>\n   -> (define-blob-record <type name>\n        ( <predicate name> <constructor name> <size name> )\n        ( <blob->record name> <record->blob name> )\n        <field spec> ...)") (pre "<field spec> -> ( <field tag> <size in bytes> <accessor name> \n                  <field->blob name> <blob->field name> )\n \n<field tag> -> <identifier>\n \n<... name>  -> <identifier>") (p "An instance of " (tt "define-blob-record") " is equivalent to the following definitions:") (ul (li (tt "<type name>") " is bound to a representation of the record type itself.") (li (tt "<constructor name>") " is bound to a procedure that takes as many arguments as there are " (tt "<field spec>") " elements and returns a new " (tt "<type name>") " record.") (li (tt "<predicate name>") " is a predicate that returns #T when given a value returned by " (tt "<constructor name>") " and #F for everything else.") (li (tt "<size name>") " is the name of a variable that contains the total size of the record blob representation in bytes.") (li "Each " (tt "<field spec>") " must provide the size of bytes for the byte blob representation of that field.") (li "Each " (tt "<field spec>") " must also provide the names of procedures that can convert the field value to and from byte blobs.") (li "Each " (tt "<accessor name>") " is a procedure that takes a record of type " (tt "<type name>") " and returns the current value of the corresponding field. It is an error to pass an accessor a value which is not a record of the appropriate type."))) (section 3 "Example" (pre "(use srfi-4 byte-blob blob-record test)\n\n(define-blob-record testrec\n  (testrec? make-testrec testrec-size)\n  (blob->testrec testrec->blob)\n  (x  8 testrec-x s16vector->byte-blob byte-blob->s16vector)\n  (y  4 testrec-y string->byte-blob byte-blob->string)\n  (z  12 testrec-z f32vector->byte-blob byte-blob->f32vector))\n\n(define-record-printer (testrec x out)\n  (fprintf out \"#<testrec x=~A y=~A z=~A>\"\n \t   (testrec-x x)\n \t   (testrec-y x)\n\t   (testrec-z x)))\n\n(define a (make-testrec (s16vector 1 3 5 7) \"blah\" (f32vector 4.0 5.0 6.0)))\n\n(blob->testrec (testrec->blob a))")) (section 3 "Version History" (ul (li "1.2 Updated test script to return proper exit code") (li "1.0 Initial release"))) (section 3 "License" (pre " Copyright 2009-2011 Ivan Raikov and the Okinawa Institute of Science and Technology.") (pre " This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as\n published by the Free Software Foundation, either version 3 of the\n License, or (at your option) any later version.") (pre " This program is distributed in the hope that it will be useful, but\n WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n General Public License for more details.") (pre " A full copy of the GPL license can be found at\n <http://www.gnu.org/licenses/>."))))