From 037150979ff809df85757bd2b3f676e2e4c6be88 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Tue, 17 Jan 2012 12:28:32 +0100 Subject: Move types and specs from erl_bif_types.erl to modules --- lib/dialyzer/test/r9c_SUITE_data/results/inets | 16 +- lib/hipe/cerl/erl_bif_types.erl | 1130 +----------------------- lib/kernel/doc/src/code.xml | 13 +- lib/kernel/doc/src/erl_ddll.xml | 159 ++-- lib/kernel/doc/src/error_logger.xml | 7 +- lib/kernel/doc/src/file.xml | 6 +- lib/kernel/doc/src/os.xml | 40 +- lib/kernel/src/code.erl | 75 +- lib/kernel/src/erl_ddll.erl | 94 +- lib/kernel/src/error_logger.erl | 14 +- lib/kernel/src/erts_debug.erl | 131 ++- lib/kernel/src/file.erl | 20 +- lib/kernel/src/net_kernel.erl | 13 +- lib/kernel/src/os.erl | 38 +- lib/stdlib/doc/src/binary.xml | 226 ++--- lib/stdlib/doc/src/ets.xml | 535 ++++------- lib/stdlib/doc/src/lists.xml | 70 +- lib/stdlib/doc/src/math.xml | 57 +- lib/stdlib/doc/src/re.xml | 90 +- lib/stdlib/doc/src/string.xml | 26 +- lib/stdlib/doc/src/unicode.xml | 50 +- lib/stdlib/src/binary.erl | 192 +++- lib/stdlib/src/ets.erl | 437 ++++++++- lib/stdlib/src/lists.erl | 57 +- lib/stdlib/src/math.erl | 112 ++- lib/stdlib/src/qlc_pt.erl | 4 +- lib/stdlib/src/re.erl | 66 +- lib/stdlib/src/string.erl | 26 +- lib/stdlib/src/unicode.erl | 48 +- 29 files changed, 1635 insertions(+), 2117 deletions(-) (limited to 'lib') diff --git a/lib/dialyzer/test/r9c_SUITE_data/results/inets b/lib/dialyzer/test/r9c_SUITE_data/results/inets index 24cb39e52b..0e8ddf5492 100644 --- a/lib/dialyzer/test/r9c_SUITE_data/results/inets +++ b/lib/dialyzer/test/r9c_SUITE_data/results/inets @@ -30,11 +30,11 @@ httpd_sup.erl:92: The variable Else can never match since previous clauses compl mod_auth.erl:559: The pattern {'error', Reason} can never match the type {_,integer(),maybe_improper_list(),_} mod_auth_dets.erl:120: The call lists:foreach(fun((_) -> 'true' | {'error','no_such_group' | 'no_such_group_member'}),{'ok',[any()]}) will never return since it differs in the 2nd argument from the success typing arguments: (fun((_) -> any()),[any()]) mod_auth_plain.erl:100: The variable _ can never match since previous clauses completely covered the type {'ok',[any()]} -mod_auth_plain.erl:159: The variable _ can never match since previous clauses completely covered the type [any()] -mod_auth_plain.erl:83: The variable O can never match since previous clauses completely covered the type [any()] +mod_auth_plain.erl:159: The variable _ can never match since previous clauses completely covered the type [[any()]] +mod_auth_plain.erl:83: The variable O can never match since previous clauses completely covered the type [[any()]] mod_cgi.erl:372: The pattern {'http_response', NewAccResponse} can never match the type 'ok' mod_dir.erl:101: The call lists:flatten(nonempty_improper_list(atom() | [any()] | char(),atom())) will never return since it differs in the 1st argument from the success typing arguments: ([any()]) -mod_dir.erl:72: The pattern {'error', Reason} can never match the type {'ok',[[[any()] | char()],...]} +mod_dir.erl:72: The pattern {'error', Reason} can never match the type {'ok',[[[any()] | non_neg_integer()],...]} mod_get.erl:135: The pattern <{'enfile', _}, _Info, Path> can never match the type mod_head.erl:80: The pattern <{'enfile', _}, _Info, Path> can never match the type mod_htaccess.erl:460: The pattern {'error', BadData} can never match the type {'ok',_} @@ -46,9 +46,9 @@ mod_include.erl:692: The pattern <{'read', Reason}, Info, Path> can never match mod_include.erl:706: The pattern <{'enfile', _}, _Info, Path> can never match the type mod_include.erl:716: Function read_error/3 will never be called mod_include.erl:719: Function read_error/4 will never be called -mod_security_server.erl:386: The variable O can never match since previous clauses completely covered the type [any()] -mod_security_server.erl:433: The variable Other can never match since previous clauses completely covered the type [any()] -mod_security_server.erl:585: The variable _ can never match since previous clauses completely covered the type [any()] -mod_security_server.erl:608: The variable _ can never match since previous clauses completely covered the type [any()] -mod_security_server.erl:641: The variable _ can never match since previous clauses completely covered the type [any()] +mod_security_server.erl:386: The variable O can never match since previous clauses completely covered the type [tuple()] +mod_security_server.erl:433: The variable Other can never match since previous clauses completely covered the type [tuple()] +mod_security_server.erl:585: The variable _ can never match since previous clauses completely covered the type [tuple()] +mod_security_server.erl:608: The variable _ can never match since previous clauses completely covered the type [tuple()] +mod_security_server.erl:641: The variable _ can never match since previous clauses completely covered the type [tuple()] uri.erl:146: The pattern {'error', Error} can never match since previous clauses completely covered the type {_,{[],[]}} diff --git a/lib/hipe/cerl/erl_bif_types.erl b/lib/hipe/cerl/erl_bif_types.erl index cee399e861..71c83d9359 100644 --- a/lib/hipe/cerl/erl_bif_types.erl +++ b/lib/hipe/cerl/erl_bif_types.erl @@ -2,7 +2,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2003-2011. All Rights Reserved. +%% Copyright Ericsson AB 2003-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -49,7 +49,6 @@ t_boolean/0, t_byte/0, t_char/0, - t_charlist/0, t_cons/0, t_cons/2, t_cons_hd/1, @@ -120,8 +119,6 @@ t_subtract/2, t_sup/1, t_sup/2, - t_tid/0, - t_timeout/0, t_tuple/0, t_tuple/1, t_tuple_args/1, @@ -146,100 +143,6 @@ type(M, F, A) -> -spec type(atom(), atom(), arity(), [erl_types:erl_type()]) -> erl_types:erl_type(). -%%-- binary ------------------------------------------------------------------- -type(binary, at, 2, Xs) -> - strict(arg_types(binary, at, 2), Xs, fun(_) -> t_integer() end); -type(binary, bin_to_list, Arity, Xs) when 1 =< Arity, Arity =< 3 -> - strict(arg_types(binary, bin_to_list, Arity), Xs, - fun(_) -> t_list(t_integer()) end); -type(binary, compile_pattern, 1, Xs) -> - strict(arg_types(binary, compile_pattern, 1), Xs, - fun(_) -> t_binary_compiled_pattern() end); -type(binary, copy, Arity, Xs) when Arity =:= 1; Arity =:= 2 -> - strict(arg_types(binary, copy, Arity), Xs, - fun(_) -> t_binary() end); -type(binary, decode_unsigned, Arity, Xs) when Arity =:= 1; Arity =:= 2 -> - strict(arg_types(binary, decode_unsigned, Arity), Xs, - fun(_) -> t_non_neg_integer() end); -type(binary, encode_unsigned, Arity, Xs) when Arity =:= 1; Arity =:= 2 -> - strict(arg_types(binary, encode_unsigned, Arity), Xs, - fun(_) -> t_binary() end); -type(binary, first, 1, Xs) -> - strict(arg_types(binary, first, 1), Xs, fun(_) -> t_non_neg_integer() end); -type(binary, last, 1, Xs) -> - strict(arg_types(binary, last, 1), Xs, fun(_) -> t_non_neg_integer() end); -type(binary, list_to_bin, 1, Xs) -> - type(erlang, list_to_binary, 1, Xs); -type(binary, longest_common_prefix, 1, Xs) -> - strict(arg_types(binary, longest_common_prefix, 1), Xs, - fun(_) -> t_integer() end); -type(binary, longest_common_suffix, 1, Xs) -> - strict(arg_types(binary, longest_common_suffix, 1), Xs, - fun(_) -> t_integer() end); -type(binary, match, Arity, Xs) when Arity =:= 2; Arity =:= 3 -> - strict(arg_types(binary, match, Arity), Xs, - fun(_) -> - t_sup(t_atom('nomatch'), t_binary_canonical_part()) - end); -type(binary, matches, Arity, Xs) when Arity =:= 2; Arity =:= 3 -> - strict(arg_types(binary, matches, Arity), Xs, - fun(_) -> t_list(t_binary_canonical_part()) end); -type(binary, part, 2, Xs) -> - type(erlang, binary_part, 2, Xs); -type(binary, part, 3, Xs) -> - type(erlang, binary_part, 3, Xs); -type(binary, referenced_byte_size, 1, Xs) -> - strict(arg_types(binary, referenced_byte_size, 1), Xs, - fun(_) -> t_non_neg_integer() end); -%%-- code --------------------------------------------------------------------- -type(code, get_chunk, 2, Xs) -> - strict(arg_types(code, get_chunk, 2), Xs, - fun (_) -> t_sup(t_binary(), t_atom('undefined')) end); -type(code, is_module_native, 1, Xs) -> - strict(arg_types(code, is_module_native, 1), Xs, - fun (_) -> t_sup(t_boolean(), t_atom('undefined')) end); -type(code, module_md5, 1, Xs) -> - strict(arg_types(code, module_md5, 1), Xs, - fun (_) -> t_sup(t_binary(), t_atom('undefined')) end); -type(code, make_stub_module, 3, Xs) -> - strict(arg_types(code, make_stub_module, 3), Xs, fun ([Mod,_,_]) -> Mod end); -type(code, rehash, 0, _) -> - t_atom('ok'); -%%-- erl_ddll ----------------------------------------------------------------- -type(erl_ddll, demonitor, 1, Xs) -> - type(erlang, demonitor, 1, Xs); -type(erl_ddll, format_error_int, 1, Xs) -> - strict(arg_types(erl_ddll, format_error_int, 1), Xs, - fun (_) -> t_string() end); -type(erl_ddll, info, 2, Xs) -> - strict(arg_types(erl_ddll, info, 2), Xs, fun (_) -> t_atom() end); -type(erl_ddll, loaded_drivers, 0, _) -> - t_tuple([t_atom('ok'), t_list(t_string())]); -type(erl_ddll, monitor, 2, Xs) -> % return type is the same, though args are not - type(erlang, monitor, 2, Xs); -type(erl_ddll, try_load, 3, Xs) -> - strict(arg_types(erl_ddll, try_load, 3), Xs, - fun (_) -> - t_sup([t_tuple([t_atom('ok'), t_atom('already_loaded')]), - t_tuple([t_atom('ok'), t_atom('loaded')]), - t_tuple([t_atom('ok'), - t_atom('pending_driver'), t_reference()]), - t_tuple([t_atom('error'), t_atom('inconsistent')]), - t_tuple([t_atom('error'), t_atom('permanent')])]) - end); -type(erl_ddll, try_unload, 2, Xs) -> - strict(arg_types(erl_ddll, try_unload, 2), Xs, - fun (_) -> - t_sup([t_tuple([t_atom('ok'), t_atom('pending_process')]), - t_tuple([t_atom('ok'), t_atom('unloaded')]), - t_tuple([t_atom('ok'), t_atom('pending_driver')]), - t_tuple([t_atom('ok'), - t_atom('pending_driver'), t_reference()]), - t_tuple([t_atom('error'), t_atom('permanent')]), - t_tuple([t_atom('error'), t_atom('not_loaded')]), - t_tuple([t_atom('error'), - t_atom('not_loaded_by_this_process')])]) - end); %%-- erlang ------------------------------------------------------------------- type(erlang, halt, 0, _) -> t_none(); type(erlang, halt, 1, _) -> t_none(); @@ -1731,250 +1634,9 @@ type(erlang, whereis, 1, Xs) -> strict(arg_types(erlang, whereis, 1), Xs, fun (_) -> t_sup([t_pid(), t_port(), t_atom('undefined')]) end); type(erlang, yield, 0, _) -> t_atom('true'); -%%-- erl_prim_loader ---------------------------------------------------------- -type(erl_prim_loader, get_file, 1, Xs) -> - strict(arg_types(erl_prim_loader, get_file, 1), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_binary(), t_string()]), - t_atom('error')) - end); -type(erl_prim_loader, get_path, 0, _) -> - t_tuple([t_atom('ok'), t_list(t_string())]); -type(erl_prim_loader, set_path, 1, Xs) -> - strict(arg_types(erl_prim_loader, set_path, 1), Xs, - fun (_) -> t_atom('ok') end); -%%-- error_logger ------------------------------------------------------------- -type(error_logger, warning_map, 0, _) -> - t_sup([t_atom('info'), t_atom('warning'), t_atom('error')]); -%%-- erts_debug --------------------------------------------------------------- -type(erts_debug, breakpoint, 2, Xs) -> - strict(arg_types(erts_debug, breakpoint, 2), Xs, fun (_) -> t_fixnum() end); -type(erts_debug, disassemble, 1, Xs) -> - strict(arg_types(erts_debug, disassemble, 1), Xs, - fun (_) -> t_sup([t_atom('false'), - t_atom('undef'), - t_tuple([t_integer(), t_binary(), t_mfa()])]) end); -type(erts_debug, display, 1, _) -> - t_string(); -type(erts_debug, dist_ext_to_term, 2, Xs) -> - strict(arg_types(erts_debug, dist_ext_to_term, 2), Xs, - fun (_) -> t_any() end); -type(erts_debug, dump_monitors, 1, Xs) -> - strict(arg_types(erts_debug, dump_monitors, 1), Xs, - fun(_) -> t_atom('true') end); -type(erts_debug, dump_links, 1, Xs) -> - strict(arg_types(erts_debug, dump_links, 1), Xs, - fun(_) -> t_atom('true') end); -type(erts_debug, flat_size, 1, Xs) -> - strict(arg_types(erts_debug, flat_size, 1), Xs, fun (_) -> t_integer() end); -type(erts_debug, get_internal_state, 1, _) -> - t_any(); -type(erts_debug, instructions, 0, _) -> - t_list(t_list(t_byte())); -type(erts_debug, lock_counters, 1, Xs) -> - strict(arg_types(erts_debug, lock_counters, 1), Xs, - fun ([Arg]) -> - case t_is_atom(Arg) of - true -> - case t_atom_vals(Arg) of - ['enabled'] -> t_boolean(); - ['info'] -> t_any(); - ['clear'] -> t_atom(ok); - _ -> t_sup([t_boolean(), t_any(), t_atom('ok')]) - end; - false -> - case t_is_tuple(Arg) of - true -> t_boolean(); - false -> t_sup([t_boolean(), t_any(), t_atom('ok')]) - end - end - end); -type(erts_debug, same, 2, Xs) -> - strict(arg_types(erts_debug, same, 2), Xs, fun (_) -> t_boolean() end); -type(erts_debug, set_internal_state, 2, _) -> - t_any(); %%-- ets ---------------------------------------------------------------------- -type(ets, all, 0, _) -> - t_list(t_tab()); -type(ets, delete, 1, Xs) -> - strict(arg_types(ets, delete, 1), Xs, fun (_) -> t_atom('true') end); -type(ets, delete, 2, Xs) -> - strict(arg_types(ets, delete, 2), Xs, fun (_) -> t_atom('true') end); -type(ets, delete_all_objects, 1, Xs) -> - strict(arg_types(ets, delete_all_objects, 1), Xs, - fun (_) -> t_atom('true') end); -type(ets, delete_object, 2, Xs) -> - strict(arg_types(ets, delete_object, 2), Xs, fun (_) -> t_atom('true') end); -type(ets, first, 1, Xs) -> - strict(arg_types(ets, first, 1), Xs, fun (_) -> t_any() end); -type(ets, give_away, 3, Xs) -> - strict(arg_types(ets, give_away, 3), Xs, fun (_) -> t_atom('true') end); -type(ets, info, 1, Xs) -> - strict(arg_types(ets, info, 1), Xs, - fun (_) -> - t_sup(t_list(t_tuple([t_ets_info_items(), t_any()])), - t_atom('undefined')) - end); -type(ets, info, 2, Xs) -> - strict(arg_types(ets, info, 2), Xs, fun (_) -> t_any() end); -type(ets, insert, 2, Xs) -> - strict(arg_types(ets, insert, 2), Xs, fun (_) -> t_atom('true') end); -type(ets, insert_new, 2, Xs) -> - strict(arg_types(ets, insert_new, 2), Xs, fun (_) -> t_boolean() end); -type(ets, is_compiled_ms, 1, Xs) -> - strict(arg_types(ets, is_compiled_ms, 1), Xs, fun (_) -> t_boolean() end); -type(ets, last, 1, Xs) -> - type(ets, first, 1, Xs); -type(ets, lookup, 2, Xs) -> - strict(arg_types(ets, lookup, 2), Xs, fun (_) -> t_list(t_tuple()) end); -type(ets, lookup_element, 3, Xs) -> - strict(arg_types(ets, lookup_element, 3), Xs, fun (_) -> t_any() end); -type(ets, match, 1, Xs) -> - strict(arg_types(ets, match, 1), Xs, fun (_) -> t_matchres() end); -type(ets, match, 2, Xs) -> - strict(arg_types(ets, match, 2), Xs, fun (_) -> t_list() end); -type(ets, match, 3, Xs) -> - strict(arg_types(ets, match, 3), Xs, fun (_) -> t_matchres() end); -type(ets, match_object, 1, Xs) -> type(ets, match, 1, Xs); -type(ets, match_object, 2, Xs) -> type(ets, match, 2, Xs); -type(ets, match_object, 3, Xs) -> type(ets, match, 3, Xs); -type(ets, match_spec_compile, 1, Xs) -> - strict(arg_types(ets, match_spec_compile, 1), Xs, fun (_) -> t_any() end); -type(ets, match_spec_run_r, 3, Xs) -> - strict(arg_types(ets, match_spec_run_r, 3), Xs, fun (_) -> t_list() end); -type(ets, member, 2, Xs) -> - strict(arg_types(ets, member, 2), Xs, fun (_) -> t_boolean() end); -type(ets, new, 2, Xs) -> - strict(arg_types(ets, new, 2), Xs, fun (_) -> t_tab() end); -type(ets, next, 2, Xs) -> - strict(arg_types(ets, next, 2), Xs, - %% t_any below stands for: term() | '$end_of_table' - fun (_) -> t_any() end); -type(ets, prev, 2, Xs) -> type(ets, next, 2, Xs); type(ets, rename, 2, Xs) -> strict(arg_types(ets, rename, 2), Xs, fun ([_, Name]) -> Name end); -type(ets, safe_fixtable, 2, Xs) -> - strict(arg_types(ets, safe_fixtable, 2), Xs, fun (_) -> t_atom('true') end); -type(ets, select, 1, Xs) -> - strict(arg_types(ets, select, 1), Xs, fun (_) -> t_matchres() end); -type(ets, select, 2, Xs) -> - strict(arg_types(ets, select, 2), Xs, fun (_) -> t_list() end); -type(ets, select, 3, Xs) -> - strict(arg_types(ets, select, 3), Xs, fun (_) -> t_matchres() end); -type(ets, select_count, 2, Xs) -> - strict(arg_types(ets, select_count, 2), Xs, - fun (_) -> t_non_neg_fixnum() end); -type(ets, select_delete, 2, Xs) -> - strict(arg_types(ets, select_delete, 2), Xs, - fun (_) -> t_non_neg_fixnum() end); -type(ets, select_reverse, 1, Xs) -> type(ets, select, 1, Xs); -type(ets, select_reverse, 2, Xs) -> type(ets, select, 2, Xs); -type(ets, select_reverse, 3, Xs) -> type(ets, select, 3, Xs); -type(ets, setopts, 2, Xs) -> - strict(arg_types(ets, setopts, 2), Xs, fun (_) -> t_atom('true') end); -type(ets, slot, 2, Xs) -> - strict(arg_types(ets, slot, 2), Xs, - fun (_) -> t_sup(t_list(t_tuple()), t_atom('$end_of_table')) end); -type(ets, update_counter, 3, Xs) -> - strict(arg_types(ets, update_counter, 3), Xs, - fun ([_, _, Op]) -> - case t_is_integer(Op) of - true -> t_integer(); - false -> - case t_is_tuple(Op) of - true -> t_integer(); - false -> - case t_is_list(Op) of - true -> t_list(t_integer()); - false -> - case t_is_nil(Op) of - true -> t_nil(); - false -> t_sup([t_integer(), t_list(t_integer())]) - end - end - end - end - end); -type(ets, update_element, 3, Xs) -> - strict(arg_types(ets, update_element, 3), Xs, fun (_) -> t_boolean() end); -%%-- file --------------------------------------------------------------------- -type(file, native_name_encoding, 0, _) -> - t_file_encoding(); -%%-- prim_file ---------------------------------------------------------------- -type(prim_file, internal_name2native, 1, Xs) -> - strict(arg_types(prim_file, internal_name2native, 1), Xs, - fun (_) -> t_binary() end); -type(prim_file, internal_native2name, 1, Xs) -> - strict(arg_types(prim_file, internal_native2name, 1), Xs, - fun (_) -> t_prim_file_name() end); -type(prim_file, internal_normalize_utf8, 1, Xs) -> - strict(arg_types(prim_file, internal_normalize_utf8, 1), Xs, - fun (_) -> t_unicode_string() end); -%%-- gen_tcp ------------------------------------------------------------------ -%% NOTE: All type information for this module added to avoid loss of precision -type(gen_tcp, accept, 1, Xs) -> - strict(arg_types(gen_tcp, accept, 1), Xs, fun (_) -> t_gen_tcp_accept() end); -type(gen_tcp, accept, 2, Xs) -> - strict(arg_types(gen_tcp, accept, 2), Xs, fun (_) -> t_gen_tcp_accept() end); -type(gen_tcp, connect, 3, Xs) -> - strict(arg_types(gen_tcp, connect, 3), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_socket()]), - t_tuple([t_atom('error'), t_inet_posix_error()])) - end); -type(gen_tcp, connect, 4, Xs) -> - strict(arg_types(gen_tcp, connect, 4), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_socket()]), - t_tuple([t_atom('error'), t_inet_posix_error()])) - end); -type(gen_tcp, listen, 2, Xs) -> - strict(arg_types(gen_tcp, listen, 2), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_socket()]), - t_tuple([t_atom('error'), t_inet_posix_error()])) - end); -type(gen_tcp, recv, 2, Xs) -> - strict(arg_types(gen_tcp, recv, 2), Xs, fun (_) -> t_gen_tcp_recv() end); -type(gen_tcp, recv, 3, Xs) -> - strict(arg_types(gen_tcp, recv, 3), Xs, fun (_) -> t_gen_tcp_recv() end); -type(gen_tcp, send, 2, Xs) -> - strict(arg_types(gen_tcp, send, 2), Xs, - fun (_) -> - t_sup(t_atom('ok'), - t_tuple([t_atom('error'), t_inet_posix_error()])) - end); -type(gen_tcp, shutdown, 2, Xs) -> - strict(arg_types(gen_tcp, shutdown, 2), Xs, - fun (_) -> - t_sup(t_atom('ok'), - t_tuple([t_atom('error'), t_inet_posix_error()])) - end); -%%-- gen_udp ------------------------------------------------------------------ -%% NOTE: All type information for this module added to avoid loss of precision -type(gen_udp, open, 1, Xs) -> - strict(arg_types(gen_udp, open, 1), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_socket()]), - t_tuple([t_atom('error'), t_inet_posix_error()])) - end); -type(gen_udp, open, 2, Xs) -> - strict(arg_types(gen_udp, open, 2), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_socket()]), - t_tuple([t_atom('error'), t_inet_posix_error()])) - end); -type(gen_udp, recv, 2, Xs) -> - strict(arg_types(gen_udp, recv, 2), Xs, fun (_) -> t_gen_udp_recv() end); -type(gen_udp, recv, 3, Xs) -> - strict(arg_types(gen_udp, recv, 3), Xs, fun (_) -> t_gen_udp_recv() end); -type(gen_udp, send, 4, Xs) -> - strict(arg_types(gen_udp, send, 4), Xs, - fun (_) -> - t_sup(t_atom('ok'), - t_tuple([t_atom('error'), t_sup(t_atom('not_owner'), - t_inet_posix_error())])) - end); %%-- hipe_bifs ---------------------------------------------------------------- type(hipe_bifs, add_ref, 2, Xs) -> strict(arg_types(hipe_bifs, add_ref, 2), Xs, fun (_) -> t_nil() end); @@ -2097,26 +1759,6 @@ type(hipe_bifs, write_u32, 2, Xs) -> strict(arg_types(hipe_bifs, write_u32, 2), Xs, fun (_) -> t_nil() end); type(hipe_bifs, write_u64, 2, Xs) -> strict(arg_types(hipe_bifs, write_u64, 2), Xs, fun (_) -> t_nil() end); -%%-- io ----------------------------------------------------------------------- -type(io, format, 1, Xs) -> - strict(arg_types(io, format, 1), Xs, fun (_) -> t_atom('ok') end); -type(io, format, 2, Xs) -> - strict(arg_types(io, format, 2), Xs, fun (_) -> t_atom('ok') end); -type(io, format, 3, Xs) -> - strict(arg_types(io, format, 3), Xs, fun (_) -> t_atom('ok') end); -type(io, fwrite, 1, Xs) -> type(io, format, 1, Xs); % same -type(io, fwrite, 2, Xs) -> type(io, format, 2, Xs); % same -type(io, fwrite, 3, Xs) -> type(io, format, 3, Xs); % same -type(io, put_chars, 1, Xs) -> - strict(arg_types(io, put_chars, 1), Xs, fun (_) -> t_atom('ok') end); -type(io, put_chars, 2, Xs) -> - strict(arg_types(io, put_chars, 2), Xs, fun (_) -> t_atom('ok') end); -%%-- io_lib ------------------------------------------------------------------- -type(io_lib, format, 2, Xs) -> - strict(arg_types(io_lib, format, 2), Xs, - %% t_list() because the character list might be arbitrarily nested - fun (_) -> t_list(t_sup(t_char(), t_list())) end); -type(io_lib, fwrite, 2, Xs) -> type(io_lib, format, 2, Xs); % same %%-- lists -------------------------------------------------------------------- type(lists, all, 2, Xs) -> strict(arg_types(lists, all, 2), Xs, @@ -2524,10 +2166,6 @@ type(lists, reverse, 1, Xs) -> strict(arg_types(lists, reverse, 1), Xs, fun ([X]) -> X end); type(lists, reverse, 2, Xs) -> type(erlang, '++', 2, Xs); % reverse-onto is just like append -type(lists, seq, 2, Xs) -> - strict(arg_types(lists, seq, 2), Xs, fun (_) -> t_list(t_integer()) end); -type(lists, seq, 3, Xs) -> - strict(arg_types(lists, seq, 3), Xs, fun (_) -> t_list(t_integer()) end); type(lists, sort, 1, Xs) -> strict(arg_types(lists, sort, 1), Xs, fun ([X]) -> X end); type(lists, sort, 2, Xs) -> @@ -2634,95 +2272,7 @@ type(lists, zipwith, 3, Xs) -> type(lists, zipwith3, 4, Xs) -> strict(arg_types(lists, zipwith3, 4), Xs, fun ([F,_As,_Bs,_Cs]) -> t_sup(t_list(t_fun_range(F)), t_nil()) end); -%%-- math --------------------------------------------------------------------- -type(math, acos, 1, Xs) -> - strict(arg_types(math, acos, 1), Xs, fun (_) -> t_float() end); -type(math, acosh, 1, Xs) -> - strict(arg_types(math, acosh, 1), Xs, fun (_) -> t_float() end); -type(math, asin, 1, Xs) -> - strict(arg_types(math, asin, 1), Xs, fun (_) -> t_float() end); -type(math, asinh, 1, Xs) -> - strict(arg_types(math, asinh, 1), Xs, fun (_) -> t_float() end); -type(math, atan, 1, Xs) -> - strict(arg_types(math, atan, 1), Xs, fun (_) -> t_float() end); -type(math, atan2, 2, Xs) -> - strict(arg_types(math, atan2, 2), Xs, fun (_) -> t_float() end); -type(math, atanh, 1, Xs) -> - strict(arg_types(math, atanh, 1), Xs, fun (_) -> t_float() end); -type(math, cos, 1, Xs) -> - strict(arg_types(math, cos, 1), Xs, fun (_) -> t_float() end); -type(math, cosh, 1, Xs) -> - strict(arg_types(math, cosh, 1), Xs, fun (_) -> t_float() end); -type(math, erf, 1, Xs) -> - strict(arg_types(math, erf, 1), Xs, fun (_) -> t_float() end); -type(math, erfc, 1, Xs) -> - strict(arg_types(math, erfc, 1), Xs, fun (_) -> t_float() end); -type(math, exp, 1, Xs) -> - strict(arg_types(math, exp, 1), Xs, fun (_) -> t_float() end); -type(math, log, 1, Xs) -> - strict(arg_types(math, log, 1), Xs, fun (_) -> t_float() end); -type(math, log10, 1, Xs) -> - strict(arg_types(math, log10, 1), Xs, fun (_) -> t_float() end); -type(math, pi, 0, _) -> t_float(); -type(math, pow, 2, Xs) -> - strict(arg_types(math, pow, 2), Xs, fun (_) -> t_float() end); -type(math, sin, 1, Xs) -> - strict(arg_types(math, sin, 1), Xs, fun (_) -> t_float() end); -type(math, sinh, 1, Xs) -> - strict(arg_types(math, sinh, 1), Xs, fun (_) -> t_float() end); -type(math, sqrt, 1, Xs) -> - strict(arg_types(math, sqrt, 1), Xs, fun (_) -> t_float() end); -type(math, tan, 1, Xs) -> - strict(arg_types(math, tan, 1), Xs, fun (_) -> t_float() end); -type(math, tanh, 1, Xs) -> - strict(arg_types(math, tanh, 1), Xs, fun (_) -> t_float() end); -%%-- net_kernel --------------------------------------------------------------- -type(net_kernel, dflag_unicode_io, 1, Xs) -> - strict(arg_types(net_kernel, dflag_unicode_io, 1), Xs, - fun (_) -> t_boolean() end); -%%-- ordsets ------------------------------------------------------------------ -type(ordsets, filter, 2, Xs) -> - type(lists, filter, 2, Xs); -type(ordsets, fold, 3, Xs) -> - type(lists, foldl, 3, Xs); -%%-- os ----------------------------------------------------------------------- -type(os, getenv, 0, _) -> t_list(t_string()); -type(os, getenv, 1, Xs) -> - strict(arg_types(os, getenv, 1), Xs, - fun (_) -> t_sup(t_string(), t_atom('false')) end); -type(os, getpid, 0, _) -> t_string(); -type(os, putenv, 2, Xs) -> - strict(arg_types(os, putenv, 2), Xs, fun (_) -> t_atom('true') end); -type(os, timestamp, 0, _) -> - t_timestamp(); -%%-- re ----------------------------------------------------------------------- -type(re, compile, 1, Xs) -> - strict(arg_types(re, compile, 1), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_re_MP()]), - t_tuple([t_atom('error'), t_re_ErrorSpec()])) - end); -type(re, compile, 2, Xs) -> - strict(arg_types(re, compile, 2), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_re_MP()]), - t_tuple([t_atom('error'), t_re_ErrorSpec()])) - end); -type(re, run, 2, Xs) -> - strict(arg_types(re, run, 2), Xs, - fun (_) -> - t_sup([t_tuple([t_atom('match'), t_re_Captured()]), - t_atom('nomatch'), - t_tuple([t_atom('error'), t_re_ErrorSpec()])]) - end); -type(re, run, 3, Xs) -> - strict(arg_types(re, run, 3), Xs, - fun (_) -> - t_sup([t_tuple([t_atom('match'), t_re_Captured()]), - t_atom('match'), - t_atom('nomatch'), - t_tuple([t_atom('error'), t_re_ErrorSpec()])]) - end); + %%-- string ------------------------------------------------------------------- type(string, chars, 2, Xs) -> % NOTE: added to avoid loss of information strict(arg_types(string, chars, 2), Xs, fun (_) -> t_string() end); @@ -2741,41 +2291,6 @@ type(string, chars, 3, Xs) -> % NOTE: added to avoid loss of information end end end); -type(string, concat, 2, Xs) -> % NOTE: added to avoid loss of information - strict(arg_types(string, concat, 2), Xs, fun (_) -> t_string() end); -type(string, equal, 2, Xs) -> % NOTE: added to avoid loss of information - strict(arg_types(string, equal, 2), Xs, fun (_) -> t_boolean() end); -type(string, to_float, 1, Xs) -> - strict(arg_types(string, to_float, 1), Xs, - fun (_) -> t_sup(t_tuple([t_float(), t_string()]), - t_tuple([t_atom('error'), - t_sup(t_atom('no_float'), - t_atom('not_a_list'))])) - end); -type(string, to_integer, 1, Xs) -> - strict(arg_types(string, to_integer, 1), Xs, - fun (_) -> t_sup(t_tuple([t_integer(), t_string()]), - t_tuple([t_atom('error'), - t_sup(t_atom('no_integer'), - t_atom('not_a_list'))])) - end); -%%-- unicode ------------------------------------------------------------------ -type(unicode, characters_to_binary, 2, Xs) -> - strict(arg_types(unicode, characters_to_binary, 2), Xs, - fun (_) -> - t_sup([t_binary(), - t_tuple([t_atom('error'), t_binary(), t_ML()]), - t_tuple([t_atom('incomplete'), t_binary(), t_ML()])]) - end); -type(unicode, characters_to_list, 2, Xs) -> - strict(arg_types(unicode, characters_to_list, 2), Xs, - fun (_) -> - t_sup([t_string(), - t_tuple([t_atom('error'), t_string(), t_ML()]), - t_tuple([t_atom('incomplete'), t_string(), t_ML()])]) - end); -type(unicode, bin_is_7bit, 1, Xs) -> - strict(arg_types(unicode, bin_is_7bit, 1), Xs, fun (_) -> t_boolean() end); %%----------------------------------------------------------------------------- type(M, F, A, Xs) when is_atom(M), is_atom(F), @@ -3230,107 +2745,6 @@ key_comparisons_fail(X0, KeyPos, TupleList) -> -spec arg_types(atom(), atom(), arity()) -> [erl_types:erl_type()] | 'unknown'. -%%------- binary -------------------------------------------------------------- -arg_types(binary, at, 2) -> - [t_binary(), t_non_neg_integer()]; -arg_types(binary, bin_to_list, 1) -> - [t_binary()]; -arg_types(binary, bin_to_list, 2) -> - [t_binary(), t_binary_part()]; -arg_types(binary, bin_to_list, 3) -> - [t_binary(), t_integer(), t_non_neg_integer()]; -arg_types(binary, compile_pattern, 1) -> - [t_sup(t_binary(), t_list(t_binary()))]; -arg_types(binary, copy, 1) -> - [t_binary()]; -arg_types(binary, copy, 2) -> - [t_binary(), t_non_neg_integer()]; -arg_types(binary, decode_unsigned, 1) -> - [t_binary()]; -arg_types(binary, decode_unsigned, 2) -> - [t_binary(), t_endian()]; -arg_types(binary, encode_unsigned, 1) -> - [t_non_neg_integer()]; -arg_types(binary, encode_unsigned, 2) -> - [t_non_neg_integer(), t_endian()]; -arg_types(binary, first, 1) -> - [t_binary()]; -arg_types(binary, last, 1) -> - [t_binary()]; -arg_types(binary, list_to_bin, 1) -> - arg_types(erlang, list_to_binary, 1); -arg_types(binary, longest_common_prefix, 1) -> - [t_list(t_binary())]; -arg_types(binary, longest_common_suffix, 1) -> - [t_list(t_binary())]; -arg_types(binary, match, 2) -> - [t_binary(), t_binary_pattern()]; -arg_types(binary, match, 3) -> - [t_binary(), t_binary_pattern(), t_binary_options()]; -arg_types(binary, matches, 2) -> - [t_binary(), t_binary_pattern()]; -arg_types(binary, matches, 3) -> - [t_binary(), t_binary_pattern(), t_binary_options()]; -arg_types(binary, part, 2) -> - arg_types(erlang, binary_part, 2); -arg_types(binary, part, 3) -> - arg_types(erlang, binary_part, 3); -arg_types(binary, referenced_byte_size, 1) -> - [t_binary()]; -%%------- code ---------------------------------------------------------------- -arg_types(code, get_chunk, 2) -> - [t_binary(), t_string()]; -arg_types(code, is_module_native, 1) -> - [t_atom()]; -arg_types(code, module_md5, 1) -> - [t_binary()]; -arg_types(code, make_stub_module, 3) -> - [t_atom(), t_binary(), t_tuple([t_list(), t_list()])]; -arg_types(code, rehash, 0) -> - []; -%%------- erl_ddll ------------------------------------------------------------ -arg_types(erl_ddll, demonitor, 1) -> - arg_types(erlang, demonitor, 1); -arg_types(erl_ddll, format_error_int, 1) -> - [t_sup([t_atom('inconsistent'), - t_atom('linked_in_driver'), - t_atom('permanent'), - t_atom('not_loaded'), - t_atom('not_loaded_by_this_process'), - t_atom('not_pending'), - t_atom('already_loaded'), - t_atom('unloading')])]; -arg_types(erl_ddll, info, 2) -> - [t_sup([t_atom(), t_string()]), - t_sup([t_atom('awaiting_load'), - t_atom('awaiting_unload'), - t_atom('driver_options'), - t_atom('linked_in_driver'), - t_atom('permanent'), - t_atom('port_count'), - t_atom('processes')])]; -arg_types(erl_ddll, loaded_drivers, 0) -> - []; -arg_types(erl_ddll, monitor, 2) -> - [t_atom('driver'), - t_tuple([t_atom(), t_sup([t_atom('loaded'), t_atom('unloaded')])])]; -arg_types(erl_ddll, try_load, 3) -> - [t_sup([t_atom(), t_string(), t_nonempty_list(t_sup([t_atom(), t_string()]))]), - t_sup([t_atom(), t_string()]), - t_list(t_sup([t_tuple([t_atom('driver_options'), - t_list(t_atom('kill_ports'))]), - t_tuple([t_atom('monitor'), - t_sup([t_atom('pending_driver'), - t_atom('pending')])]), - t_tuple([t_atom('reload'), - t_sup([t_atom('pending_driver'), - t_atom('pending')])])]))]; -arg_types(erl_ddll, try_unload, 2) -> - [t_sup([t_atom(), t_string(), t_nonempty_list(t_sup([t_atom(), t_string()]))]), - t_list(t_sup([t_atom('kill_ports'), - t_tuple([t_atom('monitor'), - t_sup([t_atom('pending_driver'), - t_atom('pending')])])]))]; %%------- erlang -------------------------------------------------------------- arg_types(erlang, '!', 2) -> Pid = t_sup([t_pid(), t_port(), t_atom(), @@ -3960,177 +3374,9 @@ arg_types(erlang, whereis, 1) -> [t_atom()]; arg_types(erlang, yield, 0) -> []; -%%------- erl_prim_loader ----------------------------------------------------- -arg_types(erl_prim_loader, get_file, 1) -> - [t_sup(t_atom(), t_string())]; -arg_types(erl_prim_loader, get_path, 0) -> - []; -arg_types(erl_prim_loader, set_path, 1) -> - [t_list(t_string())]; -%%------- error_logger -------------------------------------------------------- -arg_types(error_logger, warning_map, 0) -> - []; -%%------- erts_debug ---------------------------------------------------------- -arg_types(erts_debug, breakpoint, 2) -> - [t_tuple([t_atom(), t_atom(), t_sup(t_integer(), t_atom('_'))]), t_boolean()]; -arg_types(erts_debug, disassemble, 1) -> - [t_sup(t_mfa(), t_integer())]; -arg_types(erts_debug, display, 1) -> - [t_any()]; -arg_types(erts_debug, dist_ext_to_term, 2) -> - [t_tuple(), t_binary()]; -arg_types(erts_debug, dump_monitors, 1) -> - [t_sup([t_pid(),t_atom()])]; -arg_types(erts_debug, dump_links, 1) -> - [t_sup([t_pid(),t_atom(),t_port()])]; -arg_types(erts_debug, flat_size, 1) -> - [t_any()]; -arg_types(erts_debug, get_internal_state, 1) -> - [t_any()]; -arg_types(erts_debug, instructions, 0) -> - []; -arg_types(erts_debug, lock_counters, 1) -> - [t_sup([t_atom(enabled), - t_atom(info), - t_atom(clear), - t_tuple([t_atom(copy_save), t_boolean()]), - t_tuple([t_atom(process_locks), t_boolean()])])]; -arg_types(erts_debug, same, 2) -> - [t_any(), t_any()]; -arg_types(erts_debug, set_internal_state, 2) -> - [t_any(), t_any()]; %%------- ets ----------------------------------------------------------------- -arg_types(ets, all, 0) -> - []; -arg_types(ets, delete, 1) -> - [t_tab()]; -arg_types(ets, delete, 2) -> - [t_tab(), t_any()]; -arg_types(ets, delete_all_objects, 1) -> - [t_tab()]; -arg_types(ets, delete_object, 2) -> - [t_tab(), t_tuple()]; -arg_types(ets, first, 1) -> - [t_tab()]; -arg_types(ets, give_away, 3) -> - [t_tab(), t_pid(), t_any()]; -arg_types(ets, info, 1) -> - [t_tab()]; -arg_types(ets, info, 2) -> - [t_tab(), t_ets_info_items()]; -arg_types(ets, insert, 2) -> - [t_tab(), t_sup(t_tuple(), t_list(t_tuple()))]; -arg_types(ets, insert_new, 2) -> - [t_tab(), t_sup(t_tuple(), t_list(t_tuple()))]; -arg_types(ets, is_compiled_ms, 1) -> - [t_any()]; -arg_types(ets, last, 1) -> - arg_types(ets, first, 1); -arg_types(ets, lookup, 2) -> - [t_tab(), t_any()]; -arg_types(ets, lookup_element, 3) -> - [t_tab(), t_any(), t_pos_fixnum()]; -arg_types(ets, match, 1) -> - [t_any()]; -arg_types(ets, match, 2) -> - [t_tab(), t_match_pattern()]; -arg_types(ets, match, 3) -> - [t_tab(), t_match_pattern(), t_pos_fixnum()]; -arg_types(ets, match_object, 1) -> - arg_types(ets, match, 1); -arg_types(ets, match_object, 2) -> - arg_types(ets, match, 2); -arg_types(ets, match_object, 3) -> - arg_types(ets, match, 3); -arg_types(ets, match_spec_compile, 1) -> - [t_matchspecs()]; -arg_types(ets, match_spec_run_r, 3) -> - [t_list(t_tuple()),t_matchspecs(), t_list()]; -arg_types(ets, member, 2) -> - [t_tab(), t_any()]; -arg_types(ets, new, 2) -> - [t_atom(), t_ets_new_options()]; -arg_types(ets, next, 2) -> - [t_tab(), t_any()]; -arg_types(ets, prev, 2) -> - [t_tab(), t_any()]; arg_types(ets, rename, 2) -> [t_atom(), t_atom()]; -arg_types(ets, safe_fixtable, 2) -> - [t_tab(), t_boolean()]; -arg_types(ets, select, 1) -> - [t_any()]; -arg_types(ets, select, 2) -> - [t_tab(), t_matchspecs()]; -arg_types(ets, select, 3) -> - [t_tab(), t_matchspecs(), t_pos_fixnum()]; -arg_types(ets, select_count, 2) -> - [t_tab(), t_matchspecs()]; -arg_types(ets, select_delete, 2) -> - [t_tab(), t_matchspecs()]; -arg_types(ets, select_reverse, 1) -> - arg_types(ets, select, 1); -arg_types(ets, select_reverse, 2) -> - arg_types(ets, select, 2); -arg_types(ets, select_reverse, 3) -> - arg_types(ets, select, 3); -arg_types(ets, slot, 2) -> - [t_tab(), t_non_neg_fixnum()]; % 2nd arg can be 0 -arg_types(ets, setopts, 2) -> - Opt = t_sup([t_tuple([t_atom('heir'), t_pid(), t_any()]), - t_tuple([t_atom('heir'), t_atom('none')]), - t_tuple([t_atom('protection'), - t_sup([t_atom('protected'), - t_atom('private'), - t_atom('public')])])]), - [t_tab(), t_sup(Opt, t_list(Opt))]; -arg_types(ets, update_counter, 3) -> - Int = t_integer(), - UpdateOp = t_sup(t_tuple([Int, Int]), t_tuple([Int, Int, Int, Int])), - [t_tab(), t_any(), t_sup([UpdateOp, t_list(UpdateOp), Int])]; -arg_types(ets, update_element, 3) -> - PosValue = t_tuple([t_integer(), t_any()]), - [t_tab(), t_any(), t_sup(PosValue, t_list(PosValue))]; -%%------- file ---------------------------------------------------------------- -arg_types(file, native_name_encoding, 0) -> - []; -%%-- prim_file ---------------------------------------------------------------- -arg_types(prim_file, internal_name2native, 1) -> - [t_prim_file_name()]; -arg_types(prim_file, internal_native2name, 1) -> - [t_binary()]; -arg_types(prim_file, internal_normalize_utf8, 1) -> - [t_binary()]; -%%------- gen_tcp ------------------------------------------------------------- -arg_types(gen_tcp, accept, 1) -> - [t_socket()]; -arg_types(gen_tcp, accept, 2) -> - [t_socket(), t_timeout()]; -arg_types(gen_tcp, connect, 3) -> - [t_gen_tcp_address(), t_gen_tcp_port(), t_list(t_gen_tcp_connect_option())]; -arg_types(gen_tcp, connect, 4) -> - arg_types(gen_tcp, connect, 3) ++ [t_timeout()]; -arg_types(gen_tcp, listen, 2) -> - [t_gen_tcp_port(), t_list(t_gen_tcp_listen_option())]; -arg_types(gen_tcp, recv, 2) -> - [t_socket(), t_non_neg_integer()]; -arg_types(gen_tcp, recv, 3) -> - arg_types(gen_tcp, recv, 2) ++ [t_timeout()]; -arg_types(gen_tcp, send, 2) -> - [t_socket(), t_packet()]; -arg_types(gen_tcp, shutdown, 2) -> - [t_socket(), t_sup([t_atom('read'), t_atom('write'), t_atom('read_write')])]; -%%------- gen_udp ------------------------------------------------------------- -arg_types(gen_udp, open, 1) -> - [t_gen_tcp_port()]; -arg_types(gen_udp, open, 2) -> - [t_gen_tcp_port(), t_list(t_gen_udp_connect_option())]; -arg_types(gen_udp, recv, 2) -> - arg_types(gen_tcp, recv, 2); -arg_types(gen_udp, recv, 3) -> - arg_types(gen_tcp, recv, 3); -arg_types(gen_udp, send, 4) -> - [t_socket(), t_gen_tcp_address(), t_gen_tcp_port(), t_packet()]; %%------- hipe_bifs ----------------------------------------------------------- arg_types(hipe_bifs, add_ref, 2) -> [t_mfa(), t_tuple([t_mfa(), @@ -4228,28 +3474,6 @@ arg_types(hipe_bifs, write_u32, 2) -> [t_integer(), t_integer()]; arg_types(hipe_bifs, write_u64, 2) -> [t_integer(), t_integer()]; -%%------- io ------------------------------------------------------------------ -arg_types(io, format, 1) -> - [t_io_format_string()]; -arg_types(io, format, 2) -> - [t_io_format_string(), t_list()]; -arg_types(io, format, 3) -> - [t_io_device(), t_io_format_string(), t_list()]; -arg_types(io, fwrite, 1) -> - arg_types(io, format, 1); -arg_types(io, fwrite, 2) -> - arg_types(io, format, 2); -arg_types(io, fwrite, 3) -> - arg_types(io, format, 3); -arg_types(io, put_chars, 1) -> - [t_iodata()]; -arg_types(io, put_chars, 2) -> - [t_io_device(), t_iodata()]; -%%------- io_lib -------------------------------------------------------------- -arg_types(io_lib, format, 2) -> - arg_types(io, format, 2); -arg_types(io_lib, fwrite, 2) -> - arg_types(io_lib, format, 2); %%------- lists --------------------------------------------------------------- arg_types(lists, all, 2) -> [t_fun([t_any()], t_boolean()), t_list()]; @@ -4321,10 +3545,6 @@ arg_types(lists, reverse, 1) -> [t_list()]; arg_types(lists, reverse, 2) -> [t_list(), t_any()]; -arg_types(lists, seq, 2) -> - [t_integer(), t_integer()]; -arg_types(lists, seq, 3) -> - [t_integer(), t_integer(), t_integer()]; arg_types(lists, sort, 1) -> [t_list()]; arg_types(lists, sort, 2) -> @@ -4353,97 +3573,12 @@ arg_types(lists, zipwith, 3) -> [t_fun([t_any(), t_any()], t_any()), t_list(), t_list()]; arg_types(lists, zipwith3, 4) -> [t_fun([t_any(), t_any(), t_any()], t_any()), t_list(), t_list(), t_list()]; -%%------- math ---------------------------------------------------------------- -arg_types(math, acos, 1) -> - [t_number()]; -arg_types(math, acosh, 1) -> - [t_number()]; -arg_types(math, asin, 1) -> - [t_number()]; -arg_types(math, asinh, 1) -> - [t_number()]; -arg_types(math, atan, 1) -> - [t_number()]; -arg_types(math, atan2, 2) -> - [t_number(), t_number()]; -arg_types(math, atanh, 1) -> - [t_number()]; -arg_types(math, cos, 1) -> - [t_number()]; -arg_types(math, cosh, 1) -> - [t_number()]; -arg_types(math, erf, 1) -> - [t_number()]; -arg_types(math, erfc, 1) -> - [t_number()]; -arg_types(math, exp, 1) -> - [t_number()]; -arg_types(math, log, 1) -> - [t_number()]; -arg_types(math, log10, 1) -> - [t_number()]; -arg_types(math, pi, 0) -> - []; -arg_types(math, pow, 2) -> - [t_number(), t_number()]; -arg_types(math, sin, 1) -> - [t_number()]; -arg_types(math, sinh, 1) -> - [t_number()]; -arg_types(math, sqrt, 1) -> - [t_number()]; -arg_types(math, tan, 1) -> - [t_number()]; -arg_types(math, tanh, 1) -> - [t_number()]; -%%-- net_kernel --------------------------------------------------------------- -arg_types(net_kernel, dflag_unicode_io, 1) -> - [t_pid()]; -%%------- ordsets ------------------------------------------------------------- -arg_types(ordsets, filter, 2) -> - arg_types(lists, filter, 2); -arg_types(ordsets, fold, 3) -> - arg_types(lists, foldl, 3); -%%------- os ------------------------------------------------------------------ -arg_types(os, getenv, 0) -> - []; -arg_types(os, getenv, 1) -> - [t_string()]; -arg_types(os, getpid, 0) -> - []; -arg_types(os, putenv, 2) -> - [t_string(), t_string()]; -arg_types(os, timestamp, 0) -> - []; -%%-- re ----------------------------------------------------------------------- -arg_types(re, compile, 1) -> - [t_iodata()]; -arg_types(re, compile, 2) -> - [t_sup(t_iodata(), t_charlist()), t_list(t_re_compile_option())]; -arg_types(re, run, 2) -> - [t_sup(t_iodata(), t_charlist()), t_re_RE()]; -arg_types(re, run, 3) -> - [t_sup(t_iodata(), t_charlist()), t_re_RE(), t_list(t_re_run_option())]; + %%------- string -------------------------------------------------------------- arg_types(string, chars, 2) -> [t_char(), t_non_neg_integer()]; arg_types(string, chars, 3) -> [t_char(), t_non_neg_integer(), t_any()]; -arg_types(string, concat, 2) -> - [t_string(), t_string()]; -arg_types(string, equal, 2) -> - [t_string(), t_string()]; -arg_types(string, to_float, 1) -> - [t_string()]; -arg_types(string, to_integer, 1) -> - [t_string()]; -%%------- unicode ------------------------------------------------------------- -arg_types(unicode, characters_to_binary, 2) -> - [t_ML(), t_encoding()]; -arg_types(unicode, characters_to_list, 2) -> - [t_ML(), t_encoding()]; -arg_types(unicode, bin_is_7bit, 1) -> - [t_binary()]; %%----------------------------------------------------------------------------- arg_types(M, F, A) when is_atom(M), is_atom(F), is_integer(A), 0 =< A, A =< 255 -> @@ -4502,18 +3637,6 @@ check_fun_application(Fun, Args) -> end. -%% ===================================================================== -%% These are basic types that should probably be moved to erl_types -%% ===================================================================== - -t_socket() -> t_port(). % alias - -t_ip_address() -> - T_int16 = t_from_range(0, 16#FFFF), - t_sup(t_tuple([t_byte(), t_byte(), t_byte(), t_byte()]), - t_tuple([T_int16, T_int16, T_int16, T_int16, - T_int16, T_int16, T_int16, T_int16])). - %% ===================================================================== %% Some basic types used in various parts of the system %% ===================================================================== @@ -4594,27 +3717,6 @@ t_HttpFieldAtom() -> t_HttpString() -> t_sup(t_string(), t_binary()). -%% ===================================================================== -%% These are used for the built-in functions of 'binary' -%% ===================================================================== - -t_binary_part() -> - t_tuple([t_non_neg_integer(), t_integer()]). - -t_binary_canonical_part() -> - t_tuple([t_non_neg_integer(), t_non_neg_integer()]). - -t_binary_pattern() -> - t_sup([t_binary(), - t_list(t_binary()), - t_binary_compiled_pattern()]). - -t_binary_compiled_pattern() -> - t_tuple([t_sup(t_atom('bm'), t_atom('ac')), t_binary()]). - -t_binary_options() -> - t_list(t_tuple([t_atom('scope'), t_binary_part()])). - %% ===================================================================== %% These are used for the built-in functions of 'code' %% ===================================================================== @@ -4821,126 +3923,6 @@ t_system_profile_return() -> t_sup(t_atom('undefined'), t_tuple([t_sup(t_pid(), t_port()), t_system_profile_options()])). -%% ===================================================================== -%% These are used for the built-in functions of 'ets' -%% ===================================================================== - -t_tab() -> - t_sup(t_tid(), t_atom()). - -t_match_pattern() -> - t_sup(t_atom(), t_tuple()). - -t_matchspecs() -> - t_list(t_tuple([t_match_pattern(), t_list(), t_list()])). - -t_matchres() -> - t_sup(t_tuple([t_list(), t_any()]), t_atom('$end_of_table')). - -%% From the 'ets' documentation -%%----------------------------- -%% Option = Type | Access | named_table | {keypos,Pos} -%% | {heir,pid(),HeirData} | {heir,none} | Tweaks -%% Type = set | ordered_set | bag | duplicate_bag -%% Access = public | protected | private -%% Tweaks = {write_concurrency,boolean()} -%% | {read_concurrency,boolean()} | compressed -%% Pos = integer() -%% HeirData = term() -t_ets_new_options() -> - t_list(t_sup([t_atom('set'), - t_atom('ordered_set'), - t_atom('bag'), - t_atom('duplicate_bag'), - t_atom('public'), - t_atom('protected'), - t_atom('private'), - t_atom('named_table'), - t_tuple([t_atom('keypos'), t_integer()]), - t_tuple([t_atom('heir'), t_pid(), t_any()]), - t_tuple([t_atom('heir'), t_atom('none')]), - t_tuple([t_atom('write_concurrency'), t_boolean()]), - t_tuple([t_atom('read_concurrency'), t_boolean()]), - t_atom('compressed')])). - -t_ets_info_items() -> - t_sup([t_atom('fixed'), - t_atom('safe_fixed'), - t_atom('keypos'), - t_atom('memory'), - t_atom('name'), - t_atom('named_table'), - t_atom('node'), - t_atom('owner'), - t_atom('protection'), - t_atom('size'), - t_atom('compressed'), - t_atom('heir'), - t_atom('stats'), - t_atom('type')]). - -%% ===================================================================== -%% These are used for the built-in functions of 'gen_tcp' -%% ===================================================================== - -t_gen_tcp_accept() -> - t_sup(t_tuple([t_atom('ok'), t_socket()]), - t_tuple([t_atom('error'), t_sup([t_atom('closed'), - t_atom('timeout'), - t_inet_posix_error()])])). - -t_gen_tcp_address() -> - t_sup([t_string(), t_atom(), t_ip_address()]). - -t_gen_tcp_port() -> - t_from_range(0, 16#FFFF). - -t_gen_tcp_connect_option() -> - t_sup([t_atom('list'), - t_atom('binary'), - t_tuple([t_atom('ip'), t_ip_address()]), - t_tuple([t_atom('port'), t_gen_tcp_port()]), - t_tuple([t_atom('fd'), t_integer()]), - t_atom('inet6'), - t_atom('inet'), - t_inet_setoption()]). - -t_gen_tcp_listen_option() -> - t_sup([t_atom('list'), - t_atom('binary'), - t_tuple([t_atom('backlog'), t_non_neg_integer()]), - t_tuple([t_atom('ip'), t_ip_address()]), - t_tuple([t_atom('fd'), t_integer()]), - t_atom('inet6'), - t_atom('inet'), - t_inet_setoption()]). - -t_gen_tcp_recv() -> - t_sup(t_tuple([t_atom('ok'), t_packet()]), - t_tuple([t_atom('error'), t_sup([t_atom('closed'), - t_inet_posix_error()])])). - -%% ===================================================================== -%% These are used for the built-in functions of 'gen_udp' -%% ===================================================================== - -t_gen_udp_connect_option() -> - t_sup([t_atom('list'), - t_atom('binary'), - t_tuple([t_atom('ip'), t_ip_address()]), - t_tuple([t_atom('fd'), t_integer()]), - t_atom('inet6'), - t_atom('inet'), - t_inet_setoption()]). - -t_gen_udp_recv() -> - t_sup(t_tuple([t_atom('ok'), - t_tuple([t_ip_address(), - t_gen_tcp_port(), - t_packet()])]), - t_tuple([t_atom('error'), - t_sup(t_atom('not_owner'), t_inet_posix_error())])). - %% ===================================================================== %% These are used for the built-in functions of 'hipe_bifs' %% ===================================================================== @@ -4976,31 +3958,6 @@ t_insn_type() -> %% These are used for the built-in functions of 'inet' %% ===================================================================== -t_inet_setoption() -> - t_sup([%% first the 2-tuple options - t_tuple([t_atom('active'), t_sup(t_boolean(), t_atom('once'))]), - t_tuple([t_atom('broadcast'), t_boolean()]), - t_tuple([t_atom('delay_send'), t_boolean()]), - t_tuple([t_atom('dontroute'), t_boolean()]), - t_tuple([t_atom('exit_on_close'), t_boolean()]), - t_tuple([t_atom('header'), t_non_neg_integer()]), - t_tuple([t_atom('keepalive'), t_boolean()]), - t_tuple([t_atom('nodelay'), t_boolean()]), - t_tuple([t_atom('packet'), t_inet_setoption_packettype()]), - t_tuple([t_atom('packet_size'), t_non_neg_integer()]), - t_tuple([t_atom('read_packets'), t_non_neg_integer()]), - t_tuple([t_atom('recbuf'), t_non_neg_integer()]), - t_tuple([t_atom('reuseaddr'), t_boolean()]), - t_tuple([t_atom('send_timeout'), t_non_neg_integer()]), - t_tuple([t_atom('sndbuf'), t_non_neg_integer()]), - t_tuple([t_atom('priority'), t_non_neg_integer()]), - t_tuple([t_atom('tos'), t_non_neg_integer()]), - %% and a 4-tuple option - t_tuple([t_atom('raw'), - t_non_neg_integer(), % protocol level - t_non_neg_integer(), % option number - t_binary()])]). % actual option value - t_inet_setoption_packettype() -> t_sup([t_atom('raw'), t_integers([0,1,2,4]), @@ -5009,91 +3966,10 @@ t_inet_setoption_packettype() -> t_atom('http'), t_atom('http_bin')]). %% but t_atom('httph') is not needed -t_inet_posix_error() -> - t_atom(). %% XXX: Very underspecified - -%% ===================================================================== -%% These are used for the built-in functions of 'io' -%% ===================================================================== - -t_io_device() -> - t_sup(t_atom(), t_pid()). - -%% The documentation in R11B-4 reads -%% Format ::= atom() | string() | binary() -%% but the Format can also be a (deep) list, hence the type below -t_io_format_string() -> - t_sup([t_atom(), t_list(), t_binary()]). - -%% ===================================================================== -%% These are used for the built-in functions of 're'; the functions -%% whose last name component starts with a capital letter are types -%% ===================================================================== - -t_re_MP() -> %% it's supposed to be an opaque data type - t_tuple([t_atom('re_pattern'), t_integer(), t_integer(), t_binary()]). - -t_re_RE() -> - t_sup([t_re_MP(), t_iodata(), t_charlist()]). - -t_re_compile_option() -> - t_sup([t_atoms(['unicode', 'anchored', 'caseless', 'dollar_endonly', - 'dotall', 'extended', 'firstline', 'multiline', - 'no_auto_capture', 'dupnames', 'ungreedy']), - t_tuple([t_atom('newline'), t_re_NLSpec()]), - t_atoms(['bsr_anycrlf', 'bsr_unicode'])]). - -t_re_run_option() -> - t_sup([t_atoms(['anchored', 'global', 'notbol', 'noteol', 'notempty']), - t_tuple([t_atom('offset'), t_integer()]), - t_tuple([t_atom('newline'), t_re_NLSpec()]), - t_tuple([t_atom('capture'), t_re_ValueSpec()]), - t_tuple([t_atom('capture'), t_re_ValueSpec(), t_re_Type()]), - t_re_compile_option()]). - -t_re_ErrorSpec() -> - t_tuple([t_string(), t_non_neg_integer()]). - -t_re_Type() -> - t_atoms(['index', 'list', 'binary']). - -t_re_NLSpec() -> - t_atoms(['cr', 'crlf', 'lf', 'anycrlf', 'any']). - -t_re_ValueSpec() -> - t_sup(t_atoms(['all', 'all_but_first', 'first', 'none']), t_re_ValueList()). - -t_re_ValueList() -> - t_list(t_sup([t_integer(), t_string(), t_atom()])). - -t_re_Captured() -> - t_list(t_sup(t_re_CapturedData(), t_list(t_re_CapturedData()))). - -t_re_CapturedData() -> - t_sup([t_tuple([t_integer(), t_integer()]), t_string(), t_binary()]). - -%% ===================================================================== -%% These are used for the built-in functions of 'prim_file' -%% ===================================================================== - -t_prim_file_name() -> - t_sup(t_unicode_string(), t_binary()). - %% ===================================================================== %% These are used for the built-in functions of 'unicode' %% ===================================================================== -t_ML() -> % a binary or a possibly deep list of integers or binaries - t_sup(t_list(t_sup([t_integer(), t_binary(), t_list()])), t_binary()). - -t_encoding() -> - t_sup([t_atoms(['latin1', 'unicode', 'utf8', 'utf16', 'utf32']), - t_tuple([t_atom('utf16'), t_endian()]), - t_tuple([t_atom('utf32'), t_endian()])]). - -t_file_encoding() -> - t_atoms(['latin1', 'utf8']). - t_encoding_a2b() -> % for the 2nd arg of atom_to_binary/2 and binary_to_atom/2 t_atoms(['latin1', 'unicode', 'utf8']). diff --git a/lib/kernel/doc/src/code.xml b/lib/kernel/doc/src/code.xml index ee687511a3..bb111a2242 100644 --- a/lib/kernel/doc/src/code.xml +++ b/lib/kernel/doc/src/code.xml @@ -4,7 +4,7 @@
- 19962011 + 19962012 Ericsson AB. All Rights Reserved. @@ -728,16 +728,13 @@ rpc:call(Node, code, load_binary, [Module, Filename, Binary]), - is_module_native(Module) -> boolean() | undefined + Test whether a module has native code - - Module = module() - -

This function returns true if Module is +

This function returns true if Module is name of a loaded module that has native code loaded, and - false if Module is loaded but does not have - native. If Module is not loaded, this function returns + false if Module is loaded but does not have + native. If Module is not loaded, this function returns undefined.

diff --git a/lib/kernel/doc/src/erl_ddll.xml b/lib/kernel/doc/src/erl_ddll.xml index 1911fb628e..26db11cfcd 100644 --- a/lib/kernel/doc/src/erl_ddll.xml +++ b/lib/kernel/doc/src/erl_ddll.xml @@ -4,7 +4,7 @@
- 19972011 + 19972012 Ericsson AB. All Rights Reserved. @@ -182,11 +182,8 @@ - demonitor(MonitorRef) -> ok + Remove a monitor for a driver - - MonitorRef = reference() -

Removes a driver monitor in much the same way as erlang:demonitor/1 does with process @@ -232,24 +229,19 @@ - info(Name, Tag) -> Value + Retrieve specific information about one driver - - Name = string() | atom() - Tag = processes | driver_options | port_count | linked_in_driver | permanent | awaiting_load | awaiting_unload - Value = term() -

This function returns specific information about one aspect - of a driver. The Tag parameter specifies which aspect - to get information about. The Value return differs + of a driver. The Tag parameter specifies which aspect + to get information about. The Value return differs between different tags:

processes

Return all processes containing users of the specific drivers - as a list of tuples {pid(),int()}, where the - int() denotes the number of users in the process + as a list of tuples {pid(),integer() >= 0}, where the + integer() denotes the number of users in the process pid().

driver_options @@ -261,16 +253,16 @@ port_count -

Return the number of ports (an int()) using the driver.

+

Return the number of ports (an integer >= 0()) using the driver.

linked_in_driver -

Return a bool(), being true if the driver is a +

Return a boolean(), being true if the driver is a statically linked in one and false otherwise.

permanent -

Return a bool(), being true if the driver has made +

Return a boolean(), being true if the driver has made itself permanent (and is not a statically linked in driver). false otherwise.

@@ -278,14 +270,14 @@

Return a list of all processes having monitors for loading active, each process returned as - {pid(),int()}, where the int() is the + {pid(),integer() >= 0}, where the integer() is the number of monitors held by the process pid().

awaiting_unload

Return a list of all processes having monitors for unloading active, each process returned as - {pid(),int()}, where the int() is the + {pid(),integer() >= 0}, where the integer() is the number of monitors held by the process pid().

@@ -377,41 +369,34 @@
- monitor(Tag, Item) -> MonitorRef + Create a monitor for a driver - - Tag = driver - Item = {Name, When} - Name = atom() | string() - When = loaded | unloaded | unloaded_only - MonitorRef = reference() -

This function creates a driver monitor and works in many ways as the function erlang:monitor/2, does for processes. When a driver changes state, the monitor results in a monitor-message being sent to the calling - process. The MonitorRef returned by this function is + process. The MonitorRef returned by this function is included in the message sent.

As with process monitors, each driver monitor set will only generate one single message. The monitor is "destroyed" after the message is sent and there is then no need to call demonitor/1.

-

The MonitorRef can also be used in subsequent calls +

The MonitorRef can also be used in subsequent calls to demonitor/1 to remove a monitor.

The function accepts the following parameters:

- Tag + Tag

The monitor tag is always driver as this function can only be used to create driver monitors. In the future, driver monitors will be integrated with process monitors, why this parameter has to be given for consistence.

- Item + Item -

The Item parameter specifies which driver one +

The Item parameter specifies which driver one wants to monitor (the name of the driver) as well as which state change one wants to monitor. The parameter is a tuple of arity two whose first element is the @@ -588,22 +573,8 @@ - try_load(Path, Name, OptionList) -> {ok,Status} | {ok, PendingStatus, Ref} | {error, ErrorDesc} + Load a driver - - Path = Name = string() | atom() - OptionList = [ Option ] - Option = {driver_options, DriverOptionList} | {monitor, MonitorOption} | {reload, ReloadOption} - DriverOptionList = [ DriverOption ] - DriverOption = kill_ports - MonitorOption = pending_driver | pending - ReloadOption = pending_driver | pending - Status = loaded | already_loaded | PendingStatus - PendingStatus = pending_driver | pending_process - Ref = reference() - ErrorDesc = ErrorAtom | OpaqueError - ErrorAtom = linked_in_driver | inconsistent | permanent | not_loaded_by_this_process | not_loaded | pending_reload | pending_process -

This function provides more control than the load/2/reload/2 and @@ -655,65 +626,65 @@

When the function returns {ok, pending_driver} or {ok, pending_process}, one might want to get information about when the driver is actually loaded. This can - be achieved by using the {monitor, PendingOption} option.

+ be achieved by using the {monitor, MonitorOption} option.

When monitoring is requested, and a corresponding {ok, pending_driver} or {ok, pending_process} would be - returned, the function will instead return a tuple {ok, PendingStatus, reference()} and the process will, at a later + returned, the function will instead return a tuple {ok, PendingStatus, reference()} and the process will, at a later time when the driver actually gets loaded, get a monitor message. The monitor message one can expect is described in the monitor/2 function description.

Note that in case of loading, monitoring can - not only get triggered by using the {reload, ReloadOption} option, but also in special cases where + not only get triggered by using the {reload, ReloadOption} option, but also in special cases where the load-error is transient, why {monitor, pending_driver} should be used under basically all real world circumstances!

The function accepts the following parameters:

- Path + Path

The filesystem path to the directory where the driver object file is situated. The filename of the object file (minus extension) must correspond to the driver name (used in the name parameter) and the driver must identify itself with the very same name. The - Path might be provided as an io_list, - meaning it can be a list of other io_lists, characters + Path might be provided as an iolist(), + meaning it can be a list of other iolist()s, characters (eight bit integers) or binaries, all to be flattened into a sequence of characters.

-

The (possibly flattened) Path parameter must be +

The (possibly flattened) Path parameter must be consistent throughout the system, a driver should, by all users, be loaded - using the same literalPath. The + using the same literalPath. The exception is when reloading is requested, in - which case the Path may be specified + which case the Path may be specified differently. Note that all users trying to load the - driver at a later time will need to use the newPath if the Path is changed using a + driver at a later time will need to use the newPath if the Path is changed using a reload option. This is yet another reason to have only one loader of a driver one wants to upgrade in a running system!

- Name + Name

The name parameter is the name of the driver to be used in subsequent calls to open_port. The - name can be specified either as an io_list() or + name can be specified either as an iolist() or as an atom(). The name given when loading is used to find the actual object file (with the - help of the Path and the system implied + help of the Path and the system implied extension suffix, i.e. .so). The name by which the driver identifies itself must also be consistent - with this Name parameter, much as a beam-file's + with this Name parameter, much as a beam-file's module name much correspond to its filename.

- OptionList + OptionList

A number of options can be specified to control the loading operation. The options are given as a list of two-tuples, the tuples having the following values and meanings:

- {driver_options, DriverOptionsList} + {driver_options, DriverOptionList}

This option is to provide options that will change its general behavior and will "stick" to the driver @@ -729,14 +700,14 @@ when the last user calls try_unload/2, or the last process having loaded the driver exits.

- {monitor, MonitorOption} + {monitor, MonitorOption} -

A MonitorOption tells try_load/3 to +

A MonitorOption tells try_load/3 to trigger a driver monitor under certain conditions. When the monitor is triggered, the - function will return a three-tuple {ok, PendingStatus, reference()}, where the reference() is + function will return a three-tuple {ok, PendingStatus, reference()}, where the reference() is the monitor ref for the driver monitor.

-

Only one MonitorOption can be specified and +

Only one MonitorOption can be specified and it is either the atom pending, which means that a monitor should be created whenever a load operation is delayed, and the atom @@ -747,7 +718,7 @@ is present for completeness, it is very well defined which reload-options might give rise to which delays. It might, however, be a good idea to use the - same MonitorOption as the ReloadOption + same MonitorOption as the ReloadOption if present.

If reloading is not requested, it might still be useful to specify the monitor option, as @@ -760,12 +731,12 @@ {monitor, pending_driver} in production code (see the monitor discussion above).

- {reload,RealoadOption} + {reload,ReloadOption}

This option is used when one wants to reload a driver from disk, most often in a code upgrade scenario. Having a reload option - also implies that the Path parameter need + also implies that the Path parameter need not be consistent with earlier loads of the driver.

To reload a driver, the process needs to have previously @@ -814,9 +785,9 @@ {error,inconsistent}

The driver has already been loaded with either other - DriverOptions or a different literalPath argument.

+ DriverOptionList or a different literalPath argument.

This can happen even if a reload option is given, - if the DriverOptions differ from the current.

+ if the DriverOptionList differ from the current.

{error, permanent} @@ -830,19 +801,19 @@ {error, pending_reload} -

Driver reload is already requested by another user when the {reload, ReloadOption} option was given.

+

Driver reload is already requested by another user when the {reload, ReloadOption} option was given.

{error, not_loaded_by_this_process}

Appears when the reload option is given. The - driver Name is present in the system, but there is no + driver Name is present in the system, but there is no user of it in this process.

{error, not_loaded}

Appears when the reload option is given. The - driver Name is not in the system. Only drivers + driver Name is not in the system. Only drivers loaded by this process can be reloaded.

@@ -856,18 +827,8 @@
- try_unload(Name, OptionList) -> {ok,Status} | {ok, PendingStatus, Ref} | {error, ErrorAtom} + Unload a driver - - Name = string() | atom() - OptionList = [ Option ] - Option = {monitor, MonitorOption} | kill_ports - MonitorOption = pending_driver | pending - Status = unloaded | PendingStatus - PendingStatus = pending_driver | pending_process - Ref = reference() - ErrorAtom = linked_in_driver | not_loaded | not_loaded_by_this_process | permanent -

This is the low level function to unload (or decrement reference counts of) a driver. It can be used to force port @@ -948,15 +909,15 @@

The function accepts the following parameters:

- Name + Name

The name parameter is the name of the driver to be unloaded. The name can be specified either as an - io_list() or as an atom().

+ iolist() or as an atom().

- OptionList + OptionList -

The OptionList argument can be used to specify +

The OptionList argument can be used to specify certain behavior regarding ports as well as triggering monitors under certain conditions:

@@ -972,10 +933,10 @@ unloads, one should use the driver option kill_ports when loading the driver instead.

- {monitor, MonitorOption} + {monitor, MonitorOption}

This option creates a driver monitor if the condition - given in MonitorOptions is true. The valid + given in MonitorOption is true. The valid options are:

pending_driver @@ -989,7 +950,7 @@ {ok, pending_driver} or {ok, pending_process}.

-

The pending_driver MonitorOption is by far +

The pending_driver MonitorOption is by far the most useful and it has to be used to ensure that the driver has really been unloaded and the ports closed whenever the kill_ports option is used or the @@ -1016,11 +977,11 @@ {error, not_loaded} -

The driver Name is not present in the system.

+

The driver Name is not present in the system.

{error, not_loaded_by_this_process} -

The driver Name is present in the system, but +

The driver Name is present in the system, but there is no user of it in this process.

As a special case, drivers can be unloaded from @@ -1088,12 +1049,8 @@ - loaded_drivers() -> {ok, Drivers} + List loaded drivers - - Drivers = [Driver] - Driver = string() -

Returns a list of all the available drivers, both (statically) linked-in and dynamically loaded ones.

diff --git a/lib/kernel/doc/src/error_logger.xml b/lib/kernel/doc/src/error_logger.xml index 2d95f96ac7..5781591cca 100644 --- a/lib/kernel/doc/src/error_logger.xml +++ b/lib/kernel/doc/src/error_logger.xml @@ -4,7 +4,7 @@
- 19962011 + 19962012 Ericsson AB. All Rights Reserved. @@ -127,11 +127,8 @@ ok - warning_map() -> Tag + Return the current mapping for warning events - - Tag = error | warning | info -

Returns the current mapping for warning events. Events sent using warning_msg/1,2 or warning_report/1,2 diff --git a/lib/kernel/doc/src/file.xml b/lib/kernel/doc/src/file.xml index 772eff13cc..b2a259080d 100644 --- a/lib/kernel/doc/src/file.xml +++ b/lib/kernel/doc/src/file.xml @@ -4,7 +4,7 @@

- 19962011 + 19962012 Ericsson AB. All Rights Reserved. @@ -412,7 +412,7 @@ - file_info(Filename) -> {ok, FileInfo} | {error, Reason} + Get information about a file (deprecated)

This function is obsolete. Use read_file_info/1,2 @@ -598,7 +598,7 @@ - native_name_encoding() -> latin1 | utf8 + Return the VM's configured filename encoding.

This function returns the configured default file name encoding to use for raw file names. Generally an application supplying file names raw (as binaries), should obey the character encoding returned by this function.

diff --git a/lib/kernel/doc/src/os.xml b/lib/kernel/doc/src/os.xml index e94119845a..1bc5b9e464 100644 --- a/lib/kernel/doc/src/os.xml +++ b/lib/kernel/doc/src/os.xml @@ -4,7 +4,7 @@
- 19972011 + 19972012 Ericsson AB. All Rights Reserved. @@ -73,7 +73,7 @@ DirOut = os:cmd("dir"), % on Win32 platform - getenv() -> [string()] + List all environment variables

Returns a list of all environment variables. @@ -83,55 +83,41 @@ DirOut = os:cmd("dir"), % on Win32 platform - getenv(VarName) -> Value | false + Get the value of an environment variable - - VarName = string() - Value = string() - -

Returns the Value of the environment variable - VarName, or false if the environment variable +

Returns the Value of the environment variable + VarName, or false if the environment variable is undefined.

- getpid() -> Value + Return the process identifier of the emulator process - - Value = string() -

Returns the process identifier of the current Erlang emulator in the format most commonly used by the operating system - environment. Value is returned as a string containing + environment. Value is returned as a string containing the (usually) numerical identifier for a process. On Unix, this is typically the return value of the getpid() - system call. On VxWorks, Value contains the task id + system call. On VxWorks, Value contains the task id (decimal notation) of the Erlang task. On Windows, the process id as returned by the GetCurrentProcessId() system call is used.

- putenv(VarName, Value) -> true + Set a new value for an environment variable - - VarName = string() - Value = string() - -

Sets a new Value for the environment variable - VarName.

+

Sets a new Value for the environment variable + VarName.

- timestamp() -> Timestamp + + Timestamp = {MegaSecs, Secs, MicroSecs} Returna a timestamp from the OS in the erlang:now/0 format - - Timestamp = {MegaSecs, Secs, MicroSecs} = erlang:timestamp() - MegaSecs = Secs = MicroSecs = integer() >= 0 -

Returns a tuple in the same format as erlang:now/0. The difference is that this function returns what the operating system thinks (a.k.a. the wall clock time) without any attempts at time correction. The result of two different calls to this function is not guaranteed to be different.

The most obvious use for this function is logging. The tuple can be used together with the function calendar:now_to_universal_time/1 diff --git a/lib/kernel/src/code.erl b/lib/kernel/src/code.erl index b7fda69ce0..a9259817ea 100644 --- a/lib/kernel/src/code.erl +++ b/lib/kernel/src/code.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2011. All Rights Reserved. +%% Copyright Ericsson AB 1996-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -70,46 +70,6 @@ -include_lib("kernel/include/file.hrl"). -%% User interface. -%% -%% objfile_extension() -> ".beam" -%% get_path() -> [Dir] -%% set_path([Dir]) -> true | {error, bad_directory | bad_path} -%% add_path(Dir) -> true | {error, bad_directory} -%% add_patha(Dir) -> true | {error, bad_directory} -%% add_pathz(Dir) -> true | {error, bad_directory} -%% add_paths([Dir]) -> ok -%% add_pathsa([Dir]) -> ok -%% add_pathsz([Dir]) -> ok -%% del_path(Dir) -> boolean() | {error, bad_name} -%% replace_path(Name, Dir) -> true | {error, bad_directory | bad_name -%% | {badarg,_}} -%% load_file(Module) -> {module, Module} | {error, What :: atom()} -%% load_abs(File) -> {module, Module} | {error, What :: atom()} -%% load_abs(File, Module) -> {module, Module} | {error, What :: atom()} -%% load_binary(Module, File, Bin)-> {module, Module} | {error, What :: atom()} -%% ensure_loaded(Module) -> {module, Module} | {error, What :: atom()} -%% delete(Module) -> boolean() -%% purge(Module) -> boolean() kills all procs running old code -%% soft_purge(Module) -> boolean() -%% is_loaded(Module) -> {file, loaded_filename()} | false -%% all_loaded() -> [{Module, loaded_filename()}] -%% get_object_code(Module) -> {Module, Bin, Filename} | error -%% stop() -> no_return() -%% root_dir() -> Dir -%% compiler_dir() -> Dir -%% lib_dir() -> Dir -%% lib_dir(Application) -> Dir | {error, bad_name} -%% priv_dir(Application) -> Dir | {error, bad_name} -%% stick_dir(Dir) -> ok | error -%% unstick_dir(Dir) -> ok | error -%% stick_mod(Module) -> true -%% unstick_mod(Module) -> true -%% is_sticky(Module) -> boolean() -%% which(Module) -> Filename | loaded_ret_atoms() | non_existing -%% set_primary_archive((FileName, Bin, FileInfo) -> ok | {error, Reason} -%% clash() -> ok prints out number of clashes - %%---------------------------------------------------------------------------- %% Some types for basic exported functions of this module %%---------------------------------------------------------------------------- @@ -125,6 +85,39 @@ -type loaded_ret_atoms() :: 'cover_compiled' | 'preloaded'. -type loaded_filename() :: (Filename :: file:filename()) | loaded_ret_atoms(). +%%% BIFs + +-export([get_chunk/2, is_module_native/1, make_stub_module/3, module_md5/1]). + +-spec get_chunk(Bin, Chunk) -> + binary() | undefined when + Bin :: binary(), + Chunk :: string(). + +get_chunk(_, _) -> + erlang:nif_error(undef). + +-spec is_module_native(Module) -> true | false | undefined when + Module :: module(). + +is_module_native(_) -> + erlang:nif_error(undef). + +-spec make_stub_module(Module, Beam, Info) -> Module when + Module :: module(), + Beam :: binary(), + Info :: {list(), list()}. + +make_stub_module(_, _, _) -> + erlang:nif_error(undef). + +-spec module_md5(binary()) -> binary() | undefined. + +module_md5(_) -> + erlang:nif_error(undef). + +%%% End of BIFs + %%---------------------------------------------------------------------------- %% User interface %%---------------------------------------------------------------------------- diff --git a/lib/kernel/src/erl_ddll.erl b/lib/kernel/src/erl_ddll.erl index 646cac99c5..f967fcc2ef 100644 --- a/lib/kernel/src/erl_ddll.erl +++ b/lib/kernel/src/erl_ddll.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2011. All Rights Reserved. +%% Copyright Ericsson AB 1997-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -30,9 +30,99 @@ %%---------------------------------------------------------------------------- -type path() :: string() | atom(). --type driver() :: string() | atom(). +-type driver() :: iolist() | atom(). %%---------------------------------------------------------------------------- +%%% BIFs + +-export([demonitor/1, info/2, format_error_int/1, monitor/2, + try_load/3, try_unload/2, loaded_drivers/0]). + +-spec demonitor(MonitorRef) -> ok when + MonitorRef :: reference(). + +demonitor(_) -> + erlang:nif_error(undef). + +-spec info(Name, Tag) -> Value when + Name :: driver(), + Tag :: processes | driver_options | port_count | linked_in_driver + | permanent | awaiting_load | awaiting_unload, + Value :: term(). + +info(_, _) -> + erlang:nif_error(undef). + +-spec format_error_int(ErrSpec) -> string() when + ErrSpec :: inconsisten | linked_in_driver | permanent + | not_loaded | not_loaded_by_this_process | not_pending + | already_loaded | unloading. + +format_error_int(_) -> + erlang:nif_error(undef). + +-spec monitor(Tag, Item) -> MonitorRef when + Tag :: driver, + Item :: {Name, When}, + Name :: driver(), + When :: loaded | unloaded | unloaded_only, + MonitorRef :: reference(). + +monitor(_, _) -> + erlang:nif_error(undef). + +-spec try_load(Path, Name, OptionList) -> + {ok,Status} | + {ok, PendingStatus, Ref} | + {error, ErrorDesc} when + Path :: path(), + Name :: driver(), + OptionList :: [Option], + Option :: {driver_options, DriverOptionList} + | {monitor, MonitorOption} + | {reload, ReloadOption}, + DriverOptionList :: [DriverOption], + DriverOption :: kill_ports, + MonitorOption :: pending_driver | pending, + ReloadOption :: pending_driver | pending, + Status :: loaded | already_loaded | PendingStatus, + PendingStatus :: pending_driver | pending_process, + Ref :: reference(), + ErrorDesc :: ErrorAtom | OpaqueError, + ErrorAtom :: linked_in_driver | inconsistent | permanent + | not_loaded_by_this_process | not_loaded + | pending_reload | pending_process, + OpaqueError :: term(). + +try_load(_, _, _) -> + erlang:nif_error(undef). + +-spec try_unload(Name, OptionList) -> + {ok, Status} | + {ok, PendingStatus, Ref} | + {error, ErrorAtom} when + Name :: driver(), + OptionList :: [Option], + Option :: {monitor, MonitorOption} | kill_ports, + MonitorOption :: pending_driver | pending, + Status :: unloaded | PendingStatus, + PendingStatus :: pending_driver | pending_process, + Ref :: reference(), + ErrorAtom :: linked_in_driver | not_loaded | + not_loaded_by_this_process | permanent. + +try_unload(_, _) -> + erlang:nif_error(undef). + +-spec loaded_drivers() -> {ok, Drivers} when + Drivers :: [Driver], + Driver :: string(). + +loaded_drivers() -> + erlang:nif_error(undef). + +%%% End of BIFs + -spec start() -> {'error', {'already_started', 'undefined'}}. diff --git a/lib/kernel/src/error_logger.erl b/lib/kernel/src/error_logger.erl index f94cca000f..92c1eb80dc 100644 --- a/lib/kernel/src/error_logger.erl +++ b/lib/kernel/src/error_logger.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2011. All Rights Reserved. +%% Copyright Ericsson AB 1996-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -42,6 +42,18 @@ -type state() :: {non_neg_integer(), non_neg_integer(), [term()]}. +%%% BIF + +-export([warning_map/0]). + +-spec warning_map() -> Tag when + Tag :: error | warning | info. + +warning_map() -> + erlang:nif_error(undef). + +%%% End of BIF + %%----------------------------------------------------------------- -spec start() -> {'ok', pid()} | {'error', any()}. diff --git a/lib/kernel/src/erts_debug.erl b/lib/kernel/src/erts_debug.erl index 7d6a5ade94..b3d54ddc1d 100644 --- a/lib/kernel/src/erts_debug.erl +++ b/lib/kernel/src/erts_debug.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2009. All Rights Reserved. +%% Copyright Ericsson AB 1999-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -28,6 +28,135 @@ %% same/2 %% flat_size/1 +%%% BIFs + +-export([breakpoint/2, disassemble/1, display/1, dist_ext_to_term/2, + dump_monitors/1, dump_links/1, flat_size/1, + get_internal_state/1, instructions/0, lock_counters/1, + same/2, set_internal_state/2]). + +-spec breakpoint(MFA, Flag) -> non_neg_integer() when + MFA :: {Module :: module(), + Function :: atom(), + Arity :: arity() | '_'}, + Flag :: boolean(). + +breakpoint(_, _) -> + erlang:nif_error(undef). + +-spec disassemble(What) -> false | undef | Result when + What :: MFA | Address, + Result :: {Address, Code, MFA}, + MFA :: mfa(), + Address :: non_neg_integer(), + Code :: binary(). + +disassemble(_) -> + erlang:nif_error(undef). + +-spec display(Term) -> string() when + Term :: term(). + +display(_) -> + erlang:nif_error(undef). + +-spec dist_ext_to_term(Tuple, Binary) -> term() when + Tuple :: tuple(), + Binary :: binary(). + +dist_ext_to_term(_, _) -> + erlang:nif_error(undef). + +-spec dump_monitors(Id) -> true when + Id :: pid() | atom(). + +dump_monitors(_) -> + erlang:nif_error(undef). + +-spec dump_links(Id) -> true when + Id :: pid() | port() | atom(). + +dump_links(_) -> + erlang:nif_error(undef). + +-spec flat_size(Term) -> non_neg_integer() when + Term :: term(). + +flat_size(_) -> + erlang:nif_error(undef). + +-spec get_internal_state(W) -> term() when + W :: reds_left | node_and_dist_references | monitoring_nodes + | next_pid | 'DbTable_words' | check_io_debug + | process_info_args | processes | processes_bif_info + | max_atom_out_cache_index | nbalance | available_internal_state + | force_heap_frags | memory + | {process_status, pid()} + | {link_list, pid() | port() | node()} + | {monitor_list, pid() | node()} + | {channel_number, non_neg_integer()} + | {have_pending_exit, pid() | port() | atom()} + | {binary_info, binary()} + | {term_to_binary_no_funs, term()} + | {dist_port, port()} + | {atom_out_cache_index, atom()} + | {fake_scheduler_bindings, + default_bind | spread | processor_spread | thread_spread + | thread_no_node_processor_spread | no_node_processor_spread + | no_node_thread_spread | no_spread | unbound} + | {reader_groups_map, non_neg_integer()}. + +get_internal_state(_) -> + erlang:nif_error(undef). + +-spec instructions() -> [string()]. + +instructions() -> + erlang:nif_error(undef). + +-spec lock_counters(info) -> term(); + (clear) -> ok; + ({copy_save, boolean()}) -> boolean(); + ({process_locks, boolean()}) -> boolean(). + +lock_counters(_) -> + erlang:nif_error(undef). + +-spec same(Term1, Term2) -> boolean() when + Term1 :: term(), + Term2 :: term(). + +same(_, _) -> + erlang:nif_error(undef). + +-spec set_internal_state(available_internal_state, boolean()) -> boolean(); + (reds_left, non_neg_integer()) -> true; + (block, non_neg_integer()) -> true; + (sleep, non_neg_integer()) -> true; + (block_scheduler, non_neg_integer()) -> true; + (next_pid, non_neg_integer()) -> false | integer(); + (force_gc, pid() | atom()) -> boolean(); + (send_fake_exit_signal, {pid() | port(), pid(), term()}) -> dead | message | unaffected | exit; + (colliding_names, {atom(), non_neg_integer()}) -> + [atom()]; + (binary_loop_limit, default) -> -1; + (binary_loop_limit, non_neg_integer()) -> non_neg_integer(); + (re_loop_limit, default) -> -1; + (re_loop_limit, non_neg_integer()) -> non_neg_integer(); + (unicode_loop_limit, default) -> -1; + (unicode_loop_limit, non_neg_integer()) -> non_neg_integer(); + (hipe_test_reschedule_suspend, term()) -> nil(); + (hipe_test_reschedule_resume, pid() | port()) -> boolean(); + (test_long_gc_sleep, non_neg_integer()) -> true; + (kill_dist_connection, port()) -> boolean(); + (not_running_optimization, boolean()) -> boolean(); + (wait, deallocations) -> ok. + +set_internal_state(_, _) -> + erlang:nif_error(undef). + +%%% End of BIFs + %% size(Term) %% Returns the size of Term in actual heap words. Shared subterms are %% counted once. Example: If A = [a,b], B =[A,A] then size(B) returns 8, diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl index 4028dd4f0b..101a830ad3 100644 --- a/lib/kernel/src/file.erl +++ b/lib/kernel/src/file.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2011. All Rights Reserved. +%% Copyright Ericsson AB 1996-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -111,6 +111,24 @@ -type sendfile_option() :: {chunk_size, non_neg_integer()}. -type file_info_option() :: {'time', 'local'} | {'time', 'universal'} | {'time', 'posix'}. +%%% BIFs + +-export([file_info/1, native_name_encoding/0]). + +-spec file_info(Filename) -> {ok, FileInfo} | {error, Reason} when + Filename :: name(), + FileInfo :: file_info(), + Reason :: posix() | badarg. + +file_info(_) -> + erlang:nif_error(undef). + +-spec native_name_encoding() -> latin1 | utf8. + +native_name_encoding() -> + erlang:nif_error(undef). + +%%% End of BIFs %%%----------------------------------------------------------------- diff --git a/lib/kernel/src/net_kernel.erl b/lib/kernel/src/net_kernel.erl index 9e3d730cee..0d59e7af67 100644 --- a/lib/kernel/src/net_kernel.erl +++ b/lib/kernel/src/net_kernel.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2011. All Rights Reserved. +%% Copyright Ericsson AB 1996-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -142,6 +142,17 @@ -include("net_address.hrl"). +%%% BIF + +-export([dflag_unicode_io/1]). + +-spec dflag_unicode_io(pid()) -> boolean(). + +dflag_unicode_io(_) -> + erlang:nif_error(undef). + +%%% End of BIF + %% Interface functions kernel_apply(M,F,A) -> request({apply,M,F,A}). diff --git a/lib/kernel/src/os.erl b/lib/kernel/src/os.erl index f6769df585..b986f3a61e 100644 --- a/lib/kernel/src/os.erl +++ b/lib/kernel/src/os.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2011. All Rights Reserved. +%% Copyright Ericsson AB 1997-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -24,6 +24,42 @@ -include("file.hrl"). +%%% BIFs + +-export([getenv/0, getenv/1, getpid/0, putenv/2, timestamp/0]). + +-spec getenv() -> [string()]. + +getenv() -> erlang:nif_error(undef). + +-spec getenv(VarName) -> Value | false when + VarName :: string(), + Value :: string(). + +getenv(_) -> + erlang:nif_error(undef). + +-spec getpid() -> Value when + Value :: string(). + +getpid() -> + erlang:nif_error(undef). + +-spec putenv(VarName, Value) -> true when + VarName :: string(), + Value :: string(). + +putenv(_, _) -> + erlang:nif_error(undef). + +-spec timestamp() -> Timestamp when + Timestamp :: erlang:timestamp(). + +timestamp() -> + erlang:nif_error(undef). + +%%% End of BIFs + -spec type() -> vxworks | {Osfamily, Osname} when Osfamily :: unix | win32, Osname :: atom(). diff --git a/lib/stdlib/doc/src/binary.xml b/lib/stdlib/doc/src/binary.xml index 88ce77e0d0..06cfad0b0b 100644 --- a/lib/stdlib/doc/src/binary.xml +++ b/lib/stdlib/doc/src/binary.xml @@ -5,7 +5,7 @@

2009 - 2011 + 2012 Ericsson AB, All Rights Reserved @@ -77,41 +77,30 @@ - at(Subject, Pos) -> byte() + Returns the byte at a specific position in a binary - - Subject = binary() - Pos = integer() >= 0 - -

Returns the byte at position Pos (zero-based) in the binary - Subject as an integer. If Pos >= byte_size(Subject), +

Returns the byte at position Pos (zero-based) in the binary + Subject as an integer. If Pos >= byte_size(Subject), a badarg exception is raised.

- bin_to_list(Subject) -> [byte()] + Convert a binary to a list of integers - - Subject = binary() - -

The same as bin_to_list(Subject,{0,byte_size(Subject)}).

+

The same as bin_to_list(Subject,{0,byte_size(Subject)}).

- bin_to_list(Subject, PosLen) -> [byte()] + Convert a binary to a list of integers - - Subject = binary() - PosLen = part() - -

Converts Subject to a list of byte()s, each representing +

Converts Subject to a list of byte()s, each representing the value of one byte. The part() denotes which part of the binary() to convert. Example:

@@ -120,27 +109,19 @@ "rla" %% or [114,108,97] in list notation. -

If PosLen in any way references outside the binary, a badarg exception is raised.

+

If PosLen in any way references outside the binary, a badarg exception is raised.

- bin_to_list(Subject, Pos, Len) -> [byte()] + Convert a binary to a list of integers - - Subject = binary() - Pos = integer() >= 0 - Len = integer() >= 0 - -

The same as bin_to_list(Subject,{Pos,Len}).

+

The same as bin_to_list(Subject,{Pos,Len}).

- compile_pattern(Pattern) -> cp() + Pre-compiles a binary search pattern - - Pattern = binary() | [ binary() ] -

Builds an internal structure representing a compilation of a @@ -155,7 +136,7 @@

When a list of binaries is given, it denotes a set of alternative binaries to search for. I.e if [<<"functional">>,<<"programming">>] - is given as Pattern, this + is given as Pattern, this means "either <<"functional">> or <<"programming">>". The pattern is a set of alternatives; when only a single binary is given, the set has @@ -163,32 +144,25 @@

The list of binaries used for search alternatives shall be flat and proper.

-

If Pattern is not a binary or a flat proper list of binaries with length > 0, +

If Pattern is not a binary or a flat proper list of binaries with length > 0, a badarg exception will be raised.

- copy(Subject) -> binary() + Creates a duplicate of a binary - - Subject = binary() - -

The same as copy(Subject, 1).

+

The same as copy(Subject, 1).

- copy(Subject,N) -> binary() + Duplicates a binary N times and creates a new - - Subject = binary() - N = integer() >= 0 - -

Creates a binary with the content of Subject duplicated N times.

+

Creates a binary with the content of Subject duplicated N times.

-

This function will always create a new binary, even if N = +

This function will always create a new binary, even if N = 1. By using copy/1 on a binary referencing a larger binary, one might free up the larger binary for garbage collection.

@@ -201,32 +175,23 @@ large binaries are no longer used in any process, deliberate copying might be a good idea.

-

If N < 0, a badarg exception is raised.

+

If N < 0, a badarg exception is raised.

- decode_unsigned(Subject) -> Unsigned + Decode a whole binary into an integer of arbitrary size - - Subject = binary() - Unsigned = integer() >= 0 - -

The same as decode_unsigned(Subject,big).

+

The same as decode_unsigned(Subject, big).

- decode_unsigned(Subject, Endianess) -> Unsigned + Decode a whole binary into an integer of arbitrary size - - Subject = binary() - Endianess = big | little - Unsigned = integer() >= 0 -

Converts the binary digit representation, in big or little - endian, of a positive integer in Subject to an Erlang integer().

+ endian, of a positive integer in Subject to an Erlang integer().

Example:

@@ -237,22 +202,15 @@
- encode_unsigned(Unsigned) -> binary() + Encodes an unsigned integer into the minimal binary - - Unsigned = integer() >= 0 - -

The same as encode_unsigned(Unsigned,big).

+

The same as encode_unsigned(Unsigned, big).

- encode_unsigned(Unsigned,Endianess) -> binary() + Encodes an unsigned integer into the minimal binary - - Unsigned = integer() >= 0 - Endianess = big | little -

Converts a positive integer to the smallest possible @@ -268,51 +226,39 @@ - first(Subject) -> byte() + Returns the first byte of a binary - - Subject = binary() - -

Returns the first byte of the binary Subject as an integer. If the - size of Subject is zero, a badarg exception is raised.

+

Returns the first byte of the binary Subject as an integer. If the + size of Subject is zero, a badarg exception is raised.

- last(Subject) -> byte() + Returns the last byte of a binary - - Subject = binary() - -

Returns the last byte of the binary Subject as an integer. If the - size of Subject is zero, a badarg exception is raised.

+

Returns the last byte of the binary Subject as an integer. If the + size of Subject is zero, a badarg exception is raised.

- list_to_bin(ByteList) -> binary() + Convert a list of integers and binaries to a binary - - ByteList = iodata() (see module erlang) -

Works exactly as erlang:list_to_binary/1, added for completeness.

- longest_common_prefix(Binaries) -> integer() >= 0 + Returns length of longest common prefix for a set of binaries - - Binaries = [ binary() ] -

Returns the length of the longest common prefix of the - binaries in the list Binaries. Example:

+ binaries in the list Binaries. Example:

1> binary:longest_common_prefix([<<"erlang">>,<<"ergonomy">>]). @@ -321,19 +267,16 @@ 0 -

If Binaries is not a flat list of binaries, a badarg exception is raised.

+

If Binaries is not a flat list of binaries, a badarg exception is raised.

- longest_common_suffix(Binaries) -> integer() >= 0 + Returns length of longest common suffix for a set of binaries - - Binaries = [ binary() ] -

Returns the length of the longest common suffix of the - binaries in the list Binaries. Example:

+ binaries in the list Binaries. Example:

1> binary:longest_common_suffix([<<"erlang">>,<<"fang">>]). @@ -347,35 +290,24 @@
- match(Subject, Pattern) -> Found | nomatch + Searches for the first match of a pattern in a binary - - Subject = binary() - Pattern = binary() | [ binary() ] | cp() - Found = part() - -

The same as match(Subject, Pattern, []).

+

The same as match(Subject, Pattern, []).

- match(Subject,Pattern,Options) -> Found | nomatch + + Searches for the first match of a pattern in a binary - - Subject = binary() - Pattern = binary() | [ binary() ] | cp() - Found = part() - Options = [ Option ] - Option = {scope, part()} - -

Searches for the first occurrence of Pattern in Subject and +

Searches for the first occurrence of Pattern in Subject and returns the position and length.

-

The function will return {Pos,Length} for the binary - in Pattern starting at the lowest position in - Subject, Example:

+

The function will return {Pos, Length} for the binary + in Pattern starting at the lowest position in + Subject, Example:

1> binary:match(<<"abcde">>, [<<"bcde">>,<<"cd">>],[]). @@ -391,16 +323,16 @@

Summary of the options:

- {scope, {Start, Length}} + {scope, {Start, Length}}

Only the given part is searched. Return values still have - offsets from the beginning of Subject. A negative Length is - allowed as described in the TYPES section of this manual.

+ offsets from the beginning of Subject. A negative Length is + allowed as described in the DATA TYPES section of this manual.

If none of the strings in - Pattern is found, the atom nomatch is returned.

+ Pattern is found, the atom nomatch is returned.

-

For a description of Pattern, see +

For a description of Pattern, see compile_pattern/1.

If {scope, {Start,Length}} is given in the options @@ -412,32 +344,21 @@ - matches(Subject, Pattern) -> Found + Searches for all matches of a pattern in a binary - - Subject = binary() - Pattern = binary() | [ binary() ] | cp() - Found = [ part() ] | [] - -

The same as matches(Subject, Pattern, []).

+

The same as matches(Subject, Pattern, []).

- matches(Subject,Pattern,Options) -> Found + + Searches for all matches of a pattern in a binary - - Subject = binary() - Pattern = binary() | [ binary() ] | cp() - Found = [ part() ] | [] - Options = [ Option ] - Option = {scope, part()} - -

Works like match, but the Subject is searched until +

Works like match/2, but the Subject is searched until exhausted and a list of all non-overlapping parts matching - Pattern is returned (in order).

+ Pattern is returned (in order).

The first and longest match is preferred to a shorter, which is illustrated by the following example:

@@ -458,26 +379,22 @@

If none of the strings in pattern is found, an empty list is returned.

-

For a description of Pattern, see compile_pattern/1 and for a +

For a description of Pattern, see compile_pattern/1 and for a description of available options, see match/3.

-

If {scope, {Start,Length}} is given in the options such that - Start is larger than the size of Subject, Start + Length is - less than zero or Start + Length is larger than the size of - Subject, a badarg exception is raised.

+

If {scope, {Start,Length}} is given in the options such that + Start is larger than the size of Subject, Start + Length is + less than zero or Start + Length is larger than the size of + Subject, a badarg exception is raised.

- part(Subject, PosLen) -> binary() + Extracts a part of a binary - - Subject = binary() - PosLen = part() - -

Extracts the part of the binary Subject described by PosLen.

+

Extracts the part of the binary Subject described by PosLen.

Negative length can be used to extract bytes at the end of a binary:

@@ -494,25 +411,20 @@ binary_part/3. Those BIFs are allowed in guard tests.

-

If PosLen in any way references outside the binary, a badarg exception +

If PosLen in any way references outside the binary, a badarg exception is raised.

- part(Subject, Pos, Len) -> binary() + Extracts a part of a binary - - Subject = binary() - Pos = integer() >= 0 - Len = integer() >= 0 - -

The same as part(Subject, {Pos, Len}).

+

The same as part(Subject, {Pos, Len}).

- referenced_byte_size(binary()) -> integer() >= 0 + Determines the size of the actual binary pointed out by a sub-binary diff --git a/lib/stdlib/doc/src/ets.xml b/lib/stdlib/doc/src/ets.xml index efd9514db6..27608e9176 100644 --- a/lib/stdlib/doc/src/ets.xml +++ b/lib/stdlib/doc/src/ets.xml @@ -4,7 +4,7 @@
- 19962011 + 19962012 Ericsson AB. All Rights Reserved. @@ -127,12 +127,18 @@ + + + continuation()

Opaque continuation used by - select/1 and - select/3.

+ select/1,3, + select_reverse/1,3, + match/1,3, and + match_object/1,3.

@@ -149,14 +155,14 @@

A table identifier, as returned by new/2.

+ + +
- all() -> [Tab] + Return a list of all ETS tables. - - Tab = tid() | atom() -

Returns a list of all tables at the node. Named tables are given by their names, unnamed tables are given by their @@ -164,48 +170,34 @@ - delete(Tab) -> true + Delete an entire ETS table. - - Tab = tid() | atom() - -

Deletes the entire table Tab.

+

Deletes the entire table Tab.

- delete(Tab, Key) -> true + Delete all objects with a given key from an ETS table. - - Tab = tid() | atom() - Key = term() - -

Deletes all objects with the key Key from the table - Tab.

+

Deletes all objects with the key Key from the table + Tab.

- delete_all_objects(Tab) -> true + Delete all objects in an ETS table. - - Tab = tid() | atom() - -

Delete all objects in the ETS table Tab. +

Delete all objects in the ETS table Tab. The operation is guaranteed to be atomic and isolated.

- delete_object(Tab,Object) -> true + Deletes a specific from an ETS table. - - Tab = tid() | atom() - Object = tuple() - -

Delete the exact object Object from the ETS table, +

Delete the exact object Object from the ETS table, leaving objects with the same key but other differences (useful for type bag). In a duplicate_bag, all instances of the object will be deleted.

@@ -257,14 +249,10 @@
- first(Tab) -> Key | '$end_of_table' + Return the first key in an ETS table. - - Tab = tid() | atom() - Key = term() - -

Returns the first key Key in the table Tab. +

Returns the first key Key in the table Tab. If the table is of the ordered_set type, the first key in Erlang term order will be returned. If the table is of any other type, the first key according to the table's internal @@ -336,7 +324,7 @@ the source file.

The fun is very restricted, it can take only a single parameter (the object to match): a sole variable or a - tuple. It needs to use the is_XXX guard tests. + tuple. It needs to use the is_ guard tests. Language constructs that have no representation in a match_spec (like if, case, receive etc) are not allowed.

@@ -386,19 +374,14 @@ Error: fun containing local Erlang function calls
- give_away(Tab, Pid, GiftData) -> true + Change owner of a table. - - Tab = tid() | atom() - Pid = pid() - GiftData = term() - -

Make process Pid the new owner of table Tab. +

Make process Pid the new owner of table Tab. If successful, the message - {'ETS-TRANSFER',Tab,FromPid,GiftData} will be sent + {'ETS-TRANSFER',Tab,FromPid,GiftData} will be sent to the new owner.

-

The process Pid must be alive, local and not already the +

The process Pid must be alive, local and not already the owner of the table. The calling process must be the table owner.

Note that give_away does not at all affect the heir option of the table. A table @@ -421,81 +404,72 @@ Error: fun containing local Erlang function calls - info(Tab) -> [{Item, Value}] | undefined + Return information about an ETS table. - - Tab = tid() | atom() - Item = atom(), see below - Value = term(), see below - -

Returns information about the table Tab as a list of - {Item, Value} tuples. If Tab has the correct type +

Returns information about the table Tab as a list of + tuples. If Tab has the correct type for a table identifier, but does not refer to an existing ETS - table, undefined is returned. If Tab is not of the + table, undefined is returned. If Tab is not of the correct type, this function fails with reason badarg.

- Item=memory, Value=integer()

- - The number of words allocated to the table.
- Item=owner, Value=pid()

+ {compressed, boolean()}

- The pid of the owner of the table.
- Item=heir, Value=pid()|none

+ Indicates if the table is compressed or not.
+ {heir, pid() | none}

The pid of the heir of the table, or none if no heir is set.
- Item=name, Value=atom()

+ {keypos, integer() >= 1}

- The name of the table.
- Item=size, Value=integer()

+ The key position.
+ {memory, integer() >= 0

- The number of objects inserted in the table.
- Item=node, Value=atom()

+ The number of words allocated to the table.
+ {name, atom()}

- The node where the table is stored. This field is no longer - meaningful as tables cannot be accessed from other nodes.
- Item=named_table, Value=true|false

+ The name of the table.
+ {named_table, boolean()}

Indicates if the table is named or not.
- Item=type, Value=set|ordered_set|bag|duplicate_bag

+ {node, node()}

- The table type.
- Item=keypos, Value=integer()

+ The node where the table is stored. This field is no longer + meaningful as tables cannot be accessed from other nodes.
+ {owner, pid()}

- The key position.
- Item=protection, Value=public|protected|private

+ The pid of the owner of the table.
+ {protection, access()}

The table access rights.
- Item=compressed, Value=true|false

+ {size, integer() >= 0

- Indicates if the table is compressed or not.
+ The number of objects inserted in the table.
+ {type, type()}

+ + The table type.
- info(Tab, Item) -> Value | undefined + Return the information associated with given item for an ETS table. - - Tab = tid() | atom() - Item, Value - see below -

Returns the information associated with Item for - the table Tab, or returns undefined if Tab + the table Tab, or returns undefined if Tab does not refer an existing ETS table. - If Tab is not of the correct type, or if Item is not + If Tab is not of the correct type, or if Item is not one of the allowed values, this function fails with reason badarg.

In R11B and earlier, this function would not fail but return undefined for invalid values for Item.

-

In addition to the {Item,Value} +

In addition to the {Item,Value} pairs defined for info/1, the following items are allowed:

- Item=fixed, Value=true|false

+ Item=fixed, Value=boolean()

Indicates if the table is fixed by any process or not.
@@ -547,15 +521,11 @@ Error: fun containing local Erlang function calls
- insert(Tab, ObjectOrObjects) -> true + Insert an object into an ETS table. - - Tab = tid() | atom() - ObjectOrObjects = tuple() | [tuple()] -

Inserts the object or all of the objects in the list - ObjectOrObjects into the table Tab. + ObjectOrObjects into the table Tab. If the table is a set and the key of the inserted objects matches the key of any object in the table, the old object will be replaced. If the table is an @@ -572,19 +542,15 @@ Error: fun containing local Erlang function calls - insert_new(Tab, ObjectOrObjects) -> boolean() + Insert an object into an ETS table if the key is not already present. - - Tab = tid() | atom() - ObjectOrObjects = tuple() | [tuple()] -

This function works exactly like insert/2, with the exception that instead of overwriting objects with the same key (in the case of set or ordered_set) or adding more objects with keys already existing in the table (in the case of bag and duplicate_bag), it - simply returns false. If ObjectOrObjects is a + simply returns false. If ObjectOrObjects is a list, the function checks every key prior to inserting anything. Nothing will be inserted if not all keys present in the list are absent from the @@ -593,11 +559,8 @@ Error: fun containing local Erlang function calls - is_compiled_ms(Term) -> boolean() + Checks if an Erlang term is the result of ets:match_spec_compile - - Term = term() -

This function is used to check if a term is a valid compiled match_spec. @@ -626,14 +589,10 @@ ets:is_compiled_ms(Broken). - last(Tab) -> Key | '$end_of_table' + Return the last key in an ETS table of typeordered_set. - - Tab = tid() | atom() - Key = term() - -

Returns the last key Key according to Erlang term +

Returns the last key Key according to Erlang term order in the table Tab of the ordered_set type. If the table is of any other type, the function is synonymous to first/2. If the table is empty, @@ -642,16 +601,11 @@ ets:is_compiled_ms(Broken). - lookup(Tab, Key) -> [Object] + Return all objects with a given key in an ETS table. - - Tab = tid() | atom() - Key = term() - Object = tuple() - -

Returns a list of all objects with the key Key in - the table Tab.

+

Returns a list of all objects with the key Key in + the table Tab.

In the case of set, bag and duplicate_bag, an object is returned only if the given key matches the key of the object in the table. If the table is an @@ -681,22 +635,16 @@ ets:is_compiled_ms(Broken). - lookup_element(Tab, Key, Pos) -> Elem + Return the Pos:th element of all objects with a given key in an ETS table. - - Tab = tid() | atom() - Key = term() - Pos = integer() - Elem = term() | [term()] - -

If the table Tab is of type set or - ordered_set, the function returns the Pos:th - element of the object with the key Key.

+

If the table Tab is of type set or + ordered_set, the function returns the Pos:th + element of the object with the key Key.

If the table is of type bag or duplicate_bag, - the functions returns a list with the Pos:th element of - every object with the key Key.

-

If no object with the key Key exists, the function + the functions returns a list with the Pos:th element of + every object with the key Key.

+

If no object with the key Key exists, the function will exit with reason badarg.

The difference between set, bag and duplicate_bag on one hand, and ordered_set on @@ -708,16 +656,11 @@ ets:is_compiled_ms(Broken). - match(Tab, Pattern) -> [Match] + Match the objects in an ETS table against a pattern. - - Tab = tid() | atom() - Pattern = tuple() - Match = [term()] - -

Matches the objects in the table Tab against the - pattern Pattern.

+

Matches the objects in the table Tab against the + pattern Pattern.

A pattern is a term that may contain:

bound parts (Erlang terms), @@ -744,18 +687,12 @@ ets:is_compiled_ms(Broken). - match(Tab, Pattern, Limit) -> {[Match],Continuation} | '$end_of_table' + Match the objects in an ETS table against a pattern and returns part of the answers. - - Tab = tid() | atom() - Pattern = tuple() - Match = [term()] - Continuation = term() -

Works like ets:match/2 but only returns a limited - (Limit) number of matching objects. The - Continuation term can then be used in subsequent calls + (Limit) number of matching objects. The + Continuation term can then be used in subsequent calls to ets:match/1 to get the next chunk of matching objects. This is a space efficient way to work on objects in a table which is still faster than traversing the table object @@ -764,16 +701,12 @@ ets:is_compiled_ms(Broken). - match(Continuation) -> {[Match],Continuation} | '$end_of_table' + Continues matching objects in an ETS table. - - Match = [term()] - Continuation = term() -

Continues a match started with ets:match/3. The next chunk of the size given in the initial ets:match/3 - call is returned together with a new Continuation + call is returned together with a new Continuation that can be used in subsequent calls to this function.

'$end_of_table' is returned when there are no more objects in the table.

@@ -789,15 +722,11 @@ ets:is_compiled_ms(Broken).
- match_object(Tab, Pattern) -> [Object] + Match the objects in an ETS table against a pattern. - - Tab = tid() | atom() - Pattern = Object = tuple() - -

Matches the objects in the table Tab against the - pattern Pattern. See match/2 for a description +

Matches the objects in the table Tab against the + pattern Pattern. See match/2 for a description of patterns. The function returns a list of all objects which match the pattern.

If the key is specified in the pattern, the match is very @@ -809,18 +738,12 @@ ets:is_compiled_ms(Broken). - match_object(Tab, Pattern, Limit) -> {[Match],Continuation} | '$end_of_table' + Match the objects in an ETS table against a pattern and returns part of the answers. - - Tab = tid() | atom() - Pattern = tuple() - Match = [term()] - Continuation = term() -

Works like ets:match_object/2 but only returns a - limited (Limit) number of matching objects. The - Continuation term can then be used in subsequent calls + limited (Limit) number of matching objects. The + Continuation term can then be used in subsequent calls to ets:match_object/1 to get the next chunk of matching objects. This is a space efficient way to work on objects in a table which is still faster than traversing the table object @@ -829,29 +752,23 @@ ets:is_compiled_ms(Broken). - match_object(Continuation) -> {[Match],Continuation} | '$end_of_table' + Continues matching objects in an ETS table. - - Match = [term()] - Continuation = term() -

Continues a match started with ets:match_object/3. The next chunk of the size given in the initial ets:match_object/3 call is returned together with a - new Continuation that can be used in subsequent calls + new Continuation that can be used in subsequent calls to this function.

'$end_of_table' is returned when there are no more objects in the table.

- match_spec_compile(MatchSpec) -> CompiledMatchSpec + + + A compiled match specification. Compiles a match specification into its internal representation - - MatchSpec = match_spec() - CompiledMatchSpec = comp_match_spec() -

This function transforms a match_spec into an @@ -863,7 +780,7 @@ ets:is_compiled_ms(Broken). valid compiled match_spec, nor can it be stored on disk). The validity of a compiled match_spec can be checked using ets:is_compiled_ms/1.

-

If the term MatchSpec can not be compiled (does not +

If the term MatchSpec can not be compiled (does not represent a valid match_spec), a badarg fault is thrown.

@@ -873,25 +790,23 @@ ets:is_compiled_ms(Broken).
- match_spec_run(List,CompiledMatchSpec) -> list() + + + A compiled match specification. Performs matching, using a compiled match_spec, on a list of tuples - - List = [ tuple() ] - CompiledMatchSpec = comp_match_spec() -

This function executes the matching specified in a compiled match_spec on - a list of tuples. The CompiledMatchSpec term should be + a list of tuples. The CompiledMatchSpec term should be the result of a call to ets:match_spec_compile/1 and is hence the internal representation of the match_spec one wants to use.

-

The matching will be executed on each element in List +

The matching will be executed on each element in List and the function returns a list containing all results. If an - element in List does not match, nothing is returned + element in List does not match, nothing is returned for that element. The length of the result list is therefore equal or less than the the length of the parameter - List. The two calls in the following example will give + List. The two calls in the following example will give the same result (but certainly not the same execution time...):

@@ -910,37 +825,23 @@ ets:select(Table,MatchSpec),
- member(Tab, Key) -> true | false + Tests for occurrence of a key in an ETS table - - Tab = tid() | atom() - Key = term() -

Works like lookup/2, but does not return the objects. The function returns true if one or more elements in - the table has the key Key, false otherwise.

+ the table has the key Key, false otherwise.

- new(Name, Options) -> tid() | atom() + Create a new ETS table. - - Name = atom() - Options = [Option] -  Option = Type | Access | named_table | {keypos,Pos} | {heir,pid(),HeirData} | {heir,none} | Tweaks -   Type = set | ordered_set | bag | duplicate_bag -   Access = public | protected | private -   Tweaks = {write_concurrency,boolean()} | {read_concurrency,boolean()} | compressed -   Pos = integer() -   HeirData = term() -

Creates a new table and returns a table identifier which can be used in subsequent operations. The table identifier can be sent to other processes so that a table can be shared between different processes within a node.

-

The parameter Options is a list of atoms which +

The parameter Options is a list of atoms which specifies table type, access rights, key position and if the table is named or not. If one or more options are left out, the default values are used. This means that not specifying @@ -997,27 +898,27 @@ ets:select(Table,MatchSpec),

named_table - If this option is present, the name Name is + If this option is present, the name Name is associated with the table identifier. The name can then be used instead of the table identifier in subsequent operations.

-

{keypos,Pos} +

{keypos,Pos} Specfies which element in the stored tuples should be used as key. By default, it is the first element, i.e. - Pos=1. However, this is not always appropriate. In + Pos=1. However, this is not always appropriate. In particular, we do not want the first element to be the key if we want to store Erlang records in a table.

Note that any tuple stored in the table must have at - least Pos number of elements.

+ least Pos number of elements.

-

{heir,Pid,HeirData} | {heir,none}

+

{heir,Pid,HeirData} | {heir,none}

Set a process as heir. The heir will inherit the table if the owner terminates. The message - {'ETS-TRANSFER',tid(),FromPid,HeirData} will be sent to + {'ETS-TRANSFER',tid(),FromPid,HeirData} will be sent to the heir when that happens. The heir must be a local process. Default heir is none, which will destroy the table when the owner terminates.

@@ -1082,15 +983,11 @@ ets:select(Table,MatchSpec),
- next(Tab, Key1) -> Key2 | '$end_of_table' + Return the next key in an ETS table. - - Tab = tid() | atom() - Key1 = Key2 = term() - -

Returns the next key Key2, following the key - Key1 in the table Tab. If the table is of the +

Returns the next key Key2, following the key + Key1 in the table Tab. If the table is of the ordered_set type, the next key in Erlang term order is returned. If the table is of any other type, the next key according to the table's internal order is returned. If there @@ -1105,16 +1002,12 @@ ets:select(Table,MatchSpec), - prev(Tab, Key1) -> Key2 | '$end_of_table' + Return the previous key in an ETS table of typeordered_set. - - Tab = tid() | atom() - Key1 = Key2 = term() - -

Returns the previous key Key2, preceding the key - Key1 according the Erlang term order in the table - Tab of the ordered_set type. If the table is of +

Returns the previous key Key2, preceding the key + Key1 according the Erlang term order in the table + Tab of the ordered_set type. If the table is of any other type, the function is synonymous to next/2. If there is no previous key, '$end_of_table' is returned.

@@ -1122,14 +1015,11 @@ ets:select(Table,MatchSpec),
- rename(Tab, Name) -> Name + Rename a named ETS table. - - Tab = Name = atom() - -

Renames the named table Tab to the new name - Name. Afterwards, the old name can not be used to +

Renames the named table Tab to the new name + Name. Afterwards, the old name can not be used to access the table. Renaming an unnamed table has no effect.

@@ -1186,18 +1076,15 @@ ets:select(ets:repair_continuation(Broken,MS)). - safe_fixtable(Tab, true|false) -> true + Fix an ETS table for safe traversal. - - Tab = tid() | atom() -

Fixes a table of the set, bag or duplicate_bag table type for safe traversal.

A process fixes a table by calling - safe_fixtable(Tab,true). The table remains fixed until + safe_fixtable(Tab, true). The table remains fixed until the process releases it by calling - safe_fixtable(Tab,false), or until the process + safe_fixtable(Tab, false), or until the process terminates.

If several processes fix a table, the table will remain fixed until all processes have released it (or terminated). @@ -1242,15 +1129,10 @@ clean_all_with_value(Tab,X,Key) -> - select(Tab, MatchSpec) -> [Match] + Match the objects in an ETS table against a match_spec. - - Tab = tid() | atom() - Match = term() - MatchSpec = match_spec() - -

Matches the objects in the table Tab using a +

Matches the objects in the table Tab using a match_spec. This is a more general call than the ets:match/2 and ets:match_object/2 calls. In its simplest forms the @@ -1337,18 +1219,12 @@ is_integer(X), is_integer(Y), X + Y < 4711]]> - select(Tab, MatchSpec, Limit) -> {[Match],Continuation} | '$end_of_table' + Match the objects in an ETS table against a match_spec and returns part of the answers. - - Tab = tid() | atom() - Match = term() - MatchSpec = match_spec() - Continuation = term() -

Works like ets:select/2 but only returns a limited - (Limit) number of matching objects. The - Continuation term can then be used in subsequent calls + (Limit) number of matching objects. The + Continuation term can then be used in subsequent calls to ets:select/1 to get the next chunk of matching objects. This is a space efficient way to work on objects in a table which is still faster than traversing the table object @@ -1357,33 +1233,23 @@ is_integer(X), is_integer(Y), X + Y < 4711]]> - select(Continuation) -> {[Match],Continuation} | '$end_of_table' + Continue matching objects in an ETS table. - - Match = term() - Continuation = term() -

Continues a match started with ets:select/3. The next chunk of the size given in the initial ets:select/3 - call is returned together with a new Continuation + call is returned together with a new Continuation that can be used in subsequent calls to this function.

'$end_of_table' is returned when there are no more objects in the table.

- select_count(Tab, MatchSpec) -> NumMatched + Match the objects in an ETS table against a match_spec and returns the number of objects for which the match_spec returned 'true' - - Tab = tid() | atom() - Object = tuple() - MatchSpec = match_spec() - NumMatched = integer() - -

Matches the objects in the table Tab using a +

Matches the objects in the table Tab using a match_spec. If the match_spec returns true for an object, that object considered a match and is counted. For any other result from @@ -1396,16 +1262,10 @@ is_integer(X), is_integer(Y), X + Y < 4711]]> - select_delete(Tab, MatchSpec) -> NumDeleted + Match the objects in an ETS table against a match_spec and deletes objects where the match_spec returns 'true' - - Tab = tid() | atom() - Object = tuple() - MatchSpec = match_spec() - NumDeleted = integer() - -

Matches the objects in the table Tab using a +

Matches the objects in the table Tab using a match_spec. If the match_spec returns true for an object, that object is removed from the table. For any other result from the @@ -1422,13 +1282,8 @@ is_integer(X), is_integer(Y), X + Y < 4711]]> - select_reverse(Tab, MatchSpec) -> [Match] + Match the objects in an ETS table against a match_spec. - - Tab = tid() | atom() - Match = term() - MatchSpec = match_spec() -

Works like select/2, but returns the list in reverse @@ -1438,14 +1293,8 @@ is_integer(X), is_integer(Y), X + Y < 4711]]> - select_reverse(Tab, MatchSpec, Limit) -> {[Match],Continuation} | '$end_of_table' + Match the objects in an ETS table against a match_spec and returns part of the answers. - - Tab = tid() | atom() - Match = term() - MatchSpec = match_spec() - Continuation = term() -

