Skip to content

Commit

Permalink
Merge branch 'anders/diameter/optional_appid_in_spec/OTP-9467' into dev
Browse files Browse the repository at this point in the history
* anders/diameter/optional_appid_in_spec/OTP-9467:
  @id required in dictionary files only when @messages is specified.
  • Loading branch information
Anders Svensson committed Aug 24, 2011
2 parents 3536111 + 46bcbf8 commit f7250e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/diameter/doc/src/diameter_dict.xml
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
17 changes: 13 additions & 4 deletions lib/diameter/src/compiler/diameter_codegen.erl
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit f7250e5

Please sign in to comment.