diff options
author | Anders Svensson <[email protected]> | 2011-12-15 15:17:05 +0100 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2011-12-16 18:24:26 +0100 |
commit | 8cfe29ec1757ff7c06585aa9a88b07387ae624d0 (patch) | |
tree | fd2100b38e3889dbb614c178b07d91af19fc0077 /lib | |
parent | 62bea86c803297846430a3aee4279c33016c53ef (diff) | |
download | otp-8cfe29ec1757ff7c06585aa9a88b07387ae624d0.tar.gz otp-8cfe29ec1757ff7c06585aa9a88b07387ae624d0.tar.bz2 otp-8cfe29ec1757ff7c06585aa9a88b07387ae624d0.zip |
Allow module name mapping at dictionary compilation
This is to make the 'inherits' option usable with dictionaries
that inherit specific AVPs. Something like "diameterc -inherts from/to"
effectively replaces "@inherits from" in the source dictionary with
"@inherits to".
Diffstat (limited to 'lib')
-rw-r--r-- | lib/diameter/src/compiler/diameter_dict_util.erl | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/diameter/src/compiler/diameter_dict_util.erl b/lib/diameter/src/compiler/diameter_dict_util.erl index 6098656f03..36a6efa294 100644 --- a/lib/diameter/src/compiler/diameter_dict_util.erl +++ b/lib/diameter/src/compiler/diameter_dict_util.erl @@ -630,13 +630,28 @@ reset(K, Dict, Opts) -> opt({inherits = Key, "-"}, Dict) -> dict:erase(Key, Dict); + opt({inherits = Key, Mod}, Dict) -> - dict:append(Key, [0, {word, 0, Mod}], Dict); + case lists:splitwith(fun(C) -> C /= $/ end, Mod) of + {Mod, ""} -> + dict:append(Key, [0, {word, 0, Mod}], Dict); + {From, [$/|To]} -> + dict:store(Key, + [reinherit(From, To, M) || M <- find(Key, Dict)], + Dict) + end; + opt({Key, Val}, Dict) -> dict:store(Key, [[0, {word, 0, Val}]], Dict); + opt(_, Dict) -> Dict. +reinherit(From, To, [L, {word, _, From} = T | Avps]) -> + [L, setelement(3, T, To) | Avps]; +reinherit(_, _, T) -> + T. + %% =========================================================================== %% pass1/1 %% |