Skip to content

Commit a2e0f50

Browse files
committed
Merge branch 'dgud/wx/fix-gen-and-image/OTP-19823' into maint
* dgud/wx/fix-gen-and-image/OTP-19823: Fix OpenGL compilation/loading again Fix code generator for unsigned return types Fix code generator wx: Fixed the types of pixel values.
2 parents 4bac450 + 4ec70e8 commit a2e0f50

File tree

6 files changed

+37
-24
lines changed

6 files changed

+37
-24
lines changed

lib/wx/api_gen/gen_util.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ erl_copyright_template(License) ->
238238
w("%%~n",[]),
239239
w("%% %CopyrightBegin%~n",[]),
240240
w("%%~n",[]),
241-
w("%% SPDX-License-Identifier: ~n",[License]),
241+
w("%% SPDX-License-Identifier: ~ts~n",[License]),
242242
w("%%~n",[]),
243243
w("%% Copyright Ericsson AB ~p-~p. All Rights Reserved.~n",
244244
[StartYear, CurrentYear]),
@@ -304,8 +304,8 @@ append_license(_) ->
304304
c_copyright() ->
305305
{CurrentYear,_,_} = erlang:date(),
306306
w("/*~n",[]),
307-
w(" * %CopyrightBegin%
308-
w(" *
307+
w(" * %CopyrightBegin%~n",[]),
308+
w(" *~n",[]),
309309
w(" * SPDX-License-Identifier: Apache-2.0~n",[]),
310310
w(" *~n",[]),
311311
w(" * Copyright Ericsson AB 2008-~p. All Rights Reserved.~n",[CurrentYear]),

lib/wx/api_gen/wx_gen_erl.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ filter_attrs(#class{name=Name, parent=Parent,attributes=Attrs}) ->
12441244
gen_funcnames() ->
12451245
Ns = get_unique_names(),
12461246
open_write("../src/gen/wxe_funcs.hrl"),
1247-
erl_copyright(),
1247+
erl_wx_copyright(),
12481248
w("%% This file is generated DO NOT EDIT~n~n", []),
12491249
w("%% We define each id so we don't get huge diffs when adding new funcs/classes~n~n",[]),
12501250
[w("-define(~s_~s, ~p).~n", [Class,Name,Id]) || {Class,Name,_,Id} <- Ns],

lib/wx/api_gen/wx_gen_nif.erl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,8 +977,13 @@ return_res1(#type{name="wxCharBuffer", base={binary,_},single=true,by_val=true})
977977
{"char * Result = ", ".data()"};
978978
return_res1(#type{name=Type,single=array,ref=reference}) ->
979979
{Type ++ " Result = ", ""};
980-
return_res1(#type{name=Type,single=true,by_val=true}) ->
981-
{Type ++ " Result = ", ""}.
980+
return_res1(#type{name=Type,single=true,by_val=true, mod=Mods}) ->
981+
case lists:member(unsigned, Mods) of
982+
true ->
983+
{io_lib:format("unsigned ~s Result = ", [Type]), ""};
984+
false ->
985+
{Type ++ " Result = ", ""}
986+
end.
982987

983988
filter(Ps) ->
984989
lists:filter(fun filter_arg/1, Ps).
@@ -1458,10 +1463,12 @@ gen_macros() ->
14581463
w("#include <wx/sysopt.h>~n"),
14591464
w("#include <wx/overlay.h>~n"),
14601465
w("#include <wx/notifmsg.h>~n"),
1466+
w("#if WXE_WEBVIEW~n"),
14611467
w("#include <wx/webview.h>~n"),
14621468
w("#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE~n"),
14631469
w("#include <wx/msw/webview_ie.h>~n"),
14641470
w("#endif~n"),
1471+
w("#endif~n"),
14651472
w("#if wxUSE_GLCANVAS_EGL && !wxCHECK_VERSION(3,2,3)~n"),
14661473
w("#include <EGL/egl.h>~n"),
14671474
w("#endif~n"),

lib/wx/c_src/gen/wxe_wrapper_4.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,7 @@ void wxImage_GetAlpha_2(WxeApp *app, wxeMemEnv *memenv, wxeCommand& Ecmd)
18421842
int y;
18431843
if(!enif_get_int(env, argv[2], &y)) Badarg("y"); // int
18441844
if(!This) throw wxe_badarg("This");
1845-
char Result = This->GetAlpha(x,y);
1845+
unsigned char Result = This->GetAlpha(x,y);
18461846
wxeReturn rt = wxeReturn(memenv, Ecmd.caller, true);
18471847
rt.send( rt.make_uint(Result));
18481848

@@ -1860,7 +1860,7 @@ void wxImage_GetBlue(WxeApp *app, wxeMemEnv *memenv, wxeCommand& Ecmd)
18601860
int y;
18611861
if(!enif_get_int(env, argv[2], &y)) Badarg("y"); // int
18621862
if(!This) throw wxe_badarg("This");
1863-
char Result = This->GetBlue(x,y);
1863+
unsigned char Result = This->GetBlue(x,y);
18641864
wxeReturn rt = wxeReturn(memenv, Ecmd.caller, true);
18651865
rt.send( rt.make_uint(Result));
18661866

@@ -1892,7 +1892,7 @@ void wxImage_GetGreen(WxeApp *app, wxeMemEnv *memenv, wxeCommand& Ecmd)
18921892
int y;
18931893
if(!enif_get_int(env, argv[2], &y)) Badarg("y"); // int
18941894
if(!This) throw wxe_badarg("This");
1895-
char Result = This->GetGreen(x,y);
1895+
unsigned char Result = This->GetGreen(x,y);
18961896
wxeReturn rt = wxeReturn(memenv, Ecmd.caller, true);
18971897
rt.send( rt.make_uint(Result));
18981898

@@ -1948,7 +1948,7 @@ void wxImage_GetMaskBlue(WxeApp *app, wxeMemEnv *memenv, wxeCommand& Ecmd)
19481948
wxImage *This;
19491949
This = (wxImage *) memenv->getPtr(env, argv[0], "This");
19501950
if(!This) throw wxe_badarg("This");
1951-
char Result = This->GetMaskBlue();
1951+
unsigned char Result = This->GetMaskBlue();
19521952
wxeReturn rt = wxeReturn(memenv, Ecmd.caller, true);
19531953
rt.send( rt.make_uint(Result));
19541954

@@ -1962,7 +1962,7 @@ void wxImage_GetMaskGreen(WxeApp *app, wxeMemEnv *memenv, wxeCommand& Ecmd)
19621962
wxImage *This;
19631963
This = (wxImage *) memenv->getPtr(env, argv[0], "This");
19641964
if(!This) throw wxe_badarg("This");
1965-
char Result = This->GetMaskGreen();
1965+
unsigned char Result = This->GetMaskGreen();
19661966
wxeReturn rt = wxeReturn(memenv, Ecmd.caller, true);
19671967
rt.send( rt.make_uint(Result));
19681968

@@ -1976,7 +1976,7 @@ void wxImage_GetMaskRed(WxeApp *app, wxeMemEnv *memenv, wxeCommand& Ecmd)
19761976
wxImage *This;
19771977
This = (wxImage *) memenv->getPtr(env, argv[0], "This");
19781978
if(!This) throw wxe_badarg("This");
1979-
char Result = This->GetMaskRed();
1979+
unsigned char Result = This->GetMaskRed();
19801980
wxeReturn rt = wxeReturn(memenv, Ecmd.caller, true);
19811981
rt.send( rt.make_uint(Result));
19821982

@@ -2030,7 +2030,7 @@ void wxImage_GetRed(WxeApp *app, wxeMemEnv *memenv, wxeCommand& Ecmd)
20302030
int y;
20312031
if(!enif_get_int(env, argv[2], &y)) Badarg("y"); // int
20322032
if(!This) throw wxe_badarg("This");
2033-
char Result = This->GetRed(x,y);
2033+
unsigned char Result = This->GetRed(x,y);
20342034
wxeReturn rt = wxeReturn(memenv, Ecmd.caller, true);
20352035
rt.send( rt.make_uint(Result));
20362036

lib/wx/src/Makefile

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,7 @@
2121
#
2222

2323
include ../vsn.mk
24-
ifdef BOOTSTRAP
25-
VSN = $(WX_VSN)
26-
include $(ERL_TOP)/make/target.mk
27-
include $(ERL_TOP)/make/$(TARGET)/otp.mk
28-
RELSYSDIR = $(RELEASE_PATH)/lib/wx-$(VSN)
29-
else # Normal build
30-
include ../config.mk
31-
endif
24+
include ../config.mk
3225

3326
ESRC = .
3427
EGEN = gen

lib/wx/test/wx_class_SUITE.erl

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
init_per_testcase/2, end_per_testcase/2]).
3333

3434
-export([calendarCtrl/1, treeCtrl/1, notebook/1, staticBoxSizer/1,
35-
clipboard/1, helpFrame/1, htmlWindow/1, listCtrlSort/1, listCtrlVirtual/1,
35+
clipboard/1, helpFrame/1, htmlWindow/1, image/1, listCtrlSort/1, listCtrlVirtual/1,
3636
radioBox/1, systemSettings/1, taskBarIcon/1, toolbar/1, popup/1, modal/1,
3737
textCtrl/1, locale/1]).
3838

@@ -54,8 +54,8 @@ end_per_testcase(Func,Config) ->
5454
suite() -> [{ct_hooks,[ts_install_cth]}, {timetrap,{minutes,2}}].
5555

5656
all() ->
57-
[calendarCtrl, treeCtrl, notebook, staticBoxSizer,
58-
clipboard, helpFrame, htmlWindow, listCtrlSort, listCtrlVirtual,
57+
[calendarCtrl, treeCtrl, notebook, staticBoxSizer, clipboard,
58+
helpFrame, htmlWindow, image, listCtrlSort, listCtrlVirtual,
5959
radioBox, systemSettings, taskBarIcon, toolbar, popup, modal,
6060
textCtrl, locale].
6161

@@ -623,6 +623,19 @@ locale(_Config) ->
623623
io:format("initiated ~p~n",[R0]),
624624
lang_env(),
625625
ok.
626+
627+
image(_Config) when is_list(_Config) ->
628+
wx:new(),
629+
Bin = << <<220:8, Row:8, Col:8>> ||
630+
Row <- lists:seq(0, 127),
631+
Col <- lists:seq(0, 127) >>,
632+
Image = wxImage:new(128, 128, Bin),
633+
220 = wxImage:getRed(Image, 42, 13),
634+
42 = wxImage:getBlue(Image, 42, 13),
635+
13 = wxImage:getGreen(Image, 42, 13),
636+
ok.
637+
638+
626639
%% wx_test_lib:wx_destroy(Frame,Config).
627640

628641
lang_env() ->

0 commit comments

Comments
 (0)