25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

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])
fi
ERLANG_DEPRECATED_TYPES_CHECK
AC_SUBST(hipe)
AC_SUBST(roster_gateway_workaround)
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"
%% If the ejabberd application description isn't loaded, returns atom: undefined
-ifndef(EJABBERD_HRL).
-define(EJABBERD_HRL, true).
-define(VERSION, ejabberd_config:get_version()).
-define(MYHOSTS, ejabberd_config:get_myhosts()).
@ -49,3 +50,21 @@
-type scram() :: #scram{}.
-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(SETS, gb_sets).
@ -26,7 +28,7 @@
-record(lqueue,
{
queue :: queue(),
queue :: ?TQUEUE,
len :: integer(),
max :: integer()
}).
@ -58,8 +60,8 @@
voice_request_min_interval = 1800 :: non_neg_integer(),
max_users = ?MAX_USERS_DEFAULT :: non_neg_integer() | none,
logging = false :: boolean(),
vcard = <<"">> :: boolean(),
captcha_whitelist = (?SETS):empty() :: gb_set()
vcard = <<"">> :: binary(),
captcha_whitelist = (?SETS):empty() :: ?TGB_SET
}).
-type config() :: #config{}.
@ -92,18 +94,18 @@
access = {none,none,none,none} :: {atom(), atom(), atom(), atom()},
jid = #jid{} :: jid(),
config = #config{} :: config(),
users = (?DICT):new() :: dict(),
users = (?DICT):new() :: ?TDICT,
last_voice_request_time = treap:empty() :: treap:treap(),
robots = (?DICT):new() :: dict(),
nicks = (?DICT):new() :: dict(),
affiliations = (?DICT):new() :: dict(),
robots = (?DICT):new() :: ?TDICT,
nicks = (?DICT):new() :: ?TDICT,
affiliations = (?DICT):new() :: ?TDICT,
history :: lqueue(),
subject = <<"">> :: binary(),
subject_author = <<"">> :: binary(),
just_created = false :: boolean(),
activity = treap:empty() :: treap:treap(),
room_shaper = none :: shaper:shaper(),
room_queue = queue:new() :: queue()
room_queue = queue:new() :: ?TQUEUE
}).
-record(muc_online_users, {us = {<<>>, <<>>} :: {binary(), binary()},

View File

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

View File

@ -84,3 +84,20 @@ EOF
AC_MSG_RESULT([ok])
fi
]) 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'}];
({lager, true}) ->
[{d, 'LAGER'}];
({erlang_deprecated_types, true}) ->
[{d, 'ERL_DEPRECATED_TYPES'}];
(_) ->
[]
end, Cfg),

View File

@ -62,7 +62,7 @@
start_interval = 0 :: non_neg_integer(),
host = <<"">> :: binary(),
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).

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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