Changeset 39759 in project


Ignore:
Timestamp:
03/26/21 19:43:09 (4 weeks ago)
Author:
svnwiki
Message:

Anonymous wiki edit for IP [77.201.196.48]: Use the procedure tag, fix formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/msgpack

    r39755 r39759  
    1 
    21== msgpack
    32[[toc:]]
     
    54
    65Forked from [[http://github.com/hugoArregui/msgpack-scheme|msgpack-scheme]] and partially rewritten
    7 (ported to CHICKEN 5 and cleaned up).
    8 I kept the original license and most of the original API. However the byte-blob have been replaced with
     6(ported to CHICKEN 5 and built-in byte blob API).
     7I kept the original license and most of the original API. However, the byte-blob have been replaced with
    98Chicken 5 native blob.
    109I removed the dependency on bind egg and the need for C++ code using built-ins features of C5.
     
    1312=== Authors
    1413Hugo Arregui: Original author of the egg.
     14
    1515Théo Cavignac: ported the egg to Chicken 5
    1616
     
    2222=== Requirements
    2323This package requires the following eggs:
    24 - matchable
    25 - srfi-1
    26 - srfi-69
     24
     25* matchable
     26* srfi-1
     27* srfi-69
    2728
    2829
     
    3233
    3334From source:
    34 First install the required eggs listed above.
    35 Then clone this [[https://github.com/Lattay/chicken-msgpack|repository]].
    36 Finally run {{chicken-install -s}} in the root of this repository.
     35
     36# Install the required eggs listed above.
     37# Clone this [[https://github.com/Lattay/chicken-msgpack|repository]].
     38# Run {{chicken-install -s}} in the root of this repository.
    3739
    3840
     
    4042Primitive pack-family procedures:
    4143
    42 <enscript highlight="scheme">
    43 (pack-uint port value)     ; will produce an error if the input is negative
    44 (pack-sint port value)
    45 (pack-float port FLONUM)   ; pack 32b floats, support both exact and inexact but convert to flonum (inexact) anyway
    46 (pack-double port FLONUM)  ; pack 64b floats, same limitations as above
    47 (pack-bin port BLOB)       ; chicken.blob byte blob
    48 (pack-str port STRING)     ; string
    49 (pack-array port VECTOR)   ; scheme vector, also support lists
    50 (pack-map port HASH-TABLE) ; srfi-69 hash-table
    51 (pack-ext port EXT)        ; extension (see below)
    52 </enscript>
     44<procedure>(pack-uint port value)</procedure>
     45<procedure>(pack-sint port value)</procedure>
     46pack integer, will produce an error if the input does not respect the expected signedness
    5347
    54 Also the simplest way to use is to use the generic procedures:
     48<procedure>(pack-float port FLONUM)</procedure>
     49pack 32b floats, support both exact and inexact but convert to flonum (inexact) anyway
    5550
    56 <enscript highlight="scheme">
    57 (pack port value)
    58 (pack/blob value)
    59 </enscript>
     51<procedure>(pack-double port FLONUM)</procedure>
     52pack 64b floats, support both exact and inexact but convert to flonum (inexact) anyway
     53
     54<procedure>(pack-bin port BLOB)</procedure>
     55pack chicken.blob byte blob
     56
     57<procedure>(pack-str port STRING)</procedure>
     58pack string
     59
     60<procedure>(pack-array port VECTOR)</procedure>
     61pack scheme vectors or lists
     62
     63<procedure>(pack-map port HASH-TABLE)</procedure>
     64pack srfi-69 hash-table
     65
     66<procedure>(pack-ext port EXT)</procedure>
     67pack extension record (see below)
     68
     69Automatic procedures:
     70
     71<procedure>(pack port value)</procedure>
     72Will infer the right packer to use and write the msgpack result to port
     73
     74<procedure>(pack/blob value)</procedure>
     75Will inter the right packer and return the message as a byte blob
    6076
    6177These procedures will call primitive type packers, with the following rules:
    62 - if the value has a packer, apply it.
    63 - if the value is a string, it will be packed as str.
    64 - if the value is a blob, it will be packed as bin.
    65 - if the value is a char, it will be packed as a uint.
    66 - if the value is a list, it will be packed as an array.
    67 - if the value is a extension (see below), it will be packed as an ext
     78
     79* if the value has a packer, apply it.
     80* if the value is a string, it will be packed as str.
     81* if the value is a blob, it will be packed as bin.
     82* if the value is a char, it will be packed as a uint.
     83* if the value is a list, it will be packed as an array.
     84* if the value is a extension (see below), it will be packed as an ext
    6885
    6986The {{/blob}} version return a blob of packed data, the others directly write it to the port.
    7087
    7188Unpack procedures:
    72     [lang:scheme]
     89<procedure>(unpack port [mapper])</procedure>
     90Read msgpack data from port and return the unpacked data.
    7391
    74  (unpack port [mapper])
    75  (unpack/blob blob [mapper])
     92<procedure>(unpack/blob blob [mapper])</procedure>
     93Treat the blob as a msgpack data and return the unpacked data.
    7694
    7795The optional mapper argument is applied to the output before returning.
     
    82100Extension is a record defined as:
    83101
    84 {{
    85 (define-record extension type data)
    86 }}
     102<enscript highlight="scheme">(define-record extension type data)</enscript>
    87103
    88104* type: integer from 0 to 127
    89105* data: a blob
    90106
    91 Example:
     107Use-case example:
    92108
    93 <enscript highlight="scheme">
    94 (make-extension 10 (string->byte-blob "hi"))
    95 </enscript>
     109<enscript highlight="scheme">(make-extension 10 (string->byte-blob "hi"))</enscript>
    96110
    97111
     
    101115
    102116=== History
    103 v1.0.3 Ironing details for publication.
    104117
    105 v1.0.0 Port to Chicken 5.
     118* v1.0.3 Ironing details for publication.
     119
     120* v1.0.0 Port to Chicken 5.
    106121Breaking changes:
    107122All blob related APIs have been changed to support Chicken native blob type.
    108123
    109 v0.4 Last Chicken 4 version (2016)
     124* v0.4 Last Chicken 4 version (2016)
    110125
Note: See TracChangeset for help on using the changeset viewer.