aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2011-08-24 16:53:13 +0200
committerAnders Svensson <[email protected]>2011-08-24 16:53:13 +0200
commitf7250e531db57154f77d1e37d7a317d1bd18b616 (patch)
tree436c3eed8bad65e29b0d4136cda2e1108baa2666 /lib
parent3536111957c809976ed3e7091e85960990be904d (diff)
parent46bcbf8b8c5e53d3b9aaa1be987947fc0b927f8d (diff)
downloadotp-f7250e531db57154f77d1e37d7a317d1bd18b616.tar.gz
otp-f7250e531db57154f77d1e37d7a317d1bd18b616.tar.bz2
otp-f7250e531db57154f77d1e37d7a317d1bd18b616.zip
Merge branch 'anders/diameter/optional_appid_in_spec/OTP-9467' into dev
* anders/diameter/optional_appid_in_spec/OTP-9467: @id required in dictionary files only when @messages is specified.
Diffstat (limited to 'lib')
-rw-r--r--lib/diameter/doc/src/diameter_dict.xml3
-rw-r--r--lib/diameter/src/compiler/diameter_codegen.erl17
2 files changed, 15 insertions, 5 deletions
diff --git a/lib/diameter/doc/src/diameter_dict.xml b/lib/diameter/doc/src/diameter_dict.xml
index a87f59bad5..749b518a06 100644
--- a/lib/diameter/doc/src/diameter_dict.xml
+++ b/lib/diameter/doc/src/diameter_dict.xml
@@ -105,7 +105,7 @@ quantity is insignificant.</p>
<p>
The tags, their arguments and the contents of each corresponding
section are as follows.
-Each section can occur only once unless otherwise specified.
+Each section can occur at most once unless otherwise specified.
The order in which sections are specified is unimportant.</p>
<taglist>
@@ -115,6 +115,7 @@ The order in which sections are specified is unimportant.</p>
<p>
Defines the integer Number as the Diameter Application Id of the
application in question.
+Required if the dictionary defines <c>@messages</c>.
The section has empty content.</p>
<p>
diff --git a/lib/diameter/src/compiler/diameter_codegen.erl b/lib/diameter/src/compiler/diameter_codegen.erl
index 213ba0d22c..6895f38248 100644
--- a/lib/diameter/src/compiler/diameter_codegen.erl
+++ b/lib/diameter/src/compiler/diameter_codegen.erl
@@ -250,9 +250,14 @@ f_name(Name) ->
%%% ------------------------------------------------------------------------
f_id(Spec) ->
- Id = orddict:fetch(id, Spec),
{?function, id, 0,
- [{?clause, [], [], [?INTEGER(Id)]}]}.
+ [c_id(orddict:find(id, Spec))]}.
+
+c_id({ok, Id}) ->
+ {?clause, [], [], [?INTEGER(Id)]};
+
+c_id(error) ->
+ ?UNEXPECTED(0).
%%% ------------------------------------------------------------------------
%%% # vendor_id/0
@@ -537,10 +542,14 @@ f_msg_header(Spec) ->
{?function, msg_header, 1, msg_header(Spec) ++ [?UNEXPECTED(1)]}.
msg_header(Spec) ->
+ msg_header(get_value(messages, Spec), Spec).
+
+msg_header([], _) ->
+ [];
+msg_header(Msgs, Spec) ->
ApplId = orddict:fetch(id, Spec),
- lists:map(fun({M,C,F,_,_}) -> c_msg_header(M, C, F, ApplId) end,
- get_value(messages, Spec)).
+ lists:map(fun({M,C,F,_,_}) -> c_msg_header(M, C, F, ApplId) end, Msgs).
%% Note that any application id in the message header spec is ignored.