diff options
author | Dan Gudmundsson <[email protected]> | 2012-10-16 13:17:52 +0200 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2013-01-09 11:41:40 +0100 |
commit | aaaf448d6ad8c7a77571258f0f6a966259d72ab7 (patch) | |
tree | 6aa662e56279f6c758ad1f97715082a73157fdbf /lib/wx | |
parent | 5382426b0fb7fe5e6bd452015436eb3e7c689f31 (diff) | |
download | otp-aaaf448d6ad8c7a77571258f0f6a966259d72ab7.tar.gz otp-aaaf448d6ad8c7a77571258f0f6a966259d72ab7.tar.bz2 otp-aaaf448d6ad8c7a77571258f0f6a966259d72ab7.zip |
wx: Fix code generation bugs
Removed defines that is void, i.e.
-defined(FOO, ?NEVER_DEFINED_VALUE).
Also removed wxSTC:sendMsg/[2|3]
which was wrong before and breaks code generation with new doxygen.
Diffstat (limited to 'lib/wx')
-rw-r--r-- | lib/wx/.gitignore | 5 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen_erl.erl | 75 | ||||
-rw-r--r-- | lib/wx/api_gen/wxapi.conf | 2 |
3 files changed, 58 insertions, 24 deletions
diff --git a/lib/wx/.gitignore b/lib/wx/.gitignore index 0fa427bfe5..960c76a779 100644 --- a/lib/wx/.gitignore +++ b/lib/wx/.gitignore @@ -1,4 +1,5 @@ test_log_* wx_test_case_info -api_gen/gl_man? -doc/html/*
\ No newline at end of file +doc/html/* +%% Don't delete links to man src when git clean -dfX +%% api_gen/gl_man? diff --git a/lib/wx/api_gen/wx_gen_erl.erl b/lib/wx/api_gen/wx_gen_erl.erl index a8f23575f3..e30034f179 100644 --- a/lib/wx/api_gen/wx_gen_erl.erl +++ b/lib/wx/api_gen/wx_gen_erl.erl @@ -1014,11 +1014,23 @@ align(64, 1, Str) -> {"0:32," ++ Str,0}; align(Sz, W, Str) -> align(Sz, W rem 2, Str). enum_name(Name) -> + case enum_split(Name) of + {undefined, _} -> Name; + {_C, ErlName} -> ErlName + end. + +enum_split(Name) -> case string:tokens(Name, ":") of - [Name] -> Name; - [C,N] -> C ++ "_" ++ N + [Name] -> {undefined, Name}; + [C,N] -> {C, enum_name(C,N)} end. +enum_name(undefined, Name) -> Name; +enum_name(Enum, Name) -> Enum ++ "_" ++ Name. + +enum_name_c(undefined, Name) -> Name; +enum_name_c(Enum, Name) -> Enum ++ "::" ++ Name. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% gen_enums_ints() -> @@ -1058,6 +1070,14 @@ build_enum_ints(#enum{from=From, vals=Vals},Done) -> w("% From class ~s::~s~n",[Class, Name]) end, + Consts = get(consts), + Ignore = fun(Name) -> + case gb_trees:lookup(Name, Consts) of + {value, Const} -> Const; + none -> true + end + end, + Format = fun(#const{name="wxEVT_" ++ _}) -> ignore; %% Ignore event macros they are not valid in our event model (#const{name=Name,val=Value,is_const=true}) when is_number(Value) -> @@ -1065,44 +1085,57 @@ build_enum_ints(#enum{from=From, vals=Vals},Done) -> (#const{name=Name,val=Value,is_const=false}) when is_number(Value) -> w("-define(~s, wxe_util:get_const(~s)).~n", [enum_name(Name),enum_name(Name)]); (#const{name=Name,val={Str,0}}) -> + {EnumClass, EnumName} = enum_split(Name), case string:tokens(Str, " |()") of [Token] -> - w("-define(~s, ~s).~n", [enum_name(Name),const_value(Token)]); + w("-define(~s, ~s).~n", [EnumName,const_value(Token, EnumClass, Ignore)]); Tokens -> - Def = args(fun(T) -> const_value(T) end, " bor ", Tokens), - w("-define(~s, (~s)).~n", [enum_name(Name),Def]) + Def = args(fun(T) -> const_value(T, EnumClass, Ignore) end, " bor ", Tokens), + w("-define(~s, (~s)).~n", [EnumName, Def]) end; (#const{name=Name,val={Str,N}}) -> + {EnumClass, EnumName} = enum_split(Name), case string:tokens(Str, " |()") of [Token] -> - w("-define(~s, (?~s+~p)).~n", [enum_name(Name),Token,N]) + w("-define(~s, (~s+~p)).~n", [EnumName,const_value(Token, EnumClass, Ignore),N]) end end, - Consts = get(consts), + Write = fun({Name,_What}, Skip) -> - case gb_sets:is_member(Name,Skip) of - true -> - Skip; - false -> - case gb_trees:lookup(Name, Consts) of - {value, Const} -> - Format(Const), - gb_sets:add(Name,Skip); - none -> Skip - end + case gb_sets:is_member(Name,Skip) orelse Ignore(Name) of + true -> Skip; + Const -> + try Format(Const) + catch {unknown_value, _Error} -> + %% io:format("Const ~s uses unknown define ~p ignoring~n", [Name, _Error]), + ok + end, + gb_sets:add(Name,Skip) end end, lists:foldl(Write, Done, Vals). -const_value(V) when is_integer(V) -> integer_to_list(V); -const_value(V = "16#" ++ IntList) -> +const_value(V,_,_) when is_integer(V) -> integer_to_list(V); +const_value(V = "16#" ++ IntList,_,_) -> _ = http_util:hexlist_to_integer(IntList), %% ASSERT V; -const_value(V0) -> +const_value(V0, EnumClass, Ignore) -> try _ = list_to_integer(V0), V0 - catch _:_ -> [$?|V0] + catch _:_ -> + EEnum = enum_name(EnumClass, V0), + CEnum = enum_name_c(EnumClass, V0), + case Ignore(CEnum) of + true when CEnum == V0 -> + throw({unknown_value, EEnum}); + true -> + case Ignore(V0) of + true -> throw({unknown_value, EEnum}); + _ -> [$?|V0] + end; + _ -> [$?|EEnum] + end end. gen_event_recs() -> diff --git a/lib/wx/api_gen/wxapi.conf b/lib/wx/api_gen/wxapi.conf index 1f6225ce60..943d7abb45 100644 --- a/lib/wx/api_gen/wxapi.conf +++ b/lib/wx/api_gen/wxapi.conf @@ -1634,7 +1634,7 @@ 'StyleSetFont', 'StyleSetFontAttr', 'StyleSetCharacterSet', 'StyleSetFontEncoding', 'CmdKeyExecute', 'SetMargins', {'GetSelection', [{"startPos", [out]}, {"endPos",[out]}]}, - 'PointFromPosition', 'ScrollToLine', 'ScrollToColumn', 'SendMsg', + 'PointFromPosition', 'ScrollToLine', 'ScrollToColumn', %% 'SendMsg', 'SetVScrollBar', 'SetHScrollBar', 'GetLastKeydownProcessed', 'SetLastKeydownProcessed', 'SaveFile', 'LoadFile', 'DoDragOver', 'DoDropText', 'GetUseAntiAliasing', {'AddTextRaw', [{"text", [in, {base, binary}]}]}, |