diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-01-29 11:15:46 +0100 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-01-29 11:15:46 +0100 |
commit | cb50354a9d3463cf07b830ecf28260adc5b361c0 (patch) | |
tree | 4794bac549046c2b1039ec0ac559b955ad3b31fc /erts/doc | |
parent | d960d54f75c51b81a99a1c5cf40c19f2e9d55068 (diff) | |
parent | cf5bc2e917dbcb2c2841bf07b995efe105bea4be (diff) | |
download | otp-cb50354a9d3463cf07b830ecf28260adc5b361c0.tar.gz otp-cb50354a9d3463cf07b830ecf28260adc5b361c0.tar.bz2 otp-cb50354a9d3463cf07b830ecf28260adc5b361c0.zip |
Merge branch 'egil/maps/OTP-11616'
* egil/maps/OTP-11616: (112 commits)
compiler: Add core compile test for maps
compiler: Fix core parse for Maps
compiler: Fixup #map_pair{} spec
erts: Strengthen map_SUITE tests
erts: Update maps_fold test to respect maps:fold/3
stdlib: Make maps:fold/3 order-independent
erts: Fixup enif_make_map_put on windows
erts: Update preloaded erts_internal.beam
hipe: Fixup update cerl pretty printer
erts: Add map construction to driver API
dialyzer: Add maps tests
dialyzer: Remove dead code
dialyzer: Reflect map_pair core changes in dialyzer
hipe: Update cerl pretty printer
compiler: Update inliner tests
compiler: Squash #c_map_pair_*{} to #c_map_pair{}
compiler: Squash #k_map_pair_*{} to #k_map_pair{}
preloaded: Fixup export cmp_term in erts_internal
erts: Change 'size' argument of enif_get_map_size from int* to size_t*
erts: Fix compile error for halfword emulator
...
Diffstat (limited to 'erts/doc')
-rw-r--r-- | erts/doc/src/erl_driver.xml | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/erts/doc/src/erl_driver.xml b/erts/doc/src/erl_driver.xml index c2f7fa4588..710c9b19cf 100644 --- a/erts/doc/src/erl_driver.xml +++ b/erts/doc/src/erl_driver.xml @@ -4,7 +4,7 @@ <cref> <header> <copyright> - <year>2001</year><year>2013</year> + <year>2001</year><year>2014</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -1742,15 +1742,19 @@ typedef struct ErlIOVec { term consists of one to four elements in the array. The term first has a term type, and then arguments. The <c>port</c> parameter specifies the sending port.</p> - <p>Tuple and lists (with the exception of strings, see below), + <p>Tuples, maps and lists (with the exception of strings, see below), are built in reverse polish notation, so that to build a tuple, the elements are given first, and then the tuple - term, with a count. Likewise for lists.</p> + term, with a count. Likewise for lists and maps.</p> <p>A tuple must be specified with the number of elements. (The elements precede the <c>ERL_DRV_TUPLE</c> term.)</p> <p>A list must be specified with the number of elements, including the tail, which is the last term preceding <c>ERL_DRV_LIST</c>.</p> + <p>A map must be specified with the number of key-value pairs <c>N</c>. + The key-value pairs must precede the <c>ERL_DRV_MAP</c> in this order: + <c>key1,value1,key2,value2,...,keyN,valueN</c>. + Duplicate keys are not allowed.</p> <p>The special term <c>ERL_DRV_STRING_CONS</c> is used to "splice" in a string in a list, a string given this way is not a list per se, but the elements are elements of the @@ -1774,6 +1778,7 @@ ERL_DRV_PID ErlDrvTermData pid (from driver_connected(ErlDrvPort port) ERL_DRV_STRING_CONS char *str, int len ERL_DRV_FLOAT double *dbl ERL_DRV_EXT2TERM char *buf, ErlDrvUInt len +ERL_DRV_MAP int sz </pre> <p>The unsigned integer data type <c>ErlDrvUInt</c> and the signed integer data type <c>ErlDrvSInt</c> are 64 bits wide @@ -1856,6 +1861,24 @@ ERL_DRV_EXT2TERM char *buf, ErlDrvUInt len }; erl_drv_output_term(driver_mk_port(drvport), spec, sizeof(spec) / sizeof(spec[0])); ]]></code> + + <p>To build the map <c>#{key1 => 100, key2 => {200, 300}}</c>, the + following call could be made.</p> + <code type="none"><![CDATA[ + ErlDrvPort port = ... + ErlDrvTermData spec[] = { + ERL_DRV_ATOM, driver_mk_atom("key1"), + ERL_DRV_INT, 100, + ERL_DRV_ATOM, driver_mk_atom("key2"), + ERL_DRV_INT, 200, + ERL_DRV_INT, 300, + ERL_DRV_TUPLE, 2, + ERL_DRV_MAP, 2 + }; + erl_drv_output_term(driver_mk_port(drvport), spec, sizeof(spec) / sizeof(spec[0])); + ]]> + </code> + <p>If you want to pass a binary and don't already have the content of the binary in an <c>ErlDrvBinary</c>, you can benefit from using <c>ERL_DRV_BUF2BINARY</c> instead of creating an <c>ErlDrvBinary</c> |