diff options
author | Anders Svensson <[email protected]> | 2011-10-14 14:59:27 +0200 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2011-10-17 12:26:47 +0200 |
commit | 7352ec2c7d3f52a44b8bc18642dadfdc160209a5 (patch) | |
tree | da9f15d14d691645a81673e9ded6f83ce7a0ba0e /lib/diameter/src | |
parent | 1327c7c7d098a7593e5458bc5c06fd9459e73de3 (diff) | |
download | otp-7352ec2c7d3f52a44b8bc18642dadfdc160209a5.tar.gz otp-7352ec2c7d3f52a44b8bc18642dadfdc160209a5.tar.bz2 otp-7352ec2c7d3f52a44b8bc18642dadfdc160209a5.zip |
Allow @inherits to be set/cleared with diameterc
This is to enable dictionaries compiled with --name/--prefix
to be inherited using --inherits.
Diffstat (limited to 'lib/diameter/src')
-rw-r--r-- | lib/diameter/src/compiler/diameter_spec_util.erl | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/diameter/src/compiler/diameter_spec_util.erl b/lib/diameter/src/compiler/diameter_spec_util.erl index e62ba05427..62536bf06d 100644 --- a/lib/diameter/src/compiler/diameter_spec_util.erl +++ b/lib/diameter/src/compiler/diameter_spec_util.erl @@ -38,7 +38,7 @@ parse(Path, Opts) -> put({?MODULE, verbose}, lists:member(verbose, Opts)), {ok, B} = file:read_file(Path), Chunks = chunk(B), - Spec = reset(make_spec(Chunks), Opts, [name, prefix]), + Spec = reset(make_spec(Chunks), Opts, [name, prefix, inherits]), true = groups_defined(Spec), %% sanity checks true = customs_defined(Spec), %% Full = import_enums(import_groups(import_avps(insert_codes(Spec), Opts))), @@ -47,12 +47,22 @@ parse(Path, Opts) -> Full. reset(Spec, Opts, Keys) -> - lists:foldl(fun(K,S) -> reset(lists:keyfind(K, 1, Opts), S) end, + lists:foldl(fun(K,S) -> + reset([{A,?ATOM(V)} || {A,V} <- Opts, A == K], S) + end, Spec, Keys). -reset({Key, Str}, Spec) -> - orddict:store(Key, ?ATOM(Str), Spec); +reset(L, Spec) + when is_list(L) -> + lists:foldl(fun reset/2, Spec, L); + +reset({inherits = Key, '-'}, Spec) -> + orddict:erase(Key, Spec); +reset({inherits = Key, Dict}, Spec) -> + orddict:append(Key, Dict, Spec); +reset({Key, Atom}, Spec) -> + orddict:store(Key, Atom, Spec); reset(_, Spec) -> Spec. |