diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/wx/api_gen/gen_util.erl | 4 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen.erl | 2 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen.hrl | 6 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen_cpp.erl | 12 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen_erl.erl | 22 | ||||
-rw-r--r-- | lib/wx/api_gen/wxapi.conf | 48 | ||||
-rw-r--r-- | lib/wx/src/gen/wxGLCanvas.erl | 8 |
7 files changed, 53 insertions, 49 deletions
diff --git a/lib/wx/api_gen/gen_util.erl b/lib/wx/api_gen/gen_util.erl index 841e0c9594..b53f817ce0 100644 --- a/lib/wx/api_gen/gen_util.erl +++ b/lib/wx/api_gen/gen_util.erl @@ -40,6 +40,10 @@ strip_name([H|R1],[H|R2]) -> strip_name(R1,R2); strip_name(String,[]) -> String. + +get_hook(_Type, undefined) -> ignore; +get_hook(Type, List) -> proplists:get_value(Type, List, ignore). + open_write(File) -> %% io:format("Generating ~s~n",[File]), {ok, Fd} = file:open(File++".temp", [write]), diff --git a/lib/wx/api_gen/wx_gen.erl b/lib/wx/api_gen/wx_gen.erl index c075324c1f..2f20c42a5d 100644 --- a/lib/wx/api_gen/wx_gen.erl +++ b/lib/wx/api_gen/wx_gen.erl @@ -887,7 +887,7 @@ add_method2(M0=#method{name=Name,params=Ps0,type=T0},#class{name=CName,parent=Pa 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) + doc = get_opt(doc, Name, length(Ps), Opts) }, M = case Name of CName -> diff --git a/lib/wx/api_gen/wx_gen.hrl b/lib/wx/api_gen/wx_gen.hrl index 17265a2842..426e3adfae 100644 --- a/lib/wx/api_gen/wx_gen.hrl +++ b/lib/wx/api_gen/wx_gen.hrl @@ -43,9 +43,9 @@ id = undefined, % Id (integer) doc, % Extra documentation virtual, % Is virtual? - pre_hook, % Pre hook before call in c-code - post_hook % Post hook after call in c-code - } + pre_hook = [], % Pre hook before call in c-code + post_hook = [] % Post hook after call in c-code + } ). -record(param, diff --git a/lib/wx/api_gen/wx_gen_cpp.erl b/lib/wx/api_gen/wx_gen_cpp.erl index 4bcdbe6a68..4b33068d8f 100644 --- a/lib/wx/api_gen/wx_gen_cpp.erl +++ b/lib/wx/api_gen/wx_gen_cpp.erl @@ -269,14 +269,14 @@ gen_method(CName, M=#method{name=N,params=Ps0,type=T,method_type=MT,id=MethodId Opts = [Opt || Opt = #param{def=Def,in=In,where=Where} <- Ps2, Def =/= none, In =/= false, Where =/= c], decode_options(Opts, Align), - case M#method.pre_hook of - {c,Pre} -> w(" ~s;~n", [Pre]); - _ -> skip + case gen_util:get_hook(c, M#method.pre_hook) of + ignore -> skip; + Pre -> w(" ~s;~n", [Pre]) end, Ps3 = call_wx(N,{MT,CName},T,Ps2), - case M#method.post_hook of - {c, Post} -> w(" ~s;~n", [Post]); - _ -> skip + case gen_util:get_hook(c, M#method.post_hook) of + ignore -> skip; + Post -> w(" ~s;~n", [Post]) end, free_args(), build_return_vals(T,Ps3), diff --git a/lib/wx/api_gen/wx_gen_erl.erl b/lib/wx/api_gen/wx_gen_erl.erl index 8648174b5b..e1201ab0d4 100644 --- a/lib/wx/api_gen/wx_gen_erl.erl +++ b/lib/wx/api_gen/wx_gen_erl.erl @@ -270,14 +270,14 @@ gen_method2(M=#method{name=N,alias=A,params=Ps,type=T,method_type=MT,id=MethodId MId = arg_type_tests(Args, "?" ++ get_unique_name(MethodId)), {MArgs,Align} = marshal_args(Args), MOpts = marshal_opts(Optional, Align, Args), - case M#method.pre_hook of - {erl,Pre} -> w(" ~s~n", [Pre]); - _ -> skip + case gen_util:get_hook(erl, M#method.pre_hook) of + ignore -> skip; + Pre -> w(" ~s~n", [Pre]) end, - case M#method.post_hook of - {erl,_} -> w(" _Result = ~n", []); - _ -> skip + case gen_util:get_hook(erl, M#method.post_hook) of + ignore -> skip; + _ -> w(" _Result =", []) end, case have_return_vals(T, Ps) of @@ -288,11 +288,11 @@ gen_method2(M=#method{name=N,alias=A,params=Ps,type=T,method_type=MT,id=MethodId false -> w(" wxe_util:cast(~s,~n <<~s~s>>)", [MId, MArgs,MOpts]) end, - case M#method.post_hook of - {erl,Post} -> - w(" ~s~n", [Post]), - w(" _Result~n", []); - _ -> skip + case gen_util:get_hook(erl, M#method.post_hook) of + ignore -> skip; + Post -> + w(",~n ~s~n", [Post]), + w(" _Result", []) end, erase(current_func), diff --git a/lib/wx/api_gen/wxapi.conf b/lib/wx/api_gen/wxapi.conf index 63b136e075..aec8a4944a 100644 --- a/lib/wx/api_gen/wxapi.conf +++ b/lib/wx/api_gen/wxapi.conf @@ -505,15 +505,15 @@ {"data",[in,{base,binary}]}, {"alpha",[in,{base,binary}]}, {{4,pre_hook}, - {c, "if(!static_data) {" - "data = (unsigned char *) malloc(Ecmd.bin[0]->size);" - "memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}}, + [{c, "if(!static_data) {" + "data = (unsigned char *) malloc(Ecmd.bin[0]->size);" + "memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}]}, {{5,pre_hook}, - {c, "if(!static_data) {" - " data = (unsigned char *) malloc(Ecmd.bin[0]->size);" - " alpha = (unsigned char *) malloc(Ecmd.bin[1]->size);" - " memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);" - " memcpy(alpha,Ecmd.bin[1]->base,Ecmd.bin[1]->size);}"}} + [{c, "if(!static_data) {" + " data = (unsigned char *) malloc(Ecmd.bin[0]->size);" + " alpha = (unsigned char *) malloc(Ecmd.bin[1]->size);" + " memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);" + " memcpy(alpha,Ecmd.bin[1]->base,Ecmd.bin[1]->size);}"}]} ]}, '~wxImage',%'AddHandler', 'Blur','BlurHorizontal','BlurVertical', @@ -524,15 +524,15 @@ {"data",[in,{base,binary}]}, {"alpha",[in,{base,binary}]}, {{4,pre_hook}, - {c, "if(!static_data) {" + [{c, "if(!static_data) {" "data = (unsigned char *) malloc(Ecmd.bin[0]->size);" - "memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}}, + "memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}]}, {{5,pre_hook}, - {c, "if(!static_data) {" - " data = (unsigned char *) malloc(Ecmd.bin[0]->size);" - " alpha = (unsigned char *) malloc(Ecmd.bin[1]->size);" - " memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);" - " memcpy(alpha,Ecmd.bin[1]->base,Ecmd.bin[1]->size);}"}} + [{c, "if(!static_data) {" + " data = (unsigned char *) malloc(Ecmd.bin[0]->size);" + " alpha = (unsigned char *) malloc(Ecmd.bin[1]->size);" + " memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);" + " memcpy(alpha,Ecmd.bin[1]->base,Ecmd.bin[1]->size);}"}]} ]}, 'Destroy','FindFirstUnusedColour', % 'FindHandler', 'GetImageExtWildcard', @@ -551,15 +551,15 @@ 'Rotate90','SaveFile','Scale','Size', {'SetAlpha', [{{2,"alpha"},[in,{base,binary}, {def, none}]}, {{2,pre_hook}, - {c, "if(!static_data) {" - "alpha = (unsigned char *) malloc(Ecmd.bin[0]->size);" - "memcpy(alpha,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}} + [{c, "if(!static_data) {" + "alpha = (unsigned char *) malloc(Ecmd.bin[0]->size);" + "memcpy(alpha,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}]} ]}, {'SetData', [{"data",[in,{base,binary}]}, {pre_hook, - {c, "if(!static_data) {" - "data = (unsigned char *) malloc(Ecmd.bin[0]->size);" - "memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}} + [{c, "if(!static_data) {" + "data = (unsigned char *) malloc(Ecmd.bin[0]->size);" + "memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}]} ]}, 'SetMask','SetMaskColour','SetMaskFromImage','SetOption', 'SetPalette', @@ -1146,10 +1146,10 @@ {class, wxGLCanvas, wxWindow, [{skip, [{'SetCurrent', 2}]}], %% NA MAC - [{'wxGLCanvas', [{"attribList", [in, {single,array}]}, - {pre_hook, {erl, "{ok, _} = wxe_master:init_opengl(),"}}]}, + [{'wxGLCanvas', [{"attribList", [in, {single,array}]}]}, 'GetContext', - {'SetCurrent', [{post_hook,{c, "if(This->GetContext()) setActiveGL(Ecmd.caller,This)"}}]}, + {'SetCurrent', [{post_hook,[{c, "if(This->GetContext()) setActiveGL(Ecmd.caller,This)"}, + {erl, "{ok, _} = wxe_master:init_opengl(),"}]}]}, %%{'SetColour', [{"colour", [in, {single,array}]}]}, 'SwapBuffers']}. diff --git a/lib/wx/src/gen/wxGLCanvas.erl b/lib/wx/src/gen/wxGLCanvas.erl index e5d7bec4ca..032d42535d 100644 --- a/lib/wx/src/gen/wxGLCanvas.erl +++ b/lib/wx/src/gen/wxGLCanvas.erl @@ -105,7 +105,6 @@ new(#wx_ref{type=ParentT,ref=ParentRef}, Options) ({palette, #wx_ref{type=PaletteT,ref=PaletteRef}}, Acc) -> ?CLASS(PaletteT,wxPalette),[<<7:32/?UI,PaletteRef:32/?UI>>|Acc]; (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), - {ok, _} = wxe_master:init_opengl(), wxe_util:construct(?wxGLCanvas_new_2, <<ParentRef:32/?UI, 0:32,BinOpt/binary>>). @@ -131,7 +130,6 @@ new(#wx_ref{type=ParentT,ref=ParentRef},#wx_ref{type=SharedT,ref=SharedRef}, Opt ({palette, #wx_ref{type=PaletteT,ref=PaletteRef}}, Acc) -> ?CLASS(PaletteT,wxPalette),[<<7:32/?UI,PaletteRef:32/?UI>>|Acc]; (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), - {ok, _} = wxe_master:init_opengl(), wxe_util:construct(SharedOP, <<ParentRef:32/?UI,SharedRef:32/?UI, BinOpt/binary>>). @@ -146,8 +144,10 @@ getContext(#wx_ref{type=ThisT,ref=ThisRef}) -> %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxglcanvas.html#wxglcanvassetcurrent">external documentation</a>. setCurrent(#wx_ref{type=ThisT,ref=ThisRef}) -> ?CLASS(ThisT,wxGLCanvas), - wxe_util:cast(?wxGLCanvas_SetCurrent, - <<ThisRef:32/?UI>>). + _Result = wxe_util:cast(?wxGLCanvas_SetCurrent, + <<ThisRef:32/?UI>>), + {ok, _} = wxe_master:init_opengl(), + _Result. %% @spec (This::wxGLCanvas()) -> ok %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxglcanvas.html#wxglcanvasswapbuffers">external documentation</a>. |