Works like select/3, but for the ordered_set @@ -1456,18 +1305,14 @@ is_integer(X), is_integer(Y), X + Y < 4711]]>

Note that this is not equivalent to reversing the result list of a select/3 call, as the result list - is not only reversed, but also contains the last Limit + is not only reversed, but also contains the last Limit matching objects in the table, not the first.

- select_reverse(Continuation) -> {[Match],Continuation} | '$end_of_table' + Continue matching objects in an ETS table. - - Match = term() - Continuation = term() -

Continues a match started with @@ -1477,7 +1322,7 @@ is_integer(X), is_integer(Y), X + Y < 4711]]> returned list will also contain objects with keys in reverse order.

-

For all other table types, the behaviour is exatly that of select/1.

+

For all other table types, the behaviour is exactly that of select/1.

Example:

1> T = ets:new(x,[ordered_set]). @@ -1501,14 +1346,8 @@ is_integer(X), is_integer(Y), X + Y < 4711]]>
- setopts(Tab, Opts) -> true + Set table options. - - Tab = tid() | atom() - Opts = Opt | [Opt] - Opt = {heir,pid(),HeirData} | {heir,none} - HeirData = term() -

Set table options. The only option that currently is allowed to be set after the table has been created is @@ -1517,28 +1356,23 @@ is_integer(X), is_integer(Y), X + Y < 4711]]> - slot(Tab, I) -> [Object] | '$end_of_table' + Return all objects in a given slot of an ETS table. - - Tab = tid() | atom() - I = integer() - Object = tuple() -

