Add compatibility macros for deprecated types (thanks to Alexey)

This commit is contained in:
Christophe Romain 2015-02-11 12:08:16 +01:00
parent d8b048663d
commit 0c0947a241
14 changed files with 65 additions and 19 deletions

View File

@ -235,6 +235,8 @@ if test "$ENABLEUSER" != ""; then
AC_SUBST([INSTALLUSER], [$ENABLEUSER]) AC_SUBST([INSTALLUSER], [$ENABLEUSER])
fi fi
ERLANG_DEPRECATED_TYPES_CHECK
AC_SUBST(hipe) AC_SUBST(hipe)
AC_SUBST(roster_gateway_workaround) AC_SUBST(roster_gateway_workaround)
AC_SUBST(transient_supervisors) AC_SUBST(transient_supervisors)

View File

@ -18,8 +18,9 @@
%%% %%%
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%% This macro returns a string of the ejabberd version running, e.g. "2.3.4" -ifndef(EJABBERD_HRL).
%% If the ejabberd application description isn't loaded, returns atom: undefined -define(EJABBERD_HRL, true).
-define(VERSION, ejabberd_config:get_version()). -define(VERSION, ejabberd_config:get_version()).
-define(MYHOSTS, ejabberd_config:get_myhosts()). -define(MYHOSTS, ejabberd_config:get_myhosts()).
@ -49,3 +50,21 @@
-type scram() :: #scram{}. -type scram() :: #scram{}.
-define(SCRAM_DEFAULT_ITERATION_COUNT, 4096). -define(SCRAM_DEFAULT_ITERATION_COUNT, 4096).
-ifdef(ERL_DEPRECATED_TYPES).
-define(TDICT, dict()).
-define(TGB_TREE, gb_tree()).
-define(TGB_SET, gb_set()).
-define(TQUEUE, queue()).
-else.
-define(TDICT, dict:dict()).
-define(TGB_TREE, gb_trees:tree()).
-define(TGB_SET, gb_set:set()).
-define(TQUEUE, queue:queue()).
-endif.
-endif.

View File

