diff options
author | Dan Gudmundsson <[email protected]> | 2012-03-06 12:21:51 +0100 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2012-03-06 12:21:51 +0100 |
commit | 2738f881102a6c291c8fb1f2305677dba57fa87d (patch) | |
tree | 634e8bc7666af4b19f7baeabd474202bbefd2762 /lib/wx/api_gen/wx_gen_erl.erl | |
parent | df8cd79bef0ca7178efcda97401c892d24f920bc (diff) | |
download | otp-2738f881102a6c291c8fb1f2305677dba57fa87d.tar.gz otp-2738f881102a6c291c8fb1f2305677dba57fa87d.tar.bz2 otp-2738f881102a6c291c8fb1f2305677dba57fa87d.zip |
[wx] Fix bad defines
Reported by Vlad Dumitrescu.
Diffstat (limited to 'lib/wx/api_gen/wx_gen_erl.erl')
-rw-r--r-- | lib/wx/api_gen/wx_gen_erl.erl | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/wx/api_gen/wx_gen_erl.erl b/lib/wx/api_gen/wx_gen_erl.erl index 59a4d3d8e7..1a616ed876 100644 --- a/lib/wx/api_gen/wx_gen_erl.erl +++ b/lib/wx/api_gen/wx_gen_erl.erl @@ -1059,16 +1059,16 @@ build_enum_ints(#enum{from=From, vals=Vals},Done) -> 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_integer(Value) -> + (#const{name=Name,val=Value,is_const=true}) when is_number(Value) -> w("-define(~s, ~p).~n", [enum_name(Name),Value]); - (#const{name=Name,val=Value,is_const=false}) when is_integer(Value) -> + (#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}}) -> case string:tokens(Str, " |()") of [Token] -> - w("-define(~s, ?~s).~n", [enum_name(Name),Token]); + w("-define(~s, ~s).~n", [enum_name(Name),const_value(Token)]); Tokens -> - Def = args(fun(T) -> [$?|T] end, " bor ", Tokens), + Def = args(fun(T) -> const_value(T) end, " bor ", Tokens), w("-define(~s, (~s)).~n", [enum_name(Name),Def]) end; (#const{name=Name,val={Str,N}}) -> @@ -1093,6 +1093,17 @@ build_enum_ints(#enum{from=From, vals=Vals},Done) -> end, lists:foldl(Write, Done, Vals). +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) -> + try + _ = list_to_integer(V0), + V0 + catch _:_ -> [$?|V0] + end. + gen_event_recs() -> open_write("../include/wx.hrl"), erl_copyright(), |