This function is mostly for debugging purposes, Normally one should use first/next or last/prev instead.

-

Returns all objects in the I:th slot of the table - Tab. A table can be traversed by repeatedly calling - the function, starting with the first slot I=0 and +

Returns all objects in the I:th slot of the table + Tab. A table can be traversed by repeatedly calling + the function, starting with the first slot I=0 and ending when '$end_of_table' is returned. The function will fail with reason badarg if the - I argument is out of range.

+ I argument is out of range.

Unless a table of type set, bag or duplicate_bag is protected using safe_fixtable/2, see above, a traversal may fail if concurrent updates are made to the table. If the table is of type ordered_set, the function returns a list - containing the I:th object in Erlang term order.

+ containing the I:th object in Erlang term order.

@@ -1754,16 +1588,16 @@ true - update_counter(Tab, Key, UpdateOp) -> Result - update_counter(Tab, Key, [UpdateOp]) -> [Result] - update_counter(Tab, Key, Incr) -> Result + + + + + + + + + Update a counter object in an ETS table. - - Tab = tid() | atom() - Key = term() - UpdateOp = {Pos,Incr} | {Pos,Incr,Threshold,SetValue} - Pos = Incr = Threshold = SetValue = Result = integer() -

This function provides an efficient way to update one or more counters, without the hassle of having to look up an object, update @@ -1771,22 +1605,22 @@ true into the table again. (The update is done atomically; i.e. no process can access the ets table in the middle of the operation.)

