From bc34b5dafaebf07d7185900310246f5752c0a6c4 Mon Sep 17 00:00:00 2001
From: Sverker Eriksson
Date: Tue, 21 Jan 2014 12:21:11 +0100
Subject: erts: Add map construction to driver API
erl_drv_output_term() and erl_drv_send_term() can send messages
containing maps with the use of the new ERL_DRV_MAP.
The driver API minor version is updated as new functionality is added.
---
erts/doc/src/erl_driver.xml | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
(limited to 'erts/doc')
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 @@
- 20012013
+ 20012014
Ericsson AB. All Rights Reserved.
@@ -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
port parameter specifies the sending port.
- Tuple and lists (with the exception of strings, see below),
+
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.
+ term, with a count. Likewise for lists and maps.
A tuple must be specified with the number of elements. (The
elements precede the ERL_DRV_TUPLE term.)
A list must be specified with the number of elements,
including the tail, which is the last term preceding
ERL_DRV_LIST.
+ A map must be specified with the number of key-value pairs N.
+ The key-value pairs must precede the ERL_DRV_MAP in this order:
+ key1,value1,key2,value2,...,keyN,valueN.
+ Duplicate keys are not allowed.
The special term ERL_DRV_STRING_CONS 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
The unsigned integer data type ErlDrvUInt and the
signed integer data type ErlDrvSInt 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]));
]]>
+
+
To build the map #{key1 => 100, key2 => {200, 300}}, the
+ following call could be made.
+
+
+
If you want to pass a binary and don't already have the content
of the binary in an ErlDrvBinary, you can benefit from using
ERL_DRV_BUF2BINARY instead of creating an ErlDrvBinary
--
cgit v1.2.3