diff options
author | Tuncer Ayaz <[email protected]> | 2010-05-07 18:05:56 +0200 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2010-05-24 14:25:11 +0200 |
commit | 08d67b91c5daf5eb5e8d974ca08bb1b634c4ae2a (patch) | |
tree | 69adfaefdb7520c7abe519ad8b4cd6406598395e /erts/emulator/test/nif_SUITE_data | |
parent | 458dcb10f98bffd241a837cbac7c108eb485f706 (diff) | |
download | otp-08d67b91c5daf5eb5e8d974ca08bb1b634c4ae2a.tar.gz otp-08d67b91c5daf5eb5e8d974ca08bb1b634c4ae2a.tar.bz2 otp-08d67b91c5daf5eb5e8d974ca08bb1b634c4ae2a.zip |
erl_nif: add enif_is_list and enif_is_tuple
Add new NIF API functions
- enif_is_list
- enif_is_tuple
Signed-off-by: Tuncer Ayaz <[email protected]>
Diffstat (limited to 'erts/emulator/test/nif_SUITE_data')
-rw-r--r-- | erts/emulator/test/nif_SUITE_data/nif_SUITE.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c index 3ad4f93374..22d0d5a93b 100644 --- a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c +++ b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c @@ -630,6 +630,36 @@ static ERL_NIF_TERM release_resource(ErlNifEnv* env, int argc, const ERL_NIF_TER return enif_make_atom(env,"ok"); } +/* + * argv[0] an atom + * argv[1] a binary + * argv[2] a ref + * argv[3] 'ok' + * argv[4] a fun + * argv[5] a pid + * argv[6] a port + * argv[7] an empty list + * argv[8] a non-empty list + * argv[9] a tuple + */ +static ERL_NIF_TERM check_is(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) +{ + ERL_NIF_TERM ok_atom = enif_make_atom(env, "ok"); + + if (!enif_is_atom(env, argv[0])) return enif_make_badarg(env); + if (!enif_is_binary(env, argv[1])) return enif_make_badarg(env); + if (!enif_is_ref(env, argv[2])) return enif_make_badarg(env); + if (!enif_is_identical(env, argv[3], ok_atom)) return enif_make_badarg(env); + if (!enif_is_fun(env, argv[4])) return enif_make_badarg(env); + if (!enif_is_pid(env, argv[5])) return enif_make_badarg(env); + if (!enif_is_port(env, argv[6])) return enif_make_badarg(env); + if (!enif_is_empty_list(env, argv[7])) return enif_make_badarg(env); + if (!enif_is_list(env, argv[7])) return enif_make_badarg(env); + if (!enif_is_list(env, argv[8])) return enif_make_badarg(env); + if (!enif_is_tuple(env, argv[9])) return enif_make_badarg(env); + + return ok_atom; +} static ErlNifFunc nif_funcs[] = { @@ -656,7 +686,8 @@ static ErlNifFunc nif_funcs[] = {"get_resource", 2, get_resource}, {"release_resource", 1, release_resource}, {"last_resource_dtor_call", 0, last_resource_dtor_call}, - {"make_new_resource", 2, make_new_resource} + {"make_new_resource", 2, make_new_resource}, + {"check_is", 10, check_is} }; |