summaryrefslogtreecommitdiff
path: root/lib/wx/api_gen/gl_gen_nif.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/wx/api_gen/gl_gen_nif.erl')
-rw-r--r--lib/wx/api_gen/gl_gen_nif.erl35
1 files changed, 28 insertions, 7 deletions
diff --git a/lib/wx/api_gen/gl_gen_nif.erl b/lib/wx/api_gen/gl_gen_nif.erl
index cd8fdba7cd..a84bf454a5 100644
--- a/lib/wx/api_gen/gl_gen_nif.erl
+++ b/lib/wx/api_gen/gl_gen_nif.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2008-2021. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2023. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -422,8 +422,8 @@ decode_var(P=#arg{name=Name, in=true, alt=Alt,
decode_var(P=#arg{name=Name, in=false,
- type=#type{name=T, base=Base, size=Szs}}, Argc)
- when Base =:= binary; Base =:= string ->
+ type=#type{name=T, base=Base, size=Szs, single=Single}}, Argc)
+ when not is_tuple(Single), (Base =:= binary orelse Base =:= string) ->
Sz = case Szs of
{Max,_} when is_integer(Max) -> integer_to_list(Max);
{Max,_} -> Max;
@@ -454,6 +454,19 @@ decode_var(P=#arg{name=Name, in=false, type=#type{name=T,single={list,Sz,_}}}, A
w(" std::vector <~s> ~s (~s);\n", [T, Name, Sz]),
w(" std::vector <ERL_NIF_TERM> ~s_ts (~s);\n", [Name, Sz]),
{P,Argc};
+decode_var(P=#arg{name=Name, in=false,
+ type=#type{base=Base, name=T,single={list,Sz,_,_}, size=Size}}, Argc) ->
+ case Base of
+ string ->
+ {BinSize, _} = Size,
+ w(" ~s = (unsigned char *) enif_alloc((int) ~s*sizeof(~s));\n", [Name,BinSize,T]),
+ w(" unsigned char *~s_ptr = ~s;\n", [Name,Name]),
+ store_free(Name ++ "_ptr");
+ _ ->
+ exit({?LINE, Base, P})
+ end,
+ w(" std::vector <ERL_NIF_TERM> ~s_ts (~s);\n", [Name, Sz]),
+ {P,Argc};
decode_var(P=#arg{name=Name, in=true, type=#type{name="GLUquadric"}}, Argc) ->
w(" if(!egl_get_ptr(env, argv[~w], (void **) &~s)) Badarg(~w,\"~s\");~n",
[Argc, Name,?OP,Name]),
@@ -576,10 +589,6 @@ build_ret(Name,_Q,#type{name=T,base=Base,size=Sz,single=true})
Ptr -> io_lib:format(" enif_make_uint64(env, (egl_uint64_t) ~s)", [Name]);
true -> io_lib:format(" enif_make_int64(env, (egl_int64_t) ~s)", [Name])
end;
-build_ret(Name,_Q,#type{base=string,single=true}) ->
- io_lib:format(" enif_make_string(env, (const char *) ~s, ERL_NIF_LATIN1)",[Name]);
-build_ret(Name,_Q,#type{base=string,size={_,_OutSz}}) ->
- io_lib:format(" enif_make_string(env, (const char *) ~s, ERL_NIF_LATIN1)",[Name]);
build_ret(Name,_Q,#type{name=_T,base=float,size=Sz,single=true}) ->
if Sz =< 4 -> io_lib:format(" enif_make_double(env, (double) ~s)", [Name]);
true -> io_lib:format(" enif_make_double(env, ~s)", [Name])
@@ -602,6 +611,12 @@ build_ret(Name,false,#type{single={list,Sz}}) when Sz >= 10, is_integer(Sz) ->
io_lib:format(" enif_make_list_from_array(env, ~s_ts, ~w)",[Name, Sz]);
build_ret(Name,false,#type{single={list,_,Sz}}) ->
io_lib:format(" enif_make_list_from_array(env, ~s_ts.data(), ~s)",[Name, Sz]);
+build_ret(Name,false,#type{single={list,_,Sz,_}}) ->
+ io_lib:format(" enif_make_list_from_array(env, ~s_ts.data(), ~s)",[Name, Sz]);
+build_ret(Name,_Q,#type{base=string,single=true}) ->
+ io_lib:format(" enif_make_string(env, (const char *) ~s, ERL_NIF_LATIN1)",[Name]);
+build_ret(Name,_Q,#type{base=string,size={_,_OutSz}}) ->
+ io_lib:format(" enif_make_string(env, (const char *) ~s, ERL_NIF_LATIN1)",[Name]);
build_ret(Name,_Q,T=#type{}) ->
io:format("{~p, {~p, {single,{tuple,X}}}}.~n", [get(current_func),Name]),
io:format(" ~p~n",[T]).
@@ -615,6 +630,12 @@ prepare_ret(#arg{name=Name, type=#type{single={list,_,Sz}}=T}) ->
Fetch = build_ret(Name ++ "[ri]", false, T#type{single=true}),
w(" for(int ri=0; ri < (int) ~s; ri++)\n"
" ~s_ts[ri] = ~s;\n",[Sz, Name, Fetch]);
+prepare_ret(#arg{name=Name, type=#type{single={list,_,Sz,Lengths}}=T}) ->
+ Fetch = build_ret(Name, false, T#type{single=true}),
+ w(" for(int ri=0; ri < (int) ~s; ri++) {\n"
+ " ~s_ts[ri] = ~s;\n",[Sz, Name, Fetch]),
+ w(" ~s += ~s[ri];\n"
+ " }\n", [Name, Lengths]);
prepare_ret(_) ->
ok.