@ -18,6 +18,8 @@
%%% %%%
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
-include("ejabberd.hrl").
-define(MAX_USERS_DEFAULT, 200). -define(MAX_USERS_DEFAULT, 200).
-define(SETS, gb_sets). -define(SETS, gb_sets).
@ -26,7 +28,7 @@
-record(lqueue, -record(lqueue,
{ {
queue :: queue(), queue :: ?TQUEUE,
len :: integer(), len :: integer(),
max :: integer() max :: integer()
}). }).
@ -58,8 +60,8 @@
voice_request_min_interval = 1800 :: non_neg_integer(), voice_request_min_interval = 1800 :: non_neg_integer(),
max_users = ?MAX_USERS_DEFAULT :: non_neg_integer() | none, max_users = ?MAX_USERS_DEFAULT :: non_neg_integer() | none,
logging = false :: boolean(), logging = false :: boolean(),
vcard = <<"">> :: boolean(), vcard = <<"">> :: binary(),
captcha_whitelist = (?SETS):empty() :: gb_set() captcha_whitelist = (?SETS):empty() :: ?TGB_SET
}). }).
-type config() :: #config{}. -type config() :: #config{}.
@ -92,18 +94,18 @@
access = {none,none,none,none} :: {atom(), atom(), atom(), atom()}, access = {none,none,none,none} :: {atom(), atom(), atom(), atom()},
jid = #jid{} :: jid(), jid = #jid{} :: jid(),
config = #config{} :: config(), config = #config{} :: config(),
users = (?DICT):new() :: dict(), users = (?DICT):new() :: ?TDICT,
last_voice_request_time = treap:empty() :: treap:treap(), last_voice_request_time = treap:empty() :: treap:treap(),
robots = (?DICT):new() :: dict(), robots = (?DICT):new() :: ?TDICT,
nicks = (?DICT):new() :: dict(), nicks = (?DICT):new() :: ?TDICT,
affiliations = (?DICT):new() :: dict(), affiliations = (?DICT):new() :: ?TDICT,
history :: lqueue(), history :: lqueue(),
subject = <<"">> :: binary(), subject = <<"">> :: binary(),
subject_author = <<"">> :: binary(), subject_author = <<"">> :: binary(),
just_created = false :: boolean(), just_created = false :: boolean(),
activity = treap:empty() :: treap:treap(), activity = treap:empty() :: treap:treap(),
room_shaper = none :: shaper:shaper(), room_shaper = none :: shaper:shaper(),
room_queue = queue:new() :: queue() room_queue = queue:new() :: ?TQUEUE
}). }).
-record(muc_online_users, {us = {<<>>, <<>>} :: {binary(), binary()}, -record(muc_online_users, {us = {<<>>, <<>>} :: {binary(), binary()},

View File

@ -23,6 +23,8 @@
%%% This file contains pubsub types definition. %%% This file contains pubsub types definition.
%%% ==================================================================== %%% ====================================================================
-include("ejabberd.hrl").
%% ------------------------------- %% -------------------------------
%% Pubsub constants %% Pubsub constants
-define(ERR_EXTENDED(E, C), -define(ERR_EXTENDED(E, C),

View File

@ -84,3 +84,20 @@ EOF
AC_MSG_RESULT([ok]) AC_MSG_RESULT([ok])
fi fi
]) dnl ERLANG_VERSION_CHECK ]) dnl ERLANG_VERSION_CHECK
AC_DEFUN([ERLANG_DEPRECATED_TYPES_CHECK],
[ AC_MSG_CHECKING([whether Erlang is using deprecated types])
cat > conftest.erl <<EOF
-module(conftest).
-record(state, {host = dict:new() :: dict:dict()}).
EOF
if $ERLC conftest.erl > /dev/null 2>&1; then
AC_MSG_RESULT([no])
AC_SUBST(erlang_deprecated_types, false)
else
AC_MSG_RESULT([yes])
AC_SUBST(erlang_deprecated_types, true)
fi
])

View File

@ -24,6 +24,8 @@ Macros = lists:flatmap(
[{d, 'mssql'}]; [{d, 'mssql'}];
({lager, true}) -> ({lager, true}) ->
[{d, 'LAGER'}]; [{d, 'LAGER'}];
({erlang_deprecated_types, true}) ->
[{d, 'ERL_DEPRECATED_TYPES'}];
(_) -> (_) ->
[] []
end, Cfg), end, Cfg),

View File

@ -62,7 +62,7 @@
start_interval = 0 :: non_neg_integer(), start_interval = 0 :: non_neg_integer(),
host = <<"">> :: binary(), host = <<"">> :: binary(),
max_pending_requests_len :: non_neg_integer(), max_pending_requests_len :: non_neg_integer(),
pending_requests = {0, queue:new()} :: {non_neg_integer(), queue()}}). pending_requests = {0, queue:new()} :: {non_neg_integer(), ?TQUEUE}}).
-define(STATE_KEY, ejabberd_odbc_state). -define(STATE_KEY, ejabberd_odbc_state).

View File

@ -58,7 +58,7 @@
server = <<"">> :: binary(), server = <<"">> :: binary(),
authenticated = false :: boolean(), authenticated = false :: boolean(),
auth_domain = <<"">> :: binary(), auth_domain = <<"">> :: binary(),
connections = (?DICT):new() :: dict(), connections = (?DICT):new() :: ?TDICT,
timer = make_ref() :: reference()}). timer = make_ref() :: reference()}).
%-define(DBGFSM, true). %-define(DBGFSM, true).

View File