-

It will destructively update the object with key Key - in the table Tab by adding Incr to the element - at the Pos:th position. The new counter value is +

It will destructively update the object with key Key + in the table Tab by adding Incr to the element + at the Pos:th position. The new counter value is returned. If no position is specified, the element directly following the key (+1]]>) is updated.

-

If a Threshold is specified, the counter will be - reset to the value SetValue if the following +

If a Threshold is specified, the counter will be + reset to the value SetValue if the following conditions occur:

- The Incr is not negative (>= 0) and the - result would be greater than (>) Threshold - The Incr is negative () and the + The Incr is not negative (>= 0) and the + result would be greater than (>) Threshold + The Incr is negative () and the result would be less than () - Threshold + Threshold -

A list of UpdateOp can be supplied to do several update +

A list of UpdateOp can be supplied to do several update operations within the object. The operations are carried out in the order specified in the list. If the same counter position occurs more than one time in the list, the corresponding counter will thus @@ -1797,7 +1631,7 @@ true returned. If the function should fail, no updates will be done at all.

-

The given Key is used to identify the object by either +

The given Key is used to identify the object by either matching the key of an object in a set table, or compare equal to the key of an object in an ordered_set table (see @@ -1812,29 +1646,28 @@ true the object has the wrong arity, the element to update is not an integer, the element to update is also the key, or, - any of Pos, Incr, Threshold or - SetValue is not an integer + any of Pos, Incr, Threshold or + SetValue is not an integer - update_element(Tab, Key, {Pos,Value}) -> true | false - update_element(Tab, Key, [{Pos,Value}]) -> true | false + + + + + + Updates the Pos:th element of the object with a given key in an ETS table. - - Tab = tid() | atom() - Key = Value = term() - Pos = integer() -

This function provides an efficient way to update one or more elements within an object, without the hassle of having to look up, update and write back the entire object.

-

It will destructively update the object with key Key - in the table Tab. The element at the Pos:th position - will be given the value Value.

-

A list of {Pos,Value} can be supplied to update several +

It will destructively update the object with key Key + in the table Tab. The element at the Pos:th position + will be given the value Value.

+

A list of {Pos,Value} can be supplied to update several elements within the same object. If the same position occurs more than one in the list, the last value in the list will be written. If the list is empty or the function fails, no updates will be done at @@ -1842,9 +1675,9 @@ true can never see any intermediate results.

The function returns true if an object with the key - Key was found, false otherwise. + Key was found, false otherwise.

-

The given Key is used to identify the object by either +

The given Key is used to identify the object by either matching the key of an object in a set table, or compare equal to the key of an object in an ordered_set table (see @@ -1855,7 +1688,7 @@ true the table is not of type set or ordered_set, - Pos is less than 1 or greater than the object + Pos is less than 1 or greater than the object arity, or, the element to update is also the key diff --git a/lib/stdlib/doc/src/lists.xml b/lib/stdlib/doc/src/lists.xml index 7042c84437..fc58f3e4d2 100644 --- a/lib/stdlib/doc/src/lists.xml +++ b/lib/stdlib/doc/src/lists.xml @@ -4,7 +4,7 @@

- 19962011 + 19962012 Ericsson AB. All Rights Reserved. @@ -248,18 +248,13 @@ flatmap(Fun, List1) -> - keyfind(Key, N, TupleList) -> Tuple | false + + 1..tuple_size(Tuple) Search for an element in a list of tuples - - Key = term() - N = 1..tuple_size(Tuple) - TupleList = [Tuple] - Tuple = tuple() - - -

Searches the list of tuples TupleList for a - tuple whose Nth element compares equal to Key. - Returns Tuple if such a tuple is found, + +

Searches the list of tuples TupleList for a + tuple whose Nth element compares equal to Key. + Returns Tuple if such a tuple is found, otherwise false.

@@ -281,17 +276,12 @@ flatmap(Fun, List1) -> - keymember(Key, N, TupleList) -> boolean() + + 1..tuple_size(Tuple) Test for membership of a list of tuples - - Key = term() - N = 1..tuple_size(Tuple) - TupleList = [Tuple] -  Tuple = tuple() - - -

Returns true if there is a tuple in TupleList - whose Nth element compares equal to Key, otherwise + +

Returns true if there is a tuple in TupleList + whose Nth element compares equal to Key, otherwise false.

@@ -321,18 +311,13 @@ flatmap(Fun, List1) -> - keysearch(Key, N, TupleList) -> {value, Tuple} | false + + 1..tuple_size(Tuple) Search for an element in a list of tuples - - Key = term() - N = 1..tuple_size(Tuple) - TupleList = [Tuple] - Tuple = tuple() - - -

Searches the list of tuples TupleList for a - tuple whose Nth element compares equal to Key. - Returns {value, Tuple} if such a tuple is found, + +

Searches the list of tuples TupleList for a + tuple whose Nth element compares equal to Key. + Returns {value, Tuple} if such a tuple is found, otherwise false.

This function is retained for backward compatibility. The function lists:keyfind/3 (introduced in R13A) @@ -425,15 +410,11 @@ flatmap(Fun, List1) -> - member(Elem, List) -> boolean() + Test for membership of a list - - Elem = term() - List = [term()] - -

Returns true if Elem matches some element of - List, otherwise false.

+

Returns true if Elem matches some element of + List, otherwise false.

@@ -562,14 +543,11 @@ c - reverse(List1, Tail) -> List2 + Reverse a list appending a tail - - List1 = Tail = List2 = [term()] - -

Returns a list with the elements in List1 - in reverse order, with the tail Tail appended. For +

Returns a list with the elements in List1 + in reverse order, with the tail Tail appended. For example:

 > lists:reverse([1, 2, 3, 4], [a, b, c]).
diff --git a/lib/stdlib/doc/src/math.xml b/lib/stdlib/doc/src/math.xml
index 518457d5d8..0219dcce10 100644
--- a/lib/stdlib/doc/src/math.xml
+++ b/lib/stdlib/doc/src/math.xml
@@ -5,7 +5,7 @@
   
1996 - 2011 + 2012 Ericsson AB, All Rights Reserved @@ -52,54 +52,47 @@ - sin(X) - cos(X) - tan(X) - asin(X) - acos(X) - atan(X) - atan2(Y, X) - sinh(X) - cosh(X) - tanh(X) - asinh(X) - acosh(X) - atanh(X) - exp(X) - log(X) - log10(X) - pow(X, Y) - sqrt(X) + + + + + + + + + + + + + + + + + + + + Diverse math functions - - X = Y = number() -

A collection of math functions which return floats. Arguments are numbers.

- erf(X) -> float() + Error function. - - X = number() - -

Returns the error function of X, where

+

Returns the error function of X, where

 erf(X) = 2/sqrt(pi)*integral from 0 to X of exp(-t*t) dt.        
- erfc(X) -> float() + Another error function - - X = number() -

erfc(X) returns 1.0 - erf(X), computed by - methods that avoid cancellation for large X.

+ methods that avoid cancellation for large X.

diff --git a/lib/stdlib/doc/src/re.xml b/lib/stdlib/doc/src/re.xml index 6d5336796c..c6f45fb1e1 100644 --- a/lib/stdlib/doc/src/re.xml +++ b/lib/stdlib/doc/src/re.xml @@ -5,7 +5,7 @@
2007 - 2011 + 2012 Ericsson AB, All Rights Reserved @@ -78,28 +78,15 @@ - compile(Regexp) -> {ok, MP} | {error, ErrSpec} + Compile a regular expression into a match program - - Regexp = iodata() - -

The same as compile(Regexp,[])

+

The same as compile(Regexp,[])

- compile(Regexp,Options) -> {ok, MP} | {error, ErrSpec} + Compile a regular expression into a match program - - Regexp = iodata() | io:charlist() - Options = [ Option ] - Option = compile_option() - NLSpec = nl_spec() - MP = mp() - ErrSpec = {ErrString, Position} - ErrString = string() - Position = non_neg_integer() -

This function compiles a regular expression with the syntax described below into an internal format to be used later as a @@ -165,44 +152,23 @@ This option makes it possible to include comments inside complicated patterns. N - run(Subject,RE) -> {match, Captured} | nomatch + Match a subject against regular expression and capture subpatterns - - Subject = iodata() | io:charlist() - RE = mp() | iodata() - Captured = [ CaptureData ] - CaptureData = {integer(),integer()} - -

The same as run(Subject,RE,[]).

+

The same as run(Subject,RE,[]).

- run(Subject,RE,Options) -> {match, Captured} | match | nomatch + + See compile/2 above. Match a subject against regular expression and capture subpatterns - - Subject = iodata() | io:charlist() - RE = mp() | iodata() | io:charlist() - Options = [ Option ] - Option = anchored | global | notbol | noteol | notempty | {offset, integer() >= 0} | {newline, NLSpec} | bsr_anycrlf | bsr_unicode | {capture, ValueSpec} | {capture, ValueSpec, Type} | CompileOpt - Type = index | list | binary - ValueSpec = all | all_but_first | first | none | ValueList - ValueList = [ ValueID ] - ValueID = integer() | string() | atom() - CompileOpt = compile_option() - See compile/2 above. - NLSpec = nl_spec() - Captured = [ CaptureData ] | [ [ CaptureData ] ... ] - CaptureData = {integer(),integer()} | ListConversionData | binary() - ListConversionData = string() | {error, string(), binary()} | {incomplete, string(), binary()} -

Executes a regexp matching, returning match/{match, - Captured} or nomatch. The regular expression can be + Captured} or nomatch. The regular expression can be given either as iodata() in which case it is automatically compiled (as by re:compile/2) and executed, - or as a pre compiled mp() in which case it is executed + or as a pre-compiled mp() in which case it is executed against the subject directly.

When compilation is involved, the exception badarg is @@ -214,23 +180,23 @@ This option makes it possible to include comments inside complicated patterns. N list can only contain the options anchored, global, notbol, noteol, notempty, {offset, integer() >= 0}, {newline, - NLSpec} and {capture, ValueSpec}/{capture, ValueSpec, - Type}. Otherwise all options valid for the + NLSpec} and {capture, ValueSpec}/{capture, ValueSpec, + Type}. Otherwise all options valid for the re:compile/2 function are allowed as well. Options allowed both for compilation and execution of a match, namely - anchored and {newline, NLSpec}, will affect both + anchored and {newline, NLSpec}, will affect both the compilation and execution if present together with a non pre-compiled regular expression.

