From f951b3fcc69c195ce04ae1022fa53272cb74f71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= Date: Wed, 6 Mar 2019 15:28:30 +0100 Subject: erts: Add enif_term_type This helps avoid long sequences of enif_is_xxx in code that serializes terms (such as JSON encoders) by letting the user switch on the type. --- erts/doc/src/erl_nif.xml | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'erts/doc/src/erl_nif.xml') diff --git a/erts/doc/src/erl_nif.xml b/erts/doc/src/erl_nif.xml index cc7452bab5..cf1994887a 100644 --- a/erts/doc/src/erl_nif.xml +++ b/erts/doc/src/erl_nif.xml @@ -3368,6 +3368,48 @@ if (retval & ERL_NIF_SELECT_STOP_CALLED) { + + ErlNifTermType + enif_term_type(ErlNifEnv *env, ERL_NIF_TERM term) + + Determine the type of a term. + +

Determines the type of the given term. The term must be an ordinary + Erlang term and not one of the special terms returned by + + enif_raise_exception, + + enif_schedule_nif, or similar.

+

The following types are defined at the moment:

+ + ERL_NIF_TERM_TYPE_ATOM + + ERL_NIF_TERM_TYPE_BITSTRING +

A bitstring or binary

+ ERL_NIF_TERM_TYPE_FLOAT + + ERL_NIF_TERM_TYPE_FUN + + ERL_NIF_TERM_TYPE_INTEGER + + ERL_NIF_TERM_TYPE_LIST +

A list, empty or not

+ ERL_NIF_TERM_TYPE_MAP + + ERL_NIF_TERM_TYPE_PID + + ERL_NIF_TERM_TYPE_PORT + + ERL_NIF_TERM_TYPE_REFERENCE + + ERL_NIF_TERM_TYPE_TUPLE + +
+

Note that new types may be added in the future, so the caller must + be prepared to handle unknown types.

+
+
+ int enif_thread_create(char *name,ErlNifTid -- cgit v1.2.3