@ -77,7 +77,7 @@
try_auth = true :: boolean(), try_auth = true :: boolean(),
myname = <<"">> :: binary(), myname = <<"">> :: binary(),
server = <<"">> :: binary(), server = <<"">> :: binary(),
queue = queue:new() :: queue(), queue = queue:new() :: ?TQUEUE,
delay_to_retry = undefined_delay :: undefined_delay | non_neg_integer(), delay_to_retry = undefined_delay :: undefined_delay | non_neg_integer(),
new = false :: false | binary(), new = false :: false | binary(),
verify = false :: false | {pid(), binary(), binary()}, verify = false :: false | {pid(), binary(), binary()},

View File

@ -139,8 +139,8 @@
passwd = <<"">> :: binary(), passwd = <<"">> :: binary(),
id = 0 :: non_neg_integer(), id = 0 :: non_neg_integer(),
bind_timer = make_ref() :: reference(), bind_timer = make_ref() :: reference(),
dict = dict:new() :: dict(), dict = dict:new() :: ?TDICT,
req_q = queue:new() :: queue()}). req_q = queue:new() :: ?TQUEUE}).
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% API %%% API

View File

@ -57,6 +57,7 @@
%% TODO: Remove once XEP-0091 is Obsolete %% TODO: Remove once XEP-0091 is Obsolete
%% TODO: Remove once XEP-0091 is Obsolete %% TODO: Remove once XEP-0091 is Obsolete
-include("ejabberd.hrl").
-include("jlib.hrl"). -include("jlib.hrl").
-export_type([jid/0]). -export_type([jid/0]).
@ -972,7 +973,7 @@ i2l(L, N) when is_binary(L) ->
_ -> i2l(<<$0, L/binary>>, N) _ -> i2l(<<$0, L/binary>>, N)
end. end.
-spec queue_drop_while(fun((term()) -> boolean()), queue()) -> queue(). -spec queue_drop_while(fun((term()) -> boolean()), ?TQUEUE) -> ?TQUEUE.
queue_drop_while(F, Q) -> queue_drop_while(F, Q) ->
case queue:peek(Q) of case queue:peek(Q) of

View File

@ -51,12 +51,12 @@
encoding = <<"">> :: binary(), encoding = <<"">> :: binary(),
port = 0 :: inet:port_number(), port = 0 :: inet:port_number(),
password = <<"">> :: binary(), password = <<"">> :: binary(),
queue = queue:new() :: queue(), queue = queue:new() :: ?TQUEUE,
user = #jid{} :: jid(), user = #jid{} :: jid(),
host = <<"">> :: binary(), host = <<"">> :: binary(),
server = <<"">> :: binary(), server = <<"">> :: binary(),
nick = <<"">> :: binary(), nick = <<"">> :: binary(),
channels = dict:new() :: dict(), channels = dict:new() :: ?TDICT,
nickchannel :: binary(), nickchannel :: binary(),
mod = mod_irc :: atom(), mod = mod_irc :: atom(),
inbuf = <<"">> :: binary(), inbuf = <<"">> :: binary(),

View File

@ -63,7 +63,7 @@
send_pings = ?DEFAULT_SEND_PINGS :: boolean(), send_pings = ?DEFAULT_SEND_PINGS :: boolean(),
ping_interval = ?DEFAULT_PING_INTERVAL :: non_neg_integer(), ping_interval = ?DEFAULT_PING_INTERVAL :: non_neg_integer(),
timeout_action = none :: none | kill, timeout_action = none :: none | kill,
timers = (?DICT):new() :: dict()}). timers = (?DICT):new() :: ?TDICT}).
%%==================================================================== %%====================================================================
%% API %% API

View File

@ -14,6 +14,7 @@
{db_type, @db_type@}. {db_type, @db_type@}.
{debug, @debug@}. {debug, @debug@}.
{hipe, @hipe@}. {hipe, @hipe@}.
{erlang_deprecated_types, @erlang_deprecated_types@}.
%% Ad-hoc directories with source files %% Ad-hoc directories with source files
{tools, @tools@}. {tools, @tools@}.