If the regular expression was previously compiled with the - option unicode, the Subject should be provided as + option unicode, the Subject should be provided as a valid Unicode charlist(), otherwise any iodata() will do. If compilation is involved and the option - unicode is given, both the Subject and the regular + unicode is given, both the Subject and the regular expression should be given as valid Unicode charlists().

-

The {capture, ValueSpec}/{capture, ValueSpec, Type} +

The {capture, ValueSpec}/{capture, ValueSpec, Type} defines what to return from the function upon successful matching. The capture tuple may contain both a value specification telling which of the captured @@ -244,9 +210,9 @@ This option makes it possible to include comments inside complicated patterns. N at all is to be done ({capture, none}), the function will return the single atom match upon successful matching, otherwise the tuple - {match, ValueList} is returned. Disabling capturing can + {match, ValueList} is returned. Disabling capturing can be done either by specifying none or an empty list as - ValueSpec.

+ ValueSpec.

The options relevant for execution are:

@@ -266,7 +232,7 @@ This option makes it possible to include comments inside complicated patterns. N Perl). Each match is returned as a separate list() containing the specific match as well as any matching subexpressions (or as specified by the capture - option). The Captured part of the return value will + option). The Captured part of the return value will hence be a list() of list()s when this option is given.

@@ -362,7 +328,7 @@ This option makes it possible to include comments inside complicated patterns. N subject string. The offset is zero-based, so that the default is {offset,0} (all of the subject string). - {newline, NLSpec} + {newline, NLSpec}

