diff options
Diffstat (limited to 'lib')
73 files changed, 4035 insertions, 1888 deletions
diff --git a/lib/asn1/doc/src/asn1ct.xml b/lib/asn1/doc/src/asn1ct.xml index 9c04956e86..8a0ae52c39 100644 --- a/lib/asn1/doc/src/asn1ct.xml +++ b/lib/asn1/doc/src/asn1ct.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1997</year><year>2009</year> + <year>1997</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>asn1ct</title> @@ -52,9 +52,11 @@ <v>Options = [Option| OldOption]</v> <v>Option = ber_bin | per_bin | uper_bin | der | compact_bit_string | noobj | {n2n,EnumTypeName} |{outdir,Dir} | {i,IncludeDir} | optimize | - driver | asn1config | undec_rest | {inline,OutputName} | inline</v> + driver | asn1config | undec_rest | {inline,OutputName} | inline | + {macro_name_prefix, Prefix} | {record_name_prefix, Prefix}</v> <v>OldOption = ber | per</v> <v>Reason = term()</v> + <v>Prefix = string()</v> </type> <desc> <p>Compiles the ASN.1 module <c>Asn1module</c> and generates an @@ -270,6 +272,18 @@ Binary = binary() It is as <c>{inline,OutputName}</c>, but the output file gets the default name of the source <c>.set.asn</c> file.</p> </item> + <tag><c>{macro_name_prefix, Prefix}</c></tag> + <item> + <p>All macro names generated by the compiler are prefixed with + <c>Prefix</c>. This is useful when multiple protocols that contains + macros with identical names are included in a single module.</p> + </item> + <tag><c>{record_name_prefix, Prefix}</c></tag> + <item> + <p>All record names generated by the compiler are prefixed with + <c>Prefix</c>. This is useful when multiple protocols that contains + records with identical names are included in a single module.</p> + </item> </taglist> <p>Any additional option that is applied will be passed to the final step when the generated .erl file is compiled. diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl index fefb92bb34..b9f6c46b53 100644 --- a/lib/asn1/src/asn1ct_gen.erl +++ b/lib/asn1/src/asn1ct_gen.erl @@ -1,26 +1,26 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% -module(asn1ct_gen). -include("asn1_records.hrl"). -%%-compile(export_all). + -export([pgen_exports/3, pgen_hrl/4, gen_head/3, @@ -1301,8 +1301,8 @@ put_chars(undefined,X) -> put_chars(Y,X) -> io:put_chars(Y,X). -fopen(F, Mode) -> - case file:open(F, Mode) of +fopen(F, ModeList) -> + case file:open(F, ModeList) of {ok, Fd} -> Fd; {error, Reason} -> @@ -1357,7 +1357,8 @@ pgen_hrltypes(Erules,Module,[H|T],NumRecords) -> %% Generates a macro for value Value defined in the ASN.1 module gen_macro(Value) when is_record(Value,valuedef) -> - emit({"-define('",Value#valuedef.name,"', ", + Prefix = get_macro_name_prefix(), + emit({"-define('",Prefix,Value#valuedef.name,"', ", {asis,Value#valuedef.value},").",nl}). %% Generate record functions ************** @@ -2064,3 +2065,11 @@ get_record_name_prefix() -> {value,{_,Prefix}} -> Prefix end. + +get_macro_name_prefix() -> + case lists:keysearch(macro_name_prefix,1,get(encoding_options)) of + false -> + ""; + {value,{_,Prefix}} -> + Prefix + end. diff --git a/lib/asn1/src/asn1rt_ber_bin.erl b/lib/asn1/src/asn1rt_ber_bin.erl index 71d78377d4..ab04d981b0 100644 --- a/lib/asn1/src/asn1rt_ber_bin.erl +++ b/lib/asn1/src/asn1rt_ber_bin.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2000-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2000-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -179,7 +179,7 @@ restbytes2(_RemBytes,Bytes,noext) -> exit({error,{asn1, {unexpected,Bytes}}}); restbytes2(RemBytes,Bytes,ext) -> %% {RemBytes,0}. - {RemBytes,size(Bytes)}. + {RemBytes,byte_size(Bytes)}. @@ -256,8 +256,6 @@ skip_ExtensionAdditions(Bytes,Tags,RmB) -> end end. - - %%=============================================================================== %%=============================================================================== %%=============================================================================== @@ -339,7 +337,7 @@ peek_tag(<<PartialTag,Buffer/binary>>, TagAck) -> peek_tag(Buffer,<<TagAck/binary,PartialTag>>); peek_tag(_,TagAck) -> exit({error,{asn1, {invalid_tag,TagAck}}}). -%%peek_tag([Tag|Buffer]) when (Tag band 31) == 31 -> +%%peek_tag([Tag|Buffer]) when (Tag band 31) =:= 31 -> %% [Tag band 2#11011111 | peek_tag(Buffer,[])]; %%%% single tag (tagno < 31) %%peek_tag([Tag|Buffer]) -> @@ -474,8 +472,7 @@ encode_tags2([Tag|Trest], BytesSoFar, LenSoFar) -> encode_tags2([], BytesSoFar, LenSoFar) -> {BytesSoFar,LenSoFar}. -encode_tags1([Tag1, Tag2| Trest], Acc) - when Tag1#tag.type == 'IMPLICIT' -> +encode_tags1([Tag1, Tag2| Trest], Acc) when Tag1#tag.type =:= 'IMPLICIT' -> encode_tags1([Tag1#tag{type=Tag2#tag.type,form=Tag2#tag.form}|Trest],Acc); encode_tags1([Tag1 | Trest], Acc) -> encode_tags1(Trest, [Tag1|Acc]); @@ -483,7 +480,7 @@ encode_tags1([], Acc) -> Acc. % the resulting tags are returned in reverse order encode_one_tag(Bin) when is_binary(Bin) -> - {Bin,size(Bin)}; + {Bin,byte_size(Bin)}; encode_one_tag(#tag{class=Class,number=No,type=Type, form = Form}) -> NewForm = case Type of 'EXPLICIT' -> @@ -506,11 +503,6 @@ encode_one_tag(#tag{class=Class,number=No,type=Type, form = Form}) -> % [encode_tag_val({NewClass, OldForm, NewTagNr}) | Buffer1]. - - - - - %%=============================================================================== %% %% This comment is valid for all the encode/decode functions @@ -533,20 +525,19 @@ encode_one_tag(#tag{class=Class,number=No,type=Type, form = Form}) -> %% This version does not consider Explicit tagging of the open type. It %% is only left because of backward compatibility. encode_open_type(Val) when is_list(Val) -> - {Val,size(list_to_binary(Val))}; + {Val, byte_size(list_to_binary(Val))}; encode_open_type(Val) -> - {Val, size(Val)}. + {Val, byte_size(Val)}. %% encode_open_type(Val, []) when is_list(Val) -> - {Val,size(list_to_binary(Val))}; -encode_open_type(Val,[]) -> - {Val, size(Val)}; + {Val, byte_size(list_to_binary(Val))}; +encode_open_type(Val, []) -> + {Val, byte_size(Val)}; encode_open_type(Val, Tag) when is_list(Val) -> - encode_tags(Tag,Val,size(list_to_binary(Val))); -encode_open_type(Val,Tag) -> - encode_tags(Tag,Val, size(Val)). - + encode_tags(Tag, Val, byte_size(list_to_binary(Val))); +encode_open_type(Val, Tag) -> + encode_tags(Tag, Val, byte_size(Val)). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -652,8 +643,6 @@ decode_boolean2(Buffer, _) -> exit({error,{asn1, {decode_boolean, Buffer}}}). - - %%=========================================================================== %% Integer, ITU_T X.690 Chapter 8.3 @@ -664,7 +653,7 @@ decode_boolean2(Buffer, _) -> %%=========================================================================== encode_integer(C, Val, []) when is_integer(Val) -> - {EncVal,Len}=encode_integer(C, Val), + {EncVal,Len} = encode_integer(C, Val), dotag_universal(?N_INTEGER,EncVal,Len); encode_integer(C, Val, Tag) when is_integer(Val) -> dotag(Tag, ?N_INTEGER, encode_integer(C, Val)); @@ -674,10 +663,9 @@ encode_integer(_, Val, _) -> exit({error,{asn1, {encode_integer, Val}}}). - encode_integer(C, Val, NamedNumberList, Tag) when is_atom(Val) -> - case lists:keysearch(Val, 1, NamedNumberList) of - {value,{_, NewVal}} -> + case lists:keyfind(Val, 1, NamedNumberList) of + {_, NewVal} -> dotag(Tag, ?N_INTEGER, encode_integer(C, NewVal)); _ -> exit({error,{asn1, {encode_integer_namednumber, Val}}}) @@ -688,8 +676,6 @@ encode_integer(C, Val, _NamedNumberList, Tag) -> dotag(Tag, ?N_INTEGER, encode_integer(C, Val)). - - encode_integer(_C, Val) -> Bytes = if @@ -716,7 +702,6 @@ encode_integer_neg(N, Acc) -> %% (Buffer, Range, NamedNumberList, HasTag, TotalLen) -> {Integer, Remain, RemovedBytes} %%=============================================================================== - decode_integer(Buffer, Range, Tags, OptOrMand) -> NewTags = new_tags(Tags,#tag{class=?UNIVERSAL,number=?N_INTEGER}), decode_integer_notag(Buffer, Range, [], NewTags, OptOrMand). @@ -748,8 +733,8 @@ resolve_named_value(Result={Val,Buffer,RemBytes},NamedNumberList) -> case NamedNumberList of [] -> Result; _ -> - NewVal = case lists:keysearch(Val, 2, NamedNumberList) of - {value,{NamedVal, _}} -> + NewVal = case lists:keyfind(Val, 2, NamedNumberList) of + {NamedVal, _} -> NamedVal; _ -> Val @@ -778,10 +763,10 @@ check_integer_constraint(Result={Val, _Buffer,_},Range) -> %% encode enumerated value %%============================================================================ -encode_enumerated(Val, []) when is_integer(Val)-> +encode_enumerated(Val, []) when is_integer(Val) -> {EncVal,Len} = encode_integer(false,Val), dotag_universal(?N_ENUMERATED,EncVal,Len); -encode_enumerated(Val, DoTag) when is_integer(Val)-> +encode_enumerated(Val, DoTag) when is_integer(Val) -> dotag(DoTag, ?N_ENUMERATED, encode_integer(false,Val)); encode_enumerated({Name,Val}, DoTag) when is_atom(Name) -> encode_enumerated(Val, DoTag). @@ -797,11 +782,11 @@ encode_enumerated(C, Val, {NamedNumberList,ExtList}, DoTag) when is_atom(Val) -> end; encode_enumerated(C, Val, NamedNumberList, DoTag) when is_atom(Val) -> - case lists:keysearch(Val, 1, NamedNumberList) of - {value, {_, NewVal}} when DoTag == []-> + case lists:keyfind(Val, 1, NamedNumberList) of + {_, NewVal} when DoTag =:= [] -> {EncVal,Len} = encode_integer(C,NewVal), dotag_universal(?N_ENUMERATED,EncVal,Len); - {value, {_, NewVal}} -> + {_, NewVal} -> dotag(DoTag, ?N_ENUMERATED, encode_integer(C, NewVal)); _ -> exit({error,{asn1, {enumerated_not_in_range, Val}}}) @@ -874,8 +859,8 @@ decode_enumerated_notag(Buffer, Range, NNList, Tags, OptOrMand) -> decode_enumerated1(Val, NamedNumberList) -> %% it must be a named integer - case lists:keysearch(Val, 2, NamedNumberList) of - {value,{NamedVal, _}} -> + case lists:keyfind(Val, 2, NamedNumberList) of + {NamedVal, _} -> NamedVal; _ -> {asn1_enum,Val} @@ -1220,32 +1205,32 @@ encode_bin_bit_string(C,{Unused,BinBits},_NamedBitList,DoTag)-> remove_unused_then_dotag(DoTag,StringType,Unused,BinBits) -> case Unused of - 0 when (size(BinBits) == 0),DoTag==[] -> + 0 when (byte_size(BinBits) =:= 0), DoTag =:= [] -> %% time optimization of next case {[StringType,1,0],3}; - 0 when (size(BinBits) == 0) -> + 0 when (byte_size(BinBits) =:= 0) -> dotag(DoTag,StringType,{<<0>>,1}); - 0 when DoTag==[]-> % time optimization of next case + 0 when DoTag =:= [] -> % time optimization of next case dotag_universal(StringType,[Unused|[BinBits]],size(BinBits)+1); % {LenEnc,Len} = encode_legth(size(BinBits)+1), % {[StringType,LenEnc,[Unused|BinBits]],size(BinBits)+1+Len+1}; 0 -> dotag(DoTag,StringType,<<Unused,BinBits/binary>>); - Num when DoTag == [] -> % time optimization of next case - N = (size(BinBits)-1), + Num when DoTag =:= [] -> % time optimization of next case + N = byte_size(BinBits) - 1, <<BBits:N/binary,LastByte>> = BinBits, dotag_universal(StringType, [Unused,BBits,(LastByte bsr Num) bsl Num], - size(BinBits)+1); + byte_size(BinBits) + 1); % {LenEnc,Len} = encode_legth(size(BinBits)+1), % {[StringType,LenEnc,[Unused,BBits,(LastByte bsr Num) bsl Num], % 1+Len+size(BinBits)+1}; Num -> - N = (size(BinBits)-1), + N = byte_size(BinBits) - 1, <<BBits:N/binary,LastByte>> = BinBits, dotag(DoTag,StringType,{[Unused,binary_to_list(BBits) ++ [(LastByte bsr Num) bsl Num]], - 1+size(BinBits)}) + byte_size(BinBits) + 1}) end. @@ -1291,8 +1276,8 @@ encode_bit_string_named(C, [FirstVal | RestVal], NamedBitList, DoTag) -> get_all_bitposes([{bit,ValPos}|Rest], NamedBitList, Ack) -> get_all_bitposes(Rest, NamedBitList, [ValPos | Ack ]); get_all_bitposes([Val | Rest], NamedBitList, Ack) when is_atom(Val) -> - case lists:keysearch(Val, 1, NamedBitList) of - {value, {_ValName, ValPos}} -> + case lists:keyfind(Val, 1, NamedBitList) of + {_ValName, ValPos} -> get_all_bitposes(Rest, NamedBitList, [ValPos | Ack]); _ -> exit({error,{asn1, {bitstring_namedbit, Val}}}) @@ -1320,10 +1305,6 @@ make_and_set_list(Len, [], XPos) -> [0 | make_and_set_list(Len - 1, [], XPos + 1)]. - - - - %%================================================================= %% Encode bit string for lists of ones and zeroes %%================================================================= @@ -1342,7 +1323,7 @@ encode_bit_string_bits(C, BitListVal, _NamedBitList, DoTag) when is_list(BitList encode_constr_bit_str_bits(Constr,BitListVal,DoTag); Size -> case length(BitListVal) of - BitSize when BitSize == Size -> + BitSize when BitSize =:= Size -> encode_bitstring(BitListVal); BitSize when BitSize < Size -> PaddedList = @@ -1399,7 +1380,7 @@ encode_constr_bit_str_bits({Min,Max},BitListVal,_DoTag) -> %% as the most significant elements followed by padded zero elements pad_bit_list(Size,BitListVal) -> Tail = lists:duplicate(Size,0), - lists:append(BitListVal,Tail). + BitListVal ++ Tail. %%================================================================= %% Do the actual encoding @@ -1513,7 +1494,6 @@ decode_bitstring2(Len, Unused, %% Decode the bitlist to names %%---------------------------------------- - decode_bitstring_NNL(BitList,NamedNumberList) -> decode_bitstring_NNL(BitList,NamedNumberList,0,[]). @@ -1523,15 +1503,15 @@ decode_bitstring_NNL([],_,_No,Result) -> decode_bitstring_NNL([B|BitList],[{Name,No}|NamedNumberList],No,Result) -> if - B == 0 -> + B =:= 0 -> decode_bitstring_NNL(BitList,NamedNumberList,No+1,Result); true -> decode_bitstring_NNL(BitList,NamedNumberList,No+1,[Name|Result]) end; decode_bitstring_NNL([1|BitList],NamedNumberList,No,Result) -> - decode_bitstring_NNL(BitList,NamedNumberList,No+1,[{bit,No}|Result]); + decode_bitstring_NNL(BitList,NamedNumberList,No+1,[{bit,No}|Result]); decode_bitstring_NNL([0|BitList],NamedNumberList,No,Result) -> - decode_bitstring_NNL(BitList,NamedNumberList,No+1,Result). + decode_bitstring_NNL(BitList,NamedNumberList,No+1,Result). %%============================================================================ @@ -1542,18 +1522,18 @@ decode_bitstring_NNL([0|BitList],NamedNumberList,No,Result) -> %% the function does not check this because it takes to much time %%============================================================================ encode_octet_string(_C, OctetList, []) when is_binary(OctetList) -> - dotag_universal(?N_OCTET_STRING,OctetList,size(OctetList)); + dotag_universal(?N_OCTET_STRING,OctetList,byte_size(OctetList)); encode_octet_string(_C, OctetList, DoTag) when is_binary(OctetList) -> - dotag(DoTag, ?N_OCTET_STRING, {OctetList,size(OctetList)}); + dotag(DoTag, ?N_OCTET_STRING, {OctetList,byte_size(OctetList)}); encode_octet_string(_C, OctetList, DoTag) when is_list(OctetList) -> case length(OctetList) of - Len when DoTag == [] -> + Len when DoTag =:= [] -> dotag_universal(?N_OCTET_STRING,OctetList,Len); Len -> dotag(DoTag, ?N_OCTET_STRING, {OctetList,Len}) end; -% encode_octet_string(C, OctetList, DoTag) when is_list(OctetList) -> -% dotag(DoTag, ?N_OCTET_STRING, {OctetList,length(OctetList)}); +%% encode_octet_string(C, OctetList, DoTag) when is_list(OctetList) -> +%% dotag(DoTag, ?N_OCTET_STRING, {OctetList,length(OctetList)}); encode_octet_string(C, {Name,OctetList}, DoTag) when is_atom(Name) -> encode_octet_string(C, OctetList, DoTag). @@ -1565,7 +1545,7 @@ encode_octet_string(C, {Name,OctetList}, DoTag) when is_atom(Name) -> %% Octet string is decoded as a restricted string %%============================================================================ decode_octet_string(Buffer, Range, Tags, TotalLen, OptOrMand) -> -% NewTags = new_tags(HasTag,#tag{class=?UNIVERSAL,number=?N_OCTET_STRING}), +%% NewTags = new_tags(HasTag,#tag{class=?UNIVERSAL,number=?N_OCTET_STRING}), decode_restricted_string(Buffer, Range, ?N_OCTET_STRING, Tags, TotalLen, [], OptOrMand,old). @@ -1753,17 +1733,17 @@ decode_relative_oid_notag(Buffer, Tags, OptOrMand) -> %%============================================================================ encode_restricted_string(_C, OctetList, StringType, []) when is_binary(OctetList) -> - dotag_universal(StringType,OctetList,size(OctetList)); + dotag_universal(StringType, OctetList, byte_size(OctetList)); encode_restricted_string(_C, OctetList, StringType, DoTag) when is_binary(OctetList) -> - dotag(DoTag, StringType, {OctetList, size(OctetList)}); + dotag(DoTag, StringType, {OctetList, byte_size(OctetList)}); encode_restricted_string(_C, OctetList, StringType, []) when is_list(OctetList) -> - dotag_universal(StringType,OctetList,length(OctetList)); + dotag_universal(StringType, OctetList, length(OctetList)); encode_restricted_string(_C, OctetList, StringType, DoTag) when is_list(OctetList) -> dotag(DoTag, StringType, {OctetList, length(OctetList)}); -encode_restricted_string(C,{Name,OctetL},StringType,DoTag) when is_atom(Name)-> +encode_restricted_string(C,{Name,OctetL},StringType,DoTag) when is_atom(Name) -> encode_restricted_string(C, OctetL, StringType, DoTag). %%============================================================================ @@ -1793,23 +1773,21 @@ decode_restricted_string_tag(Buffer, Range, StringType, TagsIn, LenIn, NNList, O LenIn, NNList, OptOrMand, BinOrOld). - - check_and_convert_restricted_string(Val,StringType,Range,NamedNumberList,_BinOrOld) -> {StrLen,NewVal} = case StringType of - ?N_BIT_STRING when NamedNumberList /= [] -> + ?N_BIT_STRING when NamedNumberList =/= [] -> {no_check,Val}; ?N_BIT_STRING when is_list(Val) -> {length(Val),Val}; ?N_BIT_STRING when is_tuple(Val) -> {(size(element(2,Val))*8) - element(1,Val),Val}; _ when is_binary(Val) -> - {size(Val),binary_to_list(Val)}; + {byte_size(Val),binary_to_list(Val)}; _ when is_list(Val) -> {length(Val), Val} end, case Range of - _ when StrLen == no_check -> + _ when StrLen =:= no_check -> NewVal; [] -> % No length constraint NewVal; @@ -1832,7 +1810,6 @@ check_and_convert_restricted_string(Val,StringType,Range,NamedNumberList,_BinOrO NewVal end. - %%============================================================================= %% Common routines for several string types including bit string %% handles indefinite length @@ -1840,7 +1817,7 @@ check_and_convert_restricted_string(Val,StringType,Range,NamedNumberList,_BinOrO decode_restricted_string_notag(Buffer, _Range, StringType, TagsIn, - _, NamedNumberList, OptOrMand,BinOrOld) -> + _, NamedNumberList, OptOrMand, BinOrOld) -> %%----------------------------------------------------------- %% Get inner (the implicit tag or no tag) and %% outer (the explicit tag) lengths. @@ -1891,7 +1868,7 @@ decode_restricted_parts(Buffer, RestBytes, [], StringType, RestTags, Len, NNList {concat_bit_binaries(AccVal, Val), AccRb+Rb}; _ when is_binary(Val),is_binary(AccVal) -> {<<AccVal/binary,Val/binary>>,AccRb+Rb}; - _ when is_binary(Val), AccVal==[] -> + _ when is_binary(Val), AccVal =:= [] -> {Val,AccRb+Rb}; _ -> {AccVal++Val, AccRb+Rb} @@ -1977,16 +1954,14 @@ mk_universal_string([A,B,C,D|T],Acc) -> %% encode UTF8 string %%============================================================================ encode_UTF8_string(_,UTF8String,[]) when is_binary(UTF8String) -> - dotag_universal(?N_UTF8String,UTF8String,size(UTF8String)); + dotag_universal(?N_UTF8String,UTF8String,byte_size(UTF8String)); encode_UTF8_string(_,UTF8String,DoTag) when is_binary(UTF8String) -> - dotag(DoTag,?N_UTF8String,{UTF8String,size(UTF8String)}); + dotag(DoTag,?N_UTF8String,{UTF8String,byte_size(UTF8String)}); encode_UTF8_string(_,UTF8String,[]) -> dotag_universal(?N_UTF8String,UTF8String,length(UTF8String)); encode_UTF8_string(_,UTF8String,DoTag) -> dotag(DoTag,?N_UTF8String,{UTF8String,length(UTF8String)}). - - %%============================================================================ %% decode UTF8 string %%============================================================================ @@ -2016,7 +1991,7 @@ decode_UTF8_string_notag(Buffer, Tags, OptOrMand) -> %% encode BMP string %%============================================================================ -encode_BMP_string(C, {Name,BMPString}, DoTag) when is_atom(Name)-> +encode_BMP_string(C, {Name,BMPString}, DoTag) when is_atom(Name) -> encode_BMP_string(C, BMPString, DoTag); encode_BMP_string(_C, BMPString, []) -> OctetList = mk_BMP_list(BMPString), @@ -2464,16 +2439,16 @@ concat_bit_binaries({U1,B1},{U2,B2}) -> S2 = (size(B2) * 8) - U2, PadBits = 8 - ((S1+S2) rem 8), {PadBits, <<B1:S1/binary-unit:1,B2:S2/binary-unit:1,0:PadBits>>}; -concat_bit_binaries(L1,L2) when is_list(L1),is_list(L2) -> +concat_bit_binaries(L1,L2) when is_list(L1), is_list(L2) -> %% this case occur when decoding with NNL L1 ++ L2. get_constraint(C,Key) -> - case lists:keysearch(Key,1,C) of + case lists:keyfind(Key,1,C) of false -> no; - {value,{_,V}} -> + {_, V} -> V end. @@ -2484,7 +2459,7 @@ get_constraint(C,Key) -> new_tags([],LastTag) -> [LastTag]; -new_tags(Tags=[#tag{type='IMPLICIT'}],_LastTag) -> +new_tags(Tags = [#tag{type='IMPLICIT'}],_LastTag) -> Tags; new_tags([T1 = #tag{type='IMPLICIT'},#tag{type=T2Type}|Rest],LastTag) -> new_tags([T1#tag{type=T2Type}|Rest],LastTag); diff --git a/lib/compiler/src/sys_expand_pmod.erl b/lib/compiler/src/sys_expand_pmod.erl index dbd5c1ec2f..4fee26f2a6 100644 --- a/lib/compiler/src/sys_expand_pmod.erl +++ b/lib/compiler/src/sys_expand_pmod.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(sys_expand_pmod). @@ -283,9 +283,13 @@ expr({cons,Line,H0,T0},St) -> T1 = expr(T0,St), {cons,Line,H1,T1}; expr({lc,Line,E0,Qs0},St) -> - Qs1 = lc_quals(Qs0,St), + Qs1 = lc_bc_quals(Qs0,St), E1 = expr(E0,St), {lc,Line,E1,Qs1}; +expr({bc,Line,E0,Qs0},St) -> + Qs1 = lc_bc_quals(Qs0,St), + E1 = expr(E0,St), + {bc,Line,E1,Qs1}; expr({tuple,Line,Es0},St) -> Es1 = expr_list(Es0,St), {tuple,Line,Es1}; @@ -391,14 +395,18 @@ icr_clauses([C0|Cs],St) -> [C1|icr_clauses(Cs,St)]; icr_clauses([],_St) -> []. -lc_quals([{generate,Line,P0,E0}|Qs],St) -> +lc_bc_quals([{generate,Line,P0,E0}|Qs],St) -> + E1 = expr(E0,St), + P1 = pattern(P0,St), + [{generate,Line,P1,E1}|lc_bc_quals(Qs,St)]; +lc_bc_quals([{b_generate,Line,P0,E0}|Qs],St) -> E1 = expr(E0,St), P1 = pattern(P0,St), - [{generate,Line,P1,E1}|lc_quals(Qs,St)]; -lc_quals([E0|Qs],St) -> + [{b_generate,Line,P1,E1}|lc_bc_quals(Qs,St)]; +lc_bc_quals([E0|Qs],St) -> E1 = expr(E0,St), - [E1|lc_quals(Qs,St)]; -lc_quals([],_St) -> []. + [E1|lc_bc_quals(Qs,St)]; +lc_bc_quals([],_St) -> []. fun_clauses([C0|Cs],St) -> C1 = clause(C0,St), diff --git a/lib/compiler/test/pmod_SUITE.erl b/lib/compiler/test/pmod_SUITE.erl index c8919e5539..293e110c45 100644 --- a/lib/compiler/test/pmod_SUITE.erl +++ b/lib/compiler/test/pmod_SUITE.erl @@ -1,31 +1,31 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(pmod_SUITE). -export([all/1,init_per_testcase/2,fin_per_testcase/2, - basic/1]). + basic/1, otp_8447/1]). -include("test_server.hrl"). all(suite) -> test_lib:recompile(?MODULE), - [basic]. + [basic, otp_8447]. init_per_testcase(Case, Config) when is_atom(Case), is_list(Config) -> Dog = test_server:timetrap(?t:minutes(1)), @@ -38,8 +38,8 @@ fin_per_testcase(Case, Config) when is_atom(Case), is_list(Config) -> basic(Config) when is_list(Config) -> ?line basic_1(Config, []), - ?line basic_1(Config, [inline]), - ?line basic_1(Config, [{inline,500}]), +% ?line basic_1(Config, [inline]), +% ?line basic_1(Config, [{inline,500},inline]), ok. basic_1(Config, Opts) -> @@ -78,6 +78,12 @@ basic_1(Config, Opts) -> ok. +otp_8447(Config) when is_list(Config) -> + ?line P = pmod_basic:new(foo), + ?line [0,0,1,1,1,0,0,1] = P:bc1(), + ?line <<10:4>> = P:bc2(), + ok. + compile_load(Module, Conf, Opts) -> ?line Dir = ?config(data_dir,Conf), ?line Src = filename:join(Dir, atom_to_list(Module)), diff --git a/lib/compiler/test/pmod_SUITE_data/pmod_basic.erl b/lib/compiler/test/pmod_SUITE_data/pmod_basic.erl index e6f4c63421..0d46cffe00 100644 --- a/lib/compiler/test/pmod_SUITE_data/pmod_basic.erl +++ b/lib/compiler/test/pmod_SUITE_data/pmod_basic.erl @@ -1,25 +1,26 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(pmod_basic, [Props]). -export([lookup/1,or_props/1,prepend/1,append/1,stupid_sum/0]). -export([bar/1,bar_bar/1]). +-export([bc1/0, bc2/0]). lookup(Key) -> proplists:lookup(Key, Props). @@ -70,3 +71,9 @@ bar(S) when S#s.a == 0 -> ok. bar_bar(S) when is_record(S, s) -> ok; bar_bar(_) -> error. + +bc1() -> + [A || <<A:1>> <= <<"9">> ]. + +bc2() -> + << <<A:1>> || A <- [1,0,1,0] >>. diff --git a/lib/dialyzer/src/Makefile b/lib/dialyzer/src/Makefile index 2521a866f3..810f86dc21 100644 --- a/lib/dialyzer/src/Makefile +++ b/lib/dialyzer/src/Makefile @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2006-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2006-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # #============================================================================= diff --git a/lib/dialyzer/src/dialyzer.app.src b/lib/dialyzer/src/dialyzer.app.src index bd8b79bf21..9222a28a77 100644 --- a/lib/dialyzer/src/dialyzer.app.src +++ b/lib/dialyzer/src/dialyzer.app.src @@ -1,20 +1,20 @@ %% This is an -*- erlang -*- file. %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer.erl b/lib/dialyzer/src/dialyzer.erl index 95955db7e9..3b7b68e8c4 100644 --- a/lib/dialyzer/src/dialyzer.erl +++ b/lib/dialyzer/src/dialyzer.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%----------------------------------------------------------------------- %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer.hrl b/lib/dialyzer/src/dialyzer.hrl index d50b8720f8..2da8ed2e5d 100644 --- a/lib/dialyzer/src/dialyzer.hrl +++ b/lib/dialyzer/src/dialyzer.hrl @@ -1,20 +1,20 @@ %%% This is an -*- Erlang -*- file. %%% %%% %CopyrightBegin% -%%% -%%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%%% +%%% +%%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%%% %%% The contents of this file are subject to the Erlang Public License, %%% Version 1.1, (the "License"); you may not use this file except in %%% compliance with the License. You should have received a copy of the %%% Erlang Public License along with this software. If not, it can be %%% retrieved online at http://www.erlang.org/. -%%% +%%% %%% Software distributed under the License is distributed on an "AS IS" %%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %%% the License for the specific language governing rights and limitations %%% under the License. -%%% +%%% %%% %CopyrightEnd% %%% %%%------------------------------------------------------------------- diff --git a/lib/dialyzer/src/dialyzer_analysis_callgraph.erl b/lib/dialyzer/src/dialyzer_analysis_callgraph.erl index db62dcebac..ab1bbe5ade 100644 --- a/lib/dialyzer/src/dialyzer_analysis_callgraph.erl +++ b/lib/dialyzer/src/dialyzer_analysis_callgraph.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%-------------------------------------------------------------------- %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer_behaviours.erl b/lib/dialyzer/src/dialyzer_behaviours.erl index 61cdcf27c0..4e8dceaa8e 100644 --- a/lib/dialyzer/src/dialyzer_behaviours.erl +++ b/lib/dialyzer/src/dialyzer_behaviours.erl @@ -2,7 +2,7 @@ %%----------------------------------------------------------------------- %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. +%% Copyright Ericsson AB 2010. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in diff --git a/lib/dialyzer/src/dialyzer_callgraph.erl b/lib/dialyzer/src/dialyzer_callgraph.erl index 696d504978..f932f43548 100644 --- a/lib/dialyzer/src/dialyzer_callgraph.erl +++ b/lib/dialyzer/src/dialyzer_callgraph.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%----------------------------------------------------------------------- %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer_cl.erl b/lib/dialyzer/src/dialyzer_cl.erl index 724383d06a..d533e734db 100644 --- a/lib/dialyzer/src/dialyzer_cl.erl +++ b/lib/dialyzer/src/dialyzer_cl.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%------------------------------------------------------------------- %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer_cl_parse.erl b/lib/dialyzer/src/dialyzer_cl_parse.erl index 1f0da012d6..9a522e906a 100644 --- a/lib/dialyzer/src/dialyzer_cl_parse.erl +++ b/lib/dialyzer/src/dialyzer_cl_parse.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%----------------------------------------------------------------------- %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer_codeserver.erl b/lib/dialyzer/src/dialyzer_codeserver.erl index 3b4b66cb68..3bc5fadc21 100644 --- a/lib/dialyzer/src/dialyzer_codeserver.erl +++ b/lib/dialyzer/src/dialyzer_codeserver.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%----------------------------------------------------------------------- %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer_contracts.erl b/lib/dialyzer/src/dialyzer_contracts.erl index bad0a8d8cd..3486c72748 100644 --- a/lib/dialyzer/src/dialyzer_contracts.erl +++ b/lib/dialyzer/src/dialyzer_contracts.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%----------------------------------------------------------------------- %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2007-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2007-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer_dataflow.erl b/lib/dialyzer/src/dialyzer_dataflow.erl index dada88c8bf..a57d9a96c6 100644 --- a/lib/dialyzer/src/dialyzer_dataflow.erl +++ b/lib/dialyzer/src/dialyzer_dataflow.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%-------------------------------------------------------------------- %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer_dep.erl b/lib/dialyzer/src/dialyzer_dep.erl index 7d56376730..febb65b766 100644 --- a/lib/dialyzer/src/dialyzer_dep.erl +++ b/lib/dialyzer/src/dialyzer_dep.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%----------------------------------------------------------------------- %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer_gui_wx.erl b/lib/dialyzer/src/dialyzer_gui_wx.erl index 5b807804e2..2e309d7ec1 100644 --- a/lib/dialyzer/src/dialyzer_gui_wx.erl +++ b/lib/dialyzer/src/dialyzer_gui_wx.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%------------------------------------------------------------------------ %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2009-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer_options.erl b/lib/dialyzer/src/dialyzer_options.erl index 1f587d6df0..da0e1f9aaf 100644 --- a/lib/dialyzer/src/dialyzer_options.erl +++ b/lib/dialyzer/src/dialyzer_options.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%----------------------------------------------------------------------- %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer_plt.erl b/lib/dialyzer/src/dialyzer_plt.erl index fed1e74b33..e387077a46 100644 --- a/lib/dialyzer/src/dialyzer_plt.erl +++ b/lib/dialyzer/src/dialyzer_plt.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%---------------------------------------------------------------------- %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer_races.erl b/lib/dialyzer/src/dialyzer_races.erl index 303e64e68e..4972967960 100644 --- a/lib/dialyzer/src/dialyzer_races.erl +++ b/lib/dialyzer/src/dialyzer_races.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%----------------------------------------------------------------------- %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer_succ_typings.erl b/lib/dialyzer/src/dialyzer_succ_typings.erl index 1670a6cf89..1ff4783852 100644 --- a/lib/dialyzer/src/dialyzer_succ_typings.erl +++ b/lib/dialyzer/src/dialyzer_succ_typings.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%----------------------------------------------------------------------- %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer_typesig.erl b/lib/dialyzer/src/dialyzer_typesig.erl index 57d869b88a..35b283a00a 100644 --- a/lib/dialyzer/src/dialyzer_typesig.erl +++ b/lib/dialyzer/src/dialyzer_typesig.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%----------------------------------------------------------------------- %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/dialyzer/src/dialyzer_utils.erl b/lib/dialyzer/src/dialyzer_utils.erl index d6ddf76956..6ea243c26f 100644 --- a/lib/dialyzer/src/dialyzer_utils.erl +++ b/lib/dialyzer/src/dialyzer_utils.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %%----------------------------------------------------------------------- %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2006-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% diff --git a/lib/docbuilder/vsn.mk b/lib/docbuilder/vsn.mk index 4c782f7481..2852ebcc8b 100644 --- a/lib/docbuilder/vsn.mk +++ b/lib/docbuilder/vsn.mk @@ -1,6 +1,8 @@ -DOCB_VSN = 0.9.8.6 +DOCB_VSN = 0.9.8.7 -TICKETS = OTP-8201 +TICKETS = OTP-8343 + +TICKETS_0.9.8.6 = OTP-8201 TICKETS_0.9.8.5 = OTP-7851 diff --git a/lib/hipe/cerl/erl_bif_types.erl b/lib/hipe/cerl/erl_bif_types.erl index ee0ddd6915..38342870e5 100644 --- a/lib/hipe/cerl/erl_bif_types.erl +++ b/lib/hipe/cerl/erl_bif_types.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2003-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2003-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% ===================================================================== @@ -1771,8 +1771,29 @@ type(erts_debug, disassemble, 1, Xs) -> fun (_) -> t_sup([t_atom('false'), t_atom('undef'), t_tuple([t_integer(), t_binary(), t_mfa()])]) end); +type(erts_debug, dist_ext_to_term, 2, Xs) -> + strict(arg_types(erts_debug, dist_ext_to_term, 2), Xs, + fun (_) -> t_any() end); type(erts_debug, flat_size, 1, Xs) -> strict(arg_types(erts_debug, flat_size, 1), Xs, fun (_) -> t_integer() end); +type(erts_debug, lock_counters, 1, Xs) -> + strict(arg_types(erts_debug, lock_counters, 1), Xs, + fun ([Arg]) -> + case t_is_atom(Arg) of + true -> + case t_atom_vals(Arg) of + ['enabled'] -> t_boolean(); + ['info'] -> t_any(); + ['clear'] -> t_atom(ok); + _ -> t_sup([t_boolean(), t_any(), t_atom('ok')]) + end; + false -> + case t_is_tuple(Arg) of + true -> t_boolean(); + false -> t_sup([t_boolean(), t_any(), t_atom('ok')]) + end + end + end); type(erts_debug, same, 2, Xs) -> strict(arg_types(erts_debug, same, 2), Xs, fun (_) -> t_boolean() end); %%-- ets ---------------------------------------------------------------------- @@ -2672,6 +2693,8 @@ type(os, getenv, 1, Xs) -> type(os, getpid, 0, _) -> t_string(); type(os, putenv, 2, Xs) -> strict(arg_types(os, putenv, 2), Xs, fun (_) -> t_atom('true') end); +type(os, timestamp, 0, _) -> + t_time(); %%-- re ----------------------------------------------------------------------- type(re, compile, 1, Xs) -> strict(arg_types(re, compile, 1), Xs, @@ -3874,8 +3897,16 @@ arg_types(erts_debug, breakpoint, 2) -> [t_tuple([t_atom(), t_atom(), t_sup(t_integer(), t_atom('_'))]), t_boolean()]; arg_types(erts_debug, disassemble, 1) -> [t_sup(t_mfa(), t_integer())]; +arg_types(erts_debug, dist_ext_to_term, 2) -> + [t_tuple(), t_binary()]; arg_types(erts_debug, flat_size, 1) -> [t_any()]; +arg_types(erts_debug, lock_counters, 1) -> + [t_sup([t_atom(enabled), + t_atom(info), + t_atom(clear), + t_tuple([t_atom(copy_save), t_boolean()]), + t_tuple([t_atom(process_locks), t_boolean()])])]; arg_types(erts_debug, same, 2) -> [t_any(), t_any()]; %%------- ets ----------------------------------------------------------------- @@ -4298,6 +4329,8 @@ arg_types(os, getpid, 0) -> []; arg_types(os, putenv, 2) -> [t_string(), t_string()]; +arg_types(os, timestamp, 0) -> + []; %%-- re ----------------------------------------------------------------------- arg_types(re, compile, 1) -> [t_iodata()]; @@ -4916,7 +4949,8 @@ t_inet_setoption_packettype() -> t_integers([0,1,2,4]), t_atom('asn1'), t_atom('cdr'), t_atom('sunrm'), t_atom('fcgi'), t_atom('tpkt'), t_atom('line'), - t_atom('http')]). %% but t_atom('httph') is not needed + t_atom('http'), + t_atom('http_bin')]). %% but t_atom('httph') is not needed t_inet_posix_error() -> t_atom(). %% XXX: Very underspecified diff --git a/lib/hipe/cerl/erl_types.erl b/lib/hipe/cerl/erl_types.erl index 871856da83..b4d80d359a 100644 --- a/lib/hipe/cerl/erl_types.erl +++ b/lib/hipe/cerl/erl_types.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2003-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2003-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% ====================================================================== diff --git a/lib/mnesia/doc/src/notes.xml b/lib/mnesia/doc/src/notes.xml index 69f2185cd8..66242398d9 100644 --- a/lib/mnesia/doc/src/notes.xml +++ b/lib/mnesia/doc/src/notes.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>1996</year><year>2009</year> + <year>1996</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>Mnesia Release Notes</title> @@ -38,6 +38,35 @@ thus constitutes one section in this document. The title of each section is the version number of Mnesia.</p> + <section><title>Mnesia 4.4.13</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> + Transactions could be left hanging if a node went down + when invoking mnesia:sync_transaction/[1,2]. Thanks Igor + Ribeiro Sucupira.</p> + <p> + Own Id: OTP-8402</p> + </item> + </list> + </section> + + + <section><title>Improvements and New Features</title> + <list> + <item> + <p> + Igor Ribeiro Sucupira added the option to compress data + when copying tables between Mnesia nodes.</p> + <p> + Own Id: OTP-8406</p> + </item> + </list> + </section> + + </section> <section><title>Mnesia 4.4.12</title> <section><title>Improvements and New Features</title> diff --git a/lib/mnesia/src/mnesia.appup.src b/lib/mnesia/src/mnesia.appup.src index cad63bf8df..b3b9297db2 100644 --- a/lib/mnesia/src/mnesia.appup.src +++ b/lib/mnesia/src/mnesia.appup.src @@ -1,14 +1,30 @@ %% -*- erlang -*- {"%VSN%", [ + {"4.4.12", + [ + {update, mnesia, soft, soft_purge, soft_purge, []}, + {update, mnesia_loader, soft, soft_purge, soft_purge, []}, + {update, mnesia_monitor, soft, soft_purge, soft_purge, []}, + {update, mnesia_tm, soft, soft_purge, soft_purge, []} + ] + }, {"4.4.11", [ + {update, mnesia, soft, soft_purge, soft_purge, []}, + {update, mnesia_loader, soft, soft_purge, soft_purge, []}, + {update, mnesia_monitor, soft, soft_purge, soft_purge, []}, + {update, mnesia_tm, soft, soft_purge, soft_purge, []}, {update, mnesia_locker, soft, soft_purge, soft_purge, []}, {update, mnesia_controller, soft, soft_purge, soft_purge, []} ] }, {"4.4.10", [ + {update, mnesia, soft, soft_purge, soft_purge, []}, + {update, mnesia_loader, soft, soft_purge, soft_purge, []}, + {update, mnesia_monitor, soft, soft_purge, soft_purge, []}, + {update, mnesia_tm, soft, soft_purge, soft_purge, []}, {update, mnesia_locker, soft, soft_purge, soft_purge, []}, {update, mnesia_controller, soft, soft_purge, soft_purge, []} ] @@ -18,14 +34,30 @@ {"4.4.7", [{restart_application, mnesia}]} ], [ + {"4.4.12", + [ + {update, mnesia, soft, soft_purge, soft_purge, []}, + {update, mnesia_loader, soft, soft_purge, soft_purge, []}, + {update, mnesia_monitor, soft, soft_purge, soft_purge, []}, + {update, mnesia_tm, soft, soft_purge, soft_purge, []} + ] + }, {"4.4.11", [ + {update, mnesia, soft, soft_purge, soft_purge, []}, + {update, mnesia_loader, soft, soft_purge, soft_purge, []}, + {update, mnesia_monitor, soft, soft_purge, soft_purge, []}, + {update, mnesia_tm, soft, soft_purge, soft_purge, []}, {update, mnesia_locker, soft, soft_purge, soft_purge, []}, {update, mnesia_controller, soft, soft_purge, soft_purge, []} ] }, {"4.4.10", [ + {update, mnesia, soft, soft_purge, soft_purge, []}, + {update, mnesia_loader, soft, soft_purge, soft_purge, []}, + {update, mnesia_monitor, soft, soft_purge, soft_purge, []}, + {update, mnesia_tm, soft, soft_purge, soft_purge, []}, {update, mnesia_locker, soft, soft_purge, soft_purge, []}, {update, mnesia_controller, soft, soft_purge, soft_purge, []} ] diff --git a/lib/mnesia/vsn.mk b/lib/mnesia/vsn.mk index 2de3658bf3..f82bd45c72 100644 --- a/lib/mnesia/vsn.mk +++ b/lib/mnesia/vsn.mk @@ -1,7 +1,8 @@ -MNESIA_VSN = 4.4.12 +MNESIA_VSN = 4.4.13 -TICKETS = OTP-8250 +TICKETS = OTP-8402 OTP-8406 OTP-8250 +#TICKETS_4.4.12 = OTP-8250 #TICKETS_4.4.11 = OTP-8074 #TICKETS_4.4.10 = OTP-7928 OTP-7968 OTP-8002 #TICKETS_4.4.9 = OTP-7911 diff --git a/lib/odbc/c_src/odbcserver.c b/lib/odbc/c_src/odbcserver.c index 6a920e6c76..aaaea20a10 100644 --- a/lib/odbc/c_src/odbcserver.c +++ b/lib/odbc/c_src/odbcserver.c @@ -119,6 +119,7 @@ #include <sys/socket.h> #include <sys/uio.h> #include <netdb.h> +#include <netinet/in.h> #endif #include <limits.h> diff --git a/lib/orber/doc/src/ch_install.xml b/lib/orber/doc/src/ch_install.xml index ab5885954b..dde4bf4006 100644 --- a/lib/orber/doc/src/ch_install.xml +++ b/lib/orber/doc/src/ch_install.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>1997</year><year>2009</year> + <year>1997</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>Installing Orber</title> @@ -234,6 +234,16 @@ nodeB@hostB> orber:start(). <cell align="left" valign="middle">0</cell> </row> <row> + <cell align="left" valign="middle">iiop_out_ports_attempts</cell> + <cell align="left" valign="middle">integer() > 0</cell> + <cell align="left" valign="middle">1</cell> + </row> + <row> + <cell align="left" valign="middle">iiop_out_ports_random</cell> + <cell align="left" valign="middle">true | false</cell> + <cell align="left" valign="middle">false</cell> + </row> + <row> <cell align="left" valign="middle">iiop_max_fragments</cell> <cell align="left" valign="middle">integer() > 0 | infinity</cell> <cell align="left" valign="middle">infinity</cell> @@ -506,6 +516,13 @@ nodeB@hostB> orber:start(). If communicating via SSL, make sure you use a version that supports the local <c>{port, Port}</c> option. See also <seealso marker="ch_install#firewall">Firewall Configuration</seealso>.</item> + <tag><em>iiop_out_ports_random</em></tag> + <item>Requires that <c>iiop_out_ports</c> define a port range. If that is the + case Orber will select a port randomly from that sequence.</item> + <tag><em>iiop_out_ports_attempts</em></tag> + <item>Requires that <c>iiop_out_ports</c> define a port range. If so Orber will + accept a number of timeouts, defined by this parameter, when trying to connect + to another ORB.</item> <tag><em>iiop_max_fragments</em></tag> <item>Limits the number of IIOP fragments allowed per request.</item> <tag><em>iiop_max_in_requests</em></tag> diff --git a/lib/orber/doc/src/notes.xml b/lib/orber/doc/src/notes.xml index c7a2dab617..d388cc42a8 100644 --- a/lib/orber/doc/src/notes.xml +++ b/lib/orber/doc/src/notes.xml @@ -40,6 +40,13 @@ <list type="bulleted"> <item> <p> + Added the configuration parameters iiop_out_ports_attempts and + iiop_out_ports_random.</p> + <p> + Own Id: OTP-8448 Aux Id: seq11498</p> + </item> + <item> + <p> Removed obsolete SSL dependency.</p> <p> Own Id: OTP-8374 Aux Id:</p> diff --git a/lib/orber/doc/src/orber.xml b/lib/orber/doc/src/orber.xml index 05036667cc..5e38e4cf9f 100644 --- a/lib/orber/doc/src/orber.xml +++ b/lib/orber/doc/src/orber.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1997</year><year>2009</year> + <year>1997</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>orber</title> @@ -162,13 +162,33 @@ </func> <func> <name>iiop_out_ports() -> 0 | {Min, Max}</name> - <fsummary>Display the ports Orber may use when connecting to another ORB</fsummary> + <fsummary>Display the ports Orber may use when connecting to another ORB</fsummary> <desc> <p>The return value of this operation is what the configuration parameter <seealso marker="ch_install#config">iiop_out_ports</seealso> - have been set to.</p> + has been set to.</p> + </desc> + </func> + + <func> + <name>iiop_out_ports_random() -> true | false</name> + <fsummary>Determine if Orber should select local ports randomly</fsummary> + <desc> + <p>Return the value of the configuration parameter + <seealso marker="ch_install#config">iiop_out_ports_random</seealso>.</p> </desc> </func> + + <func> + <name>iiop_out_ports_attempts() -> int()</name> + <fsummary>Display if Orber should accept more than one timeout connecting to another ORB</fsummary> + <desc> + <p>Return the value of the configuration parameter + <seealso marker="ch_install#config">iiop_out_ports_attempts</seealso>.</p> + </desc> + </func> + + <func> <name>iiop_ssl_port() -> int()</name> <fsummary>Display the IIOP port number used for secure connections</fsummary> diff --git a/lib/orber/src/orber.erl b/lib/orber/src/orber.erl index e9c6822551..c3d37ad1fb 100644 --- a/lib/orber/src/orber.erl +++ b/lib/orber/src/orber.erl @@ -1,20 +1,20 @@ %%-------------------------------------------------------------------- %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -34,7 +34,8 @@ %% External exports %%----------------------------------------------------------------- -export([start/0, start/1, stop/0, install/1, install/2, orber_nodes/0, iiop_port/0, - domain/0, iiop_ssl_port/0, iiop_out_ports/0, + domain/0, iiop_ssl_port/0, iiop_out_ports/0, iiop_out_ports_random/0, + iiop_out_ports_attempts/0, ssl_server_certfile/0, ssl_client_certfile/0, set_ssl_client_certfile/1, ssl_server_verify/0, ssl_client_verify/0, set_ssl_client_verify/1, ssl_server_depth/0, ssl_client_depth/0, set_ssl_client_depth/1, @@ -305,6 +306,12 @@ nat_iiop_port() -> iiop_out_ports() -> orber_env:iiop_out_ports(). +iiop_out_ports_random() -> + orber_env:iiop_out_ports_random(). + +iiop_out_ports_attempts() -> + orber_env:iiop_out_ports_attempts(). + orber_nodes() -> case catch mnesia:table_info(orber_objkeys,ram_copies) of Nodes when is_list(Nodes) -> diff --git a/lib/orber/src/orber_env.erl b/lib/orber/src/orber_env.erl index 79f852eee0..d80edb4ee0 100644 --- a/lib/orber/src/orber_env.erl +++ b/lib/orber/src/orber_env.erl @@ -1,20 +1,20 @@ %%-------------------------------------------------------------------- %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2004-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -43,8 +43,8 @@ -export([iiop_acl/0, iiop_port/0, nat_iiop_port/0, nat_iiop_port/1, iiop_out_ports/0, domain/0, ip_address_variable_defined/0, nat_host/0, nat_host/1, host/0, - ip_address/0, ip_address/1, giop_version/0, iiop_timeout/0, - iiop_connection_timeout/0, iiop_setup_connection_timeout/0, + ip_address/0, ip_address/1, giop_version/0, iiop_timeout/0, iiop_out_ports_random/0, + iiop_connection_timeout/0, iiop_setup_connection_timeout/0, iiop_out_ports_attempts/0, iiop_in_connection_timeout/0, iiop_max_fragments/0, iiop_max_in_requests/0, iiop_max_in_connections/0, iiop_backlog/0, objectkeys_gc_time/0, get_ORBInitRef/0, get_ORBDefaultInitRef/0, get_interceptors/0, @@ -234,6 +234,8 @@ create_main_info() -> "IIOP out connection timeout...: ~p msec~n" "IIOP setup connection timeout.: ~p msec~n" "IIOP out ports................: ~p~n" + "IIOP out ports attempts.......: ~p~n" + "IIOP out ports random.........: ~p~n" "IIOP out connections..........: ~p~n" "IIOP out connections (pending): ~p~n" "IIOP out keepalive............: ~p~n" @@ -256,7 +258,8 @@ create_main_info() -> nat_host(), ip_address_local(), orber:orber_nodes(), Major, Minor, iiop_timeout(), iiop_connection_timeout(), - iiop_setup_connection_timeout(), iiop_out_ports(), + iiop_setup_connection_timeout(), iiop_out_ports(), + iiop_out_ports_attempts(), iiop_out_ports_random(), orber:iiop_connections(out), orber:iiop_connections_pending(), iiop_out_keepalive(), orber:iiop_connections(in), iiop_in_connection_timeout(), iiop_in_keepalive(), @@ -389,6 +392,23 @@ iiop_out_ports() -> 0 end. +iiop_out_ports_random() -> + case application:get_env(orber, iiop_out_ports_random) of + {ok, true} -> + true; + _ -> + false + end. + +iiop_out_ports_attempts() -> + case application:get_env(orber, iiop_out_ports_attempts) of + {ok, No} when is_integer(No) andalso No > 0 -> + No; + _ -> + 1 + end. + + domain() -> case application:get_env(orber, domain) of {ok, Domain} when is_list(Domain) -> @@ -1251,6 +1271,12 @@ configure(nat_ip_address, {local, Value1, Value2}, Status) when is_list(Value1) %% Set the range of ports we may use on this machine when connecting to a server. configure(iiop_out_ports, {Min, Max}, Status) when is_integer(Min) andalso is_integer(Max) -> do_safe_configure(iiop_out_ports, {Min, Max}, Status); +configure(iiop_out_ports_attempts, Max, Status) when is_integer(Max) andalso Max > 0 -> + do_safe_configure(iiop_out_ports_attempts, Max, Status); +configure(iiop_out_ports_random, true, Status) -> + do_safe_configure(iiop_out_ports_random, true, Status); +configure(iiop_out_ports_random, false, Status) -> + do_safe_configure(iiop_out_ports_random, false, Status); %% Set the lightweight option. configure(lightweight, Value, Status) when is_list(Value) -> do_safe_configure(lightweight, Value, Status); diff --git a/lib/orber/src/orber_socket.erl b/lib/orber/src/orber_socket.erl index 2a64bd4e75..af6df01b7d 100644 --- a/lib/orber/src/orber_socket.erl +++ b/lib/orber/src/orber_socket.erl @@ -1,20 +1,20 @@ %%-------------------------------------------------------------------- %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% @@ -82,17 +82,17 @@ connect(Type, Host, Port, Options) -> end, case orber:iiop_out_ports() of {Min, Max} when Type == normal -> - multi_connect(Min, Max, Type, Host, Port, - [binary, {reuseaddr, true}, - {packet,cdr}| Options2], Timeout); + multi_connect(get_port_sequence(Min, Max), orber_env:iiop_out_ports_attempts(), + Type, Host, Port, [binary, {reuseaddr, true}, + {packet,cdr}| Options2], Timeout); {Min, Max} when Generation > 2 -> - multi_connect(Min, Max, Type, Host, Port, - [binary, {reuseaddr, true}, - {packet,cdr}| Options2], Timeout); + multi_connect(get_port_sequence(Min, Max), orber_env:iiop_out_ports_attempts(), + Type, Host, Port, [binary, {reuseaddr, true}, + {packet,cdr}| Options2], Timeout); {Min, Max} -> %% reuseaddr not available for older SSL versions - multi_connect(Min, Max, Type, Host, Port, - [binary, {packet,cdr}| Options2], Timeout); + multi_connect(get_port_sequence(Min, Max), orber_env:iiop_out_ports_attempts(), + Type, Host, Port, [binary, {packet,cdr}| Options2], Timeout); _ -> connect(Type, Host, Port, [binary, {packet,cdr}| Options2], Timeout) end. @@ -130,17 +130,17 @@ connect(ssl, Host, Port, Options, Timeout) -> corba:raise(#'COMM_FAILURE'{completion_status=?COMPLETED_NO}) end. -multi_connect(CurrentPort, Max, Type, Host, Port, Options, _) when CurrentPort > Max -> +multi_connect([], _Retries, Type, Host, Port, Options, _) -> orber:dbg("[~p] orber_socket:multi_connect(~p, ~p, ~p, ~p);~n" "Unable to use any of the sockets defined by 'iiop_out_ports'.~n" "Either all ports are in use or to many connections already exists.", [?LINE, Type, Host, Port, Options], ?DEBUG_LEVEL), corba:raise(#'IMP_LIMIT'{minor=(?ORBER_VMCID bor 1), completion_status=?COMPLETED_NO}); -multi_connect(CurrentPort, Max, normal, Host, Port, Options, Timeout) -> +multi_connect([CurrentPort|Rest], Retries, normal, Host, Port, Options, Timeout) -> case catch gen_tcp:connect(Host, Port, [{port, CurrentPort}|Options], Timeout) of {ok, Socket} -> Socket; - {error, timeout} -> + {error, timeout} when Retries =< 1 -> orber:dbg("[~p] orber_socket:multi_connect(normal, ~p, ~p, ~p);~n" "Timeout after ~p msec.", [?LINE, Host, Port, [{port, CurrentPort}|Options], @@ -148,13 +148,13 @@ multi_connect(CurrentPort, Max, normal, Host, Port, Options, Timeout) -> corba:raise(#'COMM_FAILURE'{minor=(?ORBER_VMCID bor 4), completion_status=?COMPLETED_NO}); _ -> - multi_connect(CurrentPort+1, Max, normal, Host, Port, Options, Timeout) + multi_connect(Rest, Retries - 1, normal, Host, Port, Options, Timeout) end; -multi_connect(CurrentPort, Max, ssl, Host, Port, Options, Timeout) -> +multi_connect([CurrentPort|Rest], Retries, ssl, Host, Port, Options, Timeout) -> case catch ssl:connect(Host, Port, [{port, CurrentPort}|Options], Timeout) of {ok, Socket} -> Socket; - {error, timeout} -> + {error, timeout} when Retries =< 1 -> orber:dbg("[~p] orber_socket:multi_connect(ssl, ~p, ~p, ~p);~n" "Timeout after ~p msec.", [?LINE, Host, Port, [{port, CurrentPort}|Options], @@ -162,10 +162,28 @@ multi_connect(CurrentPort, Max, ssl, Host, Port, Options, Timeout) -> corba:raise(#'COMM_FAILURE'{minor=(?ORBER_VMCID bor 4), completion_status=?COMPLETED_NO}); _ -> - multi_connect(CurrentPort+1, Max, ssl, Host, Port, Options, Timeout) + multi_connect(Rest, Retries - 1, ssl, Host, Port, Options, Timeout) end. +get_port_sequence(Min, Max) -> + case orber_env:iiop_out_ports_random() of + true -> + {A1,A2,A3} = now(), + random:seed(A1, A2, A3), + Seq = lists:seq(Min, Max), + random_sequence((Max - Min) + 1, Seq, []); + _ -> + lists:seq(Min, Max) + end. + +random_sequence(0, _, Acc) -> + Acc; +random_sequence(Length, Seq, Acc) -> + Nth = random:uniform(Length), + Value = lists:nth(Nth, Seq), + NewSeq = lists:delete(Value, Seq), + random_sequence(Length-1, NewSeq, [Value|Acc]). %%----------------------------------------------------------------- %% Create a listen socket at Port in CDR mode for diff --git a/lib/orber/vsn.mk b/lib/orber/vsn.mk index b56172d7cf..d074bfb86c 100644 --- a/lib/orber/vsn.mk +++ b/lib/orber/vsn.mk @@ -4,7 +4,8 @@ ORBER_VSN = 3.6.15 TICKETS = OTP-8353 \ OTP-8354 \ OTP-8374 \ - OTP-8409 + OTP-8409 \ + OTP-8448 TICKETS_3.6.14 = OTP-8201 diff --git a/lib/os_mon/src/cpu_sup.erl b/lib/os_mon/src/cpu_sup.erl index 742e20b1fa..e414e2c10b 100644 --- a/lib/os_mon/src/cpu_sup.erl +++ b/lib/os_mon/src/cpu_sup.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(cpu_sup). @@ -65,15 +65,10 @@ %% Contract specifications %%---------------------------------------------------------------------- --type(util_cpus() :: 'all' | integer() | [integer()]). --type(util_state() :: - 'user' | - 'nice_user' | - 'kernel' | - 'wait' | - 'idle'). --type(util_value() :: {util_state(), float()} | float()). --type(util_desc() :: {util_cpus(), util_value(), util_value(), []}). +-type util_cpus() :: 'all' | integer() | [integer()]. +-type util_state() :: 'user' | 'nice_user' | 'kernel' | 'wait' | 'idle'. +-type util_value() :: {util_state(), float()} | float(). +-type util_desc() :: {util_cpus(), util_value(), util_value(), []}. %%---------------------------------------------------------------------- %% Exported functions @@ -88,28 +83,28 @@ start_link() -> stop() -> gen_server:call(cpu_sup, ?quit, infinity). --spec(nprocs/0 :: () -> integer() | {'error', any()}). +-spec nprocs() -> integer() | {'error', any()}. nprocs() -> os_mon:call(cpu_sup, ?nprocs, infinity). --spec(avg1/0 :: () -> integer() | {'error', any()}). +-spec avg1() -> integer() | {'error', any()}. avg1() -> os_mon:call(cpu_sup, ?avg1, infinity). --spec(avg5/0 :: () -> integer() | {'error', any()}). +-spec avg5() -> integer() | {'error', any()}. avg5() -> os_mon:call(cpu_sup, ?avg5, infinity). --spec(avg15/0 :: () -> integer() | {'error', any()}). +-spec avg15() -> integer() | {'error', any()}. avg15() -> os_mon:call(cpu_sup, ?avg15, infinity). --spec(util/1 :: ([ 'detailed' | 'per_cpu']) -> - util_desc() | [util_desc()] | {'error', any()}). +-spec util(['detailed' | 'per_cpu']) -> + util_desc() | [util_desc()] | {'error', any()}. util(Args) when is_list (Args) -> % Get arguments @@ -126,7 +121,7 @@ util(Args) when is_list (Args) -> util(_) -> erlang:error(badarg). --spec(util/0 :: () -> float()). +-spec util() -> float(). util() -> case util([]) of diff --git a/lib/parsetools/include/yeccpre.hrl b/lib/parsetools/include/yeccpre.hrl index 2ffa13d6a7..33a103d95f 100644 --- a/lib/parsetools/include/yeccpre.hrl +++ b/lib/parsetools/include/yeccpre.hrl @@ -1,52 +1,51 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % The parser generator will insert appropriate declarations before this line.% --type(yecc_ret() :: {'error', _} | {'ok', _}). +-type yecc_ret() :: {'error', _} | {'ok', _}. -spec parse(Tokens :: list()) -> yecc_ret(). parse(Tokens) -> yeccpars0(Tokens, {no_func, no_line}, 0, [], []). --spec(parse_and_scan/1 :: - ({function() | {atom(), atom()}, [_]} | {atom(), atom(), [_]}) -> - yecc_ret()). +-spec parse_and_scan({function() | {atom(), atom()}, [_]} | {atom(), atom(), [_]}) -> + yecc_ret(). parse_and_scan({F, A}) -> % Fun or {M, F} yeccpars0([], {{F, A}, no_line}, 0, [], []); parse_and_scan({M, F, A}) -> yeccpars0([], {{{M, F}, A}, no_line}, 0, [], []). --spec(format_error/1 :: (any()) -> [char() | list()]). +-spec format_error(any()) -> [char() | list()]. format_error(Message) -> case io_lib:deep_char_list(Message) of - true -> - Message; - _ -> - io_lib:write(Message) + true -> + Message; + _ -> + io_lib:write(Message) end. -% To be used in grammar files to throw an error message to the parser -% toplevel. Doesn't have to be exported! --compile({nowarn_unused_function, return_error/2}). --spec(return_error/2 :: (integer(), any()) -> no_return()). +%% To be used in grammar files to throw an error message to the parser +%% toplevel. Doesn't have to be exported! +-compile({nowarn_unused_function,{return_error,2}}). +-spec return_error(integer(), any()) -> no_return(). return_error(Line, Message) -> throw({error, {Line, ?MODULE, Message}}). @@ -85,7 +84,7 @@ yeccpars1([Token | Tokens], Tzr, State, States, Vstack) -> yeccpars1([], {{F, A},_Line}, State, States, Vstack) -> case apply(F, A) of {ok, Tokens, Endline} -> - yeccpars1(Tokens, {{F, A}, Endline}, State, States, Vstack); + yeccpars1(Tokens, {{F, A}, Endline}, State, States, Vstack); {eof, Endline} -> yeccpars1([], {no_func, Endline}, State, States, Vstack); {error, Descriptor, _Endline} -> @@ -118,7 +117,7 @@ yeccpars1(State1, State, States, Vstack, Token0, [], {no_func, Line}) -> yeccpars2(State, '$end', [State1 | States], [Token0 | Vstack], yecc_end(Line), [], {no_func, Line}). -% For internal use only. +%% For internal use only. yecc_end({Line,_Column}) -> {'$end', Line}; yecc_end(Line) -> diff --git a/lib/parsetools/src/yecc.erl b/lib/parsetools/src/yecc.erl index f4d76f471d..b8b2b2308c 100644 --- a/lib/parsetools/src/yecc.erl +++ b/lib/parsetools/src/yecc.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% Yacc like LALR-1 parser generator for Erlang. @@ -30,8 +30,8 @@ -import(lists, [append/1, append/2, concat/1, delete/2, filter/2, flatmap/2, foldl/3, foldr/3, foreach/2, keydelete/3, - keysearch/3, keysort/2, last/1, map/2, member/2, - reverse/1, sort/1, usort/1]). + keysort/2, last/1, map/2, member/2, reverse/1, + sort/1, usort/1]). -include("erl_compile.hrl"). -include("ms_transform.hrl"). @@ -297,18 +297,18 @@ options(Options0, [Key | Keys], L) when is_list(Options0) -> false -> Options0 end, - V = case keysearch(Key, 1, Options) of - {value, {Key, Filename0}} when Key =:= includefile; - Key =:= parserfile -> + V = case lists:keyfind(Key, 1, Options) of + {Key, Filename0} when Key =:= includefile; + Key =:= parserfile -> case is_filename(Filename0) of no -> badarg; Filename -> {ok, [{Key, Filename}]} end; - {value, {Key, Bool}} when Bool =:= true; Bool =:= false -> - {ok, [{Key, Bool}]}; - {value, {Key, _}} -> + {Key, Bool} = KB when is_boolean(Bool) -> + {ok, [KB]}; + {Key, _} -> badarg; false -> {ok, [{Key, default_option(Key)}]} @@ -348,8 +348,7 @@ atom_option(verbose) -> {verbose, true}; atom_option(Key) -> Key. is_filename(T) -> - try filename:flatten(T) of - Filename -> Filename + try filename:flatten(T) catch error: _ -> no end. @@ -366,8 +365,8 @@ shorten_filename(Name0) -> start(Infilex, Options) -> Infile = assure_extension(Infilex, ".yrl"), - {value, {_, Outfilex0}} = keysearch(parserfile, 1, Options), - {value, {_, Includefilex}} = keysearch(includefile, 1, Options), + {_, Outfilex0} = lists:keyfind(parserfile, 1, Options), + {_, Includefilex} = lists:keyfind(includefile, 1, Options), Outfilex = case Outfilex0 of [] -> filename:rootname(Infilex, ".yrl"); _ -> Outfilex0 @@ -715,14 +714,14 @@ names(Symbols) -> map(fun(Symbol) -> Symbol#symbol.name end, Symbols). symbol_line(Name, St) -> - {value, #symbol{line = Line}} = symbol_search(Name, St#yecc.all_symbols), + #symbol{line = Line} = symbol_find(Name, St#yecc.all_symbols), Line. symbol_member(Symbol, Symbols) -> - symbol_search(Symbol#symbol.name, Symbols) =/= false. + symbol_find(Symbol#symbol.name, Symbols) =/= false. -symbol_search(Name, Symbols) -> - keysearch(Name, #symbol.name, Symbols). +symbol_find(Name, Symbols) -> + lists:keyfind(Name, #symbol.name, Symbols). states_and_goto_table(St0) -> St1 = create_symbol_table(St0), @@ -876,8 +875,8 @@ add_warnings(SymNames, W0, St0) -> check_rhs([#symbol{name = '$empty'}], St) -> St; check_rhs(Rhs, St0) -> - case symbol_search('$empty', Rhs) of - {value, #symbol{line = Line}} -> + case symbol_find('$empty', Rhs) of + #symbol{line = Line} -> add_error(Line, illegal_empty, St0); false -> foldl(fun(Sym, St) -> @@ -1096,10 +1095,10 @@ compute_states2([{Sym,Seed} | Seeds], N, Try, CurrState, StateTab, Tables) -> compute_states2(Seeds, N, Try, CurrState, StateTab, Tables); {merge, M, NewCurrent} -> %% io:fwrite(<<"Merging with state ~w\n">>, [M]), - Try1 = case keysearch(M, 1, Try) of + Try1 = case lists:keyfind(M, 1, Try) of false -> [{M, NewCurrent} | Try]; - {value, {_, OldCurrent}} -> + {_, OldCurrent} -> case ordsets:is_subset(NewCurrent, OldCurrent) of true -> Try; diff --git a/lib/parsetools/src/yeccparser.erl b/lib/parsetools/src/yeccparser.erl index 80a6bbce0e..415547b4ce 100644 --- a/lib/parsetools/src/yeccparser.erl +++ b/lib/parsetools/src/yeccparser.erl @@ -16,53 +16,52 @@ line_of(Token) -> -file("/clearcase/otp/erts/lib/parsetools/include/yeccpre.hrl", 0). %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % The parser generator will insert appropriate declarations before this line.% --type(yecc_ret() :: {'error', _} | {'ok', _}). +-type yecc_ret() :: {'error', _} | {'ok', _}. --spec(parse/1 :: (_) -> yecc_ret()). +-spec parse(_) -> yecc_ret(). parse(Tokens) -> yeccpars0(Tokens, false). --spec(parse_and_scan/1 :: - ({function() | {atom(), atom()}, [_]} | {atom(), atom(), [_]}) -> - yecc_ret()). +-spec parse_and_scan({function() | {atom(), atom()}, [_]} | {atom(), atom(), [_]}) -> + yecc_ret(). parse_and_scan({F, A}) -> % Fun or {M, F} yeccpars0([], {F, A}); parse_and_scan({M, F, A}) -> yeccpars0([], {{M, F}, A}). --spec(format_error/1 :: (any()) -> [char() | list()]). +-spec format_error(any()) -> [char() | list()]. format_error(Message) -> case io_lib:deep_char_list(Message) of - true -> - Message; - _ -> - io_lib:write(Message) + true -> + Message; + _ -> + io_lib:write(Message) end. -% To be used in grammar files to throw an error message to the parser -% toplevel. Doesn't have to be exported! +%% To be used in grammar files to throw an error message to the parser +%% toplevel. Doesn't have to be exported! -compile({nowarn_unused_function,{return_error,2}}). --spec(return_error/2 :: (integer(), any()) -> no_return()). +-spec return_error(integer(), any()) -> no_return(). return_error(Line, Message) -> throw({error, {Line, ?MODULE, Message}}). @@ -101,7 +100,7 @@ yeccpars1([Token | Tokens], Tokenizer, State, States, Vstack) -> yeccpars1([], {F, A}, State, States, Vstack) -> case apply(F, A) of {ok, Tokens, _Endline} -> - yeccpars1(Tokens, {F, A}, State, States, Vstack); + yeccpars1(Tokens, {F, A}, State, States, Vstack); {eof, _Endline} -> yeccpars1([], false, State, States, Vstack); {error, Descriptor, _Endline} -> @@ -123,7 +122,7 @@ yeccpars1(State1, State, States, Vstack, Stack1, [Token | Tokens], yeccpars1(State1, State, States, Vstack, Stack1, [], {F, A}) -> case apply(F, A) of {ok, Tokens, _Endline} -> - yeccpars1(State1, State, States, Vstack, Stack1, Tokens, {F, A}); + yeccpars1(State1, State, States, Vstack, Stack1, Tokens, {F, A}); {eof, _Endline} -> yeccpars1(State1, State, States, Vstack, Stack1, [], false); {error, Descriptor, _Endline} -> diff --git a/lib/percept/src/egd.erl b/lib/percept/src/egd.erl index 7972fde597..4fb5b6c46a 100644 --- a/lib/percept/src/egd.erl +++ b/lib/percept/src/egd.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -46,10 +46,10 @@ %% @type color() %% @type render_option() = {render_engine, opaque} | {render_engine, alpha} --type(egd_image() :: pid()). --type(point() :: {non_neg_integer(), non_neg_integer()}). --type(render_option() :: {'render_engine', 'opaque'} | {'render_engine', 'alpha'}). --type(color() :: {float(), float(), float(), float()}). +-type egd_image() :: pid(). +-type point() :: {non_neg_integer(), non_neg_integer()}. +-type render_option() :: {'render_engine', 'opaque'} | {'render_engine', 'alpha'}. +-type color() :: {float(), float(), float(), float()}. %%========================================================================== %% @@ -60,7 +60,7 @@ %% @spec create(integer(), integer()) -> egd_image() %% @doc Creates an image area and returns its reference. --spec(create/2 :: (Width :: integer(), Height :: integer()) -> egd_image()). +-spec create(Width :: integer(), Height :: integer()) -> egd_image(). create(Width,Height) -> spawn_link(fun() -> init(trunc(Width),trunc(Height)) end). @@ -69,16 +69,17 @@ create(Width,Height) -> %% @spec destroy(egd_image()) -> ok %% @doc Destroys the image. --spec(destroy/1 :: (Image :: egd_image()) -> ok). +-spec destroy(Image :: egd_image()) -> ok. destroy(Image) -> cast(Image, destroy), ok. -%% @spec render(egd_image()) -> binary() +%% @spec render(egd_image()) -> binary() %% @equiv render(Image, png, [{render_engine, opaque}]) +-spec render(Image :: egd_image()) -> binary(). render(Image) -> render(Image, png, [{render_engine, opaque}]). @@ -94,10 +95,10 @@ render(Image, Type) -> %% binary can either be a raw bitmap with rgb tripplets or a binary in png %% format. --spec(render/3 :: ( +-spec render( Image :: egd_image(), Type :: 'png' | 'raw_bitmap' | 'eps', - Options :: [render_option()]) -> binary()). + Options :: [render_option()]) -> binary(). render(Image, Type, Options) -> {render_engine, RenderType} = proplists:lookup(render_engine, Options), @@ -116,11 +117,11 @@ information(Pid) -> %% @spec line(egd_image(), point(), point(), color()) -> ok %% @doc Creates a line object from P1 to P2 in the image. --spec(line/4 :: ( +-spec line( Image :: egd_image(), P1 :: point(), P2 :: point(), - Color :: color()) -> 'ok'). + Color :: color()) -> 'ok'. line(Image, P1, P2, Color) -> cast(Image, {line, P1, P2, Color}), @@ -132,9 +133,8 @@ line(Image, P1, P2, Color) -> %% Name = black | silver | gray | white | maroon | red | purple | fuchia | green | lime | olive | yellow | navy | blue | teal | aqua %% @doc Creates a color reference. --spec(color/1 :: ( - Value :: {byte(), byte(), byte()} | {byte(), byte(), byte(), byte()} | atom()) -> - color()). +-spec color(Value :: {byte(), byte(), byte()} | {byte(), byte(), byte(), byte()} | atom()) -> + color(). color(Color) -> egd_primitives:color(Color). diff --git a/lib/percept/src/egd.hrl b/lib/percept/src/egd.hrl index 274986db65..2e8f5ebc50 100644 --- a/lib/percept/src/egd.hrl +++ b/lib/percept/src/egd.hrl @@ -1,24 +1,24 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% --type(rgba_float() :: {float(), float(), float(), float()}). --type(rgba_byte() :: {byte(), byte(), byte(), byte()}). --type(rgb() :: {byte(), byte(), byte()}). +-type rgba_float() :: {float(), float(), float(), float()}. +-type rgba_byte() :: {byte(), byte(), byte(), byte()}. +-type rgb() :: {byte(), byte(), byte()}. -record(image_object, { type, diff --git a/lib/percept/src/egd_render.erl b/lib/percept/src/egd_render.erl index 4a0247dd33..7fd1072ab1 100644 --- a/lib/percept/src/egd_render.erl +++ b/lib/percept/src/egd_render.erl @@ -29,7 +29,8 @@ -include("egd.hrl"). -define('DummyC',0). -binary(Image) -> binary(Image, opaque). +binary(Image) -> + binary(Image, opaque). binary(Image, Type) -> parallel_binary(precompile(Image),Type). @@ -42,9 +43,8 @@ parallel_binary(Image = #image{ height = Height },Type) -> W = Image#image.width, Bg = Image#image.background, Os = Image#image.objects, - erlang:list_to_binary(lists:map(fun - (Y) -> scanline(Y, Os, {0,0,W - 1, Bg}, Type) - end, lists:seq(1, Height))); + erlang:list_to_binary([scanline(Y, Os, {0,0,W - 1, Bg}, Type) + || Y <- lists:seq(1, Height)]); Np -> Pids = start_workers(Np, Type), Handler = handle_workers(Height, Pids), @@ -54,7 +54,9 @@ parallel_binary(Image = #image{ height = Height },Type) -> Res end. -start_workers(Np, Type) -> start_workers(Np, Type, []). +start_workers(Np, Type) -> + start_workers(Np, Type, []). + start_workers( 0, _, Pids) -> Pids; start_workers(Np, Type, Pids) when Np > 0 -> start_workers(Np - 1, Type, [spawn_link(fun() -> worker(Type) end)|Pids]). @@ -90,7 +92,9 @@ init_workers(Image, Handler, [Pid|Pids]) -> Handler ! {Pid, scan_complete}, init_workers(Image, Handler, Pids). -handle_workers(H, Pids) -> spawn_link(fun() -> handle_workers(H, H, length(Pids)) end). +handle_workers(H, Pids) -> + spawn_link(fun() -> handle_workers(H, H, length(Pids)) end). + handle_workers(_, 0, _) -> ok; handle_workers(H, Hi, Np) when H > 0 -> N = trunc(Hi/(2*Np)), @@ -110,7 +114,9 @@ finish_workers([Pid|Pids]) -> Pid ! {self(), done}, finish_workers(Pids). -receive_binaries(H) -> receive_binaries(H, []). +receive_binaries(H) -> + receive_binaries(H, []). + receive_binaries(0, Bins) -> erlang:list_to_binary(Bins); receive_binaries(H, Bins) when H > 0 -> receive @@ -118,7 +124,6 @@ receive_binaries(H, Bins) when H > 0 -> receive_binaries(H - 1, [Bin|Bins]) end. - scanline(Y, Os, {_,_,Width,_}=LSB, Type) -> OLSs = parse_objects_on_line(Y-1, Width, Os), RLSs = resulting_line_spans([LSB|OLSs],Type), @@ -190,7 +195,6 @@ modify_layers(Layers,[{{_,Z,start},C}|Trans]) -> modify_layers(Layers,[{{_,Z,stop },C}|Trans]) -> modify_layers(remove_layer(Layers, Z, C), Trans). - add_layer([{Z1,_}=H|Layers],Z,C) when Z1 > Z -> [H|add_layer(Layers,Z,C)]; add_layer(Layers,Z,C) -> diff --git a/lib/percept/src/percept.erl b/lib/percept/src/percept.erl index af1a920efd..f5e0f7e469 100644 --- a/lib/percept/src/percept.erl +++ b/lib/percept/src/percept.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2007-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2007-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -50,7 +50,7 @@ %% @type percept_option() = procs | ports | exclusive --type(percept_option() :: 'procs' | 'ports' | 'exclusive' | 'scheduler'). +-type percept_option() :: 'procs' | 'ports' | 'exclusive' | 'scheduler'. %%========================================================================== %% @@ -85,8 +85,8 @@ stop(_State) -> %% profiling --spec(profile/1 :: (Filename :: string()) -> - {'ok', port()} | {'already_started', port()}). +-spec profile(Filename :: file:filename()) -> + {'ok', port()} | {'already_started', port()}. profile(Filename) -> percept_profile:start(Filename, [procs]). @@ -94,10 +94,9 @@ profile(Filename) -> %% @spec profile(Filename::string(), [percept_option()]) -> {ok, Port} | {already_started, Port} %% @see percept_profile --spec(profile/2 :: ( - Filename :: string(), - Options :: [percept_option()]) -> - {'ok', port()} | {'already_started', port()}). +-spec profile(Filename :: file:filename(), + Options :: [percept_option()]) -> + {'ok', port()} | {'already_started', port()}. profile(Filename, Options) -> percept_profile:start(Filename, Options). @@ -105,16 +104,15 @@ profile(Filename, Options) -> %% @spec profile(Filename::string(), MFA::mfa(), [percept_option()]) -> ok | {already_started, Port} | {error, not_started} %% @see percept_profile --spec(profile/3 :: ( - Filename :: string(), - Entry :: {atom(), atom(), list()}, - Options :: [percept_option()]) -> - 'ok' | {'already_started', port()} | {'error', 'not_started'}). +-spec profile(Filename :: file:filename(), + Entry :: {atom(), atom(), list()}, + Options :: [percept_option()]) -> + 'ok' | {'already_started', port()} | {'error', 'not_started'}. profile(Filename, MFA, Options) -> percept_profile:start(Filename, MFA, Options). --spec(stop_profile/0 :: () -> 'ok' | {'error', 'not_started'}). +-spec stop_profile() -> 'ok' | {'error', 'not_started'}. %% @spec stop_profile() -> ok | {'error', 'not_started'} %% @see percept_profile @@ -125,8 +123,8 @@ stop_profile() -> %% @spec analyze(string()) -> ok | {error, Reason} %% @doc Analyze file. --spec(analyze/1 :: (Filename :: string()) -> - 'ok' | {'error', any()}). +-spec analyze(Filename :: file:filename()) -> + 'ok' | {'error', any()}. analyze(Filename) -> case percept_db:start() of @@ -142,9 +140,8 @@ analyze(Filename) -> %% Reason = term() %% @doc Starts webserver. --spec(start_webserver/0 :: () -> - {'started', string(), pos_integer()} | - {'error', any()}). +-spec start_webserver() -> + {'started', string(), pos_integer()} | {'error', any()}. start_webserver() -> start_webserver(0). @@ -156,9 +153,8 @@ start_webserver() -> %% @doc Starts webserver. If port number is 0, an available port number will %% be assigned by inets. --spec(start_webserver/1 :: (Port :: non_neg_integer()) -> - {'started', string(), pos_integer()} | - {'error', any()}). +-spec start_webserver(Port :: non_neg_integer()) -> + {'started', string(), pos_integer()} | {'error', any()}. start_webserver(Port) when is_integer(Port) -> application:load(percept), @@ -255,20 +251,20 @@ trace_parser(Trace, {Count, Pid}) -> find_service_pid_from_port([], _) -> undefined; find_service_pid_from_port([{_, Pid, Options} | Services], Port) -> - case lists:keysearch(port, 1, Options) of + case lists:keyfind(port, 1, Options) of false -> find_service_pid_from_port(Services, Port); - {value, {port, Port}} -> + {port, Port} -> Pid end. find_service_port_from_pid([], _) -> undefined; find_service_port_from_pid([{_, Pid, Options} | _], Pid) -> - case lists:keysearch(port, 1, Options) of + case lists:keyfind(port, 1, Options) of false -> undefined; - {value, {port, Port}} -> + {port, Port} -> Port end; find_service_port_from_pid([{_, _, _} | Services], Pid) -> diff --git a/lib/percept/src/percept.hrl b/lib/percept/src/percept.hrl index a9afceb6d1..36b6f63a4d 100644 --- a/lib/percept/src/percept.hrl +++ b/lib/percept/src/percept.hrl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2007-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2007-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -23,10 +23,10 @@ %%% Type definitions %%% %%% ------------------- %%% --type(timestamp() :: {non_neg_integer(), non_neg_integer(), non_neg_integer()}). --type(true_mfa() :: {atom(), atom(), byte() | list()}). --type(state() :: 'active' | 'inactive'). --type(scheduler_id() :: {'scheduler_id', non_neg_integer()}). +-type timestamp() :: {non_neg_integer(), non_neg_integer(), non_neg_integer()}. +-type true_mfa() :: {atom(), atom(), byte() | list()}. +-type state() :: 'active' | 'inactive'. +-type scheduler_id() :: {'scheduler_id', non_neg_integer()}. %%% ------------------- %%% %%% Records %%% @@ -40,8 +40,7 @@ runnable_count = 0 %:: non_neg_integer() }). --record( - information, { +-record(information, { id ,%:: pid() | port(), name = undefined ,%:: atom() | string() | 'undefined', entry = undefined ,%:: true_mfa() | 'undefined', diff --git a/lib/percept/src/percept_db.erl b/lib/percept/src/percept_db.erl index dc85fa3510..edb0d79a29 100644 --- a/lib/percept/src/percept_db.erl +++ b/lib/percept/src/percept_db.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2007-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2007-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -72,7 +72,7 @@ %% Pid = pid() %% @doc Starts or restarts the percept database. --spec(start/0 :: () -> {'started', pid()} | {'restarted', pid()}). +-spec start() -> {'started', pid()} | {'restarted', pid()}. start() -> case erlang:whereis(percept_db) of @@ -92,7 +92,7 @@ start() -> %% Pid = pid() %% @doc Stops the percept database. --spec(stop/0 :: () -> 'not_started' | {'stopped', pid()}). +-spec stop() -> 'not_started' | {'stopped', pid()}. stop() -> case erlang:whereis(percept_db) of @@ -392,23 +392,14 @@ consolidate_runnability_loop(Key) -> consolidate_runnability_loop(ets:next(pdb_activity, Key)). list_all_ts() -> - ATs = [ Act#activity.timestamp || - Act <- select_query({activity, []})], - STs = [ Act#activity.timestamp || - Act <- select_query({scheduler, []})], + ATs = [Act#activity.timestamp || Act <- select_query({activity, []})], + STs = [Act#activity.timestamp || Act <- select_query({scheduler, []})], ITs = lists:flatten([ [I#information.start, I#information.stop] || I <- select_query({information, all})]), - % Filter out all undefined (non ts) - TsList = lists:filter( - fun(Element) -> - case Element of - {_,_,_} -> true; - _ -> false - end - end, ATs ++ STs ++ ITs), - TsList. + %% Filter out all undefined (non ts) + [Elem || Elem = {_,_,_} <- ATs ++ STs ++ ITs]. %% get_runnable_count(Type, State) -> RunnableCount %% In: diff --git a/lib/percept/src/percept_html.erl b/lib/percept/src/percept_html.erl index ffce7a98fa..7e0ea45783 100644 --- a/lib/percept/src/percept_html.erl +++ b/lib/percept/src/percept_html.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2007-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2007-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% -module(percept_html). @@ -172,12 +172,12 @@ div_tag_graph() -> width:40px; height:40px;\"></div></div>". --spec(url_graph/5 :: ( +-spec url_graph( Widht :: non_neg_integer(), Height :: non_neg_integer(), Min :: float(), Max :: float(), - Pids :: [pid()]) -> string()). + Pids :: [pid()]) -> string(). url_graph(W, H, Min, Max, []) -> "/cgi-bin/percept_graph/graph?range_min=" ++ term2html(float(Min)) @@ -508,10 +508,7 @@ cl_deltas([A,B|Ls], Out) -> cl_deltas([B|Ls], [B - A | Out]). join_strings(Strings) -> lists:flatten(Strings). --spec(join_strings_with/2 :: ( - Strings :: [string()], - Separator :: string()) -> - string()). +-spec join_strings_with(Strings :: [string()], Separator :: string()) -> string(). join_strings_with([S1, S2 | R], S) -> join_strings_with([join_strings_with(S1,S2,S) | R], S); @@ -522,7 +519,7 @@ join_strings_with(S1, S2, S) -> %%% Generic erlang2html --spec(html_table/1 :: (Rows :: [[string() | {'td' | 'th', string()}]]) -> string()). +-spec html_table(Rows :: [[string() | {'td' | 'th', string()}]]) -> string(). html_table(Rows) -> "<table>" ++ html_table_row(Rows) ++ "</table>". @@ -539,7 +536,7 @@ html_table_data([Data|Row]) -> "<td>" ++ Data ++ "</td>" ++ html_table_dat --spec(table_line/1 :: (Table :: [any()]) -> string()). +-spec table_line(Table :: [any()]) -> string(). table_line(List) -> table_line(List, ["<tr>"]). table_line([], Out) -> lists:flatten(lists:reverse(["</tr>\n"|Out])); @@ -548,16 +545,12 @@ table_line([Element | Elements], Out) when is_list(Element) -> table_line([Element | Elements], Out) -> table_line(Elements, ["<td>" ++ term2html(Element) ++ "</td>"|Out]). --spec(term2html/1 :: (any()) -> string()). +-spec term2html(any()) -> string(). term2html(Term) when is_float(Term) -> lists:flatten(io_lib:format("~.4f", [Term])); term2html(Term) -> lists:flatten(io_lib:format("~p", [Term])). --spec(mfa2html/1 :: (MFA :: { - atom(), - atom(), - list() | integer()}) -> - string()). +-spec mfa2html(MFA :: {atom(), atom(), list() | integer()}) -> string(). mfa2html({Module, Function, Arguments}) when is_list(Arguments) -> lists:flatten(io_lib:format("~p:~p/~p", [Module, Function, length(Arguments)])); @@ -566,7 +559,7 @@ mfa2html({Module, Function, Arity}) when is_integer(Arity) -> mfa2html(_) -> "undefined". --spec(pid2html/1 :: (Pid :: pid() | port()) -> string()). +-spec pid2html(Pid :: pid() | port()) -> string(). pid2html(Pid) when is_pid(Pid) -> PidString = term2html(Pid), @@ -577,14 +570,14 @@ pid2html(Pid) when is_port(Pid) -> pid2html(_) -> "undefined". --spec(image_string/1 :: (Request :: string()) -> string()). +-spec image_string(Request :: string()) -> string(). image_string(Request) -> "<img border=0 src=\"/cgi-bin/percept_graph/" ++ Request ++ " \">". --spec(image_string/2 :: (atom() | string(), list()) -> string()). +-spec image_string(atom() | string(), list()) -> string(). image_string(Request, Options) when is_atom(Request), is_list(Options) -> image_string(image_string_head(erlang:atom_to_list(Request), Options, [])); @@ -610,13 +603,13 @@ image_string_tail(Request, [{Type, Value} | Opts], Out) -> %%% percept conversions --spec(pid2value/1 :: (Pid :: pid()) -> string()). +-spec pid2value(Pid :: pid()) -> string(). pid2value(Pid) -> String = lists:flatten(io_lib:format("~p", [Pid])), lists:sublist(String, 2, erlang:length(String)-2). --spec(value2pid/1 :: (Value :: string()) -> pid()). +-spec value2pid(Value :: string()) -> pid(). value2pid(Value) -> String = lists:flatten("<" ++ Value ++ ">"), @@ -625,10 +618,8 @@ value2pid(Value) -> %%% get value --spec(get_option_value/2 :: ( - Option :: string(), - Options :: [{string(),any()}]) -> - {'error', any()} | bool() | pid() | [pid()] | number()). +-spec get_option_value(Option :: string(), Options :: [{string(),any()}]) -> + {'error', any()} | boolean() | pid() | [pid()] | number(). get_option_value(Option, Options) -> case catch get_option_value0(Option, Options) of @@ -662,8 +653,7 @@ get_default_option_value(Option) -> _ -> {error, {undefined_default_option, Option}} end. --spec(get_number_value/1 :: (Value :: string()) -> - number() | {'error', 'illegal_number'}). +-spec get_number_value(string()) -> number() | {'error', 'illegal_number'}. get_number_value(Value) -> % Try float @@ -710,7 +700,7 @@ menu() -> <li><a href=/cgi-bin/percept_html/page>overview</a></li> </ul></div>\n". --spec(error_msg/1 :: (Error :: string()) -> string()). +-spec error_msg(Error :: string()) -> string(). error_msg(Error) -> "<table width=300> diff --git a/lib/public_key/doc/src/notes.xml b/lib/public_key/doc/src/notes.xml index 822f8bdb66..a5fbc81093 100644 --- a/lib/public_key/doc/src/notes.xml +++ b/lib/public_key/doc/src/notes.xml @@ -34,6 +34,21 @@ <file>notes.xml</file> </header> +<section><title>Public_Key 0.5</title> + + <section><title>Improvements and New Features</title> + <list> + <item> + <p>Added <c>public_key:pkix_transform/2</c> to enable + ssl to send CA list during Certificate Request.</p> + <p><c>NOTE</c>: SSL (new_ssl) requires public_key-0.5. + ssl usage.</p> + <p>Own Id: OTP-8372</p> + </item> + </list> + </section> + +</section> <section><title>Public_Key 0.4</title> diff --git a/lib/public_key/src/public_key.appup.src b/lib/public_key/src/public_key.appup.src index 8d33482f11..ee0f9a3cc1 100644 --- a/lib/public_key/src/public_key.appup.src +++ b/lib/public_key/src/public_key.appup.src @@ -1,6 +1,18 @@ %% -*- erlang -*- {"%VSN%", [ + {"0.4", + [ + {update, public_key, soft, soft_purge, soft_purge, []}, + {update, pubkey_cert_records, soft, soft_purge, soft_purge, []} + ] + } ], [ + {"0.4", + [ + {update, public_key, soft, soft_purge, soft_purge, []}, + {update, pubkey_cert_records, soft, soft_purge, soft_purge, []} + ] + } ]}. diff --git a/lib/public_key/vsn.mk b/lib/public_key/vsn.mk index 64f0203915..f4d5281e94 100644 --- a/lib/public_key/vsn.mk +++ b/lib/public_key/vsn.mk @@ -1,6 +1,7 @@ -PUBLIC_KEY_VSN = 0.4 +PUBLIC_KEY_VSN = 0.5 -TICKETS = OTP-8250 +TICKETS = OTP-8372 +#TICKETS_0.4 = OTP-8250 #TICKETS_0.3 = OTP-8100 OTP-8142 #TICKETS_0.2 = OTP-7860 #TICKETS_0.1 = OTP-7637
\ No newline at end of file diff --git a/lib/reltool/doc/src/notes.xml b/lib/reltool/doc/src/notes.xml index 293793e900..524d728901 100644 --- a/lib/reltool/doc/src/notes.xml +++ b/lib/reltool/doc/src/notes.xml @@ -38,6 +38,21 @@ section is the version number of Reltool.</p> + <section><title>Reltool 0.5.3</title> + + <section><title>Improvements and New Features</title> + <list> + <item> + <p> + Removed spurious documentation files.</p> + <p> + Own Id: OTP-8057</p> + </item> + </list> + </section> + + </section> + <section><title>Reltool 0.5.2</title> <section><title>Improvements and New Features</title> diff --git a/lib/reltool/vsn.mk b/lib/reltool/vsn.mk index d5ca40619c..b0561a6110 100644 --- a/lib/reltool/vsn.mk +++ b/lib/reltool/vsn.mk @@ -1,24 +1,25 @@ # This is an -*-makefile-*- file. # %CopyrightBegin% -# -# Copyright Ericsson AB 2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2009-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% -RELTOOL_VSN = 0.5.2 +RELTOOL_VSN = 0.5.3 -TICKETS = OTP-8254 +TICKETS = OTP-8057 +TICKETS_0_5_2 = OTP-8254 TICKETS_0_5_1 = OTP-8199 TICKETS_0_5 = OTP-7949 TICKETS_0_2_2 = OTP-7999 diff --git a/lib/runtime_tools/src/percept_profile.erl b/lib/runtime_tools/src/percept_profile.erl index b333dee0cf..cdc7a0fca1 100644 --- a/lib/runtime_tools/src/percept_profile.erl +++ b/lib/runtime_tools/src/percept_profile.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -41,7 +41,7 @@ %% @type percept_option() = procs | ports | exclusive --type(percept_option() :: 'procs' | 'ports' | 'exclusive' | 'scheduler'). +-type percept_option() :: 'procs' | 'ports' | 'exclusive' | 'scheduler'. %%========================================================================== %% @@ -52,8 +52,8 @@ %% @spec start(Filename::string()) -> {ok, Port} | {already_started, Port} %% @equiv start(Filename, [procs]) --spec(start/1 :: (Filename :: string()) -> - {'ok', port()} | {'already_started', port()}). +-spec start(Filename :: file:filename()) -> + {'ok', port()} | {'already_started', port()}. start(Filename) -> profile_to_file(Filename, [procs]). @@ -64,10 +64,9 @@ start(Filename) -> %% All events are stored in the file given by Filename. %% An explicit call to stop/0 is needed to stop profiling. --spec(start/2 :: ( - Filename :: string(), - Options :: [percept_option()]) -> - {'ok', port()} | {'already_started', port()}). +-spec start(Filename :: file:filename(), + Options :: [percept_option()]) -> + {'ok', port()} | {'already_started', port()}. start(Filename, Options) -> profile_to_file(Filename, Options). @@ -79,11 +78,10 @@ start(Filename, Options) -> %% No explicit call to stop/0 is needed, the profiling stops when %% the entry function returns. --spec(start/3 :: ( - Filename :: string(), - Entry :: {atom(), atom(), list()}, - Options :: [percept_option()]) -> - 'ok' | {'already_started', port()} | {'error', 'not_started'}). +-spec start(Filename :: file:filename(), + Entry :: {atom(), atom(), list()}, + Options :: [percept_option()]) -> + 'ok' | {'already_started', port()} | {'error', 'not_started'}. start(Filename, {Module, Function, Args}, Options) -> case whereis(percept_port) of @@ -107,11 +105,11 @@ deliver_all_trace() -> receive {Tracer, ok} -> ok end, erlang:trace(Tracee, false, [procs]), ok. --spec(stop/0 :: () -> 'ok' | {'error', 'not_started'}). %% @spec stop() -> ok | {'error', 'not_started'} %% @doc Stops profiling. +-spec stop() -> 'ok' | {'error', 'not_started'}. stop() -> erlang:system_profile(undefined, [runnable_ports, runnable_procs]), @@ -192,5 +190,4 @@ parse_profile_options([Opt|Opts], {TOpts, POpts}) -> }); _ -> parse_profile_options(Opts, {TOpts, POpts}) - end. diff --git a/lib/sasl/doc/src/rb.xml b/lib/sasl/doc/src/rb.xml index 5b49a7bced..f35ceb5777 100644 --- a/lib/sasl/doc/src/rb.xml +++ b/lib/sasl/doc/src/rb.xml @@ -4,23 +4,21 @@ <erlref> <header> <copyright> - <year>1996</year> - <year>2007</year> - <holder>Ericsson AB, All Rights Reserved</holder> + <year>1996</year><year>2010</year> + <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> - The contents of this file are subject to the Erlang Public License, - Version 1.1, (the "License"); you may not use this file except in - compliance with the License. You should have received a copy of the - Erlang Public License along with this software. If not, it can be - retrieved online at http://www.erlang.org/. + The contents of this file are subject to the Erlang Public License, + Version 1.1, (the "License"); you may not use this file except in + compliance with the License. You should have received a copy of the + Erlang Public License along with this software. If not, it can be + retrieved online at http://www.erlang.org/. - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and limitations - under the License. + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and limitations + under the License. - The Initial Developer of the Original Code is Ericsson AB. </legalnotice> <title>rb</title> @@ -43,20 +41,70 @@ </description> <funcs> <func> + <name>filter(Filters)</name> + <name>filter(Filters, Dates)</name> + <fsummary>Filter reports and displays them on the screen</fsummary> + <type> + <v>Filters = [filter()]</v> + <v>filter() = {Key, Value} | {Key, Value, no} | {Key, RegExp, re} | {Key, RegExp, re, no}</v> + <v>Key = term()</v> + <v>Value = term()</v> + <v>RegExp = string() | {string, Options} | mp(), {mp(), Options}</v> + <v>Dates = {DateFrom, DateTo} | {DateFrom, from} | {DateTo, to}</v> + <v>DateFrom = DateTo = {date(), time()}</v> + <v>date() and time() are the same type as in the <c>calendar</c> module</v> + </type> + <desc> + <p>This function displays the reports that match the provided filters.</p> + <p> + When a filter includes the <c>no</c> atom it will exclude the reports that match + that filter. + </p> + <p> + The reports are matched using the <c>proplists</c> module. The report must be a proplist + to be matched against any of the <c>filters()</c>. + </p> + <p> + If the filter is of the form <c>{Key, RegExp, re}</c> the report must contain an element with + <c>key = Key</c> and <c>Value</c> must match the RegExp regular expression. + </p> + <p> + If the Dates parameter is provided, then the reports are filtered according to the date + when they occurred. If Dates is of the form <c>{DateFrom, from}</c> then reports that occurred + after DateFrom are displayed. + </p> + <p> + If Dates is of the form <c>{DateTo, to}</c> then reports that occurred before DateTo + are displayed. + </p> + <p> + If two Dates are provided, then reports that occurred between those dates are returned. + </p> + <p> + If you only want to filter only by dates, then you can provide the empty list as the Filters + parameter. + </p> + <p> + See <c>rb:grep/1</c> for more information on the RegExp parameter. + </p> + </desc> + </func> + <func> <name>grep(RegExp)</name> <fsummary>Search the reports for a regular expression</fsummary> <type> - <v>RegExp = string()</v> + <v>RegExp = string() | {string, Options} | mp(), {mp(), Options}</v> </type> <desc> <p>All reports containing the regular expression <c>RegExp</c> are printed. </p> - <p><c>RegExp</c> is a string containing the regular - expression. Refer to the module <c>regexp</c> in the STDLIB - reference manual - for a definition of valid regular expressions. They are - essentially the same as the UNIX command <c>egrep</c>. + <p><c>RegExp</c> can be a string containing the regular + expression; a tuple with the string and the options for + compilation; a compiled regular expression; a compiled + regular expression and the options for running it. + Refer to the module <c>re</c> and specially the function <c>re:run/3</c> + for a definition of valid regular expressions and options. </p> </desc> </func> diff --git a/lib/sasl/src/rb.erl b/lib/sasl/src/rb.erl index 00d86285e5..332a99c6f9 100644 --- a/lib/sasl/src/rb.erl +++ b/lib/sasl/src/rb.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(rb). @@ -22,7 +22,7 @@ %% External exports -export([start/0, start/1, stop/0, rescan/0, rescan/1]). --export([list/0, list/1, show/0, show/1, grep/1, start_log/1, stop_log/0]). +-export([list/0, list/1, show/0, show/1, grep/1, filter/1, filter/2, start_log/1, stop_log/0]). -export([h/0, help/0]). %% Internal exports @@ -73,6 +73,12 @@ show(Type) when is_atom(Type) -> grep(RegExp) -> gen_server:call(rb_server, {grep, RegExp}, infinity). +filter(Filters) when is_list(Filters) -> + gen_server:call(rb_server, {filter, Filters}, infinity). + +filter(Filters, FDates) when is_list(Filters) andalso is_tuple(FDates) -> + gen_server:call(rb_server, {filter, {Filters, FDates}}, infinity). + start_log(FileName) -> gen_server:call(rb_server, {start_log, FileName}). stop_log() -> gen_server:call(rb_server, stop_log). @@ -90,7 +96,17 @@ help() -> io:format("rb:list(Type) - list all reports of type Type~n"), io:format(" currently supported types are:~n"), print_types(), - io:format("rb:grep(RegExp) - print reports containing RegExp~n"), + io:format("rb:grep(RegExp) - print reports containing RegExp.~n"), + io:format(" RegExp must be a valid argument for ~n"), + io:format(" the function re:run/2 or re:run/3.~n"), + io:format("rb:filter(Filters) - print reports matching Filters.~n"), + io:format(" reports must be proplists.~n"), + io:format(" Filters is a list of tuples of the following form:~n"), + print_filters(), + io:format("rb:filter(Filters, Dates) -~n"), + io:format(" same as rb:filter/1 but accepts date ranges to filter reports.~n"), + io:format(" Dates must be of the following form:~n"), + print_dates(), io:format("rb:rescan() - rescans the report directory with same~n"), io:format(" options.~n"), io:format("rb:rescan(Options) - rescans the report directory with new~n"), @@ -133,7 +149,26 @@ print_types() -> io:format(" - progress~n"), io:format(" - error~n"). - +print_filters() -> + io:format(" - {Key, Value}~n"), + io:format(" includes report containing {Key, Value}~n"), + io:format(" - {Key, Value, no}~n"), + io:format(" excludes report containing {Key, Value}~n"), + io:format(" - {Key, RegExp, re}~n"), + io:format(" RegExp must be a valid argument for ~n"), + io:format(" the function re:run/2 or re:run/3.~n"), + io:format(" - {Key, RegExp, re, no}~n"), + io:format(" excludes report containing {Key, RegExp}~n"). + +print_dates() -> + io:format(" - {StartDate, EndDate}~n"), + io:format(" StartDate = EndDate = {{Y-M-D},{H,M,S}} ~n"), + io:format(" prints the reports with date between StartDate and EndDate~n"), + io:format(" - {StartDate, from}~n"), + io:format(" prints the reports with date greater than StartDate~n"), + io:format(" - {EndDate, to}~n"), + io:format(" prints the reports with date lesser than StartDate~n"). + init(Options) -> process_flag(priority, low), process_flag(trap_exit, true), @@ -190,8 +225,22 @@ handle_call(show, _From, State) -> {reply, ok, State#state{device = NewDevice}}; handle_call({grep, RegExp}, _From, State) -> #state{dir = Dir, data = Data, device = Device, abort = Abort, log = Log} = State, - NewDevice = print_grep_reports(Dir, Data, RegExp, Device, Abort, Log), - {reply, ok, State#state{device = NewDevice}}. + try print_grep_reports(Dir, Data, RegExp, Device, Abort, Log) of + NewDevice -> + {reply, ok, State#state{device = NewDevice}} + catch + error:Error -> + {reply, {error, Error}, State} + end; +handle_call({filter, Filters}, _From, State) -> + #state{dir = Dir, data = Data, device = Device, abort = Abort, log = Log} = State, + try filter_all_reports(Dir, Data, Filters, Device, Abort, Log) of + NewDevice -> + {reply, ok, State#state{device = NewDevice}} + catch + error:Error -> + {reply, {error, Error}, State} + end. terminate(_Reason, #state{device = Device}) -> close_device(Device). @@ -415,7 +464,7 @@ read_report(Fd) -> Ref = make_ref(), case (catch {Ref,binary_to_term(Bin)}) of {'EXIT',_} -> - {error, "Inclomplete erlang term in log"}; + {error, "Incomplete erlang term in log"}; {Ref,Term} -> {ok, Term} end @@ -622,21 +671,178 @@ check_rep(Fd, FilePosition, Device, RegExp, Number, Abort, Log) -> case read_rep_msg(Fd, FilePosition) of {Date, Msg} -> MsgStr = lists:flatten(io_lib:format("~p",[Msg])), - case regexp:match(MsgStr, RegExp) of - {match, _, _} -> + case run_re(MsgStr, RegExp) of + match -> io:format("Found match in report number ~w~n", [Number]), case catch rb_format_supp:print(Date, Msg, Device) of {'EXIT', _} -> handle_bad_form(Date, Msg, Device, Abort, Log); _ -> {proceed,Device} - end; + end; + _ -> + {proceed,Device} + end; + _ -> + io:format("rb: Cannot read from file~n"), + {proceed,Device} + end. + +run_re(Subject, {Regexp, Options}) -> + run_re(Subject, Regexp, Options); +run_re(Subject, Regexp) -> + run_re(Subject, Regexp, []). + +run_re(Subject, Regexp, Options) -> + case re:run(Subject, Regexp, Options) of + nomatch -> + nomatch; + _ -> + match + end. + +filter_all_reports(_Dir, [], _Filters, Device, _Abort, _Log) -> + Device; +filter_all_reports(Dir, Data, Filters, Device, Abort, Log) -> + {Next,Device1} = filter_report(Dir, Data, Filters, element(1, hd(Data)), + Device, Abort, Log), + if Next == abort -> + Device1; + true -> + filter_all_reports(Dir, tl(Data), Filters, Device1, Abort, Log) + end. + +filter_report(Dir, Data, Filters, Number, Device, Abort, Log) -> + case find_report(Data, Number) of + {Fname, FilePosition} -> + FileName = lists:concat([Dir, Fname]), + case file:open(FileName, [read]) of + {ok, Fd} -> + filter_rep(Filters, Fd, FilePosition, Device, Abort, Log); + _ -> + io:format("rb: can't open file ~p~n", [Fname]), + {proceed,Device} + end; + no_report -> + {proceed,Device} + end. + +filter_rep({Filters, FDates}, Fd, FilePosition, Device, Abort, Log) -> + RepMsg = read_rep_msg(Fd, FilePosition), + case RepMsg of + {_DateStr, {Date, _Msg}} -> + case compare_dates(Date, FDates) of + true -> + print_filter_report(RepMsg, Filters, Device, Abort, Log); _ -> {proceed,Device} end; _ -> io:format("rb: Cannot read from file~n"), {proceed,Device} + end; +filter_rep(Filters, Fd, FilePosition, Device, Abort, Log) -> + RepMsg = read_rep_msg(Fd, FilePosition), + case RepMsg of + {Date, Msg} -> + print_filter_report({Date, Msg}, Filters, Device, Abort, Log); + _ -> + io:format("rb: Cannot read from file~n"), + {proceed,Device} + end. + +filter_report([], _Msg) -> + true; +filter_report([{Key, Value}|T], Msg) -> + case proplists:get_value(Key, Msg) of + Value -> + filter_report(T, Msg); + _ -> + false + end; +filter_report([{Key, Value, no}|T], Msg) -> + case proplists:get_value(Key, Msg) of + Value -> + false; + _ -> + filter_report(T, Msg) + end; +filter_report([{Key, RegExp, re}|T], Msg) -> + case proplists:get_value(Key, Msg) of + undefined -> + false; + Value -> + Subject = lists:flatten(io_lib:format("~p",[Value])), + case run_re(Subject, RegExp) of + match -> + filter_report(T, Msg); + _ -> false + end + end; +filter_report([{Key, RegExp, re, no}|T], Msg) -> + case proplists:get_value(Key, Msg) of + undefined -> + false; + Value -> + Subject = lists:flatten(io_lib:format("~p",[Value])), + case run_re(Subject, RegExp) of + match -> false; + _ -> filter_report(T, Msg) + end + end. + +get_compare_dates(Date, CompareDate) -> + case application:get_env(sasl, utc_log) of + {ok, true} -> + {local_time_to_universal_time(Date), + local_time_to_universal_time(CompareDate)}; + _ -> + {Date, CompareDate} + end. +get_compare_dates(Date, From, To) -> + case application:get_env(sasl, utc_log) of + {ok, true} -> + {local_time_to_universal_time(Date), + local_time_to_universal_time(From), + local_time_to_universal_time(To)}; + _ -> + {Date, From, To} + end. + +compare_dates(Date, {CompareDate, from}) -> + {Date2, DateFrom} = get_compare_dates(Date, CompareDate), + calendar:datetime_to_gregorian_seconds(Date2) >= + calendar:datetime_to_gregorian_seconds(DateFrom); +compare_dates(Date, {CompareDate, to}) -> + {Date2, DateTo} = get_compare_dates(Date, CompareDate), + calendar:datetime_to_gregorian_seconds(Date2) =< + calendar:datetime_to_gregorian_seconds(DateTo); +compare_dates(Date, {From, To}) -> + {Date2, DateFrom, DateTo} = get_compare_dates(Date, From, To), + calendar:datetime_to_gregorian_seconds(Date2) >= + calendar:datetime_to_gregorian_seconds(DateFrom) + andalso + calendar:datetime_to_gregorian_seconds(Date2) =< + calendar:datetime_to_gregorian_seconds(DateTo). + +print_filter_report({Date, Msg}, Filters, Device, Abort, Log) -> + {_D, M} = Msg, + {_, _, M2} = M, + case M2 of + {_, _, Report} -> + case filter_report(Filters, Report) of + true -> + case catch rb_format_supp:print(Date, Msg, Device) of + {'EXIT', _} -> + handle_bad_form(Date, Msg, Device, Abort, Log); + _ -> + {proceed,Device} + end; + _ -> + {proceed, Device} + end; + _ -> + {proceed,Device} end. read_rep(Fd, FilePosition, Device, Abort, Log) -> diff --git a/lib/sasl/src/sasl.app.src b/lib/sasl/src/sasl.app.src index cfe4b81ab6..8c814cfaf5 100644 --- a/lib/sasl/src/sasl.app.src +++ b/lib/sasl/src/sasl.app.src @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% {application, sasl, @@ -32,6 +32,8 @@ sasl_report, sasl_report_tty_h, sasl_report_file_h, + si, + si_sasl_supp, systools, systools_make, systools_rc, diff --git a/lib/sasl/src/sasl.erl b/lib/sasl/src/sasl.erl index 979d80159e..d1babaffff 100644 --- a/lib/sasl/src/sasl.erl +++ b/lib/sasl/src/sasl.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(sasl). @@ -126,13 +126,13 @@ type(_) -> all. add_error_logger_mf(undefined) -> ok; add_error_logger_mf({Dir, MaxB, MaxF}) -> error_logger:add_report_handler( - log_mf_h, log_mf_h:init(Dir, MaxB, MaxF, {sasl, pred})). + log_mf_h, log_mf_h:init(Dir, MaxB, MaxF, fun pred/1)). delete_error_logger_mf(undefined) -> ok; delete_error_logger_mf(_) -> error_logger:delete_report_handler(log_mf_h). -pred({_Type, GL, _Msg}) when node(GL) /= node() -> false; +pred({_Type, GL, _Msg}) when node(GL) =/= node() -> false; pred(_) -> true. %%%----------------------------------------------------------------- diff --git a/lib/sasl/src/sasl_report.erl b/lib/sasl/src/sasl_report.erl index bad3a75151..c3e6fede15 100644 --- a/lib/sasl/src/sasl_report.erl +++ b/lib/sasl/src/sasl_report.erl @@ -1,40 +1,46 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(sasl_report). --export([write_report/3]). +-export([write_report/3, format_report/3]). -write_report(Fd, What, {Time, {error_report, _GL, {Pid, Type, Report}}}) -> +format_report(Fd, What, Report) -> + io_report(io_lib, Fd, What, Report). + +write_report(Fd, What, Report) -> + io_report(io, Fd, What, Report). + +io_report(IO, Fd, What, {Time, {error_report, _GL, {Pid, Type, Report}}}) -> case is_my_error_report(What, Type) of true -> Head = write_head(Type, Time, Pid), - write_report2(Fd, Head, Type, Report); + write_report2(IO, Fd, Head, Type, Report); _ -> true end; -write_report(Fd, What, {Time, {info_report, _GL, {Pid, Type, Report}}}) -> +io_report(IO, Fd, What, {Time, {info_report, _GL, {Pid, Type, Report}}}) -> case is_my_info_report(What, Type) of true -> Head = write_head(Type, Time, Pid), - write_report2(Fd, Head, Type, Report); + write_report2(IO, Fd, Head, Type, Report); _ -> true end; -write_report(_Fd, _, _) -> +io_report(_IO, _Fd, _, _) -> false. is_my_error_report(all, Type) -> is_my_error_report(Type); @@ -50,20 +56,26 @@ is_my_info_report(_, _Type) -> false. is_my_info_report(progress) -> true; is_my_info_report(_) -> false. -write_report2(Fd, Head, supervisor_report, Report) -> +write_report2(IO, Fd, Head, supervisor_report, Report) -> Name = sup_get(supervisor, Report), Context = sup_get(errorContext, Report), Reason = sup_get(reason, Report), Offender = sup_get(offender, Report), - io:format(Fd, Head ++ " Supervisor: ~p~n Context: ~p~n Reason: " - "~80.18p~n Offender: ~80.18p~n~n", - [Name,Context,Reason,Offender]); -write_report2(Fd, Head, progress, Report) -> + FmtString = " Supervisor: ~p~n Context: ~p~n Reason: " + "~80.18p~n Offender: ~80.18p~n~n", + write_report_action(IO, Fd, Head ++ FmtString, + [Name,Context,Reason,Offender]); +write_report2(IO, Fd, Head, progress, Report) -> Format = format_key_val(Report), - io:format(Fd, Head ++ "~s", [Format]); -write_report2(Fd, Head, crash_report, Report) -> + write_report_action(IO, Fd, Head ++ "~s", [Format]); +write_report2(IO, Fd, Head, crash_report, Report) -> Format = proc_lib:format(Report), - io:format(Fd, Head ++ "~s", [Format]). + write_report_action(IO, Fd, Head ++ "~s", [Format]). + +write_report_action(io, Fd, Format, Args) -> + io:format(Fd, Format, Args); +write_report_action(io_lib, _Fd, Format, Args) -> + io_lib:format(Format, Args). format_key_val([{Tag,Data}|Rep]) -> io_lib:format(" ~16w: ~p~n",[Tag,Data]) ++ format_key_val(Rep); diff --git a/lib/stdlib/src/escript.erl b/lib/stdlib/src/escript.erl index b2562c6169..05c42c24f0 100644 --- a/lib/stdlib/src/escript.erl +++ b/lib/stdlib/src/escript.erl @@ -63,7 +63,7 @@ script_name() -> %% string()). foldl(Fun, Acc0, File) when is_function(Fun, 4) -> case parse_file(File, false) of - {text, _, Forms, _Mode} when is_list(Forms) -> + {text, _, Forms, _HasRecs, _Mode} when is_list(Forms) -> GetInfo = fun() -> file:read_file_info(File) end, GetBin = fun() -> diff --git a/lib/tools/emacs/erlang-skels-old.el b/lib/tools/emacs/erlang-skels-old.el new file mode 100644 index 0000000000..b88d7bcc4b --- /dev/null +++ b/lib/tools/emacs/erlang-skels-old.el @@ -0,0 +1,1267 @@ +;; +;; %CopyrightBegin% +;; +;; Copyright Ericsson AB 2010. All Rights Reserved. +;; +;; The contents of this file are subject to the Erlang Public License, +;; Version 1.1, (the "License"); you may not use this file except in +;; compliance with the License. You should have received a copy of the +;; Erlang Public License along with this software. If not, it can be +;; retrieved online at http://www.erlang.org/. +;; +;; Software distributed under the License is distributed on an "AS IS" +;; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +;; the License for the specific language governing rights and limitations +;; under the License. +;; +;; %CopyrightEnd% +;;; +;;; Purpose: Provide Erlang code skeletons. +;;; See 'erlang-skel-file' variable. + +(defvar erlang-tempo-tags nil + "Tempo tags for erlang mode") + +(defvar erlang-skel + '(("If" "if" erlang-skel-if) + ("Case" "case" erlang-skel-case) + ("Receive" "receive" erlang-skel-receive) + ("Receive After" "after" erlang-skel-receive-after) + ("Receive Loop" "loop" erlang-skel-receive-loop) + ("Module" "module" erlang-skel-module) + ("Author" "author" erlang-skel-author) + () + ("Small Header" "small-header" + erlang-skel-small-header erlang-skel-header) + ("Normal Header" "normal-header" + erlang-skel-normal-header erlang-skel-header) + ("Large Header" "large-header" + erlang-skel-large-header erlang-skel-header) + () + ("Small Server" "small-server" + erlang-skel-small-server erlang-skel-header) + () + ("Application" "application" + erlang-skel-application erlang-skel-header) + ("Supervisor" "supervisor" + erlang-skel-supervisor erlang-skel-header) + ("supervisor_bridge" "supervisor-bridge" + erlang-skel-supervisor-bridge erlang-skel-header) + ("gen_server" "generic-server" + erlang-skel-generic-server erlang-skel-header) + ("gen_event" "gen-event" + erlang-skel-gen-event erlang-skel-header) + ("gen_fsm" "gen-fsm" + erlang-skel-gen-fsm erlang-skel-header) + ("Library module" "gen-lib" + erlang-skel-lib erlang-skel-header) + ("Corba callback" "gen-corba-cb" + erlang-skel-corba-callback erlang-skel-header) + ("Small Common Test suite" "ct-test-suite-s" + erlang-skel-ct-test-suite-s erlang-skel-header) + ("Large Common Test suite" "ct-test-suite-l" + erlang-skel-ct-test-suite-l erlang-skel-header) + ("Erlang TS test suite" "ts-test-suite" + erlang-skel-ts-test-suite erlang-skel-header) + ) + "*Description of all skeleton templates. +Both functions and menu entries will be created. + +Each entry in `erlang-skel' should be a list with three or four +elements, or the empty list. + +The first element is the name which shows up in the menu. The second +is the `tempo' identifier (The string \"erlang-\" will be added in +front of it). The third is the skeleton descriptor, a variable +containing `tempo' attributes as described in the function +`tempo-define-template'. The optional fourth elements denotes a +function which should be called when the menu is selected. + +Functions corresponding to every template will be created. The name +of the function will be `tempo-template-erlang-X' where `X' is the +tempo identifier as specified in the second argument of the elements +in this list. + +A list with zero elements means that the a horizontal line should +be placed in the menu.") + +;; In XEmacs `user-mail-address' returns "[email protected] (Foo Bar)" ARGH! +;; What's wrong with that? RFC 822 says it's legal. [sverkerw] +;; This needs to use the customized value. If that's not sane, things like +;; add-log will lose anyhow. Avoid it if there _is_ a paren. +(defvar erlang-skel-mail-address + (if (or (not user-mail-address) (string-match "(" user-mail-address)) + (concat (user-login-name) "@" + (or (and (boundp 'mail-host-address) + mail-host-address) + (system-name))) + user-mail-address) + "Mail address of the user.") + +;; Expression templates: +(defvar erlang-skel-case + '((erlang-skel-skip-blank) o > + "case " p " of" n> p "_ ->" n> p "ok" n> "end" p) + "*The skeleton of a `case' expression. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-if + '((erlang-skel-skip-blank) o > + "if" n> p " ->" n> p "ok" n> "end" p) + "The skeleton of an `if' expression. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-receive + '((erlang-skel-skip-blank) o > + "receive" n> p "_ ->" n> p "ok" n> "end" p) + "*The skeleton of a `receive' expression. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-receive-after + '((erlang-skel-skip-blank) o > + "receive" n> p "_ ->" n> p "ok" n> "after " p "T ->" n> + p "ok" n> "end" p) + "*The skeleton of a `receive' expression with an `after' clause. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-receive-loop + '(& o "loop(" p ") ->" n> "receive" n> p "_ ->" n> + "loop(" p ")" n> "end.") + "*The skeleton of a simple `receive' loop. +Please see the function `tempo-define-template'.") + + +;; Attribute templates + +(defvar erlang-skel-module + '(& "-module(" + (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) + ")." n) + "*The skeleton of a `module' attribute. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-author + '(& "-author('" erlang-skel-mail-address "')." n) + "*The skeleton of a `author' attribute. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-vc nil + "*The skeleton template to generate a version control attribute. +The default is to insert nothing. Example of usage: + + (setq erlang-skel-vc '(& \"-rcs(\\\"$\Id: $ \\\").\") n) + +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-export + '(& "-export([" n> "])." n) + "*The skeleton of an `export' attribute. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-import + '(& "%%-import(Module, [Function/Arity, ...])." n) + "*The skeleton of an `import' attribute. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-compile nil + ;; '(& "%%-compile(export_all)." n) + "*The skeleton of a `compile' attribute. +Please see the function `tempo-define-template'.") + + +;; Comment templates. + +(defvar erlang-skel-date-function 'erlang-skel-dd-mmm-yyyy + "*Function which returns date string. +Look in the module `time-stamp' for a battery of functions.") + +(defvar erlang-skel-copyright-comment '() + "*The template for a copyright line in the header, normally empty. +This variable should be bound to a `tempo' template, for example: + '(& \"%%% Copyright (C) 2000, Yoyodyne, Inc.\" n) + +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-created-comment + '(& "%%% Created : " (funcall erlang-skel-date-function) " by " + (user-full-name) " <" erlang-skel-mail-address ">" n) + "*The template for the \"Created:\" comment line.") + +(defvar erlang-skel-author-comment + '(& "%%% Author : " (user-full-name) " <" erlang-skel-mail-address ">" n) + "*The template for creating the \"Author:\" line in the header. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-file-comment + '(& "%%% File : " (file-name-nondirectory buffer-file-name) n) +"*The template for creating the \"Module:\" line in the header. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-small-header + '(o (erlang-skel-include erlang-skel-module) + ;; erlang-skel-author) + n + (erlang-skel-include erlang-skel-compile + ;; erlang-skel-export + erlang-skel-vc)) + "*The template of a small header without any comments. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-normal-header + '(o (erlang-skel-include erlang-skel-copyright-comment + erlang-skel-file-comment + erlang-skel-author-comment) + "%%% Description : " p n + (erlang-skel-include erlang-skel-created-comment) n + (erlang-skel-include erlang-skel-small-header) n) + "*The template of a normal header. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-large-header + '(o (erlang-skel-separator) + (erlang-skel-include erlang-skel-copyright-comment + erlang-skel-file-comment + erlang-skel-author-comment) + "%%% Description : " p n + "%%%" n + (erlang-skel-include erlang-skel-created-comment) + (erlang-skel-separator) + (erlang-skel-include erlang-skel-small-header) ) + "*The template of a large header. +Please see the function `tempo-define-template'.") + + +;; Server templates. + +(defvar erlang-skel-small-server + '((erlang-skel-include erlang-skel-large-header) + "-export([start/0,init/1])." n n n + "start() ->" n> "spawn(" (erlang-get-module-from-file-name) + ", init, [self()])." n n + "init(From) ->" n> + "loop(From)." n n + "loop(From) ->" n> + "receive" n> + p "_ ->" n> + "loop(From)" n> + "end." + ) + "*Template of a small server. +Please see the function `tempo-define-template'.") + +;; Behaviour templates. + +(defvar erlang-skel-application + '((erlang-skel-include erlang-skel-large-header) + "-behaviour(application)." n n + "%% Application callbacks" n + "-export([start/2, stop/1])." n n + (erlang-skel-double-separator 2) + "%% Application callbacks" n + (erlang-skel-double-separator 2) + (erlang-skel-separator 2) + "%% Function: start(Type, StartArgs) -> {ok, Pid} |" n + "%% {ok, Pid, State} |" n + "%% {error, Reason}" n + "%% Description: This function is called whenever an application " n + "%% is started using application:start/1,2, and should start the processes" n + "%% of the application. If the application is structured according to the" n + "%% OTP design principles as a supervision tree, this means starting the" n + "%% top supervisor of the tree." n + (erlang-skel-separator 2) + "start(_Type, StartArgs) ->" n> + "case 'TopSupervisor':start_link(StartArgs) of" n> + "{ok, Pid} -> " n> + "{ok, Pid};" n> + "Error ->" n> + "Error" n> + "end." n + n + (erlang-skel-separator 2) + "%% Function: stop(State) -> void()" n + "%% Description: This function is called whenever an application" n + "%% has stopped. It is intended to be the opposite of Module:start/2 and" n + "%% should do any necessary cleaning up. The return value is ignored. "n + (erlang-skel-separator 2) + "stop(_State) ->" n> + "ok." n + n + (erlang-skel-double-separator 2) + "%% Internal functions" n + (erlang-skel-double-separator 2) + ) + "*The template of an application behaviour. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-supervisor + '((erlang-skel-include erlang-skel-large-header) + "-behaviour(supervisor)." n n + + "%% API" n + "-export([start_link/0])." n n + + "%% Supervisor callbacks" n + "-export([init/1])." n n + + "-define(SERVER, ?MODULE)." n n + + (erlang-skel-double-separator 2) + "%% API functions" n + (erlang-skel-double-separator 2) + (erlang-skel-separator 2) + "%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}" n + "%% Description: Starts the supervisor" n + (erlang-skel-separator 2) + "start_link() ->" n> + "supervisor:start_link({local, ?SERVER}, ?MODULE, [])." n + n + (erlang-skel-double-separator 2) + "%% Supervisor callbacks" n + (erlang-skel-double-separator 2) + (erlang-skel-separator 2) + "%% Func: init(Args) -> {ok, {SupFlags, [ChildSpec]}} |" n + "%% ignore |" n + "%% {error, Reason}" n + "%% Description: Whenever a supervisor is started using "n + "%% supervisor:start_link/[2,3], this function is called by the new process "n + "%% to find out about restart strategy, maximum restart frequency and child "n + "%% specifications." n + (erlang-skel-separator 2) + "init([]) ->" n> + "AChild = {'AName',{'AModule',start_link,[]}," n> + "permanent,2000,worker,['AModule']}," n> + "{ok,{{one_for_all,0,1}, [AChild]}}." n + n + (erlang-skel-double-separator 2) + "%% Internal functions" n + (erlang-skel-double-separator 2) + ) + "*The template of an supervisor behaviour. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-supervisor-bridge + '((erlang-skel-include erlang-skel-large-header) + "-behaviour(supervisor_bridge)." n n + + "%% API" n + "-export([start_link/0])." n n + + "%% supervisor_bridge callbacks" n + "-export([init/1, terminate/2])." n n + + "-define(SERVER, ?MODULE)." n n + + "-record(state, {})." n n + + (erlang-skel-double-separator 2) + "%% API" n + (erlang-skel-double-separator 2) + (erlang-skel-separator 2) + "%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}" n + "%% Description: Starts the supervisor bridge" n + (erlang-skel-separator 2) + "start_link() ->" n> + "supervisor_bridge:start_link({local, ?SERVER}, ?MODULE, [])." n + n + (erlang-skel-double-separator 2) + "%% supervisor_bridge callbacks" n + (erlang-skel-double-separator 2) + (erlang-skel-separator 2) + "%% Funcion: init(Args) -> {ok, Pid, State} |" n + "%% ignore |" n + "%% {error, Reason} " n + "%% Description:Creates a supervisor_bridge process, linked to the calling" n + "%% process, which calls Module:init/1 to start the subsystem. To ensure a" n + "%% synchronized start-up procedure, this function does not return until" n + "%% Module:init/1 has returned. " n + (erlang-skel-separator 2) + "init([]) ->" n> + "case 'AModule':start_link() of" n> + "{ok, Pid} ->" n> + "{ok, Pid, #state{}};" n> + "Error ->" n> + "Error" n> + "end." n + n + (erlang-skel-separator 2) + "%% Func: terminate(Reason, State) -> void()" n + "%% Description:This function is called by the supervisor_bridge when it is"n + "%% about to terminate. It should be the opposite of Module:init/1 and stop"n + "%% the subsystem and do any necessary cleaning up.The return value is ignored." + (erlang-skel-separator 2) + "terminate(Reason, State) ->" n> + "'AModule':stop()," n> + "ok." n + n + (erlang-skel-double-separator 2) + "%% Internal functions" n + (erlang-skel-double-separator 2) + ) + "*The template of an supervisor_bridge behaviour. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-generic-server + '((erlang-skel-include erlang-skel-large-header) + "-behaviour(gen_server)." n n + + "%% API" n + "-export([start_link/0])." n n + + "%% gen_server callbacks" n + "-export([init/1, handle_call/3, handle_cast/2, " + "handle_info/2," n> + "terminate/2, code_change/3])." n n + + "-record(state, {})." n n + + (erlang-skel-double-separator 2) + "%% API" n + (erlang-skel-double-separator 2) + (erlang-skel-separator 2) + "%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}" n + "%% Description: Starts the server" n + (erlang-skel-separator 2) + "start_link() ->" n> + "gen_server:start_link({local, ?SERVER}, ?MODULE, [], [])." n + n + (erlang-skel-double-separator 2) + "%% gen_server callbacks" n + (erlang-skel-double-separator 2) + n + (erlang-skel-separator 2) + "%% Function: init(Args) -> {ok, State} |" n + "%% {ok, State, Timeout} |" n + "%% ignore |" n + "%% {stop, Reason}" n + "%% Description: Initializes the server" n + (erlang-skel-separator 2) + "init([]) ->" n> + "{ok, #state{}}." n + n + (erlang-skel-separator 2) + "%% Function: " + "%% handle_call(Request, From, State) -> {reply, Reply, State} |" n + "%% {reply, Reply, State, Timeout} |" n + "%% {noreply, State} |" n + "%% {noreply, State, Timeout} |" n + "%% {stop, Reason, Reply, State} |" n + "%% {stop, Reason, State}" n + "%% Description: Handling call messages" n + (erlang-skel-separator 2) + "handle_call(_Request, _From, State) ->" n> + "Reply = ok," n> + "{reply, Reply, State}." n + n + (erlang-skel-separator 2) + "%% Function: handle_cast(Msg, State) -> {noreply, State} |" n + "%% {noreply, State, Timeout} |" n + "%% {stop, Reason, State}" n + "%% Description: Handling cast messages" n + + (erlang-skel-separator 2) + "handle_cast(_Msg, State) ->" n> + "{noreply, State}." n + n + (erlang-skel-separator 2) + "%% Function: handle_info(Info, State) -> {noreply, State} |" n + "%% {noreply, State, Timeout} |" n + "%% {stop, Reason, State}" n + "%% Description: Handling all non call/cast messages" n + (erlang-skel-separator 2) + "handle_info(_Info, State) ->" n> + "{noreply, State}." n + n + (erlang-skel-separator 2) + "%% Function: terminate(Reason, State) -> void()" n + "%% Description: This function is called by a gen_server when it is about to"n + "%% terminate. It should be the opposite of Module:init/1 and do any necessary"n + "%% cleaning up. When it returns, the gen_server terminates with Reason." n + "%% The return value is ignored." n + + (erlang-skel-separator 2) + "terminate(_Reason, _State) ->" n> + "ok." n + n + (erlang-skel-separator 2) + "%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}" n + "%% Description: Convert process state when code is changed" n + (erlang-skel-separator 2) + "code_change(_OldVsn, State, _Extra) ->" n> + "{ok, State}." n + n + (erlang-skel-separator 2) + "%%% Internal functions" n + (erlang-skel-separator 2) + ) + "*The template of a generic server. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-gen-event + '((erlang-skel-include erlang-skel-large-header) + "-behaviour(gen_event)." n + + "%% API" n + "-export([start_link/0, add_handler/0])." n n + + "%% gen_event callbacks" n + "-export([init/1, handle_event/2, handle_call/2, " n> + "handle_info/2, terminate/2, code_change/3])." n n + + "-record(state, {})." n n + + (erlang-skel-double-separator 2) + "%% gen_event callbacks" n + (erlang-skel-double-separator 2) + (erlang-skel-separator 2) + "%% Function: start_link() -> {ok,Pid} | {error,Error} " n + "%% Description: Creates an event manager." n + (erlang-skel-separator 2) + "start_link() ->" n> + "gen_event:start_link({local, ?SERVER}). " n + n + (erlang-skel-separator 2) + "%% Function: add_handler() -> ok | {'EXIT',Reason} | term()" n + "%% Description: Adds an event handler" n + (erlang-skel-separator 2) + "add_handler() ->" n> + "gen_event:add_handler(?SERVER, ?MODULE, [])." n + n + (erlang-skel-double-separator 2) + "%% gen_event callbacks" n + (erlang-skel-double-separator 2) + (erlang-skel-separator 2) + "%% Function: init(Args) -> {ok, State}" n + "%% Description: Whenever a new event handler is added to an event manager,"n + "%% this function is called to initialize the event handler." n + (erlang-skel-separator 2) + "init([]) ->" n> + "{ok, #state{}}." n + n + (erlang-skel-separator 2) + "%% Function: "n + "%% handle_event(Event, State) -> {ok, State} |" n + "%% {swap_handler, Args1, State1, Mod2, Args2} |"n + "%% remove_handler" n + "%% Description:Whenever an event manager receives an event sent using"n + "%% gen_event:notify/2 or gen_event:sync_notify/2, this function is called for"n + "%% each installed event handler to handle the event. "n + (erlang-skel-separator 2) + "handle_event(_Event, State) ->" n> + "{ok, State}." n + n + (erlang-skel-separator 2) + "%% Function: " n + "%% handle_call(Request, State) -> {ok, Reply, State} |" n + "%% {swap_handler, Reply, Args1, State1, "n + "%% Mod2, Args2} |" n + "%% {remove_handler, Reply}" n + "%% Description: Whenever an event manager receives a request sent using"n + "%% gen_event:call/3,4, this function is called for the specified event "n + "%% handler to handle the request."n + (erlang-skel-separator 2) + "handle_call(_Request, State) ->" n> + "Reply = ok," n> + "{ok, Reply, State}." n + n + (erlang-skel-separator 2) + "%% Function: " n + "%% handle_info(Info, State) -> {ok, State} |" n + "%% {swap_handler, Args1, State1, Mod2, Args2} |" n + "%% remove_handler" n + "%% Description: This function is called for each installed event handler when"n + "%% an event manager receives any other message than an event or a synchronous"n + "%% request (or a system message)."n + (erlang-skel-separator 2) + "handle_info(_Info, State) ->" n> + "{ok, State}." n + n + (erlang-skel-separator 2) + "%% Function: terminate(Reason, State) -> void()" n + "%% Description:Whenever an event handler is deleted from an event manager,"n + "%% this function is called. It should be the opposite of Module:init/1 and "n + "%% do any necessary cleaning up. " n + (erlang-skel-separator 2) + "terminate(_Reason, _State) ->" n> + "ok." n + n + (erlang-skel-separator 2) + "%% Function: code_change(OldVsn, State, Extra) -> {ok, NewState} " n + "%% Description: Convert process state when code is changed" n + (erlang-skel-separator 2) + "code_change(_OldVsn, State, _Extra) ->" n> + "{ok, State}." n + n + (erlang-skel-separator 2) + "%%% Internal functions" n + (erlang-skel-separator 2) + ) + "*The template of a gen_event. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-gen-fsm + '((erlang-skel-include erlang-skel-large-header) + "-behaviour(gen_fsm)." n n + + "%% API" n + "-export([start_link/0])." n n + + "%% gen_fsm callbacks" n + "-export([init/1, state_name/2, state_name/3, handle_event/3," n> + "handle_sync_event/4, handle_info/3, terminate/3, code_change/4])." n n + + "-record(state, {})." n n + + (erlang-skel-double-separator 2) + "%% API" n + (erlang-skel-double-separator 2) + (erlang-skel-separator 2) + "%% Function: start_link() -> ok,Pid} | ignore | {error,Error}" n + "%% Description:Creates a gen_fsm process which calls Module:init/1 to"n + "%% initialize. To ensure a synchronized start-up procedure, this function" n + "%% does not return until Module:init/1 has returned. " n + (erlang-skel-separator 2) + "start_link() ->" n> + "gen_fsm:start_link({local, ?SERVER}, ?MODULE, [], [])." n + n + (erlang-skel-double-separator 2) + "%% gen_fsm callbacks" n + (erlang-skel-double-separator 2) + (erlang-skel-separator 2) + "%% Function: init(Args) -> {ok, StateName, State} |" n + "%% {ok, StateName, State, Timeout} |" n + "%% ignore |" n + "%% {stop, StopReason} " n + "%% Description:Whenever a gen_fsm is started using gen_fsm:start/[3,4] or"n + "%% gen_fsm:start_link/3,4, this function is called by the new process to "n + "%% initialize. " n + (erlang-skel-separator 2) + "init([]) ->" n> + "{ok, state_name, #state{}}." n + n + (erlang-skel-separator 2) + "%% Function: "n + "%% state_name(Event, State) -> {next_state, NextStateName, NextState}|" n + "%% {next_state, NextStateName, " n + "%% NextState, Timeout} |" n + "%% {stop, Reason, NewState}" n + "%% Description:There should be one instance of this function for each possible"n + "%% state name. Whenever a gen_fsm receives an event sent using" n + "%% gen_fsm:send_event/2, the instance of this function with the same name as"n + "%% the current state name StateName is called to handle the event. It is also "n + "%% called if a timeout occurs. " n + (erlang-skel-separator 2) + "state_name(_Event, State) ->" n> + "{next_state, state_name, State}." n + n + (erlang-skel-separator 2) + "%% Function:" n + "%% state_name(Event, From, State) -> {next_state, NextStateName, NextState} |"n + "%% {next_state, NextStateName, " n + "%% NextState, Timeout} |" n + "%% {reply, Reply, NextStateName, NextState}|"n + "%% {reply, Reply, NextStateName, " n + "%% NextState, Timeout} |" n + "%% {stop, Reason, NewState}|" n + "%% {stop, Reason, Reply, NewState}" n + "%% Description: There should be one instance of this function for each" n + "%% possible state name. Whenever a gen_fsm receives an event sent using" n + "%% gen_fsm:sync_send_event/2,3, the instance of this function with the same"n + "%% name as the current state name StateName is called to handle the event." n + (erlang-skel-separator 2) + "state_name(_Event, _From, State) ->" n> + "Reply = ok," n> + "{reply, Reply, state_name, State}." n + n + (erlang-skel-separator 2) + "%% Function: " n + "%% handle_event(Event, StateName, State) -> {next_state, NextStateName, "n + "%% NextState} |" n + "%% {next_state, NextStateName, "n + "%% NextState, Timeout} |" n + "%% {stop, Reason, NewState}" n + "%% Description: Whenever a gen_fsm receives an event sent using"n + "%% gen_fsm:send_all_state_event/2, this function is called to handle"n + "%% the event." n + (erlang-skel-separator 2) + "handle_event(_Event, StateName, State) ->" n> + "{next_state, StateName, State}." n + n + (erlang-skel-separator 2) + "%% Function: " n + "%% handle_sync_event(Event, From, StateName, "n + "%% State) -> {next_state, NextStateName, NextState} |" n + "%% {next_state, NextStateName, NextState, " n + "%% Timeout} |" n + "%% {reply, Reply, NextStateName, NextState}|" n + "%% {reply, Reply, NextStateName, NextState, " n + "%% Timeout} |" n + "%% {stop, Reason, NewState} |" n + "%% {stop, Reason, Reply, NewState}" n + "%% Description: Whenever a gen_fsm receives an event sent using"n + "%% gen_fsm:sync_send_all_state_event/2,3, this function is called to handle"n + "%% the event."n + (erlang-skel-separator 2) + "handle_sync_event(Event, From, StateName, State) ->" n> + "Reply = ok," n> + "{reply, Reply, StateName, State}." n + n + (erlang-skel-separator 2) + "%% Function: " n + "%% handle_info(Info,StateName,State)-> {next_state, NextStateName, NextState}|" n + "%% {next_state, NextStateName, NextState, "n + "%% Timeout} |" n + "%% {stop, Reason, NewState}" n + "%% Description: This function is called by a gen_fsm when it receives any"n + "%% other message than a synchronous or asynchronous event"n + "%% (or a system message)." n + (erlang-skel-separator 2) + "handle_info(_Info, StateName, State) ->" n> + "{next_state, StateName, State}." n + n + (erlang-skel-separator 2) + "%% Function: terminate(Reason, StateName, State) -> void()" n + "%% Description:This function is called by a gen_fsm when it is about"n + "%% to terminate. It should be the opposite of Module:init/1 and do any"n + "%% necessary cleaning up. When it returns, the gen_fsm terminates with"n + "%% Reason. The return value is ignored." n + (erlang-skel-separator 2) + "terminate(_Reason, _StateName, _State) ->" n> + "ok." n + n + (erlang-skel-separator 2) + "%% Function:" n + "%% code_change(OldVsn, StateName, State, Extra) -> {ok, StateName, NewState}" n + "%% Description: Convert process state when code is changed" n + (erlang-skel-separator 2) + "code_change(_OldVsn, StateName, State, _Extra) ->" n> + "{ok, StateName, State}." n + n + (erlang-skel-separator 2) + "%%% Internal functions" n + (erlang-skel-separator 2) + ) + "*The template of a gen_fsm. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-lib + '((erlang-skel-include erlang-skel-large-header) + + "%% API" n + "-export([])." n n + + (erlang-skel-double-separator 2) + "%% API" n + (erlang-skel-double-separator 2) + (erlang-skel-separator 2) + "%% Function: " n + "%% Description:" n + (erlang-skel-separator 2) + n + (erlang-skel-double-separator 2) + "%% Internal functions" n + (erlang-skel-double-separator 2) + ) + "*The template of a library module. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-corba-callback + '((erlang-skel-include erlang-skel-large-header) + "%% Include files" n n + + "%% API" n + "-export([])." n n + + "%% Corba callbacks" n + "-export([init/1, terminate/2, code_change/3])." n n + + "-record(state, {})." n n + + (erlang-skel-double-separator 2) + "%% Corba callbacks" n + (erlang-skel-double-separator 2) + (erlang-skel-separator 2) + "%% Function: init(Args) -> {ok, State} |" n + "%% {ok, State, Timeout} |" n + "%% ignore |" n + "%% {stop, Reason}" n + "%% Description: Initializes the server" n + (erlang-skel-separator 2) + "init([]) ->" n> + "{ok, #state{}}." n + n + (erlang-skel-separator 2) + "%% Function: terminate(Reason, State) -> void()" n + "%% Description: Shutdown the server" n + (erlang-skel-separator 2) + "terminate(_Reason, _State) ->" n> + "ok." n + n + (erlang-skel-separator 2) + "%% Function: code_change(OldVsn, State, Extra) -> {ok, NewState} " n + "%% Description: Convert process state when code is changed" n + (erlang-skel-separator 2) + "code_change(_OldVsn, State, _Extra) ->" n> + "{ok, State}." n + n + (erlang-skel-double-separator 2) + "%% Internal functions" n + (erlang-skel-double-separator 2) + ) + "*The template of a library module. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-ts-test-suite + '((erlang-skel-include erlang-skel-large-header) + "%% Note: This directive should only be used in test suites." n + "-compile(export_all)." n n + + "-include_lib(\"test_server/include/test_server.hrl\")." n n + + (erlang-skel-separator 2) + "%% TEST SERVER CALLBACK FUNCTIONS" n + (erlang-skel-separator 2) + n + (erlang-skel-separator 2) + "%% Function: init_per_suite(Config0) -> Config1 | {skip,Reason}" n + "%%" n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%% Reason = term()" n + "%% The reason for skipping the suite." n + "%%" n + "%% Description: Initialization before the suite." n + "%%" n + "%% Note: This function is free to add any key/value pairs to the Config" n + "%% variable, but should NOT alter/remove any existing entries." n + (erlang-skel-separator 2) + "init_per_suite(Config) ->" n > + "Config." n n + + (erlang-skel-separator 2) + "%% Function: end_per_suite(Config) -> void()" n + "%%" n + "%% Config = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%%" n + "%% Description: Cleanup after the suite." n + (erlang-skel-separator 2) + "end_per_suite(_Config) ->" n > + "ok." n n + + (erlang-skel-separator 2) + "%% Function: init_per_testcase(TestCase, Config0) -> Config1 |" n + "%% {skip,Reason}" n + "%% TestCase = atom()" n + "%% Name of the test case that is about to run." n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%% Reason = term()" n + "%% The reason for skipping the test case." n + "%%" n + "%% Description: Initialization before each test case." n + "%%" n + "%% Note: This function is free to add any key/value pairs to the Config" n + "%% variable, but should NOT alter/remove any existing entries." n + (erlang-skel-separator 2) + "init_per_testcase(_TestCase, Config) ->" n > + "Config." n n + + (erlang-skel-separator 2) + "%% Function: end_per_testcase(TestCase, Config) -> void()" n + "%%" n + "%% TestCase = atom()" n + "%% Name of the test case that is finished." n + "%% Config = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%%" n + "%% Description: Cleanup after each test case." n + (erlang-skel-separator 2) + "end_per_testcase(_TestCase, _Config) ->" n > + "ok."n n + + (erlang-skel-separator 2) + "%% Function: all(Clause) -> Descr | Spec | {skip,Reason}" n + "%%" n + "%% Clause = doc | suite" n + "%% Indicates expected return value." n + "%% Descr = [string()] | []" n + "%% String that describes the test suite." n + "%% Spec = [TestCase]" n + "%% A test specification." n + "%% TestCase = ConfCase | atom()" n + "%% Configuration case, or the name of a test case function." n + "%% ConfCase = {conf,Init,Spec,End} |" n + "%% {conf,Properties,Init,Spec,End}" n + "%% Init = End = {Mod,Func} | Func" n + "%% Initialization and cleanup function." n + "%% Mod = Func = atom()" n + "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n + "%% Execution properties of the test cases (may be combined)." n + "%% Shuffle = shuffle | {shuffle,Seed}" n + "%% To get cases executed in random order." n + "%% Seed = {integer(),integer(),integer()}" n + "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n + "%% repeat_until_any_ok | repeat_until_any_fail" n + "%% To get execution of cases repeated." n + "%% N = integer() | forever" n + "%% Reason = term()" n + "%% The reason for skipping the test suite." n + "%%" n + "%% Description: Returns a description of the test suite when" n + "%% Clause == doc, and a test specification (list" n + "%% of the conf and test cases in the suite) when" n + "%% Clause == suite." n + (erlang-skel-separator 2) + "all(doc) -> " n > + "[\"Describe the main purpose of this suite\"];" n n + "all(suite) -> " n > + "[a_test_case]." n n + n + (erlang-skel-separator 2) + "%% TEST CASES" n + (erlang-skel-separator 2) + n + (erlang-skel-separator 2) + "%% Function: TestCase(Arg) -> Descr | Spec | ok | exit() | {skip,Reason}" n + "%%" n + "%% Arg = doc | suite | Config" n + "%% Indicates expected behaviour and return value." n + "%% Config = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%% Descr = [string()] | []" n + "%% String that describes the test case." n + "%% Spec = [tuple()] | []" n + "%% A test specification, see all/1." n + "%% Reason = term()" n + "%% The reason for skipping the test case." n + "%%" n + "%% Description: Test case function. Returns a description of the test" n + "%% case (doc), then returns a test specification (suite)," n + "%% or performs the actual test (Config)." n + (erlang-skel-separator 2) + "a_test_case(doc) -> " n > + "[\"Describe the main purpose of this test case\"];" n n + "a_test_case(suite) -> " n > + "[];" n n + "a_test_case(Config) when is_list(Config) -> " n > + "ok." n + ) + "*The template of a library module. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-ct-test-suite-l + '((erlang-skel-include erlang-skel-large-header) + "%% Note: This directive should only be used in test suites." n + "-compile(export_all)." n n + + "-include_lib(\"common_test/include/ct.hrl\")." n n + + (erlang-skel-separator 2) + "%% COMMON TEST CALLBACK FUNCTIONS" n + (erlang-skel-separator 2) + n + (erlang-skel-separator 2) + "%% Function: suite() -> Info" n + "%%" n + "%% Info = [tuple()]" n + "%% List of key/value pairs." n + "%%" n + "%% Description: Returns list of tuples to set default properties" n + "%% for the suite." n + "%%" n + "%% Note: The suite/0 function is only meant to be used to return" n + "%% default data values, not perform any other operations." n + (erlang-skel-separator 2) + "suite() ->" n > + "[{timetrap,{minutes,10}}]." n n + + (erlang-skel-separator 2) + "%% Function: init_per_suite(Config0) ->" n + "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n + "%%" n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%% Reason = term()" n + "%% The reason for skipping the suite." n + "%%" n + "%% Description: Initialization before the suite." n + "%%" n + "%% Note: This function is free to add any key/value pairs to the Config" n + "%% variable, but should NOT alter/remove any existing entries." n + (erlang-skel-separator 2) + "init_per_suite(Config) ->" n > + "Config." n n + + (erlang-skel-separator 2) + "%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}" n + "%%" n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%%" n + "%% Description: Cleanup after the suite." n + (erlang-skel-separator 2) + "end_per_suite(_Config) ->" n > + "ok." n n + + (erlang-skel-separator 2) + "%% Function: init_per_group(GroupName, Config0) ->" n + "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n + "%%" n + "%% GroupName = atom()" n + "%% Name of the test case group that is about to run." n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding configuration data for the group." n + "%% Reason = term()" n + "%% The reason for skipping all test cases and subgroups in the group." n + "%%" n + "%% Description: Initialization before each test case group." n + (erlang-skel-separator 2) + "init_per_group(_GroupName, Config) ->" n > + "Config." n n + + (erlang-skel-separator 2) + "%% Function: end_per_group(GroupName, Config0) ->" n + "%% void() | {save_config,Config1}" n + "%%" n + "%% GroupName = atom()" n + "%% Name of the test case group that is finished." n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding configuration data for the group." n + "%%" n + "%% Description: Cleanup after each test case group." n + (erlang-skel-separator 2) + "end_per_group(_GroupName, _Config) ->" n > + "ok." n n + + (erlang-skel-separator 2) + "%% Function: init_per_testcase(TestCase, Config0) ->" n + "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n + "%%" n + "%% TestCase = atom()" n + "%% Name of the test case that is about to run." n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%% Reason = term()" n + "%% The reason for skipping the test case." n + "%%" n + "%% Description: Initialization before each test case." n + "%%" n + "%% Note: This function is free to add any key/value pairs to the Config" n + "%% variable, but should NOT alter/remove any existing entries." n + (erlang-skel-separator 2) + "init_per_testcase(_TestCase, Config) ->" n > + "Config." n n + + (erlang-skel-separator 2) + "%% Function: end_per_testcase(TestCase, Config0) ->" n + "%% void() | {save_config,Config1} | {fail,Reason}" n + "%%" n + "%% TestCase = atom()" n + "%% Name of the test case that is finished." n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%% Reason = term()" n + "%% The reason for failing the test case." n + "%%" n + "%% Description: Cleanup after each test case." n + (erlang-skel-separator 2) + "end_per_testcase(_TestCase, _Config) ->" n > + "ok." n n + + (erlang-skel-separator 2) + "%% Function: groups() -> [Group]" n + "%%" n + "%% Group = {GroupName,Properties,GroupsAndTestCases}" n + "%% GroupName = atom()" n + "%% The name of the group." n + "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n + "%% Group properties that may be combined." n + "%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]" n + "%% TestCase = atom()" n + "%% The name of a test case." n + "%% Shuffle = shuffle | {shuffle,Seed}" n + "%% To get cases executed in random order." n + "%% Seed = {integer(),integer(),integer()}" n + "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n + "%% repeat_until_any_ok | repeat_until_any_fail" n + "%% To get execution of cases repeated." n + "%% N = integer() | forever" n + "%%" n + "%% Description: Returns a list of test case group definitions." n + (erlang-skel-separator 2) + "groups() ->" n > + "[]." n n + + (erlang-skel-separator 2) + "%% Function: all() -> GroupsAndTestCases | {skip,Reason}" n + "%%" n + "%% GroupsAndTestCases = [{group,GroupName} | TestCase]" n + "%% GroupName = atom()" n + "%% Name of a test case group." n + "%% TestCase = atom()" n + "%% Name of a test case." n + "%% Reason = term()" n + "%% The reason for skipping all groups and test cases." n + "%%" n + "%% Description: Returns the list of groups and test cases that" n + "%% are to be executed." n + (erlang-skel-separator 2) + "all() -> " n > + "[my_test_case]." n n + + n + (erlang-skel-separator 2) + "%% TEST CASES" n + (erlang-skel-separator 2) + n + + (erlang-skel-separator 2) + "%% Function: TestCase() -> Info" n + "%%" n + "%% Info = [tuple()]" n + "%% List of key/value pairs." n + "%%" n + "%% Description: Test case info function - returns list of tuples to set" n + "%% properties for the test case." n + "%%" n + "%% Note: This function is only meant to be used to return a list of" n + "%% values, not perform any other operations." n + (erlang-skel-separator 2) + "my_test_case() -> " n > + "[]." n n + + (erlang-skel-separator 2) + "%% Function: TestCase(Config0) ->" n + "%% ok | exit() | {skip,Reason} | {comment,Comment} |" n + "%% {save_config,Config1} | {skip_and_save,Reason,Config1}" n + "%%" n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%% Reason = term()" n + "%% The reason for skipping the test case." n + "%% Comment = term()" n + "%% A comment about the test case that will be printed in the html log." n + "%%" n + "%% Description: Test case function. (The name of it must be specified in" n + "%% the all/0 list or in a test case group for the test case" n + "%% to be executed)." n + (erlang-skel-separator 2) + "my_test_case(_Config) -> " n > + "ok." n + ) + "*The template of a library module. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-ct-test-suite-s + '((erlang-skel-include erlang-skel-large-header) + "-compile(export_all)." n n + + "-include_lib(\"common_test/include/ct.hrl\")." n n + + (erlang-skel-separator 2) + "%% Function: suite() -> Info" n + "%% Info = [tuple()]" n + (erlang-skel-separator 2) + "suite() ->" n > + "[{timetrap,{seconds,30}}]." n n + + (erlang-skel-separator 2) + "%% Function: init_per_suite(Config0) ->" n + "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n + "%% Config0 = Config1 = [tuple()]" n + "%% Reason = term()" n + (erlang-skel-separator 2) + "init_per_suite(Config) ->" n > + "Config." n n + + (erlang-skel-separator 2) + "%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}" n + "%% Config0 = Config1 = [tuple()]" n + (erlang-skel-separator 2) + "end_per_suite(_Config) ->" n > + "ok." n n + + (erlang-skel-separator 2) + "%% Function: init_per_group(GroupName, Config0) ->" n + "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n + "%% GroupName = atom()" n + "%% Config0 = Config1 = [tuple()]" n + "%% Reason = term()" n + (erlang-skel-separator 2) + "init_per_group(_GroupName, Config) ->" n > + "Config." n n + + (erlang-skel-separator 2) + "%% Function: end_per_group(GroupName, Config0) ->" n + "%% void() | {save_config,Config1}" n + "%% GroupName = atom()" n + "%% Config0 = Config1 = [tuple()]" n + (erlang-skel-separator 2) + "end_per_group(_GroupName, _Config) ->" n > + "ok." n n + + (erlang-skel-separator 2) + "%% Function: init_per_testcase(TestCase, Config0) ->" n + "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n + "%% TestCase = atom()" n + "%% Config0 = Config1 = [tuple()]" n + "%% Reason = term()" n + (erlang-skel-separator 2) + "init_per_testcase(_TestCase, Config) ->" n > + "Config." n n + + (erlang-skel-separator 2) + "%% Function: end_per_testcase(TestCase, Config0) ->" n + "%% void() | {save_config,Config1} | {fail,Reason}" n + "%% TestCase = atom()" n + "%% Config0 = Config1 = [tuple()]" n + "%% Reason = term()" n + (erlang-skel-separator 2) + "end_per_testcase(_TestCase, _Config) ->" n > + "ok." n n + + (erlang-skel-separator 2) + "%% Function: groups() -> [Group]" n + "%% Group = {GroupName,Properties,GroupsAndTestCases}" n + "%% GroupName = atom()" n + "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n + "%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]" n + "%% TestCase = atom()" n + "%% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}}" n + "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n + "%% repeat_until_any_ok | repeat_until_any_fail" n + "%% N = integer() | forever" n + (erlang-skel-separator 2) + "groups() ->" n > + "[]." n n + + (erlang-skel-separator 2) + "%% Function: all() -> GroupsAndTestCases | {skip,Reason}" n + "%% GroupsAndTestCases = [{group,GroupName} | TestCase]" n + "%% GroupName = atom()" n + "%% TestCase = atom()" n + "%% Reason = term()" n + (erlang-skel-separator 2) + "all() -> " n > + "[my_test_case]." n n + + (erlang-skel-separator 2) + "%% Function: TestCase() -> Info" n + "%% Info = [tuple()]" n + (erlang-skel-separator 2) + "my_test_case() -> " n > + "[]." n n + + (erlang-skel-separator 2) + "%% Function: TestCase(Config0) ->" n + "%% ok | exit() | {skip,Reason} | {comment,Comment} |" n + "%% {save_config,Config1} | {skip_and_save,Reason,Config1}" n + "%% Config0 = Config1 = [tuple()]" n + "%% Reason = term()" n + "%% Comment = term()" n + (erlang-skel-separator 2) + "my_test_case(_Config) -> " n > + "ok." n + ) + "*The template of a library module. +Please see the function `tempo-define-template'.") diff --git a/lib/tools/emacs/erlang-skels.el b/lib/tools/emacs/erlang-skels.el new file mode 100644 index 0000000000..355b223822 --- /dev/null +++ b/lib/tools/emacs/erlang-skels.el @@ -0,0 +1,1553 @@ +;; +;; %CopyrightBegin% +;; +;; Copyright Ericsson AB 2010. All Rights Reserved. +;; +;; The contents of this file are subject to the Erlang Public License, +;; Version 1.1, (the "License"); you may not use this file except in +;; compliance with the License. You should have received a copy of the +;; Erlang Public License along with this software. If not, it can be +;; retrieved online at http://www.erlang.org/. +;; +;; Software distributed under the License is distributed on an "AS IS" +;; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +;; the License for the specific language governing rights and limitations +;; under the License. +;; +;; %CopyrightEnd% +;;; +;;; Purpose: Provide Erlang code skeletons. +;;; See 'erlang-skel-file' variable. + +(defvar erlang-tempo-tags nil + "Tempo tags for erlang mode") + +(defvar erlang-skel + '(("If" "if" erlang-skel-if) + ("Case" "case" erlang-skel-case) + ("Receive" "receive" erlang-skel-receive) + ("Receive After" "after" erlang-skel-receive-after) + ("Receive Loop" "loop" erlang-skel-receive-loop) + ("Module" "module" erlang-skel-module) + ("Author" "author" erlang-skel-author) + ("Function" "function" erlang-skel-function) + () + ("Small Header" "small-header" + erlang-skel-small-header erlang-skel-header) + ("Normal Header" "normal-header" + erlang-skel-normal-header erlang-skel-header) + ("Large Header" "large-header" + erlang-skel-large-header erlang-skel-header) + () + ("Small Server" "small-server" + erlang-skel-small-server erlang-skel-header) + () + ("Application" "application" + erlang-skel-application erlang-skel-header) + ("Supervisor" "supervisor" + erlang-skel-supervisor erlang-skel-header) + ("supervisor_bridge" "supervisor-bridge" + erlang-skel-supervisor-bridge erlang-skel-header) + ("gen_server" "generic-server" + erlang-skel-generic-server erlang-skel-header) + ("gen_event" "gen-event" + erlang-skel-gen-event erlang-skel-header) + ("gen_fsm" "gen-fsm" + erlang-skel-gen-fsm erlang-skel-header) + ("Library module" "gen-lib" + erlang-skel-lib erlang-skel-header) + ("Corba callback" "gen-corba-cb" + erlang-skel-corba-callback erlang-skel-header) + ("Small Common Test suite" "ct-test-suite-s" + erlang-skel-ct-test-suite-s erlang-skel-header) + ("Large Common Test suite" "ct-test-suite-l" + erlang-skel-ct-test-suite-l erlang-skel-header) + ("Erlang TS test suite" "ts-test-suite" + erlang-skel-ts-test-suite erlang-skel-header) + ) + "*Description of all skeleton templates. +Both functions and menu entries will be created. + +Each entry in `erlang-skel' should be a list with three or four +elements, or the empty list. + +The first element is the name which shows up in the menu. The second +is the `tempo' identifier (The string \"erlang-\" will be added in +front of it). The third is the skeleton descriptor, a variable +containing `tempo' attributes as described in the function +`tempo-define-template'. The optional fourth elements denotes a +function which should be called when the menu is selected. + +Functions corresponding to every template will be created. The name +of the function will be `tempo-template-erlang-X' where `X' is the +tempo identifier as specified in the second argument of the elements +in this list. + +A list with zero elements means that the a horizontal line should +be placed in the menu.") + +(defvar erlang-skel-use-separators t + "A boolean than determines whether the skeletons include horizontal +separators. + +Should this variable be nil, the documentation for functions will not +include separators of the form %%--...") + +;; In XEmacs `user-mail-address' returns "[email protected] (Foo Bar)" ARGH! +;; What's wrong with that? RFC 822 says it's legal. [sverkerw] +;; This needs to use the customized value. If that's not sane, things like +;; add-log will lose anyhow. Avoid it if there _is_ a paren. +(defvar erlang-skel-mail-address + (if (or (not user-mail-address) (string-match "(" user-mail-address)) + (concat (user-login-name) "@" + (or (and (boundp 'mail-host-address) + mail-host-address) + (system-name))) + user-mail-address) + "Mail address of the user.") + +;; Expression templates: +(defvar erlang-skel-case + '((erlang-skel-skip-blank) o > + "case " p " of" n> p "_ ->" n> p "ok" n> "end" p) + "*The skeleton of a `case' expression. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-if + '((erlang-skel-skip-blank) o > + "if" n> p " ->" n> p "ok" n> "end" p) + "The skeleton of an `if' expression. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-receive + '((erlang-skel-skip-blank) o > + "receive" n> p "_ ->" n> p "ok" n> "end" p) + "*The skeleton of a `receive' expression. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-receive-after + '((erlang-skel-skip-blank) o > + "receive" n> p "_ ->" n> p "ok" n> "after " p "T ->" n> + p "ok" n> "end" p) + "*The skeleton of a `receive' expression with an `after' clause. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-receive-loop + '(& o "loop(" p ") ->" n> "receive" n> p "_ ->" n> + "loop(" p ")" n> "end.") + "*The skeleton of a simple `receive' loop. +Please see the function `tempo-define-template'.") + + +(defvar erlang-skel-function + '((erlang-skel-separator-start 2) + "%% @doc" n + "%% @spec" n + (erlang-skel-separator-end 2)) + "*The template of a function skeleton. +Please see the function `tempo-define-template'.") + + +;; Attribute templates + +(defvar erlang-skel-module + '(& "-module(" + (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) + ")." n) + "*The skeleton of a `module' attribute. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-author + '(& "-author('" erlang-skel-mail-address "')." n) + "*The skeleton of a `author' attribute. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-vc nil + "*The skeleton template to generate a version control attribute. +The default is to insert nothing. Example of usage: + + (setq erlang-skel-vc '(& \"-rcs(\\\"$\Id: $ \\\").\") n) + +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-export + '(& "-export([" n> "])." n) + "*The skeleton of an `export' attribute. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-import + '(& "%%-import(Module, [Function/Arity, ...])." n) + "*The skeleton of an `import' attribute. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-compile nil + ;; '(& "%%-compile(export_all)." n) + "*The skeleton of a `compile' attribute. +Please see the function `tempo-define-template'.") + + +;; Comment templates. + +(defvar erlang-skel-date-function 'erlang-skel-dd-mmm-yyyy + "*Function which returns date string. +Look in the module `time-stamp' for a battery of functions.") + +(defvar erlang-skel-copyright-comment + (if (boundp '*copyright-organization*) + '(& "%%% @copyright (C) " (format-time-string "%Y") ", " + *copyright-organization* n) + '(& "%%% @copyright (C) " (format-time-string "%Y") ", " + (user-full-name) n)) + "*The template for a copyright line in the header, normally empty. +This variable should be bound to a `tempo' template, for example: + '(& \"%%% Copyright (C) 2000, Yoyodyne, Inc.\" n) +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-created-comment + '(& "%%% Created : " (funcall erlang-skel-date-function) " by " + (user-full-name) " <" erlang-skel-mail-address ">" n) + "*The template for the \"Created:\" comment line.") + +(defvar erlang-skel-author-comment + '(& "%%% @author " (user-full-name) " <" erlang-skel-mail-address ">" n) + "*The template for creating the \"Author:\" line in the header. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-small-header + '(o (erlang-skel-include erlang-skel-module) + n + (erlang-skel-include erlang-skel-compile erlang-skel-vc)) + "*The template of a small header without any comments. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-normal-header + '(o (erlang-skel-include erlang-skel-author-comment) + (erlang-skel-include erlang-skel-copyright-comment) + "%%% @doc" n + "%%%" p n + "%%% @end" n + (erlang-skel-include erlang-skel-created-comment) n + (erlang-skel-include erlang-skel-small-header) n) + "*The template of a normal header. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-large-header + '(o (erlang-skel-separator) + (erlang-skel-include erlang-skel-author-comment) + (erlang-skel-include erlang-skel-copyright-comment) + "%%% @doc" n + "%%%" p n + "%%% @end" n + (erlang-skel-include erlang-skel-created-comment) + (erlang-skel-separator) + (erlang-skel-include erlang-skel-small-header) ) + "*The template of a large header. +Please see the function `tempo-define-template'.") + + + ;; Server templates. +(defvar erlang-skel-small-server + '((erlang-skel-include erlang-skel-large-header) + "-export([start/0, init/1])." n n n + "start() ->" n> "spawn(" (erlang-get-module-from-file-name) + ", init, [self()])." n n + "init(From) ->" n> + "loop(From)." n n + "loop(From) ->" n> + "receive" n> + p "_ ->" n> + "loop(From)" n> + "end." n + ) + "*Template of a small server. +Please see the function `tempo-define-template'.") + +;; Behaviour templates. +(defvar erlang-skel-application + '((erlang-skel-include erlang-skel-large-header) + "-behaviour(application)." n n + "%% Application callbacks" n + "-export([start/2, stop/1])." n n + (erlang-skel-double-separator-start 3) + "%%% Application callbacks" n + (erlang-skel-double-separator-end 3) n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% This function is called whenever an application is started using" n + "%% application:start/[1,2], and should start the processes of the" n + "%% application. If the application is structured according to the OTP" n + "%% design principles as a supervision tree, this means starting the" n + "%% top supervisor of the tree." n + "%%" n + "%% @spec start(StartType, StartArgs) -> {ok, Pid} |" n + "%% {ok, Pid, State} |" n + "%% {error, Reason}" n + "%% StartType = normal | {takeover, Node} | {failover, Node}" n + "%% StartArgs = term()" n + (erlang-skel-separator-end 2) + "start(_StartType, _StartArgs) ->" n> + "case 'TopSupervisor':start_link() of" n> + "{ok, Pid} ->" n> + "{ok, Pid};" n> + "Error ->" n> + "Error" n> + "end." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% This function is called whenever an application has stopped. It" n + "%% is intended to be the opposite of Module:start/2 and should do" n + "%% any necessary cleaning up. The return value is ignored." n + "%%" n + "%% @spec stop(State) -> void()" n + (erlang-skel-separator-end 2) + "stop(_State) ->" n> + "ok." n + n + (erlang-skel-double-separator-start 3) + "%%% Internal functions" n + (erlang-skel-double-separator-end 3) + ) + "*The template of an application behaviour. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-supervisor + '((erlang-skel-include erlang-skel-large-header) + "-behaviour(supervisor)." n n + + "%% API" n + "-export([start_link/0])." n n + + "%% Supervisor callbacks" n + "-export([init/1])." n n + + "-define(SERVER, ?MODULE)." n n + + (erlang-skel-double-separator-start 3) + "%%% API functions" n + (erlang-skel-double-separator-end 3) n + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Starts the supervisor" n + "%%" n + "%% @spec start_link() -> {ok, Pid} | ignore | {error, Error}" n + (erlang-skel-separator-end 2) + "start_link() ->" n> + "supervisor:start_link({local, ?SERVER}, ?MODULE, [])." n + n + (erlang-skel-double-separator-start 3) + "%%% Supervisor callbacks" n + (erlang-skel-double-separator-end 3) n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Whenever a supervisor is started using supervisor:start_link/[2,3]," n + "%% this function is called by the new process to find out about" n + "%% restart strategy, maximum restart frequency and child" n + "%% specifications." n + "%%" n + "%% @spec init(Args) -> {ok, {SupFlags, [ChildSpec]}} |" n + "%% ignore |" n + "%% {error, Reason}" n + (erlang-skel-separator-end 2) + "init([]) ->" n> + "RestartStrategy = one_for_one," n> + "MaxRestarts = 1000," n> + "MaxSecondsBetweenRestarts = 3600," n + "" n> + "SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts}," n + "" n> + "Restart = permanent," n> + "Shutdown = 2000," n> + "Type = worker," n + "" n> + "AChild = {'AName', {'AModule', start_link, []}," n> + "Restart, Shutdown, Type, ['AModule']}," n + "" n> + "{ok, {SupFlags, [AChild]}}." n + n + (erlang-skel-double-separator-start 3) + "%%% Internal functions" n + (erlang-skel-double-separator-end 3) + ) + "*The template of an supervisor behaviour. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-supervisor-bridge + '((erlang-skel-include erlang-skel-large-header) + "-behaviour(supervisor_bridge)." n n + + "%% API" n + "-export([start_link/0])." n n + + "%% supervisor_bridge callbacks" n + "-export([init/1, terminate/2])." n n + + "-define(SERVER, ?MODULE)." n n + + "-record(state, {})." n n + + (erlang-skel-double-separator-start 3) + "%%% API" n + (erlang-skel-double-separator-end 3) n + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Starts the supervisor bridge" n + "%%" n + "%% @spec start_link() -> {ok, Pid} | ignore | {error, Error}" n + (erlang-skel-separator-end 2) + "start_link() ->" n> + "supervisor_bridge:start_link({local, ?SERVER}, ?MODULE, [])." n + n + (erlang-skel-double-separator-start 3) + "%%% supervisor_bridge callbacks" n + (erlang-skel-double-separator-end 3) n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Creates a supervisor_bridge process, linked to the calling process," n + "%% which calls Module:init/1 to start the subsystem. To ensure a" n + "%% synchronized start-up procedure, this function does not return" n + "%% until Module:init/1 has returned." n + "%%" n + "%% @spec init(Args) -> {ok, Pid, State} |" n + "%% ignore |" n + "%% {error, Reason}" n + (erlang-skel-separator-end 2) + "init([]) ->" n> + "case 'AModule':start_link() of" n> + "{ok, Pid} ->" n> + "{ok, Pid, #state{}};" n> + "Error ->" n> + "Error" n> + "end." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% This function is called by the supervisor_bridge when it is about" n + "%% to terminate. It should be the opposite of Module:init/1 and stop" n + "%% the subsystem and do any necessary cleaning up.The return value is" n + "%% ignored." n + "%%" n + "%% @spec terminate(Reason, State) -> void()" n + (erlang-skel-separator-end 2) + "terminate(Reason, State) ->" n> + "'AModule':stop()," n> + "ok." n + n + (erlang-skel-double-separator-start 3) + "%%% Internal functions" n + (erlang-skel-double-separator-end 3) + ) + "*The template of an supervisor_bridge behaviour. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-generic-server + '((erlang-skel-include erlang-skel-large-header) + "-behaviour(gen_server)." n n + + "%% API" n + "-export([start_link/0])." n n + + "%% gen_server callbacks" n + "-export([init/1, handle_call/3, handle_cast/2, " + "handle_info/2," n> + "terminate/2, code_change/3])." n n + + "-define(SERVER, ?MODULE). " n n + + "-record(state, {})." n n + + (erlang-skel-double-separator-start 3) + "%%% API" n + (erlang-skel-double-separator-end 3) n + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Starts the server" n + "%%" n + "%% @spec start_link() -> {ok, Pid} | ignore | {error, Error}" n + (erlang-skel-separator-end 2) + "start_link() ->" n> + "gen_server:start_link({local, ?SERVER}, ?MODULE, [], [])." n + n + (erlang-skel-double-separator-start 3) + "%%% gen_server callbacks" n + (erlang-skel-double-separator-end 3) + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Initializes the server" n + "%%" n + "%% @spec init(Args) -> {ok, State} |" n + "%% {ok, State, Timeout} |" n + "%% ignore |" n + "%% {stop, Reason}" n + (erlang-skel-separator-end 2) + "init([]) ->" n> + "{ok, #state{}}." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Handling call messages" n + "%%" n + "%% @spec handle_call(Request, From, State) ->" n + "%% {reply, Reply, State} |" n + "%% {reply, Reply, State, Timeout} |" n + "%% {noreply, State} |" n + "%% {noreply, State, Timeout} |" n + "%% {stop, Reason, Reply, State} |" n + "%% {stop, Reason, State}" n + (erlang-skel-separator-end 2) + "handle_call(_Request, _From, State) ->" n> + "Reply = ok," n> + "{reply, Reply, State}." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Handling cast messages" n + "%%" n + "%% @spec handle_cast(Msg, State) -> {noreply, State} |" n + "%% {noreply, State, Timeout} |" n + "%% {stop, Reason, State}" n + (erlang-skel-separator-end 2) + "handle_cast(_Msg, State) ->" n> + "{noreply, State}." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Handling all non call/cast messages" n + "%%" n + "%% @spec handle_info(Info, State) -> {noreply, State} |" n + "%% {noreply, State, Timeout} |" n + "%% {stop, Reason, State}" n + (erlang-skel-separator-end 2) + "handle_info(_Info, State) ->" n> + "{noreply, State}." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% This function is called by a gen_server when it is about to" n + "%% terminate. It should be the opposite of Module:init/1 and do any" n + "%% necessary cleaning up. When it returns, the gen_server terminates" n + "%% with Reason. The return value is ignored." n + "%%" n + "%% @spec terminate(Reason, State) -> void()" n + (erlang-skel-separator-end 2) + "terminate(_Reason, _State) ->" n> + "ok." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Convert process state when code is changed" n + "%%" n + "%% @spec code_change(OldVsn, State, Extra) -> {ok, NewState}" n + (erlang-skel-separator-end 2) + "code_change(_OldVsn, State, _Extra) ->" n> + "{ok, State}." n + n + (erlang-skel-double-separator-start 3) + "%%% Internal functions" n + (erlang-skel-double-separator-end 3) + ) + "*The template of a generic server. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-gen-event + '((erlang-skel-include erlang-skel-large-header) + "-behaviour(gen_event)." n n + + "%% API" n + "-export([start_link/0, add_handler/0])." n n + + "%% gen_event callbacks" n + "-export([init/1, handle_event/2, handle_call/2, " n> + "handle_info/2, terminate/2, code_change/3])." n n + + "-define(SERVER, ?MODULE). " n n + + "-record(state, {})." n n + + (erlang-skel-double-separator-start 3) + "%%% gen_event callbacks" n + (erlang-skel-double-separator-end 3) n + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Creates an event manager" n + "%%" n + "%% @spec start_link() -> {ok, Pid} | {error, Error}" n + (erlang-skel-separator-end 2) + "start_link() ->" n> + "gen_event:start_link({local, ?SERVER})." n + n + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Adds an event handler" n + "%%" n + "%% @spec add_handler() -> ok | {'EXIT', Reason} | term()" n + (erlang-skel-separator-end 2) + "add_handler() ->" n> + "gen_event:add_handler(?SERVER, ?MODULE, [])." n + n + (erlang-skel-double-separator-start 3) + "%%% gen_event callbacks" n + (erlang-skel-double-separator-end 3) n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Whenever a new event handler is added to an event manager," n + "%% this function is called to initialize the event handler." n + "%%" n + "%% @spec init(Args) -> {ok, State}" n + (erlang-skel-separator-end 2) + "init([]) ->" n> + "{ok, #state{}}." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Whenever an event manager receives an event sent using" n + "%% gen_event:notify/2 or gen_event:sync_notify/2, this function is" n + "%% called for each installed event handler to handle the event." n + "%%" n + "%% @spec handle_event(Event, State) ->" n + "%% {ok, State} |" n + "%% {swap_handler, Args1, State1, Mod2, Args2} |"n + "%% remove_handler" n + (erlang-skel-separator-end 2) + "handle_event(_Event, State) ->" n> + "{ok, State}." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Whenever an event manager receives a request sent using" n + "%% gen_event:call/3,4, this function is called for the specified" n + "%% event handler to handle the request." n + "%%" n + "%% @spec handle_call(Request, State) ->" n + "%% {ok, Reply, State} |" n + "%% {swap_handler, Reply, Args1, State1, Mod2, Args2} |" n + "%% {remove_handler, Reply}" n + (erlang-skel-separator-end 2) + "handle_call(_Request, State) ->" n> + "Reply = ok," n> + "{ok, Reply, State}." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% This function is called for each installed event handler when" n + "%% an event manager receives any other message than an event or a" n + "%% synchronous request (or a system message)." n + "%%" n + "%% @spec handle_info(Info, State) ->" n + "%% {ok, State} |" n + "%% {swap_handler, Args1, State1, Mod2, Args2} |" n + "%% remove_handler" n + (erlang-skel-separator-end 2) + "handle_info(_Info, State) ->" n> + "{ok, State}." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Whenever an event handler is deleted from an event manager, this" n + "%% function is called. It should be the opposite of Module:init/1 and" n + "%% do any necessary cleaning up." n + "%%" n + "%% @spec terminate(Reason, State) -> void()" n + (erlang-skel-separator-end 2) + "terminate(_Reason, _State) ->" n> + "ok." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Convert process state when code is changed" n + "%%" n + "%% @spec code_change(OldVsn, State, Extra) -> {ok, NewState}" n + (erlang-skel-separator-end 2) + "code_change(_OldVsn, State, _Extra) ->" n> + "{ok, State}." n + n + (erlang-skel-double-separator-start 3) + "%%% Internal functions" n + (erlang-skel-double-separator-end 3) + ) + "*The template of a gen_event. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-gen-fsm + '((erlang-skel-include erlang-skel-large-header) + "-behaviour(gen_fsm)." n n + + "%% API" n + "-export([start_link/0])." n n + + "%% gen_fsm callbacks" n + "-export([init/1, state_name/2, state_name/3, handle_event/3," n> + "handle_sync_event/4, handle_info/3, terminate/3, code_change/4])." n n + + "-define(SERVER, ?MODULE)." n n + + "-record(state, {})." n n + + (erlang-skel-double-separator-start 3) + "%%% API" n + (erlang-skel-double-separator-end 3) n + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Creates a gen_fsm process which calls Module:init/1 to" n + "%% initialize. To ensure a synchronized start-up procedure, this" n + "%% function does not return until Module:init/1 has returned." n + "%%" n + "%% @spec start_link() -> {ok, Pid} | ignore | {error, Error}" n + (erlang-skel-separator-end 2) + "start_link() ->" n> + "gen_fsm:start_link({local, ?SERVER}, ?MODULE, [], [])." n + n + (erlang-skel-double-separator-start 3) + "%%% gen_fsm callbacks" n + (erlang-skel-double-separator-end 3) n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Whenever a gen_fsm is started using gen_fsm:start/[3,4] or" n + "%% gen_fsm:start_link/[3,4], this function is called by the new" n + "%% process to initialize." n + "%%" n + "%% @spec init(Args) -> {ok, StateName, State} |" n + "%% {ok, StateName, State, Timeout} |" n + "%% ignore |" n + "%% {stop, StopReason}" n + (erlang-skel-separator-end 2) + "init([]) ->" n> + "{ok, state_name, #state{}}." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% There should be one instance of this function for each possible" n + "%% state name. Whenever a gen_fsm receives an event sent using" n + "%% gen_fsm:send_event/2, the instance of this function with the same" n + "%% name as the current state name StateName is called to handle" n + "%% the event. It is also called if a timeout occurs." n + "%%" n + "%% @spec state_name(Event, State) ->" n + "%% {next_state, NextStateName, NextState} |" n + "%% {next_state, NextStateName, NextState, Timeout} |" n + "%% {stop, Reason, NewState}" n + (erlang-skel-separator-end 2) + "state_name(_Event, State) ->" n> + "{next_state, state_name, State}." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% There should be one instance of this function for each possible" n + "%% state name. Whenever a gen_fsm receives an event sent using" n + "%% gen_fsm:sync_send_event/[2,3], the instance of this function with" n + "%% the same name as the current state name StateName is called to" n + "%% handle the event." n + "%%" n + "%% @spec state_name(Event, From, State) ->" n + "%% {next_state, NextStateName, NextState} |"n + "%% {next_state, NextStateName, NextState, Timeout} |" n + "%% {reply, Reply, NextStateName, NextState} |" n + "%% {reply, Reply, NextStateName, NextState, Timeout} |" n + "%% {stop, Reason, NewState} |" n + "%% {stop, Reason, Reply, NewState}" n + (erlang-skel-separator-end 2) + "state_name(_Event, _From, State) ->" n> + "Reply = ok," n> + "{reply, Reply, state_name, State}." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Whenever a gen_fsm receives an event sent using" n + "%% gen_fsm:send_all_state_event/2, this function is called to handle" n + "%% the event." n + "%%" n + "%% @spec handle_event(Event, StateName, State) ->" n + "%% {next_state, NextStateName, NextState} |" n + "%% {next_state, NextStateName, NextState, Timeout} |" n + "%% {stop, Reason, NewState}" n + (erlang-skel-separator-end 2) + "handle_event(_Event, StateName, State) ->" n> + "{next_state, StateName, State}." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Whenever a gen_fsm receives an event sent using" n + "%% gen_fsm:sync_send_all_state_event/[2,3], this function is called" n + "%% to handle the event." n + "%%" n + "%% @spec handle_sync_event(Event, From, StateName, State) ->" n + "%% {next_state, NextStateName, NextState} |" n + "%% {next_state, NextStateName, NextState, Timeout} |" n + "%% {reply, Reply, NextStateName, NextState} |" n + "%% {reply, Reply, NextStateName, NextState, Timeout} |" n + "%% {stop, Reason, NewState} |" n + "%% {stop, Reason, Reply, NewState}" n + (erlang-skel-separator-end 2) + "handle_sync_event(_Event, _From, StateName, State) ->" n> + "Reply = ok," n> + "{reply, Reply, StateName, State}." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% This function is called by a gen_fsm when it receives any" n + "%% message other than a synchronous or asynchronous event" n + "%% (or a system message)." n + "%%" n + "%% @spec handle_info(Info,StateName,State)->" n + "%% {next_state, NextStateName, NextState} |" n + "%% {next_state, NextStateName, NextState, Timeout} |" n + "%% {stop, Reason, NewState}" n + (erlang-skel-separator-end 2) + "handle_info(_Info, StateName, State) ->" n> + "{next_state, StateName, State}." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% This function is called by a gen_fsm when it is about to" n + "%% terminate. It should be the opposite of Module:init/1 and do any" n + "%% necessary cleaning up. When it returns, the gen_fsm terminates with" n + "%% Reason. The return value is ignored." n + "%%" n + "%% @spec terminate(Reason, StateName, State) -> void()" n + (erlang-skel-separator-end 2) + "terminate(_Reason, _StateName, _State) ->" n> + "ok." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Convert process state when code is changed" n + "%%" n + "%% @spec code_change(OldVsn, StateName, State, Extra) ->" n + "%% {ok, StateName, NewState}" n + (erlang-skel-separator-end 2) + "code_change(_OldVsn, StateName, State, _Extra) ->" n> + "{ok, StateName, State}." n + n + (erlang-skel-double-separator-start 3) + "%%% Internal functions" n + (erlang-skel-double-separator-end 3) + ) + "*The template of a gen_fsm. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-lib + '((erlang-skel-include erlang-skel-large-header) + + "%% API" n + "-export([])." n n + + (erlang-skel-double-separator-start 3) + "%%% API" n + (erlang-skel-double-separator-end 3) n + (erlang-skel-separator-start 2) + "%% @doc" n + "%% @spec" n + (erlang-skel-separator-end 2) + n + (erlang-skel-double-separator-start 3) + "%%% Internal functions" n + (erlang-skel-double-separator-end 3) + ) + "*The template of a library module. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-corba-callback + '((erlang-skel-include erlang-skel-large-header) + "%% Include files" n n + + "%% API" n + "-export([])." n n + + "%% Corba callbacks" n + "-export([init/1, terminate/2, code_change/3])." n n + + "-record(state, {})." n n + + (erlang-skel-double-separator-start 3) + "%%% Corba callbacks" n + (erlang-skel-double-separator-end 3) n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Initializes the server" n + "%%" n + "%% @spec init(Args) -> {ok, State} |" n + "%% {ok, State, Timeout} |" n + "%% ignore |" n + "%% {stop, Reason}" n + (erlang-skel-separator-end 2) + "init([]) ->" n> + "{ok, #state{}}." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Shutdown the server" n + "%%" n + "%% @spec terminate(Reason, State) -> void()" n + (erlang-skel-separator-end 2) + "terminate(_Reason, _State) ->" n> + "ok." n + n + (erlang-skel-separator-start 2) + "%% @private" n + "%% @doc" n + "%% Convert process state when code is changed" n + "%%" n + "%% @spec code_change(OldVsn, State, Extra) -> {ok, NewState}" n + (erlang-skel-separator-end 2) + "code_change(_OldVsn, State, _Extra) ->" n> + "{ok, State}." n + n + (erlang-skel-double-separator-start 3) + "%%% Internal functions" n + (erlang-skel-double-separator-end 3) + ) + "*The template of a library module. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-ts-test-suite + '((erlang-skel-include erlang-skel-large-header) + "%% Note: This directive should only be used in test suites." n + "-compile(export_all)." n n + + "-include_lib(\"test_server/include/test_server.hrl\")." n n + + (erlang-skel-separator-start 2) + "%% TEST SERVER CALLBACK FUNCTIONS" n + (erlang-skel-separator 2) + n + (erlang-skel-separator-start 2) + "%%" n + "%% @doc" n + "%% Initialization before the suite." n + "%%" n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%% Reason = term()" n + "%% The reason for skipping the suite." n + "%%" n + "%% Note: This function is free to add any key/value pairs to the Config" n + "%% variable, but should NOT alter/remove any existing entries." n + "%%" n + "%% @spec init_per_suite(Config) -> Config" n + (erlang-skel-separator-end 2) + "init_per_suite(Config) ->" n > + "Config." n n + + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Cleanup after the suite." n + "%% Config - [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%%" n + "%% @spec end_per_suite(Config) -> _" n + (erlang-skel-separator-end 2) + "end_per_suite(_Config) ->" n > + "ok." n n + + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Initialization before each test case" n + "%%" n + "%% TestCase - atom()" n + "%% Name of the test case that is about to be run." n + "%% Config - [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%% Reason = term()" n + "%% The reason for skipping the test case." n + "%%" n + "%% Note: This function is free to add any key/value pairs to the Config" n + "%% variable, but should NOT alter/remove any existing entries." n + "%%" n + "%% @spec init_per_testcase(TestCase, Config) -> Config" n + (erlang-skel-separator-end 2) + "init_per_testcase(_TestCase, Config) ->" n > + "Config." n n + + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Cleanup after each test case" n + "%%" n + "%% TestCase = atom()" n + "%% Name of the test case that is finished." n + "%% Config = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%%" n + "%% @spec end_per_testcase(TestCase, Config) -> _" n + (erlang-skel-separator-end 2) + "end_per_testcase(_TestCase, _Config) ->" n > + "ok."n n + + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Returns a description of the test suite when" n + "%% Clause == doc, and a test specification (list" n + "%% of the conf and test cases in the suite) when" n + "%% Clause == suite." n + "%% Returns a list of all test cases in this test suite" n + "%%" n + "%% Clause = doc | suite" n + "%% Indicates expected return value." n + "%% Descr = [string()] | []" n + "%% String that describes the test suite." n + "%% Spec = [TestCase]" n + "%% A test specification." n + "%% TestCase = ConfCase | atom()" n + "%% Configuration case, or the name of a test case function." n + "%% ConfCase = {conf,Init,Spec,End} |" n + "%% {conf,Properties,Init,Spec,End}" n + "%% Init = End = {Mod,Func} | Func" n + "%% Initialization and cleanup function." n + "%% Mod = Func = atom()" n + "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n + "%% Execution properties of the test cases (may be combined)." n + "%% Shuffle = shuffle | {shuffle,Seed}" n + "%% To get cases executed in random order." n + "%% Seed = {integer(),integer(),integer()}" n + "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n + "%% repeat_until_any_ok | repeat_until_any_fail" n + "%% To get execution of cases repeated." n + "%% N = integer() | forever" n + "%% Reason = term()" n + "%% The reason for skipping the test suite." n + "%%" n + "%% @spec all(Clause) -> TestCases" n + (erlang-skel-separator-end 2) + "all(doc) ->" n > + "[\"Describe the main purpose of this suite\"];" n n + "all(suite) -> " n > + "[a_test_case]." n n + n + (erlang-skel-separator-start 2) + "%% TEST CASES" n + (erlang-skel-separator 2) + n + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Test case function. Returns a description of the test" n + "%% case (doc), then returns a test specification (suite)," n + "%% or performs the actual test (Config)." n + "%%" n + "%% Arg = doc | suite | Config" n + "%% Indicates expected behaviour and return value." n + "%% Config = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%% Descr = [string()] | []" n + "%% String that describes the test case." n + "%% Spec = [tuple()] | []" n + "%% A test specification, see all/1." n + "%% Reason = term()" n + "%% The reason for skipping the test case." n + "%%" n + "%% @spec TestCase(Arg) -> Descr | Spec | ok | exit() | {skip,Reason}" n + + (erlang-skel-separator-end 2) + "a_test_case(doc) -> " n > + "[\"Describe the main purpose of this test case\"];" n n + "a_test_case(suite) -> " n > + "[];" n n + "a_test_case(Config) when is_list(Config) -> " n > + "ok." n + ) + "*The template of a library module. +Please see the function `tempo-define-template'.") + +(defvar erlang-skel-ct-test-suite-s + '((erlang-skel-include erlang-skel-large-header) + "-compile(export_all)." n n + + "-include_lib(\"common_test/include/ct.hrl\")." n n + + (erlang-skel-separator-start 2) + "%% @spec suite() -> Info" n + "%% Info = [tuple()]" n + (erlang-skel-separator-end 2) + "suite() ->" n > + "[{timetrap,{seconds,30}}]." n n + + (erlang-skel-separator-start 2) + "%% @spec init_per_suite(Config0) ->" n + "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n + "%% Config0 = Config1 = [tuple()]" n + "%% Reason = term()" n + (erlang-skel-separator-end 2) + "init_per_suite(Config) ->" n > + "Config." n n + + (erlang-skel-separator-start 2) + "%% @spec end_per_suite(Config0) -> void() | {save_config,Config1}" n + "%% Config0 = Config1 = [tuple()]" n + (erlang-skel-separator-end 2) + "end_per_suite(_Config) ->" n > + "ok." n n + + (erlang-skel-separator-start 2) + "%% @spec init_per_group(GroupName, Config0) ->" n + "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n + "%% GroupName = atom()" n + "%% Config0 = Config1 = [tuple()]" n + "%% Reason = term()" n + (erlang-skel-separator-end 2) + "init_per_group(_GroupName, Config) ->" n > + "Config." n n + + (erlang-skel-separator-start 2) + "%% @spec end_per_group(GroupName, Config0) ->" n + "%% void() | {save_config,Config1}" n + "%% GroupName = atom()" n + "%% Config0 = Config1 = [tuple()]" n + (erlang-skel-separator-end 2) + "end_per_group(_GroupName, _Config) ->" n > + "ok." n n + + (erlang-skel-separator-start 2) + "%% @spec init_per_testcase(TestCase, Config0) ->" n + "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n + "%% TestCase = atom()" n + "%% Config0 = Config1 = [tuple()]" n + "%% Reason = term()" n + (erlang-skel-separator-end 2) + "init_per_testcase(_TestCase, Config) ->" n > + "Config." n n + + (erlang-skel-separator-start 2) + "%% @spec end_per_testcase(TestCase, Config0) ->" n + "%% void() | {save_config,Config1} | {fail,Reason}" n + "%% TestCase = atom()" n + "%% Config0 = Config1 = [tuple()]" n + "%% Reason = term()" n + (erlang-skel-separator-end 2) + "end_per_testcase(_TestCase, _Config) ->" n > + "ok." n n + + (erlang-skel-separator-start 2) + "%% @spec groups() -> [Group]" n + "%% Group = {GroupName,Properties,GroupsAndTestCases}" n + "%% GroupName = atom()" n + "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n + "%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]" n + "%% TestCase = atom()" n + "%% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}}" n + "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n + "%% repeat_until_any_ok | repeat_until_any_fail" n + "%% N = integer() | forever" n + (erlang-skel-separator-end 2) + "groups() ->" n > + "[]." n n + + (erlang-skel-separator-start 2) + "%% @spec all() -> GroupsAndTestCases | {skip,Reason}" n + "%% GroupsAndTestCases = [{group,GroupName} | TestCase]" n + "%% GroupName = atom()" n + "%% TestCase = atom()" n + "%% Reason = term()" n + (erlang-skel-separator-end 2) + "all() -> " n > + "[my_test_case]." n n + + (erlang-skel-separator-start 2) + "%% @spec TestCase() -> Info" n + "%% Info = [tuple()]" n + (erlang-skel-separator-end 2) + "my_test_case() -> " n > + "[]." n n + + (erlang-skel-separator-start 2) + "%% @spec TestCase(Config0) ->" n + "%% ok | exit() | {skip,Reason} | {comment,Comment} |" n + "%% {save_config,Config1} | {skip_and_save,Reason,Config1}" n + "%% Config0 = Config1 = [tuple()]" n + "%% Reason = term()" n + "%% Comment = term()" n + (erlang-skel-separator-end 2) + "my_test_case(_Config) -> " n > + "ok." n + ) + "*The template of a library module. +Please see the function `tempo-define-template'.") + + +(defvar erlang-skel-ct-test-suite-l + '((erlang-skel-include erlang-skel-large-header) + "%% Note: This directive should only be used in test suites." n + "-compile(export_all)." n n + + "-include_lib(\"common_test/include/ct.hrl\")." n n + + (erlang-skel-separator-start 2) + "%% COMMON TEST CALLBACK FUNCTIONS" n + (erlang-skel-separator 2) + n + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Returns list of tuples to set default properties" n + "%% for the suite." n + "%%" n + "%% Function: suite() -> Info" n + "%%" n + "%% Info = [tuple()]" n + "%% List of key/value pairs." n + "%%" n + "%% Note: The suite/0 function is only meant to be used to return" n + "%% default data values, not perform any other operations." n + "%%" n + "%% @spec suite() -> Info" n + (erlang-skel-separator-end 2) + "suite() ->" n > + "[{timetrap,{minutes,10}}]." n n + + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Initialization before the whole suite" n + "%%" n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%% Reason = term()" n + "%% The reason for skipping the suite." n + "%%" n + "%% Note: This function is free to add any key/value pairs to the Config" n + "%% variable, but should NOT alter/remove any existing entries." n + "%%" n + "%% @spec init_per_suite(Config0) ->" n + "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n + (erlang-skel-separator-end 2) + "init_per_suite(Config) ->" n > + "Config." n n + + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Cleanup after the whole suite" n + "%%" n + "%% Config - [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%%" n + "%% @spec end_per_suite(Config) -> _" n + (erlang-skel-separator-end 2) + "end_per_suite(_Config) ->" n > + "ok." n n + + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Initialization before each test case group." n + "%%" n + "%% GroupName = atom()" n + "%% Name of the test case group that is about to run." n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding configuration data for the group." n + "%% Reason = term()" n + "%% The reason for skipping all test cases and subgroups in the group." n + "%%" n + "%% @spec init_per_group(GroupName, Config0) ->" n + "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n + (erlang-skel-separator-end 2) + "init_per_group(_GroupName, Config) ->" n > + "Config." n n + + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Cleanup after each test case group." n + "%%" n + "%% GroupName = atom()" n + "%% Name of the test case group that is finished." n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding configuration data for the group." n + "%%" n + "%% @spec end_per_group(GroupName, Config0) ->" n + "%% void() | {save_config,Config1}" n + (erlang-skel-separator-end 2) + "end_per_group(_GroupName, _Config) ->" n > + "ok." n n + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Initialization before each test case" n + "%%" n + "%% TestCase - atom()" n + "%% Name of the test case that is about to be run." n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%% Reason = term()" n + "%% The reason for skipping the test case." n + "%%" n + "%% Note: This function is free to add any key/value pairs to the Config" n + "%% variable, but should NOT alter/remove any existing entries." n + "%%" n + "%% @spec init_per_testcase(TestCase, Config0) ->" n + "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n + (erlang-skel-separator-end 2) + "init_per_testcase(_TestCase, Config) ->" n > + "Config." n n + + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Cleanup after each test case" n + "%%" n + "%% TestCase - atom()" n + "%% Name of the test case that is finished." n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%%" n + "%% @spec end_per_testcase(TestCase, Config0) ->" n + "%% void() | {save_config,Config1} | {fail,Reason}" n + (erlang-skel-separator-end 2) + "end_per_testcase(_TestCase, _Config) ->" n > + "ok." n n + + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Returns a list of test case group definitions." n + "%%" n + "%% Group = {GroupName,Properties,GroupsAndTestCases}" n + "%% GroupName = atom()" n + "%% The name of the group." n + "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n + "%% Group properties that may be combined." n + "%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]" n + "%% TestCase = atom()" n + "%% The name of a test case." n + "%% Shuffle = shuffle | {shuffle,Seed}" n + "%% To get cases executed in random order." n + "%% Seed = {integer(),integer(),integer()}" n + "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n + "%% repeat_until_any_ok | repeat_until_any_fail" n + "%% To get execution of cases repeated." n + "%% N = integer() | forever" n + "%%" n + "%% @spec: groups() -> [Group]" n + (erlang-skel-separator-end 2) + "groups() ->" n > + "[]." n n + + (erlang-skel-separator-start 2) + "%% @doc" n + "%% Returns the list of groups and test cases that" n + "%% are to be executed." n + "%%" n + "%% GroupsAndTestCases = [{group,GroupName} | TestCase]" n + "%% GroupName = atom()" n + "%% Name of a test case group." n + "%% TestCase = atom()" n + "%% Name of a test case." n + "%% Reason = term()" n + "%% The reason for skipping all groups and test cases." n + "%%" n + "%% @spec all() -> GroupsAndTestCases | {skip,Reason}" n + (erlang-skel-separator-end 2) + "all() -> " n > + "[my_test_case]." n n + + n + (erlang-skel-separator-start 2) + "%% TEST CASES" n + (erlang-skel-separator 2) + n + + (erlang-skel-separator-start 2) + "%% @doc " n + "%% Test case info function - returns list of tuples to set" n + "%% properties for the test case." n + "%%" n + "%% Info = [tuple()]" n + "%% List of key/value pairs." n + "%%" n + "%% Note: This function is only meant to be used to return a list of" n + "%% values, not perform any other operations." n + "%%" n + "%% @spec TestCase() -> Info " n + (erlang-skel-separator-end 2) + "my_test_case() -> " n > + "[]." n n + + (erlang-skel-separator 2) + "%% @doc Test case function. (The name of it must be specified in" n + "%% the all/0 list or in a test case group for the test case" n + "%% to be executed)." n + "%%" n + "%% Config0 = Config1 = [tuple()]" n + "%% A list of key/value pairs, holding the test case configuration." n + "%% Reason = term()" n + "%% The reason for skipping the test case." n + "%% Comment = term()" n + "%% A comment about the test case that will be printed in the html log." n + "%%" n + "%% @spec TestCase(Config0) ->" n + "%% ok | exit() | {skip,Reason} | {comment,Comment} |" n + "%% {save_config,Config1} | {skip_and_save,Reason,Config1}" n + (erlang-skel-separator-end 2) + "my_test_case(_Config) -> " n > + "ok." n + + ) + "*The template of a library module. + Please see the function `tempo-define-template'.") + +;; Skeleton code: + +;; This code is based on the package `tempo' which is part of modern +;; Emacsen. (GNU Emacs 19.25 (?) and XEmacs 19.14.) + +(defun erlang-skel-init () + "Generate the skeleton functions and menu items. +The variable `erlang-skel' contains the name and descriptions of +all skeletons. + +The skeleton routines are based on the `tempo' package. Should this +package not be present, this function does nothing." + (interactive) + (condition-case nil + (require 'tempo) + (error t)) + (if (featurep 'tempo) + (let ((skel erlang-skel) + (menu '())) + (while skel + (cond ((null (car skel)) + (setq menu (cons nil menu))) + (t + (funcall (symbol-function 'tempo-define-template) + (concat "erlang-" (nth 1 (car skel))) + ;; The tempo template used contains an `include' + ;; function call only, hence changes to the + ;; variables describing the templates take effect + ;; immdiately. + (list (list 'erlang-skel-include (nth 2 (car skel)))) + (nth 1 (car skel))) + (setq menu (cons (erlang-skel-make-menu-item + (car skel)) menu)))) + (setq skel (cdr skel))) + (setq erlang-menu-skel-items + (list nil (list "Skeletons" (nreverse menu)))) + (setq erlang-menu-items + (erlang-menu-add-above 'erlang-menu-skel-items + 'erlang-menu-version-items + erlang-menu-items)) + (erlang-menu-init)))) + +(defun erlang-skel-make-menu-item (skel) + (let ((func (intern (concat "tempo-template-erlang-" (nth 1 skel))))) + (cond ((null (nth 3 skel)) + (list (car skel) func)) + (t + (list (car skel) + (list 'lambda '() + '(interactive) + (list 'funcall + (list 'quote (nth 3 skel)) + (list 'quote func)))))))) + +;; Functions designed to be added to the skeleton menu. +;; (Not normally used) +(defun erlang-skel-insert (func) + "Insert skeleton generated by FUNC and goto first tempo mark." + (save-excursion (funcall func)) + (funcall (symbol-function 'tempo-forward-mark))) + +(defun erlang-skel-header (func) + "Insert the header generated by FUNC at the beginning of the buffer." + (goto-char (point-min)) + (save-excursion (funcall func)) + (funcall (symbol-function 'tempo-forward-mark))) + + +;; Functions used inside the skeleton descriptions. +(defun erlang-skel-skip-blank () + (skip-chars-backward " \t") + nil) + +(defun erlang-skel-include (&rest args) + "Include a template inside another template. + +Example of use, assuming that `erlang-skel-func' is defined: + + (defvar foo-skeleton '(\"%%% New function:\" + (erlang-skel-include erlang-skel-func))) + +Technically, this function returns the `tempo' attribute`(l ...)' which +can contain other `tempo' attributes. Please see the function +`tempo-define-template' for a description of the `(l ...)' attribute." + (let ((res '()) + entry) + (while args + (setq entry (car args)) + (while entry + (setq res (cons (car entry) res)) + (setq entry (cdr entry))) + (setq args (cdr args))) + (cons 'l (nreverse res)))) + +(defun erlang-skel-separator (&optional percent) + "Return a comment separator." + (let ((percent (or percent 3))) + (concat (make-string percent ?%) + (make-string (- 70 percent) ?-) + "\n"))) + +(defun erlang-skel-separator-start (&optional percent) + "Return a comment separator or an empty string if separators +are configured off." + (if erlang-skel-use-separators + (erlang-skel-separator percent) + "")) + +(defun erlang-skel-separator-end (&optional percent) + "Return a comment separator to end a function comment block or an +empty string if separators are configured off." + (if erlang-skel-use-separators + (concat "%% @end\n" (erlang-skel-separator percent)) + "")) + +(defun erlang-skel-double-separator (&optional percent) + "Return a double line (equals sign) comment separator." + (let ((percent (or percent 3))) + (concat (make-string percent ?%) + (make-string (- 70 percent) ?=) + "\n"))) + +(defun erlang-skel-double-separator-start (&optional percent) + "Return a double separator or a newline if separators are configured off." + (if erlang-skel-use-separators + (erlang-skel-double-separator percent) + "\n")) + +(defun erlang-skel-double-separator-end (&optional percent) + "Return a double separator or an empty string if separators are +configured off." + (if erlang-skel-use-separators + (erlang-skel-double-separator percent) + "")) + +(defun erlang-skel-dd-mmm-yyyy () + "Return the current date as a string in \"DD Mon YYYY\" form. +The first character of DD is space if the value is less than 10." + (let ((date (current-time-string))) + (format "%2d %s %s" + (string-to-int (substring date 8 10)) + (substring date 4 7) + (substring date -4)))) + +;; Local variables: +;; coding: iso-8859-1 +;; End: + +;;; erlang-skels.el ends here diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el index 4fc4826238..da586ee09a 100644 --- a/lib/tools/emacs/erlang.el +++ b/lib/tools/emacs/erlang.el @@ -1,19 +1,19 @@ ;; erlang.el --- Major modes for editing and running Erlang ;; %CopyrightBegin% -;; -;; Copyright Ericsson AB 1996-2009. All Rights Reserved. -;; +;; +;; Copyright Ericsson AB 1996-2010. All Rights Reserved. +;; ;; The contents of this file are subject to the Erlang Public License, ;; Version 1.1, (the "License"); you may not use this file except in ;; compliance with the License. You should have received a copy of the ;; Erlang Public License along with this software. If not, it can be ;; retrieved online at http://www.erlang.org/. -;; +;; ;; Software distributed under the License is distributed on an "AS IS" ;; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See ;; the License for the specific language governing rights and limitations ;; under the License. -;; +;; ;; %CopyrightEnd% ;; ;; Copyright (C) 2004 Free Software Foundation, Inc. @@ -72,7 +72,7 @@ ;; Variables: -(defconst erlang-version "2.6.2" +(defconst erlang-version "2.7" "The version number of Erlang mode.") (defvar erlang-root-dir nil @@ -895,1254 +895,16 @@ behaviour.") (defconst inferior-erlang-use-cmm (boundp 'minor-mode-overriding-map-alist) "Non-nil means use `compilation-minor-mode' in Erlang shell.") -;; Tempo skeleton templates: - -(defvar erlang-tempo-tags nil - "Tempo tags for erlang mode") - -(defvar erlang-skel - '(("If" "if" erlang-skel-if) - ("Case" "case" erlang-skel-case) - ("Receive" "receive" erlang-skel-receive) - ("Receive After" "after" erlang-skel-receive-after) - ("Receive Loop" "loop" erlang-skel-receive-loop) - ("Module" "module" erlang-skel-module) - ("Author" "author" erlang-skel-author) - () - ("Small Header" "small-header" - erlang-skel-small-header erlang-skel-header) - ("Normal Header" "normal-header" - erlang-skel-normal-header erlang-skel-header) - ("Large Header" "large-header" - erlang-skel-large-header erlang-skel-header) - () - ("Small Server" "small-server" - erlang-skel-small-server erlang-skel-header) - () - ("Application" "application" - erlang-skel-application erlang-skel-header) - ("Supervisor" "supervisor" - erlang-skel-supervisor erlang-skel-header) - ("supervisor_bridge" "supervisor-bridge" - erlang-skel-supervisor-bridge erlang-skel-header) - ("gen_server" "generic-server" - erlang-skel-generic-server erlang-skel-header) - ("gen_event" "gen-event" - erlang-skel-gen-event erlang-skel-header) - ("gen_fsm" "gen-fsm" - erlang-skel-gen-fsm erlang-skel-header) - ("Library module" "gen-lib" - erlang-skel-lib erlang-skel-header) - ("Corba callback" "gen-corba-cb" - erlang-skel-corba-callback erlang-skel-header) - ("Small Common Test suite" "ct-test-suite-s" - erlang-skel-ct-test-suite-s erlang-skel-header) - ("Large Common Test suite" "ct-test-suite-l" - erlang-skel-ct-test-suite-l erlang-skel-header) - ("Erlang TS test suite" "ts-test-suite" - erlang-skel-ts-test-suite erlang-skel-header) - ) - "*Description of all skeleton templates. -Both functions and menu entries will be created. - -Each entry in `erlang-skel' should be a list with three or four -elements, or the empty list. - -The first element is the name which shows up in the menu. The second -is the `tempo' identifier (The string \"erlang-\" will be added in -front of it). The third is the skeleton descriptor, a variable -containing `tempo' attributes as described in the function -`tempo-define-template'. The optional fourth elements denotes a -function which should be called when the menu is selected. - -Functions corresponding to every template will be created. The name -of the function will be `tempo-template-erlang-X' where `X' is the -tempo identifier as specified in the second argument of the elements -in this list. - -A list with zero elements means that the a horizontal line should -be placed in the menu.") - -;; In XEmacs `user-mail-address' returns "[email protected] (Foo Bar)" ARGH! -;; What's wrong with that? RFC 822 says it's legal. [sverkerw] -;; This needs to use the customized value. If that's not sane, things like -;; add-log will lose anyhow. Avoid it if there _is_ a paren. -(defvar erlang-skel-mail-address - (if (or (not user-mail-address) (string-match "(" user-mail-address)) - (concat (user-login-name) "@" - (or (and (boundp 'mail-host-address) - mail-host-address) - (system-name))) - user-mail-address) - "Mail address of the user.") - -;; Expression templates: -(defvar erlang-skel-case - '((erlang-skel-skip-blank) o > - "case " p " of" n> p "_ ->" n> p "ok" n> "end" p) - "*The skeleton of a `case' expression. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-if - '((erlang-skel-skip-blank) o > - "if" n> p " ->" n> p "ok" n> "end" p) - "The skeleton of an `if' expression. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-receive - '((erlang-skel-skip-blank) o > - "receive" n> p "_ ->" n> p "ok" n> "end" p) - "*The skeleton of a `receive' expression. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-receive-after - '((erlang-skel-skip-blank) o > - "receive" n> p "_ ->" n> p "ok" n> "after " p "T ->" n> - p "ok" n> "end" p) - "*The skeleton of a `receive' expression with an `after' clause. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-receive-loop - '(& o "loop(" p ") ->" n> "receive" n> p "_ ->" n> - "loop(" p ")" n> "end.") - "*The skeleton of a simple `receive' loop. -Please see the function `tempo-define-template'.") - - -;; Attribute templates - -(defvar erlang-skel-module - '(& "-module(" - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) - ")." n) - "*The skeleton of a `module' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-author - '(& "-author('" erlang-skel-mail-address "')." n) - "*The skeleton of a `author' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-vc nil - "*The skeleton template to generate a version control attribute. -The default is to insert nothing. Example of usage: - - (setq erlang-skel-vc '(& \"-rcs(\\\"$\Id: $ \\\").\") n) - -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-export - '(& "-export([" n> "])." n) - "*The skeleton of an `export' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-import - '(& "%%-import(Module, [Function/Arity, ...])." n) - "*The skeleton of an `import' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-compile nil - ;; '(& "%%-compile(export_all)." n) - "*The skeleton of a `compile' attribute. -Please see the function `tempo-define-template'.") - - -;; Comment templates. - -(defvar erlang-skel-date-function 'erlang-skel-dd-mmm-yyyy - "*Function which returns date string. -Look in the module `time-stamp' for a battery of functions.") - -(defvar erlang-skel-copyright-comment '() - "*The template for a copyright line in the header, normally empty. -This variable should be bound to a `tempo' template, for example: - '(& \"%%% Copyright (C) 2000, Yoyodyne, Inc.\" n) - -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-created-comment - '(& "%%% Created : " (funcall erlang-skel-date-function) " by " - (user-full-name) " <" erlang-skel-mail-address ">" n) - "*The template for the \"Created:\" comment line.") - -(defvar erlang-skel-author-comment - '(& "%%% Author : " (user-full-name) " <" erlang-skel-mail-address ">" n) - "*The template for creating the \"Author:\" line in the header. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-file-comment - '(& "%%% File : " (file-name-nondirectory buffer-file-name) n) -"*The template for creating the \"Module:\" line in the header. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-small-header - '(o (erlang-skel-include erlang-skel-module) - ;; erlang-skel-author) - n - (erlang-skel-include erlang-skel-compile - ;; erlang-skel-export - erlang-skel-vc)) - "*The template of a small header without any comments. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-normal-header - '(o (erlang-skel-include erlang-skel-copyright-comment - erlang-skel-file-comment - erlang-skel-author-comment) - "%%% Description : " p n - (erlang-skel-include erlang-skel-created-comment) n - (erlang-skel-include erlang-skel-small-header) n) - "*The template of a normal header. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-large-header - '(o (erlang-skel-separator) - (erlang-skel-include erlang-skel-copyright-comment - erlang-skel-file-comment - erlang-skel-author-comment) - "%%% Description : " p n - "%%%" n - (erlang-skel-include erlang-skel-created-comment) - (erlang-skel-separator) - (erlang-skel-include erlang-skel-small-header) ) - "*The template of a large header. -Please see the function `tempo-define-template'.") - - -;; Server templates. - -(defvar erlang-skel-small-server - '((erlang-skel-include erlang-skel-large-header) - "-export([start/0,init/1])." n n n - "start() ->" n> "spawn(" (erlang-get-module-from-file-name) - ", init, [self()])." n n - "init(From) ->" n> - "loop(From)." n n - "loop(From) ->" n> - "receive" n> - p "_ ->" n> - "loop(From)" n> - "end." - ) - "*Template of a small server. -Please see the function `tempo-define-template'.") - -;; Behaviour templates. - -(defvar erlang-skel-application - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(application)." n n - "%% Application callbacks" n - "-export([start/2, stop/1])." n n - (erlang-skel-double-separator 2) - "%% Application callbacks" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start(Type, StartArgs) -> {ok, Pid} |" n - "%% {ok, Pid, State} |" n - "%% {error, Reason}" n - "%% Description: This function is called whenever an application " n - "%% is started using application:start/1,2, and should start the processes" n - "%% of the application. If the application is structured according to the" n - "%% OTP design principles as a supervision tree, this means starting the" n - "%% top supervisor of the tree." n - (erlang-skel-separator 2) - "start(_Type, StartArgs) ->" n> - "case 'TopSupervisor':start_link(StartArgs) of" n> - "{ok, Pid} -> " n> - "{ok, Pid};" n> - "Error ->" n> - "Error" n> - "end." n - n - (erlang-skel-separator 2) - "%% Function: stop(State) -> void()" n - "%% Description: This function is called whenever an application" n - "%% has stopped. It is intended to be the opposite of Module:start/2 and" n - "%% should do any necessary cleaning up. The return value is ignored. "n - (erlang-skel-separator 2) - "stop(_State) ->" n> - "ok." n - n - (erlang-skel-double-separator 2) - "%% Internal functions" n - (erlang-skel-double-separator 2) - ) - "*The template of an application behaviour. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-supervisor - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(supervisor)." n n - "%% API" n - "-export([start_link/0])." n n +(defvar erlang-skel-file "erlang-skels" + "The type of erlang-skeletons that should be used, default + uses edoc type, for the old type, standard comments, + set \"erlang-skels-old\" in your .emacs and restart. - "%% Supervisor callbacks" n - "-export([init/1])." n n + Or define your own and set the variable to that file.") - "-define(SERVER, ?MODULE)." n n - - (erlang-skel-double-separator 2) - "%% API functions" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}" n - "%% Description: Starts the supervisor" n - (erlang-skel-separator 2) - "start_link() ->" n> - "supervisor:start_link({local, ?SERVER}, ?MODULE, [])." n - n - (erlang-skel-double-separator 2) - "%% Supervisor callbacks" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Func: init(Args) -> {ok, {SupFlags, [ChildSpec]}} |" n - "%% ignore |" n - "%% {error, Reason}" n - "%% Description: Whenever a supervisor is started using "n - "%% supervisor:start_link/[2,3], this function is called by the new process "n - "%% to find out about restart strategy, maximum restart frequency and child "n - "%% specifications." n - (erlang-skel-separator 2) - "init([]) ->" n> - "AChild = {'AName',{'AModule',start_link,[]}," n> - "permanent,2000,worker,['AModule']}," n> - "{ok,{{one_for_all,0,1}, [AChild]}}." n - n - (erlang-skel-double-separator 2) - "%% Internal functions" n - (erlang-skel-double-separator 2) - ) - "*The template of an supervisor behaviour. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-supervisor-bridge - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(supervisor_bridge)." n n - - "%% API" n - "-export([start_link/0])." n n - - "%% supervisor_bridge callbacks" n - "-export([init/1, terminate/2])." n n - - "-define(SERVER, ?MODULE)." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator 2) - "%% API" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}" n - "%% Description: Starts the supervisor bridge" n - (erlang-skel-separator 2) - "start_link() ->" n> - "supervisor_bridge:start_link({local, ?SERVER}, ?MODULE, [])." n - n - (erlang-skel-double-separator 2) - "%% supervisor_bridge callbacks" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Funcion: init(Args) -> {ok, Pid, State} |" n - "%% ignore |" n - "%% {error, Reason} " n - "%% Description:Creates a supervisor_bridge process, linked to the calling" n - "%% process, which calls Module:init/1 to start the subsystem. To ensure a" n - "%% synchronized start-up procedure, this function does not return until" n - "%% Module:init/1 has returned. " n - (erlang-skel-separator 2) - "init([]) ->" n> - "case 'AModule':start_link() of" n> - "{ok, Pid} ->" n> - "{ok, Pid, #state{}};" n> - "Error ->" n> - "Error" n> - "end." n - n - (erlang-skel-separator 2) - "%% Func: terminate(Reason, State) -> void()" n - "%% Description:This function is called by the supervisor_bridge when it is"n - "%% about to terminate. It should be the opposite of Module:init/1 and stop"n - "%% the subsystem and do any necessary cleaning up.The return value is ignored." - (erlang-skel-separator 2) - "terminate(Reason, State) ->" n> - "'AModule':stop()," n> - "ok." n - n - (erlang-skel-double-separator 2) - "%% Internal functions" n - (erlang-skel-double-separator 2) - ) - "*The template of an supervisor_bridge behaviour. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-generic-server - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_server)." n n - - "%% API" n - "-export([start_link/0])." n n - - "%% gen_server callbacks" n - "-export([init/1, handle_call/3, handle_cast/2, " - "handle_info/2," n> - "terminate/2, code_change/3])." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator 2) - "%% API" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}" n - "%% Description: Starts the server" n - (erlang-skel-separator 2) - "start_link() ->" n> - "gen_server:start_link({local, ?SERVER}, ?MODULE, [], [])." n - n - (erlang-skel-double-separator 2) - "%% gen_server callbacks" n - (erlang-skel-double-separator 2) - n - (erlang-skel-separator 2) - "%% Function: init(Args) -> {ok, State} |" n - "%% {ok, State, Timeout} |" n - "%% ignore |" n - "%% {stop, Reason}" n - "%% Description: Initiates the server" n - (erlang-skel-separator 2) - "init([]) ->" n> - "{ok, #state{}}." n - n - (erlang-skel-separator 2) - "%% Function: " - "%% handle_call(Request, From, State) -> {reply, Reply, State} |" n - "%% {reply, Reply, State, Timeout} |" n - "%% {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, Reply, State} |" n - "%% {stop, Reason, State}" n - "%% Description: Handling call messages" n - (erlang-skel-separator 2) - "handle_call(_Request, _From, State) ->" n> - "Reply = ok," n> - "{reply, Reply, State}." n - n - (erlang-skel-separator 2) - "%% Function: handle_cast(Msg, State) -> {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, State}" n - "%% Description: Handling cast messages" n - - (erlang-skel-separator 2) - "handle_cast(_Msg, State) ->" n> - "{noreply, State}." n - n - (erlang-skel-separator 2) - "%% Function: handle_info(Info, State) -> {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, State}" n - "%% Description: Handling all non call/cast messages" n - (erlang-skel-separator 2) - "handle_info(_Info, State) ->" n> - "{noreply, State}." n - n - (erlang-skel-separator 2) - "%% Function: terminate(Reason, State) -> void()" n - "%% Description: This function is called by a gen_server when it is about to"n - "%% terminate. It should be the opposite of Module:init/1 and do any necessary"n - "%% cleaning up. When it returns, the gen_server terminates with Reason." n - "%% The return value is ignored." n - - (erlang-skel-separator 2) - "terminate(_Reason, _State) ->" n> - "ok." n - n - (erlang-skel-separator 2) - "%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}" n - "%% Description: Convert process state when code is changed" n - (erlang-skel-separator 2) - "code_change(_OldVsn, State, _Extra) ->" n> - "{ok, State}." n - n - (erlang-skel-separator 2) - "%%% Internal functions" n - (erlang-skel-separator 2) - ) - "*The template of a generic server. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-gen-event - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_event)." n - - "%% API" n - "-export([start_link/0, add_handler/0])." n n - - "%% gen_event callbacks" n - "-export([init/1, handle_event/2, handle_call/2, " n> - "handle_info/2, terminate/2, code_change/3])." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator 2) - "%% gen_event callbacks" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start_link() -> {ok,Pid} | {error,Error} " n - "%% Description: Creates an event manager." n - (erlang-skel-separator 2) - "start_link() ->" n> - "gen_event:start_link({local, ?SERVER}). " n - n - (erlang-skel-separator 2) - "%% Function: add_handler() -> ok | {'EXIT',Reason} | term()" n - "%% Description: Adds an event handler" n - (erlang-skel-separator 2) - "add_handler() ->" n> - "gen_event:add_handler(?SERVER, ?MODULE, [])." n - n - (erlang-skel-double-separator 2) - "%% gen_event callbacks" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: init(Args) -> {ok, State}" n - "%% Description: Whenever a new event handler is added to an event manager,"n - "%% this function is called to initialize the event handler." n - (erlang-skel-separator 2) - "init([]) ->" n> - "{ok, #state{}}." n - n - (erlang-skel-separator 2) - "%% Function: "n - "%% handle_event(Event, State) -> {ok, State} |" n - "%% {swap_handler, Args1, State1, Mod2, Args2} |"n - "%% remove_handler" n - "%% Description:Whenever an event manager receives an event sent using"n - "%% gen_event:notify/2 or gen_event:sync_notify/2, this function is called for"n - "%% each installed event handler to handle the event. "n - (erlang-skel-separator 2) - "handle_event(_Event, State) ->" n> - "{ok, State}." n - n - (erlang-skel-separator 2) - "%% Function: " n - "%% handle_call(Request, State) -> {ok, Reply, State} |" n - "%% {swap_handler, Reply, Args1, State1, "n - "%% Mod2, Args2} |" n - "%% {remove_handler, Reply}" n - "%% Description: Whenever an event manager receives a request sent using"n - "%% gen_event:call/3,4, this function is called for the specified event "n - "%% handler to handle the request."n - (erlang-skel-separator 2) - "handle_call(_Request, State) ->" n> - "Reply = ok," n> - "{ok, Reply, State}." n - n - (erlang-skel-separator 2) - "%% Function: " n - "%% handle_info(Info, State) -> {ok, State} |" n - "%% {swap_handler, Args1, State1, Mod2, Args2} |" n - "%% remove_handler" n - "%% Description: This function is called for each installed event handler when"n - "%% an event manager receives any other message than an event or a synchronous"n - "%% request (or a system message)."n - (erlang-skel-separator 2) - "handle_info(_Info, State) ->" n> - "{ok, State}." n - n - (erlang-skel-separator 2) - "%% Function: terminate(Reason, State) -> void()" n - "%% Description:Whenever an event handler is deleted from an event manager,"n - "%% this function is called. It should be the opposite of Module:init/1 and "n - "%% do any necessary cleaning up. " n - (erlang-skel-separator 2) - "terminate(_Reason, _State) ->" n> - "ok." n - n - (erlang-skel-separator 2) - "%% Function: code_change(OldVsn, State, Extra) -> {ok, NewState} " n - "%% Description: Convert process state when code is changed" n - (erlang-skel-separator 2) - "code_change(_OldVsn, State, _Extra) ->" n> - "{ok, State}." n - n - (erlang-skel-separator 2) - "%%% Internal functions" n - (erlang-skel-separator 2) - ) - "*The template of a gen_event. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-gen-fsm - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_fsm)." n n - - "%% API" n - "-export([start_link/0])." n n - - "%% gen_fsm callbacks" n - "-export([init/1, state_name/2, state_name/3, handle_event/3," n> - "handle_sync_event/4, handle_info/3, terminate/3, code_change/4])." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator 2) - "%% API" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start_link() -> ok,Pid} | ignore | {error,Error}" n - "%% Description:Creates a gen_fsm process which calls Module:init/1 to"n - "%% initialize. To ensure a synchronized start-up procedure, this function" n - "%% does not return until Module:init/1 has returned. " n - (erlang-skel-separator 2) - "start_link() ->" n> - "gen_fsm:start_link({local, ?SERVER}, ?MODULE, [], [])." n - n - (erlang-skel-double-separator 2) - "%% gen_fsm callbacks" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: init(Args) -> {ok, StateName, State} |" n - "%% {ok, StateName, State, Timeout} |" n - "%% ignore |" n - "%% {stop, StopReason} " n - "%% Description:Whenever a gen_fsm is started using gen_fsm:start/[3,4] or"n - "%% gen_fsm:start_link/3,4, this function is called by the new process to "n - "%% initialize. " n - (erlang-skel-separator 2) - "init([]) ->" n> - "{ok, state_name, #state{}}." n - n - (erlang-skel-separator 2) - "%% Function: "n - "%% state_name(Event, State) -> {next_state, NextStateName, NextState}|" n - "%% {next_state, NextStateName, " n - "%% NextState, Timeout} |" n - "%% {stop, Reason, NewState}" n - "%% Description:There should be one instance of this function for each possible"n - "%% state name. Whenever a gen_fsm receives an event sent using" n - "%% gen_fsm:send_event/2, the instance of this function with the same name as"n - "%% the current state name StateName is called to handle the event. It is also "n - "%% called if a timeout occurs. " n - (erlang-skel-separator 2) - "state_name(_Event, State) ->" n> - "{next_state, state_name, State}." n - n - (erlang-skel-separator 2) - "%% Function:" n - "%% state_name(Event, From, State) -> {next_state, NextStateName, NextState} |"n - "%% {next_state, NextStateName, " n - "%% NextState, Timeout} |" n - "%% {reply, Reply, NextStateName, NextState}|"n - "%% {reply, Reply, NextStateName, " n - "%% NextState, Timeout} |" n - "%% {stop, Reason, NewState}|" n - "%% {stop, Reason, Reply, NewState}" n - "%% Description: There should be one instance of this function for each" n - "%% possible state name. Whenever a gen_fsm receives an event sent using" n - "%% gen_fsm:sync_send_event/2,3, the instance of this function with the same"n - "%% name as the current state name StateName is called to handle the event." n - (erlang-skel-separator 2) - "state_name(_Event, _From, State) ->" n> - "Reply = ok," n> - "{reply, Reply, state_name, State}." n - n - (erlang-skel-separator 2) - "%% Function: " n - "%% handle_event(Event, StateName, State) -> {next_state, NextStateName, "n - "%% NextState} |" n - "%% {next_state, NextStateName, "n - "%% NextState, Timeout} |" n - "%% {stop, Reason, NewState}" n - "%% Description: Whenever a gen_fsm receives an event sent using"n - "%% gen_fsm:send_all_state_event/2, this function is called to handle"n - "%% the event." n - (erlang-skel-separator 2) - "handle_event(_Event, StateName, State) ->" n> - "{next_state, StateName, State}." n - n - (erlang-skel-separator 2) - "%% Function: " n - "%% handle_sync_event(Event, From, StateName, "n - "%% State) -> {next_state, NextStateName, NextState} |" n - "%% {next_state, NextStateName, NextState, " n - "%% Timeout} |" n - "%% {reply, Reply, NextStateName, NextState}|" n - "%% {reply, Reply, NextStateName, NextState, " n - "%% Timeout} |" n - "%% {stop, Reason, NewState} |" n - "%% {stop, Reason, Reply, NewState}" n - "%% Description: Whenever a gen_fsm receives an event sent using"n - "%% gen_fsm:sync_send_all_state_event/2,3, this function is called to handle"n - "%% the event."n - (erlang-skel-separator 2) - "handle_sync_event(Event, From, StateName, State) ->" n> - "Reply = ok," n> - "{reply, Reply, StateName, State}." n - n - (erlang-skel-separator 2) - "%% Function: " n - "%% handle_info(Info,StateName,State)-> {next_state, NextStateName, NextState}|" n - "%% {next_state, NextStateName, NextState, "n - "%% Timeout} |" n - "%% {stop, Reason, NewState}" n - "%% Description: This function is called by a gen_fsm when it receives any"n - "%% other message than a synchronous or asynchronous event"n - "%% (or a system message)." n - (erlang-skel-separator 2) - "handle_info(_Info, StateName, State) ->" n> - "{next_state, StateName, State}." n - n - (erlang-skel-separator 2) - "%% Function: terminate(Reason, StateName, State) -> void()" n - "%% Description:This function is called by a gen_fsm when it is about"n - "%% to terminate. It should be the opposite of Module:init/1 and do any"n - "%% necessary cleaning up. When it returns, the gen_fsm terminates with"n - "%% Reason. The return value is ignored." n - (erlang-skel-separator 2) - "terminate(_Reason, _StateName, _State) ->" n> - "ok." n - n - (erlang-skel-separator 2) - "%% Function:" n - "%% code_change(OldVsn, StateName, State, Extra) -> {ok, StateName, NewState}" n - "%% Description: Convert process state when code is changed" n - (erlang-skel-separator 2) - "code_change(_OldVsn, StateName, State, _Extra) ->" n> - "{ok, StateName, State}." n - n - (erlang-skel-separator 2) - "%%% Internal functions" n - (erlang-skel-separator 2) - ) - "*The template of a gen_fsm. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-lib - '((erlang-skel-include erlang-skel-large-header) - - "%% API" n - "-export([])." n n - - (erlang-skel-double-separator 2) - "%% API" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: " n - "%% Description:" n - (erlang-skel-separator 2) - n - (erlang-skel-double-separator 2) - "%% Internal functions" n - (erlang-skel-double-separator 2) - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-corba-callback - '((erlang-skel-include erlang-skel-large-header) - "%% Include files" n n - - "%% API" n - "-export([])." n n - - "%% Corba callbacks" n - "-export([init/1, terminate/2, code_change/3])." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator 2) - "%% Corba callbacks" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: init(Args) -> {ok, State} |" n - "%% {ok, State, Timeout} |" n - "%% ignore |" n - "%% {stop, Reason}" n - "%% Description: Initiates the server" n - (erlang-skel-separator 2) - "init([]) ->" n> - "{ok, #state{}}." n - n - (erlang-skel-separator 2) - "%% Function: terminate(Reason, State) -> void()" n - "%% Description: Shutdown the server" n - (erlang-skel-separator 2) - "terminate(_Reason, _State) ->" n> - "ok." n - n - (erlang-skel-separator 2) - "%% Function: code_change(OldVsn, State, Extra) -> {ok, NewState} " n - "%% Description: Convert process state when code is changed" n - (erlang-skel-separator 2) - "code_change(_OldVsn, State, _Extra) ->" n> - "{ok, State}." n - n - (erlang-skel-double-separator 2) - "%% Internal functions" n - (erlang-skel-double-separator 2) - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-ts-test-suite - '((erlang-skel-include erlang-skel-large-header) - "%% Note: This directive should only be used in test suites." n - "-compile(export_all)." n n - - "-include(\"test_server.hrl\")." n n - - (erlang-skel-separator 2) - "%% TEST SERVER CALLBACK FUNCTIONS" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% Function: init_per_suite(Config0) -> Config1 | {skip,Reason}" n - "%%" n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for skipping the suite." n - "%%" n - "%% Description: Initialization before the suite." n - "%%" n - "%% Note: This function is free to add any key/value pairs to the Config" n - "%% variable, but should NOT alter/remove any existing entries." n - (erlang-skel-separator 2) - "init_per_suite(Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_suite(Config) -> void()" n - "%%" n - "%% Config = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%%" n - "%% Description: Cleanup after the suite." n - (erlang-skel-separator 2) - "end_per_suite(_Config) ->" n > - "ok." n n - - (erlang-skel-separator 2) - "%% Function: init_per_testcase(TestCase, Config0) -> Config1 |" n - "%% {skip,Reason}" n - "%% TestCase = atom()" n - "%% Name of the test case that is about to run." n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for skipping the test case." n - "%%" n - "%% Description: Initialization before each test case." n - "%%" n - "%% Note: This function is free to add any key/value pairs to the Config" n - "%% variable, but should NOT alter/remove any existing entries." n - (erlang-skel-separator 2) - "init_per_testcase(_TestCase, Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_testcase(TestCase, Config) -> void()" n - "%%" n - "%% TestCase = atom()" n - "%% Name of the test case that is finished." n - "%% Config = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%%" n - "%% Description: Cleanup after each test case." n - (erlang-skel-separator 2) - "end_per_testcase(_TestCase, _Config) ->" n > - "ok."n n - - (erlang-skel-separator 2) - "%% Function: all(Clause) -> Descr | Spec | {skip,Reason}" n - "%%" n - "%% Clause = doc | suite" n - "%% Indicates expected return value." n - "%% Descr = [string()] | []" n - "%% String that describes the test suite." n - "%% Spec = [TestCase]" n - "%% A test specification." n - "%% TestCase = ConfCase | atom()" n - "%% Configuration case, or the name of a test case function." n - "%% ConfCase = {conf,Init,Spec,End} |" n - "%% {conf,Properties,Init,Spec,End}" n - "%% Init = End = {Mod,Func} | Func" n - "%% Initialization and cleanup function." n - "%% Mod = Func = atom()" n - "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n - "%% Execution properties of the test cases (may be combined)." n - "%% Shuffle = shuffle | {shuffle,Seed}" n - "%% To get cases executed in random order." n - "%% Seed = {integer(),integer(),integer()}" n - "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n - "%% repeat_until_any_ok | repeat_until_any_fail" n - "%% To get execution of cases repeated." n - "%% N = integer() | forever" n - "%% Reason = term()" n - "%% The reason for skipping the test suite." n - "%%" n - "%% Description: Returns a description of the test suite when" n - "%% Clause == doc, and a test specification (list" n - "%% of the conf and test cases in the suite) when" n - "%% Clause == suite." n - (erlang-skel-separator 2) - "all(doc) -> " n > - "[\"Describe the main purpose of this suite\"];" n n - "all(suite) -> " n > - "[a_test_case]." n n - n - (erlang-skel-separator 2) - "%% TEST CASES" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% Function: TestCase(Arg) -> Descr | Spec | ok | exit() | {skip,Reason}" n - "%%" n - "%% Arg = doc | suite | Config" n - "%% Indicates expected behaviour and return value." n - "%% Config = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Descr = [string()] | []" n - "%% String that describes the test case." n - "%% Spec = [tuple()] | []" n - "%% A test specification, see all/1." n - "%% Reason = term()" n - "%% The reason for skipping the test case." n - "%%" n - "%% Description: Test case function. Returns a description of the test" n - "%% case (doc), then returns a test specification (suite)," n - "%% or performs the actual test (Config)." n - (erlang-skel-separator 2) - "a_test_case(doc) -> " n > - "[\"Describe the main purpose of this test case\"];" n n - "a_test_case(suite) -> " n > - "[];" n n - "a_test_case(Config) when is_list(Config) -> " n > - "ok." n - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-ct-test-suite-l - '((erlang-skel-include erlang-skel-large-header) - "%% Note: This directive should only be used in test suites." n - "-compile(export_all)." n n - - "-include(\"ct.hrl\")." n n - - (erlang-skel-separator 2) - "%% COMMON TEST CALLBACK FUNCTIONS" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% Function: suite() -> Info" n - "%%" n - "%% Info = [tuple()]" n - "%% List of key/value pairs." n - "%%" n - "%% Description: Returns list of tuples to set default properties" n - "%% for the suite." n - "%%" n - "%% Note: The suite/0 function is only meant to be used to return" n - "%% default data values, not perform any other operations." n - (erlang-skel-separator 2) - "suite() ->" n > - "[{timetrap,{minutes,10}}]." n n - - (erlang-skel-separator 2) - "%% Function: init_per_suite(Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - "%%" n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for skipping the suite." n - "%%" n - "%% Description: Initialization before the suite." n - "%%" n - "%% Note: This function is free to add any key/value pairs to the Config" n - "%% variable, but should NOT alter/remove any existing entries." n - (erlang-skel-separator 2) - "init_per_suite(Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}" n - "%%" n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%%" n - "%% Description: Cleanup after the suite." n - (erlang-skel-separator 2) - "end_per_suite(_Config) ->" n > - "ok." n n - - (erlang-skel-separator 2) - "%% Function: init_per_group(GroupName, Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - "%%" n - "%% GroupName = atom()" n - "%% Name of the test case group that is about to run." n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding configuration data for the group." n - "%% Reason = term()" n - "%% The reason for skipping all test cases and subgroups in the group." n - "%%" n - "%% Description: Initialization before each test case group." n - (erlang-skel-separator 2) - "init_per_group(_GroupName, Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_group(GroupName, Config0) ->" n - "%% void() | {save_config,Config1}" n - "%%" n - "%% GroupName = atom()" n - "%% Name of the test case group that is finished." n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding configuration data for the group." n - "%%" n - "%% Description: Cleanup after each test case group." n - (erlang-skel-separator 2) - "end_per_group(_GroupName, _Config) ->" n > - "ok." n n - - (erlang-skel-separator 2) - "%% Function: init_per_testcase(TestCase, Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - "%%" n - "%% TestCase = atom()" n - "%% Name of the test case that is about to run." n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for skipping the test case." n - "%%" n - "%% Description: Initialization before each test case." n - "%%" n - "%% Note: This function is free to add any key/value pairs to the Config" n - "%% variable, but should NOT alter/remove any existing entries." n - (erlang-skel-separator 2) - "init_per_testcase(_TestCase, Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_testcase(TestCase, Config0) ->" n - "%% void() | {save_config,Config1} | {fail,Reason}" n - "%%" n - "%% TestCase = atom()" n - "%% Name of the test case that is finished." n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for failing the test case." n - "%%" n - "%% Description: Cleanup after each test case." n - (erlang-skel-separator 2) - "end_per_testcase(_TestCase, _Config) ->" n > - "ok." n n - - (erlang-skel-separator 2) - "%% Function: groups() -> [Group]" n - "%%" n - "%% Group = {GroupName,Properties,GroupsAndTestCases}" n - "%% GroupName = atom()" n - "%% The name of the group." n - "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n - "%% Group properties that may be combined." n - "%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]" n - "%% TestCase = atom()" n - "%% The name of a test case." n - "%% Shuffle = shuffle | {shuffle,Seed}" n - "%% To get cases executed in random order." n - "%% Seed = {integer(),integer(),integer()}" n - "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n - "%% repeat_until_any_ok | repeat_until_any_fail" n - "%% To get execution of cases repeated." n - "%% N = integer() | forever" n - "%%" n - "%% Description: Returns a list of test case group definitions." n - (erlang-skel-separator 2) - "groups() ->" n > - "[]." n n - - (erlang-skel-separator 2) - "%% Function: all() -> GroupsAndTestCases | {skip,Reason}" n - "%%" n - "%% GroupsAndTestCases = [{group,GroupName} | TestCase]" n - "%% GroupName = atom()" n - "%% Name of a test case group." n - "%% TestCase = atom()" n - "%% Name of a test case." n - "%% Reason = term()" n - "%% The reason for skipping all groups and test cases." n - "%%" n - "%% Description: Returns the list of groups and test cases that" n - "%% are to be executed." n - (erlang-skel-separator 2) - "all() -> " n > - "[my_test_case]." n n - - n - (erlang-skel-separator 2) - "%% TEST CASES" n - (erlang-skel-separator 2) - n - - (erlang-skel-separator 2) - "%% Function: TestCase() -> Info" n - "%%" n - "%% Info = [tuple()]" n - "%% List of key/value pairs." n - "%%" n - "%% Description: Test case info function - returns list of tuples to set" n - "%% properties for the test case." n - "%%" n - "%% Note: This function is only meant to be used to return a list of" n - "%% values, not perform any other operations." n - (erlang-skel-separator 2) - "my_test_case() -> " n > - "[]." n n - - (erlang-skel-separator 2) - "%% Function: TestCase(Config0) ->" n - "%% ok | exit() | {skip,Reason} | {comment,Comment} |" n - "%% {save_config,Config1} | {skip_and_save,Reason,Config1}" n - "%%" n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for skipping the test case." n - "%% Comment = term()" n - "%% A comment about the test case that will be printed in the html log." n - "%%" n - "%% Description: Test case function. (The name of it must be specified in" n - "%% the all/0 list or in a test case group for the test case" n - "%% to be executed)." n - (erlang-skel-separator 2) - "my_test_case(_Config) -> " n > - "ok." n - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-ct-test-suite-s - '((erlang-skel-include erlang-skel-large-header) - "-compile(export_all)." n n - - "-include(\"ct.hrl\")." n n - - (erlang-skel-separator 2) - "%% Function: suite() -> Info" n - "%% Info = [tuple()]" n - (erlang-skel-separator 2) - "suite() ->" n > - "[{timetrap,{seconds,30}}]." n n - - (erlang-skel-separator 2) - "%% Function: init_per_suite(Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - "%% Config0 = Config1 = [tuple()]" n - "%% Reason = term()" n - (erlang-skel-separator 2) - "init_per_suite(Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}" n - "%% Config0 = Config1 = [tuple()]" n - (erlang-skel-separator 2) - "end_per_suite(_Config) ->" n > - "ok." n n - - (erlang-skel-separator 2) - "%% Function: init_per_group(GroupName, Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - "%% GroupName = atom()" n - "%% Config0 = Config1 = [tuple()]" n - "%% Reason = term()" n - (erlang-skel-separator 2) - "init_per_group(_GroupName, Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_group(GroupName, Config0) ->" n - "%% void() | {save_config,Config1}" n - "%% GroupName = atom()" n - "%% Config0 = Config1 = [tuple()]" n - (erlang-skel-separator 2) - "end_per_group(_GroupName, _Config) ->" n > - "ok." n n - - (erlang-skel-separator 2) - "%% Function: init_per_testcase(TestCase, Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - "%% TestCase = atom()" n - "%% Config0 = Config1 = [tuple()]" n - "%% Reason = term()" n - (erlang-skel-separator 2) - "init_per_testcase(_TestCase, Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_testcase(TestCase, Config0) ->" n - "%% void() | {save_config,Config1} | {fail,Reason}" n - "%% TestCase = atom()" n - "%% Config0 = Config1 = [tuple()]" n - "%% Reason = term()" n - (erlang-skel-separator 2) - "end_per_testcase(_TestCase, _Config) ->" n > - "ok." n n - - (erlang-skel-separator 2) - "%% Function: groups() -> [Group]" n - "%% Group = {GroupName,Properties,GroupsAndTestCases}" n - "%% GroupName = atom()" n - "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n - "%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]" n - "%% TestCase = atom()" n - "%% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}}" n - "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n - "%% repeat_until_any_ok | repeat_until_any_fail" n - "%% N = integer() | forever" n - (erlang-skel-separator 2) - "groups() ->" n > - "[]." n n - - (erlang-skel-separator 2) - "%% Function: all() -> GroupsAndTestCases | {skip,Reason}" n - "%% GroupsAndTestCases = [{group,GroupName} | TestCase]" n - "%% GroupName = atom()" n - "%% TestCase = atom()" n - "%% Reason = term()" n - (erlang-skel-separator 2) - "all() -> " n > - "[my_test_case]." n n - - (erlang-skel-separator 2) - "%% Function: TestCase() -> Info" n - "%% Info = [tuple()]" n - (erlang-skel-separator 2) - "my_test_case() -> " n > - "[]." n n - - (erlang-skel-separator 2) - "%% Function: TestCase(Config0) ->" n - "%% ok | exit() | {skip,Reason} | {comment,Comment} |" n - "%% {save_config,Config1} | {skip_and_save,Reason,Config1}" n - "%% Config0 = Config1 = [tuple()]" n - "%% Reason = term()" n - "%% Comment = term()" n - (erlang-skel-separator 2) - "my_test_case(_Config) -> " n > - "ok." n - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") +;; Tempo skeleton templates: +(load erlang-skel-file) ;; Font-lock variables diff --git a/lib/typer/src/typer_annotator.erl b/lib/typer/src/typer_annotator.erl index a68360604d..68a8f03a5c 100644 --- a/lib/typer/src/typer_annotator.erl +++ b/lib/typer/src/typer_annotator.erl @@ -1,20 +1,20 @@ %% -*- erlang-indent-level: 2 -*- %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %%============================================================================ diff --git a/lib/wx/api_gen/wx_gen.erl b/lib/wx/api_gen/wx_gen.erl index 780bb2e741..2ed4476440 100644 --- a/lib/wx/api_gen/wx_gen.erl +++ b/lib/wx/api_gen/wx_gen.erl @@ -73,8 +73,7 @@ gen_xml() -> -record(hs,{alias,skip,fs,fopt,ev,acc,info}). init_defs(List0) -> - List1 = to_lists(List0), - lists:map(fun mangle_info/1, List1). + [mangle_info(L) || L <- to_lists(List0)]. mangle_info(E={enum,Type0,SkipStr}) -> Type = case is_atom(Type0) of true -> atom_to_list(Type0); false -> Type0 end, @@ -138,9 +137,9 @@ parse_defs([{class,Name,Parent,Info}|Rest], Acc0) -> Defs0 = load_members(FileName, Name, gb_trees:empty(), Tab, Type, Info), put(current_class, Name), - Class0 = #class{name=name(Name,Info),parent=Parent, + Class0 = #class{name=name(Name,Info), parent=Parent, doc=get_value(doc,Info#hs.info,undefined), - file=FileName,options=Info#hs.info, id=next_id(class_id)}, + file=FileName, options=Info#hs.info, id=next_id(class_id)}, ParseClass = fun(Member,{Class,Dfs}) -> parse_class(Member,Tab,Dfs,Class,Info) end, @@ -161,12 +160,11 @@ parse_defs([], Acc) -> reverse(Acc). meta_info(C=#class{name=CName,methods=Ms0}) -> Ms = lists:append(Ms0), - HaveConstructor = - lists:keysearch(constructor, #method.method_type, Ms) =/= false, + HaveConstructor = lists:keymember(constructor, #method.method_type, Ms), case lists:keysearch(destructor, #method.method_type, Ms) of false when HaveConstructor -> - Dest = #method{name="destroy",id=next_id(func_id), - method_type=destructor, params=[this(CName)]}, + Dest = #method{name = "destroy", id = next_id(func_id), + method_type = destructor, params = [this(CName)]}, C#class{methods = [[Dest]|Ms0]}; false -> C#class{abstract = true}; @@ -451,9 +449,9 @@ find_erl_alias_name(MName,Ps,Fopts) -> _ -> Find = fun({all,AliasName},Acc) -> [AliasName|Acc]; ({Var,AliasName},Acc) -> - case lists:keysearch(Var, #param.name, Ps) of - {value, _} -> [AliasName|Acc]; - _ -> Acc + case lists:keymember(Var, #param.name, Ps) of + true -> [AliasName|Acc]; + false -> Acc end end, case lists:foldl(Find, [], Aliases) of @@ -873,11 +871,14 @@ add_method2(M0=#method{name=Name,params=Ps0,type=T0},#class{name=CName,parent=Pa end, M1 = M0#method{defined_in=CName, min_arity = length(Req), - max_arity = length(Req) + if length(Opt) > 0 -> 1; true -> 0 end, + max_arity = length(Req) + case Opt of + [_ | _] -> 1; + _ -> 0 + end, type = Type, method_type = IsStatic, where = Where, - id=next_id(func_id), + id = next_id(func_id), pre_hook = get_opt(pre_hook, Name, length(Ps), Opts), post_hook = get_opt(post_hook, Name, length(Ps), Opts), doc = get_opt(doc, Name, length(Ps), Opts) @@ -1037,10 +1038,10 @@ types_differ([list|R1], [opt_list|R2]) -> types_differ([opt_list|R1], [list|R2]) -> types_differ(R1,R2); types_differ([C1|R1], [C2|R2]) when is_tuple(C1), is_tuple(C2) -> - (size(C1) =/= size(C2)) orelse types_differ(R1,R2); + (tuple_size(C1) =/= tuple_size(C2)) orelse types_differ(R1,R2); types_differ([C1|_R1], [_C2|_R2]) when is_tuple(C1) -> true; -types_differ([_C1|_R1], [C2|_R2]) when is_tuple(C2)-> +types_differ([_C1|_R1], [C2|_R2]) when is_tuple(C2) -> true; types_differ([_C1|R1], [_C2|R2]) -> %% More cases? types_differ(R1,R2); @@ -1198,7 +1199,7 @@ name(Name0, #hs{alias=Alias}) -> Name0; "esaBrekciP" ++ _ -> %% Arrg uses base Name0; - "esaB" ++ Rest when hd(Name0) == $w -> + "esaB" ++ Rest when hd(Name0) =:= $w -> %% Arrg Some decl uses base class directly reverse(Rest); _F -> diff --git a/lib/wx/doc/src/notes.xml b/lib/wx/doc/src/notes.xml index f9f16defd3..92933c348b 100644 --- a/lib/wx/doc/src/notes.xml +++ b/lib/wx/doc/src/notes.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2009</year> + <year>2009</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>wxErlang Release Notes</title> @@ -31,6 +31,58 @@ <p>This document describes the changes made to the wxErlang application.</p> +<section><title>Wx 0.98.5</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> + Corrected incorrectly generated wxFileDialog:getPaths/1. + Reported by Jason/hornja.</p> + <p> + Own Id: OTP-8330</p> + </item> + <item> + <p> + Fixed a memory reference bug which caused unexplained + {badarg, Int} exits when running multiple wx + applications.</p> + <p> + Own Id: OTP-8461</p> + </item> + </list> + </section> + + + <section><title>Improvements and New Features</title> + <list> + <item> + <p> + Added <c>wxListCtrl:getEditCtrl/1</c> (not available on + Mac).</p> + <p> + Own Id: OTP-8408</p> + </item> + <item> + <p> + Cleanups suggested by tidier and modernization of types + and specs.</p> + <p> + Own Id: OTP-8455</p> + </item> + <item> + <p> Changed representation of wxTreeItem to be an + integer. This saves memory, where the driver do not need + to keep a object reference to each tree item. </p> <p> + Added getFirstChild and getNextChild to wxTreeCtrl.</p> + <p> + Own Id: OTP-8462</p> + </item> + </list> + </section> + +</section> + <section><title>Wx 0.98.4</title> <section><title>Improvements and New Features</title> diff --git a/lib/wx/examples/demo/demo_html_tagger.erl b/lib/wx/examples/demo/demo_html_tagger.erl index 9b6d1fd950..243e5d659f 100644 --- a/lib/wx/examples/demo/demo_html_tagger.erl +++ b/lib/wx/examples/demo/demo_html_tagger.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2009-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% -module(demo_html_tagger). @@ -462,7 +462,7 @@ fix_remote([H|T]) -> fix_remote([]) -> []. --spec is_keyword(atom()) -> bool(). +-spec is_keyword(atom()) -> boolean(). is_keyword('after' ) -> true; is_keyword('and') -> true; diff --git a/lib/wx/vsn.mk b/lib/wx/vsn.mk index 91bbdc8c99..54ab92cad2 100644 --- a/lib/wx/vsn.mk +++ b/lib/wx/vsn.mk @@ -1,6 +1,7 @@ -WX_VSN = 0.98.4 +WX_VSN = 0.98.5 -TICKETS = OTP-8243 OTP-8250 OTP-8292 +TICKETS = OTP-8330 OTP-8461 OTP-8408 OTP-8455 OTP-8462 +TICKETS_0.98.4 = OTP-8243 OTP-8250 OTP-8292 TICKETS_0.98.3 = OTP-8138 OTP-8126 OTP-8083 TICKETS_0.98.2 = OTP-7943 TICKETS_0.98.1 = OTP-7875
\ No newline at end of file diff --git a/lib/xmerl/doc/src/notes.xml b/lib/xmerl/doc/src/notes.xml index 115c81a806..0f30ae9eca 100644 --- a/lib/xmerl/doc/src/notes.xml +++ b/lib/xmerl/doc/src/notes.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2004</year><year>2009</year> + <year>2004</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>Xmerl Release Notes</title> @@ -31,6 +31,20 @@ <p>This document describes the changes made to the Xmerl application.</p> +<section><title>Xmerl 1.2.4</title> + + <section><title>Improvements and New Features</title> + <list> + <item> + <p>Updated the documentation Makefile to work with the + new documentation build process.</p> + <p> + Own Id: OTP-8343</p> + </item> + </list> + </section> + +</section> <section><title>Xmerl 1.2.3</title> diff --git a/lib/xmerl/vsn.mk b/lib/xmerl/vsn.mk index 0bb57ea252..4162b52a80 100644 --- a/lib/xmerl/vsn.mk +++ b/lib/xmerl/vsn.mk @@ -1,28 +1,30 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2003-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2003-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% # -XMERL_VSN = 1.2.3 +XMERL_VSN = 1.2.4 + TICKETS = \ - OTP-8251 \ - OTP-8252 \ - OTP-8253 + OTP-8343 + +TICKETS_1.2.4 = \ + OTP-8343 TICKETS_1.2.3 = \ OTP-8251 \ |