diff options
author | Dan Gudmundsson <[email protected]> | 2012-12-13 08:54:29 +0100 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2013-01-09 11:41:41 +0100 |
commit | 204d0bdc0acaf8017372a3b93f54bb846b6be58e (patch) | |
tree | d7e83d8ee7a465a1fad978d9cfdecb15e56c223e /lib/wx/api_gen | |
parent | ad6e421879217ee76d3c7267bcd8234ec33153a1 (diff) | |
download | otp-204d0bdc0acaf8017372a3b93f54bb846b6be58e.tar.gz otp-204d0bdc0acaf8017372a3b93f54bb846b6be58e.tar.bz2 otp-204d0bdc0acaf8017372a3b93f54bb846b6be58e.zip |
wx: Fix int to enum
In 2.9 several functions takes enum's instead of int as arguments,
remove dirty -fpermissive fix and fix it correctly instead.
Diffstat (limited to 'lib/wx/api_gen')
-rw-r--r-- | lib/wx/api_gen/wx_gen.erl | 8 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen_cpp.erl | 12 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen_erl.erl | 23 | ||||
-rw-r--r-- | lib/wx/api_gen/wxapi.conf | 55 |
4 files changed, 70 insertions, 28 deletions
diff --git a/lib/wx/api_gen/wx_gen.erl b/lib/wx/api_gen/wx_gen.erl index cc1453158d..53bf9a6ecb 100644 --- a/lib/wx/api_gen/wx_gen.erl +++ b/lib/wx/api_gen/wx_gen.erl @@ -103,7 +103,12 @@ mangle_info({class,CN,P,O,FL}) -> Event = get_value(event,O, false), Acc = get_value(acc, O, []), {Fs,Fopts} = foldr(fun(FWO={F,FO},{Fl,Fopt}) when is_list(FO) -> - {[F|Fl],[FWO|Fopt]}; + Opt = case F of + {Name, ArgLen} when is_integer(ArgLen) -> + {Name, FO}; + _ -> FWO + end, + {[F|Fl],[Opt|Fopt]}; (F,{Fl,Fopt}) -> {[F|Fl], Fopt} end, {[],[]}, FL), @@ -568,6 +573,7 @@ handle_param_opt(both, P) -> P#param{in=both}; handle_param_opt({def,Def},P) -> P#param{def=Def}; handle_param_opt({type,Type}, P=#param{type=T}) -> P#param{type=T#type{name=Type}}; handle_param_opt({single,Opt}, P=#param{type=T}) -> P#param{type=T#type{single=Opt}}; +handle_param_opt({base,Enum={enum,Type}}, P=#param{type=T}) -> P#param{type=T#type{base=Enum, name=Type}}; handle_param_opt({base,Opt}, P=#param{type=T}) -> P#param{type=T#type{base=Opt}}; handle_param_opt({c_only,Opt},P) -> P#param{where=c, alt=Opt}; handle_param_opt({ref, pointer}, P=#param{type=T}) -> diff --git a/lib/wx/api_gen/wx_gen_cpp.erl b/lib/wx/api_gen/wx_gen_cpp.erl index 04d3f9264c..7027ac305d 100644 --- a/lib/wx/api_gen/wx_gen_cpp.erl +++ b/lib/wx/api_gen/wx_gen_cpp.erl @@ -170,6 +170,14 @@ gen_funcs(Defs) -> w("#include \"wxe_macros.h\"~n"), w("#include \"wxe_derived_dest.h\"~n~n"), + w("#if !wxCHECK_VERSION(2,9,0)~n", []), + [w("#define ~p int~n", [Enum]) || + Enum <- [wxPenJoin, wxPenCap, wxImageResizeQuality, %%wxBitmapType, + wxPolygonFillMode, wxMappingMode, wxRasterOperationMode, + wxFloodFillStyle + ]], + w("#endif~n",[]), + w("void WxeApp::wxe_dispatch(wxeCommand& Ecmd)~n{~n"), w(" char * bp = Ecmd.buffer;~n"), w(" wxeMemEnv *memenv = getMemEnv(Ecmd.port);~n"), @@ -812,12 +820,12 @@ call_arg(#param{where=c, alt={size,Id}}) when is_integer(Id) -> call_arg(#param{name=N,def=Def,type=#type{name=Type,by_val=true,single=true,base=Base}}) when Base =:= int; Base =:= long; Base =:= float; Base =:= double; Base =:= bool -> case Def of - none -> "(" ++ to_string(Type) ++ ") *" ++ N; + none -> "(" ++ to_string(Type) ++ ") *" ++ N; %% Remove _ -> N end; call_arg(#param{name=N,type=#type{base={enum,Type}, by_val=true,single=true}}) -> - "(" ++ enum_type(Type) ++") " ++ N; + "(" ++ enum_type(Type) ++") " ++ N; %% Remove call_arg(#param{name=N,type=#type{base={class,_},by_val=true,single=true}}) -> "*" ++ N; call_arg(#param{name=N,type=#type{base={class,_},ref=reference,single=true}}) -> "*" ++ N; call_arg(#param{name=N,type=#type{base=eventType}}) -> diff --git a/lib/wx/api_gen/wx_gen_erl.erl b/lib/wx/api_gen/wx_gen_erl.erl index 35eba29450..a999a869e6 100644 --- a/lib/wx/api_gen/wx_gen_erl.erl +++ b/lib/wx/api_gen/wx_gen_erl.erl @@ -842,15 +842,20 @@ doc_enum(_,Ps) -> [doc_enum_type(Type,Name) || #param{name=Name, type=#type{base={enum,Type}}} <- Ps]. doc_enum_type(Type, Name) -> - {Enum0, #enum{vals=Vals}} = wx_gen:get_enum(Type), - Enum = case Enum0 of {_, E} -> E; E -> E end, - Consts = get(consts), - Format = fun({N,_What}) -> - #const{name=N} = gb_trees:get(N, Consts), - "?" ++ enum_name(N) - end, - Vs = args(Format, " | ", Vals), - {uppercase(Enum),Name, Vs}. + try + {Enum0, #enum{vals=Vals}} = wx_gen:get_enum(Type), + Enum = case Enum0 of {_, E} -> E; E -> E end, + Consts = get(consts), + Format = fun({N,_What}) -> + #const{name=N} = gb_trees:get(N, Consts), + "?" ++ enum_name(N) + end, + Vs = args(Format, " | ", Vals), + {uppercase(Enum),Name, Vs} + catch _:_ -> + io:format("Warning missing enum type ~p~n", [Type]), + {uppercase(Type),Name,"integer"} + end. doc_enum_desc([]) -> ok; doc_enum_desc([{_Enum,Name,Vs}|R]) -> diff --git a/lib/wx/api_gen/wxapi.conf b/lib/wx/api_gen/wxapi.conf index 385d7ca7f2..4610f80234 100644 --- a/lib/wx/api_gen/wxapi.conf +++ b/lib/wx/api_gen/wxapi.conf @@ -322,7 +322,8 @@ {class, wxDC, object, [{skip, [{'DrawEllipse',5},{'DrawRectangle',5}, {'DrawRoundedRectangle',6},{'SetClippingRegion',5}]}], - [{'Blit',7},'CalcBoundingBox','Clear', + [{{'Blit',7},[{"rop", [{base, {enum, "wxRasterOperationMode"}}]}]}, + 'CalcBoundingBox','Clear', {'ComputeScaleAndOrigin',[{deprecated, "!wxCHECK_VERSION(2,9,0)"}]}, {'CrossHair',1}, 'DestroyClippingRegion','DeviceToLogicalX','DeviceToLogicalXRel', @@ -330,11 +331,16 @@ {'DrawCheckMark',1},{'DrawCircle',2},'DrawEllipse',{'DrawEllipticArc',4}, {'DrawIcon',2},{'DrawLabel',4},{'DrawLine',2}, {'DrawLines', [{"n",{c_only,{length,"points"}}}]}, - {'DrawPolygon', [{"n",{c_only,{length,"points"}}}]}, %'DrawPolyPolygon', + {'DrawPolygon', [{"n",{c_only,{length,"points"}}}, + {"fillStyle", [{base, {enum, "wxPolygonFillMode"}}]} + ]}, + %%'DrawPolyPolygon', {'DrawPoint',1},'DrawRectangle', {'DrawRotatedText',3}, 'DrawRoundedRectangle',%'DrawSpline', {'DrawText',2}, - 'EndDoc','EndPage',{'FloodFill',3},'GetBackground','GetBackgroundMode', + 'EndDoc','EndPage', + {{'FloodFill',3},[{"style", [{base, {enum, "wxFloodFillStyle"}}]}]}, + 'GetBackground','GetBackgroundMode', 'GetBrush','GetCharHeight','GetCharWidth',{'GetClippingBox',[{"rect", skip_member}]}, 'GetFont','GetLayoutDirection','GetLogicalFunction','GetMapMode','GetMultiLineTextExtent', {'GetPartialTextExtents', [{"widths", out}]}, @@ -345,7 +351,10 @@ 'LogicalToDeviceX','LogicalToDeviceXRel','LogicalToDeviceY','LogicalToDeviceYRel', 'MaxX','MaxY','MinX','MinY','IsOk','ResetBoundingBox','SetAxisOrientation', 'SetBackground','SetBackgroundMode','SetBrush','SetClippingRegion','SetDeviceOrigin', - 'SetFont','SetLayoutDirection','SetLogicalFunction','SetMapMode', 'SetPalette', + 'SetFont','SetLayoutDirection', + {'SetLogicalFunction', [{"function", [{base, {enum, "wxRasterOperationMode"}}]}]}, + {'SetMapMode', [{"mode", [{base, {enum, "wxMappingMode"}}]}]}, + 'SetPalette', 'SetPen','SetTextBackground','SetTextForeground','SetUserScale','StartDoc','StartPage']}. {class,wxMirrorDC, wxDC, [], ['wxMirrorDC', '~wxMirrorDC']}. @@ -382,9 +391,11 @@ 'CreateFont','CreateMatrix', 'CreatePath','Clip','ResetClip', 'DrawBitmap','DrawEllipse','DrawIcon', - {'DrawLines', [{"n",{c_only,{length,"points"}}}, {"points", {single,array}}]}, - 'DrawPath', - 'DrawRectangle','DrawRoundedRectangle','DrawText','FillPath', + {'DrawLines', [{"n",{c_only,{length,"points"}}}, {"points", {single,array}}, + {"fillStyle", [{base, {enum, "wxPolygonFillMode"}}]}]}, + {'DrawPath',[{"fillStyle", [{base, {enum, "wxPolygonFillMode"}}]}]}, + 'DrawRectangle','DrawRoundedRectangle','DrawText', + {'FillPath',[{"fillStyle", [{base, {enum, "wxPolygonFillMode"}}]}]}, 'StrokePath', %% 'GetNativeContext', {'GetPartialTextExtents', [{"widths", out}]}, 'GetTextExtent','Rotate','Scale','Translate', @@ -399,8 +410,9 @@ {class, wxGraphicsPath, wxGraphicsObject, [{ifdef, wxUSE_GRAPHICS_CONTEXT}], ['MoveToPoint','AddArc','AddArcToPoint','AddCircle','AddCurveToPoint', 'AddEllipse','AddLineToPoint','AddPath','AddQuadCurveToPoint', - 'AddRectangle','AddRoundedRectangle','CloseSubpath','Contains', - 'GetBox','GetCurrentPoint','Transform' + 'AddRectangle','AddRoundedRectangle','CloseSubpath', + {'Contains', [{"fillStyle", [{base, {enum, "wxPolygonFillMode"}}]}]}, + 'GetBox','GetCurrentPoint','Transform' %'GetNativePath','UnGetNativePath' ]}. {class, wxGraphicsRenderer, object, [{ifdef, wxUSE_GRAPHICS_CONTEXT}], @@ -519,10 +531,13 @@ 'CopyFromBitmap','~wxIcon']}. {class, wxIconBundle, root, [], - ['wxIconBundle','~wxIconBundle','AddIcon','GetIcon']}. + ['wxIconBundle','~wxIconBundle','AddIcon', + 'GetIcon']}. +%% {'GetIcon', [{return, {by_val, true}}]}]}. {class, wxCursor, wxBitmap,[], - [{'wxCursor',[{"bits",[in,{base,binary},{single,true}]}, + [{'wxCursor',[{{func, 5}, [{deprecated, "!wxCHECK_VERSION(2,9,0)"}]}, + {"bits",[in,{base,binary},{single,true}]}, {"maskBits",nowhere},{"fg",nowhere},{"bg",nowhere}]}, '~wxCursor','Ok']}. @@ -567,16 +582,22 @@ {'GetAlpha',[{{0,return},{base,{binary,"(This->GetWidth()*This->GetHeight())"}}}]}, 'GetBlue', {'GetData', [{return,{base,{binary,"(This->GetWidth()*This->GetHeight()*3)"}}}]}, - 'GetGreen', 'GetImageCount', %'GetHandlers', + 'GetGreen', + {'GetImageCount', [{"type", [{base, {enum, "wxBitmapType"}}]}]}, + %%'GetHandlers', 'GetHeight','GetMaskBlue','GetMaskGreen', 'GetMaskRed','GetOrFindMaskColour','GetPalette', 'GetRed','GetSubImage', 'GetWidth',%%':HSVValue', 'HSVtoRGB', 'HasAlpha','HasMask','GetOption','GetOptionInt','HasOption', 'InitAlpha','InitStandardHandlers',%'InsertHandler', 'IsTransparent', 'LoadFile','Ok',%%RGBValue 'RGBtoHSV', - 'RemoveHandler','Mirror','Replace','Rescale','Resize', + 'RemoveHandler','Mirror','Replace', + {'Rescale', [{"quality", [{base, {enum, "wxImageResizeQuality"}}]}]}, + 'Resize', 'Rotate', 'RotateHue', - 'Rotate90','SaveFile','Scale','Size', + 'Rotate90','SaveFile', + {'Scale', [{"quality", [{base, {enum, "wxImageResizeQuality"}}]}]}, + 'Size', {'SetAlpha', [{{2,"alpha"},[in,{base,binary}, {def, none}]}, {{2,pre_hook}, [{c, "if(!static_data) {" @@ -600,9 +621,11 @@ {class, wxPen, object, [], ['wxPen','~wxPen','GetCap','GetColour', %%'GetDashes', %'GetStipple', - 'GetJoin', 'GetStyle','GetWidth','IsOk','SetCap','SetColour', + 'GetJoin', 'GetStyle','GetWidth','IsOk', + {'SetCap', [{"capStyle", [{base, {enum, "wxPenCap"}}]}]}, + 'SetColour', %%'SetDashes', %'SetStipple', - 'SetJoin', 'SetStyle','SetWidth']}. + {'SetJoin', [{"joinStyle", [{base, {enum, "wxPenJoin"}}]}]}, 'SetStyle','SetWidth']}. {enum, wxRegionContain, "wx"}. |