Override the default definition of a newline in the subject string, which is LF (ASCII 10) in Erlang.

@@ -383,7 +349,7 @@ This option makes it possible to include comments inside complicated patterns. N bsr_unicode Specifies specifically that \R is to match all the Unicode newline characters (including crlf etc, the default).(overrides compilation option) - {capture, ValueSpec}/{capture, ValueSpec, Type} + {capture, ValueSpec}/{capture, ValueSpec, Type}

Specifies which captured substrings are returned and in what @@ -392,7 +358,7 @@ This option makes it possible to include comments inside complicated patterns. N substring as well as all capturing subpatterns (all of the pattern is automatically captured). The default return type is (zero-based) indexes of the captured parts of the string, given as - {Offset,Length} pairs (the index Type of + {Offset,Length} pairs (the index Type of capturing).

As an example of the default behavior, the following call:

@@ -422,8 +388,8 @@ This option makes it possible to include comments inside complicated patterns. N

The capture tuple is built up as follows:

- ValueSpec -

Specifies which captured (sub)patterns are to be returned. The ValueSpec can either be an atom describing a predefined set of return values, or a list containing either the indexes or the names of specific subpatterns to return.

+ ValueSpec +

Specifies which captured (sub)patterns are to be returned. The ValueSpec can either be an atom describing a predefined set of return values, or a list containing either the indexes or the names of specific subpatterns to return.

The predefined sets of subpatterns are:

all @@ -437,7 +403,7 @@ This option makes it possible to include comments inside complicated patterns. N

The value list is a list of indexes for the subpatterns to return, where index 0 is for all of the pattern, and 1 is for the first explicit capturing subpattern in the regular expression, and so forth. When using named captured subpatterns (see below) in the regular expression, one can use atom()s or string()s to specify the subpatterns to be returned. For example, consider the regular expression:

".*(abcd).*" -

matched against the string ""ABCabcdABC", capturing only the "abcd" part (the first explicit subpattern):

+

matched against the string "ABCabcdABC", capturing only the "abcd" part (the first explicit subpattern):

re:run("ABCabcdABC",".*(abcd).*",[{capture,[1]}]).

The call will yield the following result:

{match,[{3,4}]} @@ -460,8 +426,8 @@ This option makes it possible to include comments inside complicated patterns. N or list respectively.

- Type -

Optionally specifies how captured substrings are to be returned. If omitted, the default of index is used. The Type can be one of the following:

+ Type +

Optionally specifies how captured substrings are to be returned. If omitted, the default of index is used. The Type can be one of the following:

index Return captured substrings as pairs of byte indexes into the subject string and length of the matching string in the subject (as if the subject string was flattened with iolist_to_binary/1 or unicode:characters_to_binary/2 prior to matching). Note that the unicode option results in byte-oriented indexes in a (possibly virtual) UTF-8 encoded binary. A byte index tuple {0,2} might therefore represent one or two characters when unicode is in effect. This might seem counter-intuitive, but has been deemed the most effective and useful way to way to do it. To return lists instead might result in simpler code if that is desired. This return type is the default. @@ -478,7 +444,7 @@ This option makes it possible to include comments inside complicated patterns. N "ABCabcdABC"

the subpattern at index 2 won't match, as "abdd" is not present in the string, but the complete pattern matches (due to the alternative a(..d). The subpattern at index 2 is therefore unassigned and the default return value will be:

{match,[{0,10},{3,4},{-1,0},{4,3}]} -

Setting the capture Type to binary would give the following:

+

Setting the capture Type to binary would give the following:

{match,[<<"ABCabcdABC">>,<<"abcd">>,<<>>,<<"bcd">>]}

where the empty binary (<<>>) represents the unassigned subpattern. In the binary case, some information about the matching is therefore lost, the <<>> might just as well be an empty string captured.

If differentiation between empty matches and non existing subpatterns is necessary, use the type index diff --git a/lib/stdlib/doc/src/string.xml b/lib/stdlib/doc/src/string.xml index 48867ffe72..549c871aed 100644 --- a/lib/stdlib/doc/src/string.xml +++ b/lib/stdlib/doc/src/string.xml @@ -4,7 +4,7 @@

- 19962011 + 19962012 Ericsson AB. All Rights Reserved. @@ -255,18 +255,12 @@ sub_string("Hello World", 4, 8). - to_float(String) -> {Float,Rest} | {error,Reason} + Returns a float whose text representation is the integers (ASCII values) in String. - - String = string() - Float = float() - Rest = string() - Reason = no_float | not_a_list - -

Argument String is expected to start with a valid text +

Argument String is expected to start with a valid text represented float (the digits being ASCII values). Remaining characters - in the string after the float are returned in Rest.

+ in the string after the float are returned in Rest.

Example:

> {F1,Fs} = string:to_float("1.0-1.0e-1"), @@ -280,18 +274,12 @@ sub_string("Hello World", 4, 8).
- to_integer(String) -> {Int,Rest} | {error,Reason} + Returns an integer whose text representation is the integers (ASCII values) in String. - - String = string() - Int = integer() - Rest = string() - Reason = no_integer | not_a_list - -

Argument String is expected to start with a valid text +

Argument String is expected to start with a valid text represented integer (the digits being ASCII values). Remaining characters - in the string after the integer are returned in Rest.

+ in the string after the integer are returned in Rest.

Example:

> {I1,Is} = string:to_integer("33+22"), diff --git a/lib/stdlib/doc/src/unicode.xml b/lib/stdlib/doc/src/unicode.xml index 1001ebbae4..1f6cbaccd7 100644 --- a/lib/stdlib/doc/src/unicode.xml +++ b/lib/stdlib/doc/src/unicode.xml @@ -5,7 +5,7 @@
1996 - 2011 + 2012 Ericsson AB, All Rights Reserved @@ -130,34 +130,24 @@ - characters_to_list(Data, InEncoding) -> Result + Convert a collection of characters to list of Unicode characters - - Data = latin1_chardata() - | chardata() - | external_chardata() - Result = list() | {error, list(), RestData} | {incomplete, list(), binary()} - RestData = latin1_chardata() - | chardata() - | external_chardata() - InEncoding = encoding() -

This function converts a possibly deep list of integers and binaries into a list of integers representing unicode characters. The binaries in the input may have characters encoded as latin1 (0 - 255, one character per byte), in which - case the InEncoding parameter should be given as + case the InEncoding parameter should be given as latin1, or have characters encoded as one of the - UTF-encodings, which is given as the InEncoding - parameter. Only when the InEncoding is one of the UTF + UTF-encodings, which is given as the InEncoding + parameter. Only when the InEncoding is one of the UTF encodings, integers in the list are allowed to be grater than 255.

-

If InEncoding is latin1, the Data parameter +

If InEncoding is latin1, the Data parameter corresponds to the iodata() type, but for unicode, - the Data parameter can contain integers greater than 255 + the Data parameter can contain integers greater than 255 (unicode characters beyond the iso-latin-1 range), which would make it invalid as iodata().

@@ -188,16 +178,16 @@ depth as the original data. The error occurs when traversing the list and whatever's left to decode is simply returned as is.

-

However, if the input Data is a pure binary, the third +

However, if the input Data is a pure binary, the third part of the error tuple is guaranteed to be a binary as well.

Errors occur for the following reasons:

- Integers out of range - If InEncoding is + Integers out of range - If InEncoding is latin1, an error occurs whenever an integer greater - than 255 is found in the lists. If InEncoding is + than 255 is found in the lists. If InEncoding is of a Unicode type, an error occurs whenever an integer greater than 16#10FFFF @@ -208,7 +198,7 @@ is found. - UTF encoding incorrect - If InEncoding is + UTF encoding incorrect - If InEncoding is one of the UTF types, the bytes in any binaries have to be valid in that encoding. Errors can occur for various reasons, including "pure" decoding errors @@ -220,7 +210,7 @@ number should have been encoded in fewer bytes. The case of a truncated UTF is handled specially, see the paragraph about incomplete binaries below. If - InEncoding is latin1, binaries are always valid + InEncoding is latin1, binaries are always valid as long as they contain whole bytes, as each byte falls into the valid iso-latin-1 range. @@ -238,7 +228,7 @@ the first part of a (so far) valid UTF character.

If one UTF characters is split over two consecutive - binaries in the Data, the conversion succeeds. This means + binaries in the Data, the conversion succeeds. This means that a character can be decoded from a range of binaries as long as the whole range is given as input without errors occurring. Example:

@@ -274,21 +264,11 @@
- characters_to_binary(Data,InEncoding) -> Result + Convert a collection of characters to an UTF-8 binary - - Data = latin1_chardata() - | chardata() - | external_chardata() - Result = binary() | {error, binary(), RestData} | {incomplete, binary(), binary()} - RestData = latin1_chardata() - | chardata() - | external_chardata() - InEncoding = encoding() - -

Same as characters_to_binary(Data, InEncoding, unicode).

+

Same as characters_to_binary(Data, InEncoding, unicode).

diff --git a/lib/stdlib/src/binary.erl b/lib/stdlib/src/binary.erl index cb1e12ae46..0e95372a76 100644 --- a/lib/stdlib/src/binary.erl +++ b/lib/stdlib/src/binary.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2010-2011. All Rights Reserved. +%% Copyright Ericsson AB 2010-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -18,29 +18,185 @@ %% -module(binary). %% -%% The following functions implemented as BIF's -%% binary:compile_pattern/1 -%% binary:match/{2,3} -%% binary:matches/{2,3} -%% binary:longest_common_prefix/1 -%% binary:longest_common_suffix/1 -%% binary:first/1 -%% binary:last/1 -%% binary:at/2 -%% binary:part/{2,3} -%% binary:bin_to_list/{1,2,3} -%% binary:list_to_bin/1 -%% binary:copy/{1,2} -%% binary:referenced_byte_size/1 -%% binary:decode_unsigned/{1,2} -%% - Not yet: -%% %% Implemented in this module: -export([split/2,split/3,replace/3,replace/4]). -opaque cp() :: tuple(). -type part() :: {Start :: non_neg_integer(), Length :: integer()}. +%%% BIFs. + +-export([at/2, bin_to_list/1, bin_to_list/2, bin_to_list/3, + compile_pattern/1, copy/1, copy/2, decode_unsigned/1, + decode_unsigned/2, encode_unsigned/1, encode_unsigned/2, + first/1, last/1, list_to_bin/1, longest_common_prefix/1, + longest_common_suffix/1, match/2, match/3, matches/2, + matches/3, part/2, part/3, referenced_byte_size/1]). + +-spec at(Subject, Pos) -> byte() when + Subject :: binary(), + Pos :: non_neg_integer(). + +at(_, _) -> + erlang:nif_error(undef). + +-spec bin_to_list(Subject) -> [byte()] when + Subject :: binary(). + +bin_to_list(_) -> + erlang:nif_error(undef). + +-spec bin_to_list(Subject, PosLen) -> [byte()] when + Subject :: binary(), + PosLen :: part(). + +bin_to_list(_, _) -> + erlang:nif_error(undef). + +-spec bin_to_list(Subject, Pos, Len) -> [byte()] when + Subject :: binary(), + Pos :: non_neg_integer(), + Len :: non_neg_integer(). + +bin_to_list(_, _, _) -> + erlang:nif_error(undef). + +-spec compile_pattern(Pattern) -> cp() when + Pattern :: binary() | [binary()]. + +compile_pattern(_) -> + erlang:nif_error(undef). + +-spec copy(Subject) -> binary() when + Subject :: binary(). + +copy(_) -> + erlang:nif_error(undef). + +-spec copy(Subject, N) -> binary() when + Subject :: binary(), + N :: non_neg_integer(). + +copy(_, _) -> + erlang:nif_error(undef). + +-spec decode_unsigned(Subject) -> Unsigned when + Subject :: binary(), + Unsigned :: non_neg_integer(). + +decode_unsigned(_) -> + erlang:nif_error(undef). + +-spec decode_unsigned(Subject, Endianess) -> Unsigned when + Subject :: binary(), + Endianess :: big | little, + Unsigned :: non_neg_integer(). + +decode_unsigned(_, _) -> + erlang:nif_error(undef). + +-spec encode_unsigned(Unsigned) -> binary() when + Unsigned :: non_neg_integer(). + +encode_unsigned(_) -> + erlang:nif_error(undef). + +-spec encode_unsigned(Unsigned, Endianess) -> binary() when + Unsigned :: non_neg_integer(), + Endianess :: big | little. + +encode_unsigned(_, _) -> + erlang:nif_error(undef). + +-spec first(Subject) -> byte() when + Subject :: binary(). + +first(_) -> + erlang:nif_error(undef). + +-spec last(Subject) -> byte() when + Subject :: binary(). + +last(_) -> + erlang:nif_error(undef). + +-spec list_to_bin(ByteList) -> binary() when + ByteList :: iodata(). + +list_to_bin(_) -> + erlang:nif_error(undef). + +-spec longest_common_prefix(Binaries) -> non_neg_integer() when + Binaries :: [binary()]. + +longest_common_prefix(_) -> + erlang:nif_error(undef). + +-spec longest_common_suffix(Binaries) -> non_neg_integer() when + Binaries :: [binary()]. + +longest_common_suffix(_) -> + erlang:nif_error(undef). + +-spec match(Subject, Pattern) -> Found | nomatch when + Subject :: binary(), + Pattern :: binary() | [binary()] | cp(), + Found :: part(). + +match(_, _) -> + erlang:nif_error(undef). + +-spec match(Subject, Pattern, Options) -> Found | nomatch when + Subject :: binary(), + Pattern :: binary() | [binary()] | cp(), + Found :: part(), + Options :: [Option], + Option :: {scope, part()}. + +match(_, _, _) -> + erlang:nif_error(undef). + +-spec matches(Subject, Pattern) -> Found when + Subject :: binary(), + Pattern :: binary() | [binary()] | cp(), + Found :: [part()]. + +matches(_, _) -> + erlang:nif_error(undef). + +-spec matches(Subject, Pattern, Options) -> Found when + Subject :: binary(), + Pattern :: binary() | [binary()] | cp(), + Found :: [part()], + Options :: [Option], + Option :: {scope, part()}. + +matches(_, _, _) -> + erlang:nif_error(undef). + +-spec part(Subject, PosLen) -> binary() when + Subject :: binary(), + PosLen :: part(). + +part(_, _) -> + erlang:nif_error(undef). + +-spec part(Subject, Pos, Len) -> binary() when + Subject :: binary(), + Pos :: non_neg_integer(), + Len :: non_neg_integer(). + +part(_, _, _) -> + erlang:nif_error(undef). + +-spec referenced_byte_size(Binary) -> non_neg_integer() when + Binary :: binary(). + +referenced_byte_size(_) -> + erlang:nif_error(undef). + +%%% End of BIFs. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% split %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/lib/stdlib/src/ets.erl b/lib/stdlib/src/ets.erl index afa914a456..4a96808810 100644 --- a/lib/stdlib/src/ets.erl +++ b/lib/stdlib/src/ets.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2011. All Rights Reserved. +%% Copyright Ericsson AB 1996-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -46,7 +46,12 @@ %%----------------------------------------------------------------------------- +-type access() :: public | protected | private. -type tab() :: atom() | tid(). +-type type() :: set | ordered_set | bag | duplicate_bag. +-type continuation() :: '$end_of_table' + | {tab(),integer(),integer(),binary(),list(),integer()} + | {tab(),_,_,integer(),binary(),list(),integer(),integer()}. %% a similar definition is also in erl_types -opaque tid() :: integer(). @@ -57,59 +62,397 @@ %%----------------------------------------------------------------------------- -%% The following functions used to be found in this module, but -%% are now BIFs (i.e. implemented in C). -%% -%% all/0 -%% new/2 -%% delete/1 -%% delete/2 -%% first/1 -%% info/1 -%% info/2 -%% safe_fixtable/2 -%% lookup/2 -%% lookup_element/3 -%% insert/2 -%% is_compiled_ms/1 -%% last/1 -%% member/2 -%% next/2 -%% prev/2 -%% rename/2 -%% slot/2 -%% match/1 -%% match/2 -%% match/3 -%% match_object/1 -%% match_object/2 -%% match_object/3 -%% match_spec_compile/1 -%% match_spec_run_r/3 -%% select/1 -%% select/2 -%% select/3 -%% select_count/2 -%% select_reverse/1 -%% select_reverse/2 -%% select_reverse/3 -%% select_delete/2 -%% setopts/2 -%% update_counter/3 -%% update_element/3 -%% +%%% BIFs + +-export([all/0, delete/1, delete/2, delete_all_objects/1, + delete_object/2, first/1, give_away/3, info/1, info/2, + insert/2, insert_new/2, is_compiled_ms/1, last/1, lookup/2, + lookup_element/3, match/1, match/2, match/3, match_object/1, + match_object/2, match_object/3, match_spec_compile/1, + match_spec_run_r/3, member/2, new/2, next/2, prev/2, + rename/2, safe_fixtable/2, select/1, select/2, select/3, + select_count/2, select_delete/2, select_reverse/1, + select_reverse/2, select_reverse/3, setopts/2, slot/2, + update_counter/3, update_element/3]). + +-spec all() -> [Tab] when + Tab :: tab(). + +all() -> + erlang:nif_error(undef). + +-spec delete(Tab) -> true when + Tab :: tab(). + +delete(_) -> + erlang:nif_error(undef). + +-spec delete(Tab, Key) -> true when + Tab :: tab(), + Key :: term(). + +delete(_, _) -> + erlang:nif_error(undef). + +-spec delete_all_objects(Tab) -> true when + Tab :: tab(). + +delete_all_objects(_) -> + erlang:nif_error(undef). + +-spec delete_object(Tab, Object) -> true when + Tab :: tab(), + Object :: tuple(). + +delete_object(_, _) -> + erlang:nif_error(undef). + +-spec first(Tab) -> Key | '$end_of_table' when + Tab :: tab(), + Key :: term(). + +first(_) -> + erlang:nif_error(undef). + +-spec give_away(Tab, Pid, GiftData) -> true when + Tab :: tab(), + Pid :: pid(), + GiftData :: term(). + +give_away(_, _, _) -> + erlang:nif_error(undef). + +-spec info(Tab) -> InfoList | undefined when + Tab :: tab(), + InfoList :: [InfoTuple], + InfoTuple :: {compressed, boolean()} + | {heir, pid() | none} + | {keypos, pos_integer()} + | {memory, non_neg_integer()} + | {name, atom()} + | {named_table, boolean()} + | {node, node()} + | {owner, pid()} + | {protection, access()} + | {size, non_neg_integer()} + | {type, type()}. + +info(_) -> + erlang:nif_error(undef). + +-spec info(Tab, Item) -> Value | undefined when + Tab :: tab(), + Item :: compressed | fixed | heir | keypos | memory + | name | named_table | node | owner | protection + | safe_fixed | size | stats | type, + Value :: term(). + +info(_, _) -> + erlang:nif_error(undef). + +-spec insert(Tab, ObjectOrObjects) -> true when + Tab :: tab(), + ObjectOrObjects :: tuple() | [tuple()]. + +insert(_, _) -> + erlang:nif_error(undef). + +-spec insert_new(Tab, ObjectOrObjects) -> boolean() when + Tab :: tab(), + ObjectOrObjects :: tuple() | [tuple()]. + +insert_new(_, _) -> + erlang:nif_error(undef). + +-spec is_compiled_ms(Term) -> boolean() when + Term :: term(). + +is_compiled_ms(_) -> + erlang:nif_error(undef). + +-spec last(Tab) -> Key | '$end_of_table' when + Tab :: tab(), + Key :: term(). + +last(_) -> + erlang:nif_error(undef). + +-spec lookup(Tab, Key) -> [Object] when + Tab :: tab(), + Key :: term(), + Object :: tuple(). + +lookup(_, _) -> + erlang:nif_error(undef). + +-spec lookup_element(Tab, Key, Pos) -> Elem when + Tab :: tab(), + Key :: term(), + Pos :: pos_integer(), + Elem :: term() | [term()]. + +lookup_element(_, _, _) -> + erlang:nif_error(undef). + +-spec match(Tab, Pattern) -> [Match] when + Tab :: tab(), + Pattern :: match_pattern(), + Match :: [term()]. + +match(_, _) -> + erlang:nif_error(undef). + +-spec match(Tab, Pattern, Limit) -> {[Match], Continuation} | + '$end_of_table' when + Tab :: tab(), + Pattern :: match_pattern(), + Limit :: pos_integer(), + Match :: [term()], + Continuation :: continuation(). + +match(_, _, _) -> + erlang:nif_error(undef). + +-spec match(Continuation) -> {[Match], Continuation} | + '$end_of_table' when + Match :: [term()], + Continuation :: continuation(). + +match(_) -> + erlang:nif_error(undef). + +-spec match_object(Tab, Pattern) -> [Object] when + Tab :: tab(), + Pattern :: match_pattern(), + Object :: tuple(). + +match_object(_, _) -> + erlang:nif_error(undef). + +-spec match_object(Tab, Pattern, Limit) -> {[Match], Continuation} | + '$end_of_table' when + Tab :: tab(), + Pattern :: match_pattern(), + Limit :: pos_integer(), + Match :: [term()], + Continuation :: continuation(). + +match_object(_, _, _) -> + erlang:nif_error(undef). + +-spec match_object(Continuation) -> {[Match], Continuation} | + '$end_of_table' when + Match :: [term()], + Continuation :: continuation(). + +match_object(_) -> + erlang:nif_error(undef). + +-spec match_spec_compile(MatchSpec) -> CompiledMatchSpec when + MatchSpec :: match_spec(), + CompiledMatchSpec :: comp_match_spec(). + +match_spec_compile(_) -> + erlang:nif_error(undef). + +-spec match_spec_run_r(List, CompiledMatchSpec, list()) -> list() when + List :: [tuple()], + CompiledMatchSpec :: comp_match_spec(). + +match_spec_run_r(_, _, _) -> + erlang:nif_error(undef). + +-spec member(Tab, Key) -> boolean() when + Tab :: tab(), + Key :: term(). + +member(_, _) -> + erlang:nif_error(undef). + +-spec new(Name, Options) -> tid() | atom() when + Name :: atom(), + Options :: [Option], + Option :: Type | Access | named_table | {keypos,Pos} + | {heir, Pid :: pid(), HeirData} | {heir, none} | Tweaks, + Type :: type(), + Access :: access(), + Tweaks :: {write_concurrency, boolean()} + | {read_concurrency, boolean()} + | compressed, + Pos :: pos_integer(), + HeirData :: term(). + +new(_, _) -> + erlang:nif_error(undef). + +-spec next(Tab, Key1) -> Key2 | '$end_of_table' when + Tab :: tab(), + Key1 :: term(), + Key2 :: term(). + +next(_, _) -> + erlang:nif_error(undef). + +-spec prev(Tab, Key1) -> Key2 | '$end_of_table' when + Tab :: tab(), + Key1 :: term(), + Key2 :: term(). + +prev(_, _) -> + erlang:nif_error(undef). + +-spec rename(Tab, Name) -> Name when + Tab :: tab(), + Name :: atom(). + +rename(_, _) -> + erlang:nif_error(undef). + +-spec safe_fixtable(Tab, Fix) -> true when + Tab :: tab(), + Fix :: boolean(). + +safe_fixtable(_, _) -> + erlang:nif_error(undef). + +-spec select(Tab, MatchSpec) -> [Match] when + Tab :: tab(), + MatchSpec :: match_spec(), + Match :: term(). + +select(_, _) -> + erlang:nif_error(undef). + +-spec select(Tab, MatchSpec, Limit) -> {[Match],Continuation} | + '$end_of_table' when + Tab :: tab(), + MatchSpec :: match_spec(), + Limit :: pos_integer(), + Match :: term(), + Continuation :: continuation(). + +select(_, _, _) -> + erlang:nif_error(undef). + +-spec select(Continuation) -> {[Match],Continuation} | '$end_of_table' when + Match :: term(), + Continuation :: continuation(). + +select(_) -> + erlang:nif_error(undef). + +-spec select_count(Tab, MatchSpec) -> NumMatched when + Tab :: tab(), + MatchSpec :: match_spec(), + NumMatched :: non_neg_integer(). + +select_count(_, _) -> + erlang:nif_error(undef). + +-spec select_delete(Tab, MatchSpec) -> NumDeleted when + Tab :: tab(), + MatchSpec :: match_spec(), + NumDeleted :: non_neg_integer(). + +select_delete(_, _) -> + erlang:nif_error(undef). + +-spec select_reverse(Tab, MatchSpec) -> [Match] when + Tab :: tab(), + MatchSpec :: match_spec(), + Match :: term(). + +select_reverse(_, _) -> + erlang:nif_error(undef). + +-spec select_reverse(Tab, MatchSpec, Limit) -> {[Match],Continuation} | + '$end_of_table' when + Tab :: tab(), + MatchSpec :: match_spec(), + Limit :: pos_integer(), + Match :: term(), + Continuation :: continuation(). + +select_reverse(_, _, _) -> + erlang:nif_error(undef). + +-spec select_reverse(Continuation) -> {[Match],Continuation} | + '$end_of_table' when + Continuation :: continuation(), + Match :: term(). + +select_reverse(_) -> + erlang:nif_error(undef). + +-spec setopts(Tab, Opts) -> true when + Tab :: tab(), + Opts :: Opt | [Opt], + Opt :: {heir, pid(), HeirData} | {heir,none}, + HeirData :: term(). + +setopts(_, _) -> + erlang:nif_error(undef). + +-spec slot(Tab, I) -> [Object] | '$end_of_table' when + Tab :: tab(), + I :: non_neg_integer(), + Object :: tuple(). + +slot(_, _) -> + erlang:nif_error(undef). + +-spec update_counter(Tab, Key, UpdateOp) -> Result when + Tab :: tab(), + Key :: term(), + UpdateOp :: {Pos, Incr} | {Pos, Incr, Threshold, SetValue}, + Pos :: integer(), + Incr :: integer(), + Threshold :: integer(), + SetValue :: integer(), + Result :: integer(); + (Tab, Key, [UpdateOp]) -> [Result] when + Tab :: tab(), + Key :: term(), + UpdateOp :: {Pos, Incr} | {Pos, Incr, Threshold, SetValue}, + Pos :: integer(), + Incr :: integer(), + Threshold :: integer(), + SetValue :: integer(), + Result :: integer(); + (Tab, Key, Incr) -> Result when + Tab :: tab(), + Key :: term(), + Incr :: integer(), + Result :: integer(). + +update_counter(_, _, _) -> + erlang:nif_error(undef). + +-spec update_element(Tab, Key, ElementSpec :: {Pos, Value}) -> boolean() when + Tab :: tab(), + Key :: term(), + Pos :: pos_integer(), + Value :: term(); + (Tab, Key, ElementSpec :: [{Pos, Value}]) -> boolean() when + Tab :: tab(), + Key :: term(), + Pos :: pos_integer(), + Value :: term(). + +update_element(_, _, _) -> + erlang:nif_error(undef). + +%%% End of BIFs -opaque comp_match_spec() :: any(). %% this one is REALLY opaque --spec match_spec_run([tuple()], comp_match_spec()) -> [term()]. +-spec match_spec_run(List, CompiledMatchSpec) -> list() when + List :: [tuple()], + CompiledMatchSpec :: comp_match_spec(). match_spec_run(List, CompiledMS) -> lists:reverse(ets:match_spec_run_r(List, CompiledMS, [])). --type continuation() :: '$end_of_table' - | {tab(),integer(),integer(),binary(),list(),integer()} - | {tab(),_,_,integer(),binary(),list(),integer(),integer()}. - -spec repair_continuation(Continuation, MatchSpec) -> Continuation when Continuation :: continuation(), MatchSpec :: match_spec(). diff --git a/lib/stdlib/src/lists.erl b/lib/stdlib/src/lists.erl index e73c087753..d4f14dc8f5 100644 --- a/lib/stdlib/src/lists.erl +++ b/lib/stdlib/src/lists.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2011. All Rights Reserved. +%% Copyright Ericsson AB 1996-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -33,9 +33,6 @@ keysort/2, keymerge/3, rkeymerge/3, rukeymerge/3, ukeysort/2, ukeymerge/3, keymap/3]). -%% Bifs: member/2, reverse/2 -%% Bifs: keymember/3, keysearch/3, keyfind/3 - -export([merge/3, rmerge/3, sort/2, umerge/3, rumerge/3, usort/2]). -export([all/2,any/2,map/2,flatmap/2,foldl/3,foldr/3,filter/2, @@ -43,6 +40,55 @@ mapfoldl/3,mapfoldr/3,foreach/2,takewhile/2,dropwhile/2,splitwith/2, split/2]). +%%% BIFs +-export([keyfind/3, keymember/3, keysearch/3, member/2, reverse/2]). + +-spec keyfind(Key, N, TupleList) -> Tuple | false when + Key :: term(), + N :: pos_integer(), + TupleList :: [Tuple], + Tuple :: tuple(). + +keyfind(_, _, _) -> + erlang:nif_error(undef). + +-spec keymember(Key, N, TupleList) -> boolean() when + Key :: term(), + N :: pos_integer(), + TupleList :: [Tuple], + Tuple :: tuple(). + +keymember(_, _, _) -> + erlang:nif_error(undef). + +-spec keysearch(Key, N, TupleList) -> {value, Tuple} | false when + Key :: term(), + N :: pos_integer(), + TupleList :: [Tuple], + Tuple :: tuple(). + +keysearch(_, _, _) -> + erlang:nif_error(undef). + +-spec member(Elem, List) -> boolean() when + Elem :: T, + List :: [T], + T :: term(). + +member(_, _) -> + erlang:nif_error(undef). + +-spec reverse(List1, Tail) -> List2 when + List1 :: [T], + Tail :: term(), + List2 :: [T], + T :: term(). + +reverse(_, _) -> + erlang:nif_error(undef). + +%%% End of BIFs + %% member(X, L) -> (true | false) %% test if X is a member of the list L %% Now a BIF! @@ -84,7 +130,7 @@ append([]) -> []. subtract(L1, L2) -> L1 -- L2. -%% reverse(L) reverse all elements in the list L. Is now a BIF! +%% reverse(L) reverse all elements in the list L. reverse/2 is now a BIF! -spec reverse(List1) -> List2 when List1 :: [T], @@ -581,6 +627,7 @@ flatlength([_|T], L) -> flatlength([], L) -> L. %% keymember(Key, Index, [Tuple]) Now a BIF! +%% keyfind(Key, Index, [Tuple]) A BIF! %% keysearch(Key, Index, [Tuple]) Now a BIF! %% keydelete(Key, Index, [Tuple]) %% keyreplace(Key, Index, [Tuple], NewTuple) diff --git a/lib/stdlib/src/math.erl b/lib/stdlib/src/math.erl index b2ea6195c5..c3fb684ec3 100644 --- a/lib/stdlib/src/math.erl +++ b/lib/stdlib/src/math.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. +%% Copyright Ericsson AB 1996-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -20,6 +20,116 @@ -export([pi/0]). +%%% BIFs + +-export([sin/1, cos/1, tan/1, asin/1, acos/1, atan/1, atan2/2, sinh/1, + cosh/1, tanh/1, asinh/1, acosh/1, atanh/1, exp/1, log/1, + log10/1, pow/2, sqrt/1, erf/1, erfc/1]). + +-spec acos(X) -> float() when + X :: number(). +acos(_) -> + erlang:nif_error(undef). + +-spec acosh(X) -> float() when + X :: number(). +acosh(_) -> + erlang:nif_error(undef). + +-spec asin(X) -> float() when + X :: number(). +asin(_) -> + erlang:nif_error(undef). + +-spec asinh(X) -> float() when + X :: number(). +asinh(_) -> + erlang:nif_error(undef). + +-spec atan(X) -> float() when + X :: number(). +atan(_) -> + erlang:nif_error(undef). + +-spec atan2(X, Y) -> float() when + X :: number(), + Y :: number(). +atan2(_, _) -> + erlang:nif_error(undef). + +-spec atanh(X) -> float() when + X :: number(). +atanh(_) -> + erlang:nif_error(undef). + +-spec cos(X) -> float() when + X :: number(). +cos(_) -> + erlang:nif_error(undef). + +-spec cosh(X) -> float() when + X :: number(). +cosh(_) -> + erlang:nif_error(undef). + +-spec erf(X) -> float() when + X :: number(). +erf(_) -> + erlang:nif_error(undef). + +-spec erfc(X) -> float() when + X :: number(). +erfc(_) -> + erlang:nif_error(undef). + +-spec exp(X) -> float() when + X :: number(). +exp(_) -> + erlang:nif_error(undef). + +-spec log(X) -> float() when + X :: number(). +log(_) -> + erlang:nif_error(undef). + +-spec log10(X) -> float() when + X :: number(). +log10(_) -> + erlang:nif_error(undef). + +-spec pow(X, Y) -> float() when + X :: number(), + Y :: number(). +pow(_, _) -> + erlang:nif_error(undef). + +-spec sin(X) -> float() when + X :: number(). +sin(_) -> + erlang:nif_error(undef). + +-spec sinh(X) -> float() when + X :: number(). +sinh(_) -> + erlang:nif_error(undef). + +-spec sqrt(X) -> float() when + X :: number(). +sqrt(_) -> + erlang:nif_error(undef). + +-spec tan(X) -> float() when + X :: number(). +tan(_) -> + erlang:nif_error(undef). + +-spec tanh(X) -> float() when + X :: number(). +tanh(_) -> + erlang:nif_error(undef). + +%%% End of BIFs + -spec pi() -> float(). pi() -> 3.1415926535897932. diff --git a/lib/stdlib/src/qlc_pt.erl b/lib/stdlib/src/qlc_pt.erl index 21504d707b..ad25fd559c 100644 --- a/lib/stdlib/src/qlc_pt.erl +++ b/lib/stdlib/src/qlc_pt.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2004-2011. All Rights Reserved. +%% Copyright Ericsson AB 2004-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -2186,7 +2186,7 @@ try_ms(E, P, Fltr, State) -> {function,L,foo,0,[{clause,L,[],[],[MS0]}]} = lists:last(X), MS = erl_parse:normalise(var2const(MS0)), XMS = ets:match_spec_compile(MS), - true = is_binary(XMS), + true = ets:is_compiled_ms(XMS), {ok, MS, MS0} end of {'EXIT', _Reason} -> diff --git a/lib/stdlib/src/re.erl b/lib/stdlib/src/re.erl index 246d535943..359afc8c14 100644 --- a/lib/stdlib/src/re.erl +++ b/lib/stdlib/src/re.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2011. All Rights Reserved. +%% Copyright Ericsson AB 2008-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -30,11 +30,65 @@ | {newline, nl_spec()}| bsr_anycrlf | bsr_unicode. -%% Emulator builtins in this module: -%% re:compile/1 -%% re:compile/2 -%% re:run/2 -%% re:run/3 +%%% BIFs + +-export([compile/1, compile/2, run/2, run/3]). + +-spec compile(Regexp) -> {ok, MP} | {error, ErrSpec} when + Regexp :: iodata(), + MP :: mp(), + ErrSpec :: {ErrString :: string(), Position :: non_neg_integer()}. + +compile(_) -> + erlang:nif_error(undef). + +-spec compile(Regexp, Options) -> {ok, MP} | {error, ErrSpec} when + Regexp :: iodata() | unicode:charlist(), + Options :: [Option], + Option :: compile_option(), + MP :: mp(), + ErrSpec :: {ErrString :: string(), Position :: non_neg_integer()}. + +compile(_, _) -> + erlang:nif_error(undef). + +-spec run(Subject, RE) -> {match, Captured} | nomatch when + Subject :: iodata() | unicode:charlist(), + RE :: mp() | iodata(), + Captured :: [CaptureData], + CaptureData :: {integer(), integer()}. + +run(_, _) -> + erlang:nif_error(undef). + +-spec run(Subject, RE, Options) -> {match, Captured} | + match | + nomatch when + Subject :: iodata() | unicode:charlist(), + RE :: mp() | iodata() | unicode:charlist(), + Options :: [Option], + Option :: anchored | global | notbol | noteol | notempty + | {offset, non_neg_integer()} | + {newline, NLSpec :: nl_spec()} | + bsr_anycrlf | bsr_unicode | {capture, ValueSpec} | + {capture, ValueSpec, Type} | CompileOpt, + Type :: index | list | binary, + ValueSpec :: all | all_but_first | first | none | ValueList, + ValueList :: [ValueID], + ValueID :: integer() | string() | atom(), + CompileOpt :: compile_option(), + Captured :: [CaptureData] | [[CaptureData]], + CaptureData :: {integer(), integer()} + | ListConversionData + | binary(), + ListConversionData :: string() + | {error, string(), binary()} + | {incomplete, string(), binary()}. + +run(_, _, _) -> + erlang:nif_error(undef). + +%%% End of BIFs -spec split(Subject, RE) -> SplitList when Subject :: iodata() | unicode:charlist(), diff --git a/lib/stdlib/src/string.erl b/lib/stdlib/src/string.erl index 30eac4f07d..fc029a582f 100644 --- a/lib/stdlib/src/string.erl +++ b/lib/stdlib/src/string.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2011. All Rights Reserved. +%% Copyright Ericsson AB 1996-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -29,6 +29,30 @@ %%--------------------------------------------------------------------------- +%%% BIFs + +-export([to_float/1, to_integer/1]). + +-spec to_float(String) -> {Float, Rest} | {error, Reason} when + String :: string(), + Float :: float(), + Rest :: string(), + Reason :: no_float | not_a_list. + +to_float(_) -> + erlang:nif_error(undef). + +-spec to_integer(String) -> {Int, Rest} | {error, Reason} when + String :: string(), + Int :: integer(), + Rest :: string(), + Reason :: no_integer | not_a_list. + +to_integer(_) -> + erlang:nif_error(undef). + +%%% End of BIFs + %% Robert's bit %% len(String) diff --git a/lib/stdlib/src/unicode.erl b/lib/stdlib/src/unicode.erl index e9b90befe6..8b9412fb1b 100644 --- a/lib/stdlib/src/unicode.erl +++ b/lib/stdlib/src/unicode.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2011. All Rights Reserved. +%% Copyright Ericsson AB 2008-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -18,13 +18,6 @@ %% -module(unicode). -%% Implemented in the emulator: -%% characters_to_binary/2 (will trap to characters_to_binary_int/2 -%% if InEncoding is not {latin1 | unicode | utf8}) -%% characters_to_list/2 (will trap to characters_to_list_int/2 if -%% InEncoding is not {latin1 | unicode | utf8}) -%% - -export([characters_to_list/1, characters_to_list_int/2, characters_to_binary/1, characters_to_binary_int/2, characters_to_binary/3, @@ -52,6 +45,45 @@ -type latin1_charlist() :: [latin1_char() | latin1_binary() | latin1_charlist()]. +%%% BIFs +%%% +%%% characters_to_binary/2 (will trap to characters_to_binary_int/2 +%%% if InEncoding is not {latin1 | unicode | utf8}) +%%% characters_to_list/2 (will trap to characters_to_list_int/2 if +%%% InEncoding is not {latin1 | unicode | utf8}) + +-export([bin_is_7bit/1, characters_to_binary/2, characters_to_list/2]). + +-spec bin_is_7bit(Binary) -> boolean() when + Binary :: binary(). + +bin_is_7bit(_) -> + erlang:nif_error(undef). + +-spec characters_to_binary(Data, InEncoding) -> Result when + Data :: latin1_chardata() | chardata() | external_chardata(), + InEncoding :: encoding(), + Result :: binary() + | {error, binary(), RestData} + | {incomplete, binary(), binary()}, + RestData :: latin1_chardata() | chardata() | external_chardata(). + +characters_to_binary(_, _) -> + erlang:nif_error(undef). + +-spec characters_to_list(Data, InEncoding) -> Result when + Data :: latin1_chardata() | chardata() | external_chardata(), + InEncoding :: encoding(), + Result :: list() + | {error, list(), RestData} + | {incomplete, list(), binary()}, + RestData :: latin1_chardata() | chardata() | external_chardata(). + +characters_to_list(_, _) -> + erlang:nif_error(undef). + +%%% End of BIFs + -spec characters_to_list(Data) -> Result when Data :: latin1_chardata() | chardata() | external_chardata(), Result :: list() -- cgit v1.2.3