diff options
Diffstat (limited to 'lib/wx/api_gen')
-rw-r--r-- | lib/wx/api_gen/Makefile | 13 | ||||
-rw-r--r-- | lib/wx/api_gen/README | 18 | ||||
-rw-r--r-- | lib/wx/api_gen/gen_util.erl | 60 | ||||
-rw-r--r-- | lib/wx/api_gen/gl_doxygen.conf | 17 | ||||
-rw-r--r-- | lib/wx/api_gen/gl_gen.erl | 42 | ||||
-rw-r--r-- | lib/wx/api_gen/gl_gen_c.erl | 186 | ||||
-rw-r--r-- | lib/wx/api_gen/gl_gen_erl.erl | 169 | ||||
-rw-r--r-- | lib/wx/api_gen/glapi.conf | 203 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_doxygen.conf | 23 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_extra/wxListCtrl.c_src | 161 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_extra/wxListCtrl.erl | 112 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen.erl | 77 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen.hrl | 18 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen_cpp.erl | 379 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen_erl.erl | 348 | ||||
-rw-r--r-- | lib/wx/api_gen/wxapi.conf | 79 |
16 files changed, 1284 insertions, 621 deletions
diff --git a/lib/wx/api_gen/Makefile b/lib/wx/api_gen/Makefile index c6b65b60bc..756ec598ce 100644 --- a/lib/wx/api_gen/Makefile +++ b/lib/wx/api_gen/Makefile @@ -1,7 +1,7 @@ # # %CopyrightBegin% # -# Copyright Ericsson AB 2008-2009. All Rights Reserved. +# Copyright Ericsson AB 2008-2010. All Rights Reserved. # # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in @@ -39,14 +39,14 @@ TARGET_CDIR = ../c_src/gen C_TARGETS = wxe_funcs.cpp GL_C_TARGETS = gl_funcs.cpp -WX = $(TARGET_CDIR)/$(C_TARGETS) +WX = wx_code_generated -GL = $(TARGET_CDIR)/$(GL_C_TARGETS) +GL = gl_code_generated opt: $(WX) $(GL) $(WX): wxxml_generated $(COMPILER_T) wxapi.conf $(wildcard wx_extra/wx*.c_src) $(wildcard wx_extra/wx*.erl) - erl -noshell -run wx_gen code + erl -noshell -run wx_gen code && touch wx_code_generated wxxml_generated: wx_doxygen.conf wx_extra/bugs.h wx_extra/wxe_evth.h sed -e 's|@WXGTK_DIR@|$(WXGTK_DIR)|g' wx_doxygen.conf > wx_doxygen @@ -56,9 +56,8 @@ glxml_generated: gl_doxygen.conf sed -e 's|@GL_DIR@|$(GL_DIR)|g' gl_doxygen.conf > gl_doxygen doxygen gl_doxygen && touch glxml_generated - $(GL): glxml_generated $(GL_COMP_T) glapi.conf - erl -noshell -run gl_gen code + erl -noshell -run gl_gen code && touch gl_code_generated %.beam: %.erl wx_gen.hrl gl_gen.hrl $(ERLC) -W $(ERL_FLAGS) $(ERL_COMPILE_FLAGS) $< -o$(EBIN) @@ -66,7 +65,7 @@ $(GL): glxml_generated $(GL_COMP_T) glapi.conf # TODO split cleans into separate targets? complete_clean: rm -f gl_doxygen wx_doxygen wx_xml/*.x* gl_xml/*.x* - rm -f glxml_generated wxxml_generated + rm -f *_generated $(MAKE) clean clean: rm -f *~ diff --git a/lib/wx/api_gen/README b/lib/wx/api_gen/README index 3c49f7b2a5..10b5209789 100644 --- a/lib/wx/api_gen/README +++ b/lib/wx/api_gen/README @@ -2,16 +2,20 @@ API GENERATION: Most of the code in wx is generated. Users of wxErlang should not normally need to regenerate the generated code, as it is checked in by wxErlang developers, when changes are made. - 2008-09-29 Code checked in is currently generated from wxwidgets 2.8.7. + + Code checked in is currently generated from wxwidgets 2.8.10. REQUIREMENTS: The code generation requires doxygen (1.4.6) which is used to parse wxWidgets c++ headers and generate xml files (in wx_xml/). - (2008-09-29 doxygen 1.4.6 is required. - Later versions of Doxygen - up to 1.5.6 at least - have a bug in the xml generation - which causes us problems. This has been logged and we are waiting for a fix.) + 2008-09-29 doxygen 1.4.6 is required. + Later versions of Doxygen - up to 1.5.6 at least - have a bug in the xml generation + which causes us problems. This has been logged and we are waiting for a fix. + + doxygen 1.6.1 and doxygen 1.6.3 might work but is not what I use, i.e. + review the diffs. CONFIGURATION: wxapi.conf contains the specification to the code generator. The code @@ -22,5 +26,11 @@ CONFIGURATION: and running make. Sometimes the code generator will require changes, I havn't thought of everything yet. +RUNNING: + I use the following alias wxgen='make WXGTK_DIR=/opt/local/include/wx-2.8/ GL_DIR=/home/dgud/opengl' + + I keep the opengl headers separate so I don't go backwards in version when generating the code + from another machine. + CONTRIBUTION: Send me patches or update the svn version. diff --git a/lib/wx/api_gen/gen_util.erl b/lib/wx/api_gen/gen_util.erl index 859317bdef..df5b4c3405 100644 --- a/lib/wx/api_gen/gen_util.erl +++ b/lib/wx/api_gen/gen_util.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% Copyright Ericsson AB 2008-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -40,38 +40,46 @@ 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). + +get_taylor_made(Str, Name) -> + re:run(Str, "<<"++Name++"(.*)"++Name++">>", + [dotall, {capture, all_but_first, list}]). + open_write(File) -> %% io:format("Generating ~s~n",[File]), {ok, Fd} = file:open(File++".temp", [write]), put(current_file, {Fd,File}). - + close() -> case get(current_file) of - undefined -> + undefined -> ok; {closed, File} -> io:format("Closing twice ~s~n",[File]); {Fd,File} -> file:close(Fd), case os:cmd("diff " ++ File ++ " " ++ File ++ ".temp" ++ "| head -30") of - [] -> + [] -> ok = file:delete(File ++ ".temp"), %% So that make understands that we have made this - case os:getenv("CLEARCASE_ROOT") of - false -> os:cmd("touch " ++ File); - _ -> ignore - end, + %% case os:getenv("CLEARCASE_ROOT") of + %% false -> os:cmd("touch " ++ File); + %% _ -> ignore + %% end, ok; Diff -> case check_diff(Diff) of copyright -> %% We ignore copyright changes only ok = file:delete(File ++ ".temp"); - _ -> + _ -> io:format("Diff in ~s~n~s ~n", [File, Diff]), case file:rename(File ++ ".temp", File) of ok -> ok; - _ -> + _ -> io:format("***** Failed to save file ~p ~n",[File]) end end @@ -81,9 +89,9 @@ close() -> check_diff(Diff) -> - try + try [_,D1,_,D2|Tail] = re:split(Diff, "\n"), - case Tail of + case Tail of [] -> ok; [<<>>] -> ok; _ -> throw(diff) @@ -113,29 +121,29 @@ args(Fun, Limit, List, Max) -> args(Fun, Limit, List, Max, 0). args(_Fun, _Limit, [], _Max, _) -> ""; %% No args -args(Fun, _Limit, [Last], _Max, _Pos) -> - case Fun(Last) of +args(Fun, _Limit, [Last], _Max, _Pos) -> + case Fun(Last) of skip -> ""; %% FIXME bug if last skips Str -> Str end; args(Fun, Limit, [H|R], Max, Pos) -> - case Fun(H) of + case Fun(H) of skip -> args(Fun,Limit,R, Max, Pos); - Str -> - {NL, NewPos} = + Str -> + {NL, NewPos} = case length(Str) + Pos of Curr when Curr > Max -> {"\n ", 0}; - Curr -> + Curr -> {"", Curr} end, - case args(Fun,Limit,R, Max, NewPos) of + case args(Fun,Limit,R, Max, NewPos) of "" -> Str; End -> Str ++ Limit ++ NL ++ End end end. - + tokens(S) -> @@ -163,11 +171,11 @@ replace_and_remove([E|R], Acc) when is_list(E) -> %% Keep everything that is a w replace_and_remove(R, [E|Acc]); replace_and_remove([$\n | R], Acc) -> %% It is semi line oriented so keep eol replace_and_remove(R, [eol|Acc]); -replace_and_remove([$( | R], Acc) -> +replace_and_remove([$( | R], Acc) -> replace_and_remove(R, ["("|Acc]); replace_and_remove([$) | R], Acc) -> replace_and_remove(R, [")"|Acc]); -replace_and_remove([${ | R], Acc) -> +replace_and_remove([${ | R], Acc) -> replace_and_remove(R, ["{"|Acc]); replace_and_remove([$} | R], Acc) -> replace_and_remove(R, ["}"|Acc]); @@ -183,7 +191,7 @@ replace_and_remove([$, | R], Acc) -> replace_and_remove(R, [cont|Acc]); replace_and_remove([$; | R], Acc) -> replace_and_remove(R, [eoe|Acc]); -replace_and_remove([$@ | R], Acc) -> +replace_and_remove([$@ | R], Acc) -> replace_and_remove(R, [directive|Acc]); replace_and_remove([_E|R], Acc) -> %% Ignore everthing else @@ -209,7 +217,7 @@ erl_copyright() -> w("%%~n",[]), w("%% %CopyrightBegin%~n",[]), w("%%~n",[]), - w("%% Copyright Ericsson AB ~p-2010. All Rights Reserved.~n", + w("%% Copyright Ericsson AB ~p-2011. All Rights Reserved.~n", [StartYear]), w("%%~n",[]), w("%% The contents of this file are subject to the Erlang Public License,~n",[]), @@ -225,11 +233,11 @@ erl_copyright() -> w("%%~n",[]), w("%% %CopyrightEnd%~n",[]). -c_copyright() -> +c_copyright() -> w("/*~n",[]), w(" * %CopyrightBegin%~n",[]), w(" *~n",[]), - w(" * Copyright Ericsson AB 2008-2010. All Rights Reserved.~n",[]), + w(" * Copyright Ericsson AB 2008-2011. All Rights Reserved.~n",[]), w(" *~n",[]), w(" * The contents of this file are subject to the Erlang Public License,~n",[]), w(" * Version 1.1, (the \"License\"); you may not use this file except in~n",[]), diff --git a/lib/wx/api_gen/gl_doxygen.conf b/lib/wx/api_gen/gl_doxygen.conf index e29a3654b5..c9bdb6a408 100644 --- a/lib/wx/api_gen/gl_doxygen.conf +++ b/lib/wx/api_gen/gl_doxygen.conf @@ -8,7 +8,7 @@ PROJECT_NUMBER = 0.1 OUTPUT_DIRECTORY = ./ CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English -USE_WINDOWS_ENCODING = NO +#USE_WINDOWS_ENCODING = NO BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ABBREVIATE_BRIEF = @@ -20,7 +20,7 @@ STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO +# DETAILS_AT_TOP = NO INHERIT_DOCS = YES DISTRIBUTE_GROUP_DOC = NO SEPARATE_MEMBER_PAGES = NO @@ -175,17 +175,20 @@ PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = NO +EXPAND_ONLY_PREDEF = YES SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = \ APIENTRY="" \ + APIENTRYP="*" \ + GLAPIENTRY="" \ + GLAPIENTRYP="*" \ WINGDIAPI="" \ GLAPI="" \ GL_GLEXT_PROTOTYPES="1" -EXPAND_AS_DEFINED = YES +EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references @@ -214,9 +217,9 @@ DIRECTORY_GRAPH = YES DOT_IMAGE_FORMAT = png DOT_PATH = DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1024 -MAX_DOT_GRAPH_DEPTH = 0 +#MAX_DOT_GRAPH_WIDTH = 1024 +#MAX_DOT_GRAPH_HEIGHT = 1024 +#MAX_DOT_GRAPH_DEPTH = 0 DOT_TRANSPARENT = NO DOT_MULTI_TARGETS = NO GENERATE_LEGEND = YES diff --git a/lib/wx/api_gen/gl_gen.erl b/lib/wx/api_gen/gl_gen.erl index 91a6a1adbf..8998d341e7 100644 --- a/lib/wx/api_gen/gl_gen.erl +++ b/lib/wx/api_gen/gl_gen.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2011. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %%%------------------------------------------------------------------- @@ -44,12 +44,12 @@ devcode() -> spawn(fun() -> safe(fun gen_code/0,false) end). safe(What, QuitOnErr) -> try What(), - io:format("Completed succesfully~n~n", []), + io:format("Completed successfully~n~n", []), QuitOnErr andalso gen_util:halt(0) catch Err:Reason -> - catch gen_util:close(), io:format("Error ~p: ~p:~p~n ~p~n", [get(current_func),Err,Reason,erlang:get_stacktrace()]), + (catch gen_util:close()), timer:sleep(1999), QuitOnErr andalso gen_util:halt(1) end. @@ -67,7 +67,7 @@ gen_code() -> gl_gen_erl:gl_defines(GLDefines), gl_gen_erl:gl_api(GLFuncs), - gl_gen_erl:gen_debug(GLFuncs,GLUFuncs), + %%gl_gen_erl:gen_debug(GLFuncs,GLUFuncs), gl_gen_c:gen(GLFuncs,GLUFuncs), ok. @@ -206,10 +206,10 @@ parse_define([], D, _Opts) -> parse_func(Xml, Opts) -> {Func,_} = foldl(fun(X,Acc) -> parse_func(X,Acc,Opts) end, {#func{},1}, Xml), + put(current_func, Func#func.name), #func{params=Args0,type=Type0} = Func, Args = filter(fun(#arg{type=void}) -> false; (_) -> true end, Args0), - #arg{type=Type} = - patch_param(Func#func.name,#arg{name="result",type=Type0},Opts), + #arg{type=Type} = patch_param(Func#func.name,#arg{name="result",type=Type0},Opts), Func#func{params=reverse(Args), type=Type}. parse_func(#xmlElement{name=type, content=C}, {F,AC}, Os) -> @@ -220,6 +220,7 @@ parse_func(#xmlElement{name=name, content=[#xmlText{value=C}]},{F,AC},Os) -> put(current_func, Func), {F#func{name=name(Func,Os)},AC}; parse_func(#xmlElement{name=param, content=C},{F,AC},Os) -> + put(current_func, F#func.name), Parse = fun(Con, Ac) -> parse_param(Con, Ac, Os) end, Param0 = foldl(Parse, #arg{}, drop_empty(C)), Param = fix_param_name(Param0, F, AC), @@ -314,11 +315,17 @@ handle_arg_opt(both, P) -> P#arg{in=both}; handle_arg_opt(binary, P=#arg{type=T}) -> P#arg{type=T#type{size=undefined,base=binary}}; handle_arg_opt({binary,Sz}, P=#arg{type=T}) -> - P#arg{type=T#type{size=Sz,base=binary}}; + P#arg{type=T#type{size={Sz, Sz},base=binary}}; +handle_arg_opt({binary,Max, Sz}, P=#arg{type=T}) -> + P#arg{type=T#type{size={Max, Sz},base=binary}}; handle_arg_opt({type,Type}, P=#arg{type=T}) -> P#arg{type=T#type{name=Type}}; handle_arg_opt({single,Opt},P=#arg{type=T}) -> P#arg{type=T#type{single=Opt}}; +handle_arg_opt({base,{Opt, Sz}}, P=#arg{type=T}) -> P#arg{type=T#type{base=Opt, size=Sz}}; handle_arg_opt({base,Opt}, P=#arg{type=T}) -> P#arg{type=T#type{base=Opt}}; -handle_arg_opt({c_only,Opt},P) -> P#arg{where=c, alt=Opt}. +handle_arg_opt({c_only,Opt},P) -> P#arg{where=c, alt=Opt}; +handle_arg_opt(string, P=#arg{type=T}) -> P#arg{type=T#type{base=string}}; +handle_arg_opt({string,Max,Sz}, P=#arg{type=T}) -> + P#arg{type=T#type{base=string, size={Max,Sz}}}. parse_type([], _Os) -> void; parse_type(C, Os) -> @@ -367,6 +374,8 @@ parse_type2([N="GLbitfield"|R],T,Opts) -> parse_type2(R,T#type{name=N, size=4, base=int},Opts); parse_type2([N="GLvoid"|R],T,Opts) -> parse_type2(R,T#type{name=N, base=idx_binary},Opts); +parse_type2([N="GLsync"|R],T,Opts) -> + parse_type2(R,T#type{name=N, base=int, size=8},Opts); parse_type2([N="GLbyte"|R],T,Opts) -> parse_type2(R,T#type{name=N, size=1, base=int},Opts); @@ -378,6 +387,11 @@ parse_type2([N="GLushort"|R],T,Opts) -> parse_type2(R,T#type{name=N, size=2, base=int},Opts); parse_type2([N="GLint"|R],T,Opts) -> parse_type2(R,T#type{name=N, size=4, base=int},Opts); +parse_type2([N="GLint64"|R],T,Opts) -> + parse_type2(R,T#type{name=N, size=8, base=int},Opts); +parse_type2([N="GLuint64"|R],T,Opts) -> + parse_type2(R,T#type{name=N, size=8, base=int},Opts); + parse_type2([N="GLuint"|R],T,Opts) -> parse_type2(R,T#type{name=N, size=4, base=int},Opts); parse_type2([N="GLsizei"|R],T,Opts) -> @@ -548,8 +562,10 @@ setup_idx_binary(Name,Ext,_Opts) -> %% Ok warn if single is undefined lists:foreach(fun(#arg{type=#type{base=memory}}) -> ok; + (#arg{type=#type{base=string}}) -> ok; (#arg{type=#type{base=idx_binary}}) -> ok; (#arg{type=#type{name="GLUquadric"}}) -> ok; + (#arg{type=#type{base=binary, size=Sz}}) when Sz =/= undefined -> ok; (A=#arg{type=#type{single=undefined}}) -> ?warning("~p Unknown size of~n ~p~n", [get(current_func),A]), @@ -605,7 +621,7 @@ is_equal(F1=#func{type=T1,params=A1},F2=#func{type=T2,params=A2}) -> true -> ok; false -> %% io:format("A1: ~p~nA2: ~p~n",[A1,A2]), - ?warning("Skipped Ext Not Equal ~p ~p~n", + ?warning("Keeping Ext Not Equal ~p ~p~n", [F1#func.name,F2#func.name]) end, Equal. diff --git a/lib/wx/api_gen/gl_gen_c.erl b/lib/wx/api_gen/gl_gen_c.erl index 864ce8b1ac..0f5cb0e1f4 100644 --- a/lib/wx/api_gen/gl_gen_c.erl +++ b/lib/wx/api_gen/gl_gen_c.erl @@ -47,34 +47,29 @@ gen(GLFuncs, GLUFuncs) -> w("/***** This file is generated do not edit ****/~n~n", []), w("#include <stdio.h>~n", []), w("#include <string.h>~n", []), - w("#include \"../wxe_impl.h\"~n", []), - w("#include \"../wxe_gl.h\"~n", []), - w("#include \"gl_fdefs.h\"~n", []), + w("#include \"../egl_impl.h\"~n", []), + w("#include \"gl_fdefs.h\"~n~n", []), + w("extern gl_fns_t gl_fns[];~n~n", []), - w("~nint gl_error_op;~n", []), - w("void gl_dispatch(int op, char *bp,ErlDrvTermData caller,WXEBinRef *bins[]){~n", + w("void egl_dispatch(int op, char *bp, ErlDrvPort port, " + "ErlDrvTermData caller, char *bins[], int bins_sz[]){~n", []), - w(" gl_error_op = op;~n", []), - w(" if(caller != gl_active) {~n", []), - w(" wxGLCanvas * current = glc[caller];~n", []), - w(" if(current) { gl_active = caller; current->SetCurrent();}~n", []), - w(" else {~n " - " ErlDrvTermData rt[] = // Error msg~n" - " {ERL_DRV_ATOM, driver_mk_atom((char *) \"_wxe_error_\"),~n" - " ERL_DRV_INT, op,~n" - " ERL_DRV_ATOM, driver_mk_atom((char *) \"no_gl_context\"),~n" - " ERL_DRV_TUPLE,3};~n" - " driver_send_term(WXE_DRV_PORT,caller,rt,8);~n" - " return ;~n }~n };~n~n", []), - + w(" try {~n",[]), w(" switch(op)~n{~n",[]), - w(" case 5000:~n wxe_tess_impl(bp, caller);~n break;~n", []), - w(" case WXE_BIN_INCR:~n driver_binary_inc_refc(bins[0]->bin);~n break;~n",[]), - w(" case WXE_BIN_DECR:~n driver_binary_dec_refc(bins[0]->bin);~n break;~n",[]), + w(" case 5000:~n erl_tess_impl(bp, port, caller);~n break;~n", []), [funcs(F) || F <- GLUFuncs], [funcs(F) || F <- GLFuncs], + w("}} catch (char *err_msg) {\n" + "int AP = 0; ErlDrvTermData rt[12];\n" + "rt[AP++] = ERL_DRV_ATOM; rt[AP++]=driver_mk_atom((char *) \"_egl_error_\");\n" + "rt[AP++] = ERL_DRV_INT; rt[AP++] = (int) op;\n" + "rt[AP++] = ERL_DRV_ATOM; rt[AP++] = driver_mk_atom((char *) err_msg);\n" + "// rt[AP++] = ERL_DRV_ATOM; rt[AP++] = driver_mk_atom((char *) gl_fns[op-GLE_GL_FUNC_START].name);\n" + "// rt[AP++] = ERL_DRV_TUPLE; rt[AP++] = 2;\n" + "rt[AP++] = ERL_DRV_TUPLE; rt[AP++] = 3;\n" + "driver_send_term(port,caller,rt,AP);\n", []), w("}} /* The End */~n~n",[]), close(). @@ -123,26 +118,53 @@ declare_var(A=#arg{name=N,in=false,type=#type{name=T,base=B,single={tuple,Sz}}}) true = is_number(Sz), %% Assert w(" ~s ~s[~p] = {~s};~n", [T,N,Sz,args(fun zero/1,",",lists:duplicate(Sz,B))]), A; -declare_var(A=#arg{name=N,in=false,type=#type{name=T,base=B,single={list,Sz}}}) when is_number(Sz) -> +declare_var(A=#arg{name=N,in=false,type=#type{name=T,base=B,single={list,Sz}}}) + when is_number(Sz) -> w(" ~s ~s[~p] = {~s};~n", [T,N,Sz,args(fun zero/1,",",lists:duplicate(Sz,B))]), A; +declare_var(A=#arg{name=N,in=false,type=#type{name=T,base=string,size={Max,_}, single=Single}}) -> + case is_integer(Max) of + true -> + w(" ~s ~s[~p];~n", [T,N,Max]); + false -> + %% w(" ~s ~s[*~s];~n", [T,N,Max]), + w(" ~s *~s;~n", [T,N]), + w(" ~s = (~s *) driver_alloc(sizeof(~s) * *~s);~n", [N,T,T,Max]), + store_free(N) + %% case Single of + %% {list, _, _} -> + %% w(" ~s *~s_p = ~s;~n", [T,N,N]); + %% _ -> ok + %% end + end, + A; +declare_var(A=#arg{name=N,in=false,type=#type{base=binary,size={MaxSz, _}}}) -> + MaxSz == undefined andalso error({assert, A}), + case is_integer(MaxSz) of + true -> + w(" ErlDrvBinary *~s = driver_alloc_binary(~p);~n", [N,MaxSz]); + false -> + w(" ErlDrvBinary *~s = driver_alloc_binary(*~s);~n", [N,MaxSz]) + end, + A; declare_var(A=#arg{name=N,in=false,type=#type{name=T,single={list,ASz,_USz},mod=[]}}) -> true = is_list(ASz), %% Assert w(" ~s *~s;~n", [T,N]), w(" ~s = (~s *) driver_alloc(sizeof(~s) * *~s);~n", [N,T,T,ASz]), store_free(N), + %% w(" ~s ~s[*~s];~n", [T,N,ASz]), A; -declare_var(A=#arg{name=N,in=false,type=#type{name=T,base=binary,size=Sz}}) -> - true = is_number(Sz), %% Assert - w(" ~s ~s[~p];~n", [T,N,Sz]), +declare_var(A=#arg{in=false, type=#type{name="GLUquadric",by_val=false,single=true}}) -> A; -declare_var(A=#arg{name=N,in=false, - type=#type{name=T="GLUquadric",base=B,by_val=false,single=true}}) -> +declare_var(A=#arg{in=false, type=#type{base=string,by_val=false,single=true}}) -> A; declare_var(A=#arg{name=N,in=false, type=#type{name=T,base=B,by_val=false,single=true}}) -> w(" ~s ~s[1] = {~s};~n", [T,N,zero(B)]), A; +declare_var(A=#arg{where=c, type=#type{name=T}, alt={size,Var}}) -> + w(" ~s ~s_size = bins_sz[~p];~n", [T, Var, get(bin_count)]), + A; declare_var(A=#arg{where=_}) -> A. @@ -172,10 +194,10 @@ decode_arg(P=#arg{where=c},A) -> {P,A}; decode_arg(P=#arg{in=false},A) -> {P,A}; decode_arg(P=#arg{name=Name,type=#type{name=Type,base=binary}},A0) -> - w(" ~s *~s = (~s *) bins[~p]->base;~n", [Type,Name,Type,next_id(bin_count)]), + w(" ~s *~s = (~s *) bins[~p];~n", [Type,Name,Type,next_id(bin_count)]), {P, A0}; decode_arg(P=#arg{name=Name,type=#type{name=Type,base=memory}},A0) -> - w(" ~s *~s = (~s *) bins[~p]->base;~n", [Type,Name,Type,next_id(bin_count)]), + w(" ~s *~s = (~s *) bins[~p];~n", [Type,Name,Type,next_id(bin_count)]), {P, A0}; decode_arg(P=#arg{name=Name,type=#type{name=T,base=string,single=list}},A0) -> A = align(4,A0), @@ -220,7 +242,7 @@ decode_arg(P=#arg{name=Name,type=#type{name=Type,base=guard_int}},A0) -> {P, A}; decode_arg(P=#arg{name=Name,type=#type{name=Type,base=string,single=true}},A0) -> w(" ~s *~s = (~s *) bp;~n", [Type,Name,Type]), - w(" int ~sLen = strlen((char *)~s); bp += ~sLen+1+((8-((1+~sLen+~p)%8))%8);~n", + w(" int ~sLen[1] = {strlen((char *)~s)}; bp += ~sLen[0]+1+((8-((1+~sLen[0]+~p)%8))%8);~n", [Name,Name,Name,Name,A0]), {P, 0}; decode_arg(P=#arg{name=Name, @@ -289,6 +311,8 @@ result_type(#type{name=T, ref=undefined}) -> T; result_type(#type{name=T, ref={pointer,1}, mod=Mods}) -> mod(Mods) ++ T ++ " * ". +call_arg(#arg{alt={size,Alt},type=#type{}}) -> + Alt ++ "_size"; call_arg(#arg{alt={length,Alt},type=#type{}}) -> "*" ++ Alt ++ "Len"; call_arg(#arg{alt={constant,Alt},type=#type{}}) -> @@ -299,6 +323,8 @@ call_arg(#arg{name=Name,type=#type{single={list, _}}}) -> Name; call_arg(#arg{name=Name,type=#type{size=8,base=int,ref=undefined}}) -> Name; +call_arg(#arg{name=Name,in=false,type=#type{name=T, base=binary}}) -> + "(" ++ T ++ "*) " ++ Name ++ "->orig_bytes"; call_arg(#arg{name=Name,type=#type{ref=undefined}}) -> "*" ++ Name; call_arg(#arg{name=Name,type=#type{base=guard_int}}) -> @@ -319,27 +345,27 @@ build_return_vals(Type,As) -> true -> w(" int AP = 0; ErlDrvTermData rt[6];~n",[]), w(" rt[AP++]=ERL_DRV_ATOM;" - " rt[AP++]=driver_mk_atom((char *) \"_wxe_result_\");~n",[]), + " rt[AP++]=driver_mk_atom((char *) \"_egl_result_\");~n",[]), w(" rt[AP++]=ERL_DRV_ATOM;" " rt[AP++]=driver_mk_atom((char *) \"ok\");~n",[]), w(" rt[AP++] = ERL_DRV_TUPLE; rt[AP++] = 2;~n",[]), - w(" driver_send_term(WXE_DRV_PORT,caller,rt,AP);~n",[]), + w(" driver_send_term(port,caller,rt,AP);~n",[]), ok end; {Val,Vars,Cnt} -> ExtraTuple = if Cnt > 1 -> 2; true -> 0 end, - CSize = if Vars =:= none -> - Sz = integer_to_list(Val+4+ExtraTuple), - w(" int AP = 0; ErlDrvTermData rt[~s];~n",[Sz]), - Sz; - true -> - Sz = integer_to_list(Val+4+ExtraTuple) ++ " + " ++ Vars, - w(" int AP = 0; ErlDrvTermData *rt;~n",[]), - w(" rt = (ErlDrvTermData *) " - "driver_alloc(sizeof(ErlDrvTermData)*(~s));~n", [Sz]), - Sz - end, - w(" rt[AP++]=ERL_DRV_ATOM; rt[AP++]=driver_mk_atom((char *) \"_wxe_result_\");~n",[]), + if Vars =:= none -> + Sz = integer_to_list(Val+4+ExtraTuple), + w(" int AP = 0; ErlDrvTermData rt[~s];~n",[Sz]), + Sz; + true -> + Sz = integer_to_list(Val+4+ExtraTuple) ++ " + " ++ Vars, + w(" int AP = 0; ErlDrvTermData *rt;~n",[]), + w(" rt = (ErlDrvTermData *) " + "driver_alloc(sizeof(ErlDrvTermData)*(~s));~n", [Sz]), + Sz + end, + w(" rt[AP++]=ERL_DRV_ATOM; rt[AP++]=driver_mk_atom((char *) \"_egl_result_\");~n",[]), FreeList = build_ret_types(Type,As), case Cnt of 1 -> ok; @@ -347,9 +373,9 @@ build_return_vals(Type,As) -> w(" rt[AP++] = ERL_DRV_TUPLE; rt[AP++] = ~p;~n",[Cnt]) end, w(" rt[AP++] = ERL_DRV_TUPLE; rt[AP++] = 2;~n",[]), - w(" if (AP != ~s ) fprintf(stderr, \"%d: ERROR AP mismatch %d %d\\r\\n\",__LINE__,AP,~s);~n", - [CSize,CSize]), - w(" driver_send_term(WXE_DRV_PORT,caller,rt,AP);~n",[]), + %%w(" if (AP != ~s ) fprintf(stderr, \"%d: ERROR AP mismatch %d %d\\r\\n\",__LINE__,AP,~s);~n", + %% [CSize,CSize]), + w(" driver_send_term(port,caller,rt,AP);~n",[]), case Vars of none -> ignore; _ -> @@ -372,7 +398,7 @@ calc_sizes(Type,As) -> {Val, none} -> {Sz+Val, Vars, Cnt+1}; {Val, Var} when Vars =:= none -> {Sz+Val, Var,Cnt+1}; - {Val, Var} when Vars =:= none -> + {Val, Var} -> {Sz+Val, Var ++ " + " ++ Vars,Cnt+1} end; (_,Acc) -> Acc @@ -380,13 +406,16 @@ calc_sizes(Type,As) -> foldl(Calc, TSz, As). return_size(_N,void) -> {0, none}; -return_size(_N,#type{base=binary}) -> {4, none}; -return_size(_N,#type{single=true}) -> {2,none}; return_size(_N,#type{single={tuple,Sz}}) -> {Sz*2+2, none}; -return_size(_N,#type{name="GLubyte",single={list,null}}) ->{3, none}; return_size(_N,#type{single={list,Sz}}) -> {Sz*2+3, none}; -return_size(_N,#type{base=string,single={list,_,_}}) -> {3, none}; -return_size(_N,#type{single={list,_,Sz}}) -> {3, "(*" ++Sz++")*2"}. +return_size(_N,#type{base=string,single=true}) -> {3, none}; +return_size(_N,#type{base=string,single=undefined}) -> {3, none}; +return_size(_N,#type{base=string,single={list,_,"result"}}) -> {3, "result*3"}; +return_size(_N,#type{base=string,single={list,_,Sz}}) -> {3, "(*" ++Sz++")*3"}; +return_size(_N,#type{single={list,_,"result"}}) -> {3, "result*2"}; +return_size(_N,#type{single={list,_,Sz}}) -> {3, "(*" ++Sz++")*2"}; +return_size(_N,#type{base=binary}) -> {4, none}; +return_size(_N,#type{single=true}) -> {2, none}. build_ret_types(void,Ps) -> @@ -445,17 +474,27 @@ build_ret(Name,_Q,#type{name=T,base=_,single={tuple,Sz}}) -> [w(" rt[AP++] = ERL_DRV_INT; rt[AP++] = (ErlDrvSInt) *~s++;~n", [Temp]) || _ <- lists:seq(1,Sz)], w(" rt[AP++] = ERL_DRV_TUPLE; rt[AP++] = ~p;~n",[Sz]); -build_ret(Name,_Q,#type{name="GLubyte",single={list,null}}) -> +build_ret(Name,_Q,#type{base=string,size=1,single=true}) -> w(" rt[AP++] = ERL_DRV_STRING; rt[AP++] = (ErlDrvTermData) ~s;" " rt[AP++] = strlen((char *) ~s);\n", [Name, Name]); -build_ret(Name,_Q,#type{base=string,single={list,_,Sz}}) -> +build_ret(Name,_Q,#type{base=string, size={_Max,Sz}, single=S}) + when S == true; S == undefined -> w(" rt[AP++] = ERL_DRV_STRING; rt[AP++] = (ErlDrvTermData) ~s;" " rt[AP++] = *~s;\n", [Name, Sz]); +build_ret(Name,_Q,#type{name=_T,base=string,size={_, SSz}, single={list,_,Sz}}) -> + P = if Sz == "result" -> ["(int) "]; true -> "*" end, + w(" for(int i=0; i < ~s~s; i++) {\n", [P,Sz]), + w(" rt[AP++] = ERL_DRV_STRING; rt[AP++] = (ErlDrvTermData) ~s;" + " rt[AP++] = ~s[i]-1;\n", [Name, SSz]), + w(" ~s += ~s[i]; }~n", [Name, SSz]), + w(" rt[AP++] = ERL_DRV_NIL;", []), + w(" rt[AP++] = ERL_DRV_LIST; rt[AP++] = (~s~s)+1;~n",[P,Sz]); build_ret(Name,_Q,#type{name=_T,base=B,single={list,_,Sz}}) when B =/= float -> - w(" for(int i=0; i < *~s; i++) {\n", [Sz]), + P = if Sz == "result" -> ["(int) "]; true -> "*" end, + w(" for(int i=0; i < ~s~s; i++) {\n", [P,Sz]), w(" rt[AP++] = ERL_DRV_INT; rt[AP++] = (ErlDrvSInt) ~s[i];}~n", [Name]), w(" rt[AP++] = ERL_DRV_NIL;", []), - w(" rt[AP++] = ERL_DRV_LIST; rt[AP++] = (*~s)+1;~n",[Sz]); + w(" rt[AP++] = ERL_DRV_LIST; rt[AP++] = (~s~s)+1;~n",[P,Sz]); build_ret(Name,_Q,#type{name=_T,size=FSz,base=float,single={list,Sz}}) -> Temp = Name ++ "Tmp", case FSz of @@ -476,12 +515,14 @@ build_ret(Name,_Q,#type{name=T,base=_,single={list,Sz}}) -> || _ <- lists:seq(1,Sz)], w(" rt[AP++] = ERL_DRV_NIL;", []), w(" rt[AP++] = ERL_DRV_LIST; rt[AP++] = ~p+1;~n",[Sz]); -build_ret(Name,_Q,#type{name="GLubyte",base=binary,size=Sz}) -> - w(" ErlDrvBinary * BinCopy = driver_alloc_binary(~p);~n", [Sz]), - w(" memcpy(BinCopy->orig_bytes, ~s, ~p);~n", [Name,Sz]), - w(" rt[AP++] = ERL_DRV_BINARY; rt[AP++] = (ErlDrvTermData) BinCopy;", []), - w(" rt[AP++] = ~p; rt[AP++] = 0;~n", [Sz]), - "driver_free_binary(BinCopy);"; +build_ret(Name,_Q,#type{base=binary,size={_,Sz}}) -> + w(" rt[AP++] = ERL_DRV_BINARY; rt[AP++] = (ErlDrvTermData) ~s;", [Name]), + if is_integer(Sz) -> + w(" rt[AP++] = ~p; rt[AP++] = 0;~n", [Sz]); + is_list(Sz) -> + w(" rt[AP++] = *~s; rt[AP++] = 0;~n", [Sz]) + end, + "driver_free_binary(" ++ Name ++ ");"; build_ret(Name,_Q,T=#type{}) -> io:format("{~p, {~p, {single,{tuple,X}}}}.~n", [get(current_func),Name]), io:format(" ~p~n",[T]). @@ -497,6 +538,19 @@ gen_defines(GLFuncs,GLUFuncs) -> w("# define WXE_EXTERN~n", []), w("#else~n# define WXE_EXTERN extern~n", []), w("#endif~n~n", []), + + w("typedef struct {\n" + " const char * name;\n" + " const char * alt;\n" + " void * func;\n" + "} gl_fns_t;\n\n", []), + + GLFirst = case hd(GLFuncs) of + [First|_] when is_list(First) -> get(First); + First -> get(First) + end, + w("#define GLE_GL_FUNC_START ~p~n", [GLFirst#func.id]), + [fdefs(F) || F <- GLFuncs], [fdefs(F) || F <- GLUFuncs], close(). @@ -544,11 +598,7 @@ gl_gen_init(Funcs) -> open_write("../c_src/gen/gl_finit.h"), c_copyright(), w("/***** This file is generated do not edit ****/~n~n", []), - w("static struct {\n" - " const char * name;\n" - " const char * alt;\n" - " void * func;\n" - "} gl_fns[] = \n" + w("gl_fns_t gl_fns[] = \n" "{\n", []), [finits(F) || F <- Funcs], w(" { NULL, NULL, NULL}};\n",[]), diff --git a/lib/wx/api_gen/gl_gen_erl.erl b/lib/wx/api_gen/gl_gen_erl.erl index 07e4d6f783..f292c8723e 100644 --- a/lib/wx/api_gen/gl_gen_erl.erl +++ b/lib/wx/api_gen/gl_gen_erl.erl @@ -49,7 +49,7 @@ glu_defines(Defs) -> w("~n%% GLU DEFINITIONS~n~n", []), w("%% This file is generated DO NOT EDIT~n~n", []), [gen_define(Def) || Def=#def{} <- Defs], - close(), + close(), ok. gen_define(#def{name=N, val=Val, type=int}) -> @@ -78,7 +78,11 @@ types() -> {"GLsizeiptr","64/native-unsigned"}, % 64 bits int, convert on c-side {"GLintptr", "64/native-unsigned"}, % 64 bits int, convert on c-sidew {"GLUquadric", "64/native-unsigned"},% Handle 32bits aargh 64bits on mac64 - {"GLhandleARB","64/native-unsigned"} % Handle 32bits aargh 64bits on mac64 + {"GLhandleARB","64/native-unsigned"},% Handle 32bits aargh 64bits on mac64 + + {"GLsync", "64/native-unsigned"}, % Pointer to record + {"GLuint64", "64/native-unsigned"}, + {"GLint64", "64/native-signed"} ]. gl_api(Fs) -> @@ -90,22 +94,53 @@ gl_api(Fs) -> w("%% See <a href=\"http://www.opengl.org/sdk/docs/man/\">www.opengl.org</a>~n",[]), w("%%~n", []), w("%% Booleans are represented by integers 0 and 1.~n~n", []), - w("%% @type wx_mem(). see wx.erl on memory allocation functions~n", []), + w("%% @type mem(). memory block~n", []), w("%% @type enum(). An integer defined in gl.hrl~n", []), w("%% @type offset(). An integer which is an offset in an array~n", []), w("%% @type clamp(). A float clamped between 0.0 - 1.0~n", []), w("-module(gl).~n~n",[]), w("-compile(inline).~n", []), - %% w("-compile(export_all).~n~n", []), - %% w("-compile(binary_comprehension).~n~n", []), - w("-include(\"wxe.hrl\").~n", []), +%% w("-include(\"wxe.hrl\").~n", []), [w("-define(~s,~s).~n", [GL,Erl]) || {GL,Erl} <- types()], - + + gen_types(gl), + Exp = fun(F) -> gen_export(F) end, ExportList = lists:map(Exp,Fs), w("~n-export([~s]).~n~n", [args(fun(EF) -> EF end, ",", ExportList, 60)]), - + w("-export([call/2, cast/2, send_bin/1]).~n",[]), + w("%% @hidden~n", []), + w("call(Op, Args) ->~n", []), + w(" Port = get(opengl_port), ~n", []), + w(" _ = erlang:port_control(Port,Op,Args),~n", []), + w(" rec().~n", []), + w(" ~n", []), + w("%% @hidden~n", []), + w("cast(Op, Args) ->~n", []), + w(" Port = get(opengl_port), ~n", []), + w(" _ = erlang:port_control(Port,Op,Args),~n", []), + w(" ok.~n", []), + w(" ~n", []), + w("%% @hidden~n", []), + w("rec() ->~n", []), + w(" receive ~n", []), + w(" {'_egl_result_', Res} -> Res;~n", []), + w(" {'_egl_error_', Op, Res} -> error({error,Res,Op})~n", []), + w(" end. ~n", []), + w("~n", []), + w("%% @hidden~n", []), + w("send_bin(Bin) when is_binary(Bin) ->~n", []), + w(" Port = get(opengl_port), ~n", []), + w(" erlang:port_command(Port,Bin);~n", []), + w("send_bin(Tuple) when is_tuple(Tuple) ->~n", []), + w(" Port = get(opengl_port), ~n", []), + w(" case element(2, Tuple) of~n", []), + w(" Bin when is_binary(Bin) ->~n", []), + w(" erlang:port_command(Port,Bin)~n", []), + w(" end.~n", []), + w("~n", []), + w("~n%% API~n~n", []), [gen_funcs(F) || F <- Fs], close(), @@ -120,20 +155,22 @@ glu_api(Fs) -> w("%% See <a href=\"http://www.opengl.org/sdk/docs/man/\">www.opengl.org</a>~n",[]), w("%%~n", []), w("%% Booleans are represented by integers 0 and 1.~n~n", []), - w("%% @type wx_mem(). see wx.erl on memory allocation functions~n", []), + w("%% @type mem(). memory block~n", []), w("%% @type enum(). An integer defined in gl.hrl~n", []), w("%% @type offset(). An integer which is an offset in an array~n", []), w("%% @type clamp(). A float clamped between 0.0 - 1.0~n~n", []), w("-module(glu).~n",[]), w("-compile(inline).~n", []), - w("-include(\"wxe.hrl\").~n", []), + %%w("-include(\"wxe.hrl\").~n", []), [w("-define(~s,~s).~n", [GL,Erl]) || {GL,Erl} <- types()], + gen_types(glu), + Exp = fun(F) -> gen_export(F) end, ExportList = ["tesselate/2" | lists:map(Exp,Fs)], w("~n-export([~s]).~n~n", [args(fun(EF) -> EF end, ",", ExportList, 60)]), - + w("-import(gl, [call/2,cast/2,send_bin/1]).", []), w("~n%% API~n~n", []), w("%% @spec (Vec3, [Vec3]) -> {Triangles, VertexPos}~n",[]), @@ -148,13 +185,13 @@ glu_api(Fs) -> "%% may contain newly created vertices in the end.~n", []), w("tesselate({Nx,Ny,Nz}, Vs) ->~n",[]), - w(" wxe_util:call(5000, <<(length(Vs)):32/native,0:32,~n" + w(" call(5000, <<(length(Vs)):32/native,0:32,~n" " Nx:?GLdouble,Ny:?GLdouble,Nz:?GLdouble,~n" " (<< <<Vx:?GLdouble,Vy:?GLdouble,Vz:?GLdouble >>~n" " || {Vx,Vy,Vz} <- Vs>>)/binary >>).~n~n", []), [gen_funcs(F) || F <- Fs], - close(), + close(), ok. gen_funcs([F]) when is_list(F) -> @@ -178,9 +215,27 @@ gen_funcs(F) -> erase(current_func), w(".~n~n",[]). -gen_export([F|_]) when is_list(F) -> +gen_types(Where) -> + case Where of + glu -> ignore; + gl -> + w("-type clamp() :: float().~n", []), + w("-type offset() :: non_neg_integer().~n", []) + end, + w("-type enum() :: non_neg_integer().~n", []), + w("-type mem() :: binary() | tuple().~n", []), + ok. + +gen_export(F) -> + try gen_export_1(F) + catch E:R -> + io:format("Crash ~p:~p in ~p ~n",[E,R, erlang:get_stacktrace()]), + io:format("Func = ~p~n ~p", [F, get(F)]) + end. + +gen_export_1([F|_]) when is_list(F) -> gen_export2(get(F)); -gen_export(F) when is_list(F) -> +gen_export_1(F) when is_list(F) -> gen_export2(get(F)). gen_export2(#func{name=Name,alt={vector,VecPos,Vec}}) -> @@ -192,19 +247,27 @@ gen_export2(#func{name=Name,params=As0}) -> Args = lists:filter(fun(Arg) -> func_arg(Arg) =/= skip end, As0), erl_func_name(Name) ++ "/" ++ integer_to_list(length(Args)). - -gen_doc([#func{alt={vector,VecPos,Vec}}]) -> +gen_doc([#func{name=Name, alt={vector,VecPos,Vec}}]) -> #func{type=T,params=As} = get(Vec), {As1,As2} = lists:split(VecPos, As), Args1 = case args(fun func_arg/1, ",", As1) of [] -> []; Else -> Else++"," end, Args2 = args(fun func_arg/1, ",", As2), - w("%% @spec (~s{~s}) -> ~s~n",[Args1,Args2,doc_return_types(T,As)]), - w("%% @equiv ~s(~s)~n",[erl_func_name(Vec), Args1++Args2]); + w("%% @spec (~s{~s}) -> ~s~n",[Args1,Args2,doc_return_types(T,As, doc)]), + w("%% @equiv ~s(~s)~n",[erl_func_name(Vec), Args1++Args2]), + SA1 = case doc_arg_types(As1, spec) of [] -> []; E -> E++"," end, + SA2 = doc_arg_types(As2, spec), + w("-spec ~s(~s{~s}) -> ~s.~n", + [erl_func_name(Name), SA1, SA2, + doc_return_types(T,As, spec)]); + gen_doc([#func{name=Name,type=T,params=As,alt=Alt}|_]) -> - w("%% @spec (~s) -> ~s~n", [doc_arg_types(As),doc_return_types(T,As)]), + w("%% @spec (~s) -> ~s~n", [doc_arg_types(As, doc),doc_return_types(T,As, doc)]), GLDoc = "http://www.opengl.org/sdk/docs/man/xhtml/", w("%% @doc See <a href=\"~s~s.xml\">external</a> documentation.~n", - [GLDoc, doc_name(Name,Alt)]). + [GLDoc, doc_name(Name,Alt)]), + w("-spec ~s(~s) -> ~s.~n", + [erl_func_name(Name), doc_arg_types(As, spec), doc_return_types(T,As, spec)]). + gen_func(#func{name=Name,alt={vector,VecPos,Vec}}) -> #func{params=As} = get(Vec), @@ -222,9 +285,9 @@ gen_func(_F=#func{name=Name,type=T,params=As,id=MId}) -> {StrArgs,_} = marshal_args(PreAs), case have_return_vals(T,As) of true -> - w(" wxe_util:call(~p, <<~s>>)", [MId, StrArgs]); + w(" call(~p, <<~s>>)", [MId, StrArgs]); false -> - w(" wxe_util:cast(~p, <<~s>>)", [MId, StrArgs]) + w(" cast(~p, <<~s>>)", [MId, StrArgs]) end. func_arg(#arg{in=In,where=W,name=Name,type=Type}) @@ -242,60 +305,65 @@ func_arg(#arg{in=In,where=W,name=Name,type=Type}) end; func_arg(_) -> skip. -doc_arg_types(Ps0) -> +doc_arg_types(Ps0, Type) -> Ps = [P || P=#arg{in=In, where=Where} <- Ps0,In =/= false, Where =/= c], - args(fun doc_arg_type/1, ",", Ps). + args(fun(Arg) -> doc_arg_type(Arg, Type) end, ",", Ps). -doc_return_types(T, Ps0) -> +doc_return_types(T, Ps0, Type) -> Ps = [P || P=#arg{in=In, where=Where} <- Ps0,In =/= true, Where =/= c], - doc_return_types2(T, Ps). - -doc_return_types2(void, []) -> "ok"; -doc_return_types2(void, [#arg{type=T}]) -> doc_arg_type2(T); -doc_return_types2(T, []) -> doc_arg_type2(T); -doc_return_types2(void, Ps) -> - "{" ++ args(fun doc_arg_type/1,",",Ps) ++ "}"; -doc_return_types2(T, Ps) -> - "{" ++ doc_arg_type2(T) ++ "," ++ args(fun doc_arg_type/1,",",Ps) ++ "}". - -doc_arg_type(#arg{name=Name,type=T}) -> + doc_return_types2(T, Ps, Type). + +doc_return_types2(void, [], _) -> "ok"; +doc_return_types2(void, [#arg{type=T}], _) -> doc_arg_type2(T); +doc_return_types2(T, [], _) -> doc_arg_type2(T); +doc_return_types2(void, Ps, Type) -> + "{" ++ args(fun(Arg) -> doc_arg_type(Arg, Type) end,",",Ps) ++ "}"; +doc_return_types2(T, Ps, Type) -> + "{" ++ doc_arg_type2(T) ++ "," ++ + args(fun(Arg) -> doc_arg_type(Arg, Type) end,",",Ps) ++ "}". + +doc_arg_type(#arg{name=Name,type=T}, doc) -> try erl_arg_name(Name) ++ "::" ++ doc_arg_type2(T) catch _:Error -> io:format("Error: ~p ~p~n~p~n",[Name, Error, erlang:get_stacktrace()]), exit(error) + end; +doc_arg_type(#arg{name=Name,type=T}, spec) -> + try + doc_arg_type2(T) + catch _:Error -> + io:format("Error spec: ~p ~p~n~p~n",[Name, Error, erlang:get_stacktrace()]), + exit(error) end. + doc_arg_type2(T=#type{single=true}) -> doc_arg_type3(T); doc_arg_type2(T=#type{single=undefined}) -> doc_arg_type3(T); doc_arg_type2(T=#type{single={tuple,undefined}}) -> "{" ++ doc_arg_type3(T) ++ "}"; -doc_arg_type2(T=#type{single={tuple,_Sz}}) -> - "{" ++ doc_arg_type3(T) ++ "}"; +doc_arg_type2(T=#type{single={tuple,Sz}}) -> + "{" ++ args(fun doc_arg_type3/1, ",", lists:duplicate(Sz,T)) ++ "}"; doc_arg_type2(T=#type{single=list}) -> "[" ++ doc_arg_type3(T) ++ "]"; -doc_arg_type2(T=#type{single={list, Max}}) when is_integer(Max) -> +doc_arg_type2(T=#type{single={list, _Max}}) -> "[" ++ doc_arg_type3(T) ++ "]"; -doc_arg_type2(_T=#type{single={list,null}}) -> - "string()"; -doc_arg_type2(T=#type{base=string}) -> - doc_arg_type3(T); doc_arg_type2(T=#type{single={list,_,_}}) -> "[" ++ doc_arg_type3(T) ++ "]"; -doc_arg_type2(T=#type{single={tuple_list,_TSz}}) -> - "[{" ++ doc_arg_type3(T) ++ "}]". +doc_arg_type2(T=#type{single={tuple_list,Sz}}) -> + "[{" ++ args(fun doc_arg_type3/1, ",", lists:duplicate(Sz,T)) ++ "}]". doc_arg_type3(#type{name="GLenum"}) -> "enum()"; doc_arg_type3(#type{name="GLclamp"++_}) -> "clamp()"; doc_arg_type3(#type{base=int}) -> "integer()"; doc_arg_type3(#type{base=float}) -> "float()"; -doc_arg_type3(#type{base=guard_int}) -> "offset()|binary()"; +doc_arg_type3(#type{base=guard_int}) -> "offset()|mem()"; doc_arg_type3(#type{base=string}) -> "string()"; doc_arg_type3(#type{base=bool}) -> "0|1"; doc_arg_type3(#type{base=binary}) -> "binary()"; -doc_arg_type3(#type{base=memory}) -> "wx:wx_mem()". +doc_arg_type3(#type{base=memory}) -> "mem()". guard_test(As) -> Str = args(fun(#arg{name=N,type=#type{base=guard_int}}) -> @@ -309,10 +377,10 @@ guard_test(As) -> end. pre_marshal([#arg{name=N,in=true,type=#type{base=binary}}|R]) -> - w(" wxe_util:send_bin(~s),~n", [erl_arg_name(N)]), + w(" send_bin(~s),~n", [erl_arg_name(N)]), pre_marshal(R); pre_marshal([#arg{name=N,type=#type{base=memory}}|R]) -> - w(" wxe_util:send_bin(~s#wx_mem.bin),~n", [erl_arg_name(N)]), + w(" send_bin(~s),~n", [erl_arg_name(N)]), pre_marshal(R); pre_marshal([A=#arg{name=N,type=#type{base=string,single=list}}|R]) -> %% With null terminations @@ -588,6 +656,7 @@ gen_debug(GL, GLU) -> w("].~n~n", []), close(). + printd([F|R],Mod) when is_list(F) -> printd(F,Mod), printd(R,Mod); diff --git a/lib/wx/api_gen/glapi.conf b/lib/wx/api_gen/glapi.conf index f9ed7a1065..525ccf8b68 100644 --- a/lib/wx/api_gen/glapi.conf +++ b/lib/wx/api_gen/glapi.conf @@ -29,8 +29,35 @@ "glMatrixIndexPointerARB", "glPixelTransformParameter", %% OpengGL 3.0 - %"glGetTransformFeedbackVarying", %% Jobbiga - %"glTransformFeedbackVaryings", + + %% ARB + "glCreateSyncFromCLeventARB", % _cl_context _cl_event ?? + "glDebugMessageCallbackARB", + + "glGetn", %* + "glReadnPixels", %* + + "glVertexP2", %* + "glVertexP3", %* + "glVertexP4", %* + "glTexCoordP1", %* + "glTexCoordP2", %* + "glTexCoordP3", %* + "glTexCoordP4", %* + "glMultiTexCoordP1", %* + "glMultiTexCoordP2", %* + "glMultiTexCoordP3", %* + "glMultiTexCoordP4", %* + "glNormalP3", %* + "glColorP3", %* + "glColorP4", %* + "glSecondaryColorP3", %* + "glVertexAttribP1", %* + "glVertexAttribP2", %* + "glVertexAttribP3", %* + "glVertexAttribP4", %* + + "glGetActiveSubroutineUniformiv", %% Bad API don't know what to allocate needs to ask %% EXT %% By default skip these extensions @@ -136,11 +163,12 @@ {"glRect", [{"v1", {single,{tuple,2}}},{"v2", {single,{tuple,2}}}]}. -{"glGetString", {"result", {single,{list,null}}}}. +{"glGetString", {"result", string}}. {"glGetBooleanv", {"params", {single,{list,16}}}}. {"glGetDoublev", {"params", {single,{list,16}}}}. {"glGetFloatv", {"params", {single,{list,16}}}}. {"glGetIntegerv", {"params", {single,{list,16}}}}. +{"glGetInteger64v", {"params", {single,{list,16}}}}. {"glFeedbackBuffer", {"buffer", [{base,memory}, in]}}. {"glSelectBuffer", {"buffer", [{base,memory}, in]}}. @@ -174,24 +202,24 @@ {"glGetActiveAttribARB", [{"length",[skip,{single, true}]}, {"size", {single, true}}, {"type", {single, true}}, - {"name", {single, {list,"maxLength","length"}}} + {"name", {string,"maxLength","length"}} ]}. {"glGetActiveAttrib", [{"length",[skip,{single, true}]}, {"size", {single, true}}, {"type", {single, true}}, - {"name", {single, {list,"bufSize","length"}}} + {"name", {string,"bufSize","length"}} ]}. {"glGetActiveUniformARB", [{"length",[skip,{single, true}]}, {"size", {single, true}}, {"type", {single, true}}, - {"name", {single, {list,"maxLength","length"}}} + {"name", {string,"maxLength","length"}} ]}. {"glGetActiveUniform", [{"length",[skip,{single, true}]}, {"size", {single, true}}, {"type", {single, true}}, - {"name", {single, {list,"bufSize","length"}}} + {"name", {string,"bufSize","length"}} ]}. {"glGetAttachedShaders", [{"count", [skip,{single,true}]}, @@ -201,18 +229,18 @@ {"glGetProgramiv", {"params", {single,true}}}. {"glGetProgramInfoLog", [{"length", [skip,{single,true}]}, - {"infoLog", {single, {list,"bufSize","length"}}} + {"infoLog", {string,"bufSize","length"}} ]}. {"glGetShaderiv", {"params", {single,true}}}. {"glGetShaderInfoLog", [{"length", [skip,{single,true}]}, - {"infoLog", {single, {list,"bufSize","length"}}} + {"infoLog", {string,"bufSize","length"}} ]}. {"glGetShaderSourceARB", [{"length", [skip,{single,true}]}, - {"source", {single, {list,"maxLength","length"}}} + {"source", {string,"maxLength","length"}} ]}. {"glGetShaderSource", [{"length", [skip,{single,true}]}, - {"source", {single, {list,"bufSize","length"}}} + {"source", {string,"bufSize","length"}} ]}. @@ -239,7 +267,7 @@ {"glMatrixIndex", [{"size",{c_only,{length,"indices"}}}, {"indices", {single,list}}]}. -{"glProgramStringARB", [{"len",{c_only,{constant,"stringLen"}}}, +{"glProgramStringARB", [{"len",{c_only,{length,"string"}}}, {"string",[{base,string},{single,true}]}]}. {"glGetProgramStringARB", {"string", [in,{base,memory}]}}. {"glGenProgramsARB", {"programs", {single,{list,"n","n"}}}}. @@ -250,7 +278,7 @@ {"glGetProgramLocalParameter", {"params", {single,{tuple,4}}}}. {"glGetObjectParameter", {"params", {single,true}}}. {"glGetInfoLogARB", [{"length", [skip,{single,true}]}, - {"infoLog", {single, {list,"maxLength","length"}}} + {"infoLog", {string,"maxLength","length"}} ]}. {"glGetAttachedObjectsARB", [{"count", [skip,{single,true}]}, {"obj", {single, {list,"maxCount","count"}}} @@ -280,9 +308,10 @@ {"objW",[{single,true},out]}]}. {"gluBuild", {"data", [binary]}}. {"gluScaleImage", [{"dataIn", [in, binary]}, {"dataOut", [in, {base, memory}]}]}. -{"gluCheckExtension", [{"extName", {single, list}}, {"extString", {single, list}}]}. -{"gluErrorString", {"result", {single, {list,null}}}}. -{"gluGetString", {"result", {single, {list,null}}}}. +{"gluCheckExtension", [{"extName", string}, + {"extString", string}]}. +{"gluErrorString", {"result", string}}. +{"gluGetString", {"result", string}}. {"gluDeleteQuadric", {"quad", in}}. {"gluQuadric", {"quad", in}}. @@ -291,15 +320,21 @@ {"gluDisk", {"quad", in}}. {"gluCylinder", {"quad", in}}. -%% OpenGL 3.0 +%% OpenGL 3.0 and later {"glGetBooleani_v", {"data", {single,{list,16}}}}. {"glGetIntegeri_v", {"data", {single,{list,16}}}}. +{"glGetFloati_v", {"data", {single,{list,16}}}}. +{"glGetDoublei_v", {"data", {single,{list,16}}}}. +{"glGetInteger64i_v", {"data", {single,{list,16}}}}. + +{"glGetBufferParameteriv", {"params", {single,{list,16}}}}. +{"glGetBufferParameteri64v", {"params", {single,{list,16}}}}. {"glTransformFeedbackVaryings", [{"count", {c_only,{length,"varyings"}}}, {"varyings", [{base,string}, {single,list}]}]}. -{"glGetTransformFeedbackVarying", [{"size", {single, true}},{"type", {single, true}}, +{"glGetTransformFeedbackVarying", [{"size", {single, true}},{"type", {single, true}}, {"length", [skip, {single, true}]}, - {"name", {single, {list,"bufSize","length"}}}]}. + {"name", {string,"bufSize","length"}}]}. {"glGenRenderbuffers", {"renderbuffers", {single,{list,"n","n"}}}}. @@ -327,7 +362,133 @@ {"params", [out, {single, {list, "uniformIndicesLen", "uniformIndicesLen"}}]}]}. {"glGetActiveUniformName", [{"length",[skip,{single, true}]}, - {"uniformName", {single, {list,"bufSize","length"}}}]}. + {"uniformName", {string,"bufSize","length"}}]}. {"glGetActiveUniformBlockName", [{"length",[skip,{single, true}]}, - {"uniformBlockName", {single, {list,"bufSize","length"}}}]}. + {"uniformBlockName", {string,"bufSize","length"}}]}. {"glGetActiveUniformBlockiv", {"params", [in, {base,memory}]}}. + + +{"glGetSynciv", [{"values", {single, {list, "bufSize","length"}}}, + {"length", [skip,{single, true}]}]}. + +{"glGetMultisamplefv", {"val", [out, {single, {tuple,2}}]}}. + + +{"glNamedStringARB", [{"stringlen", {c_only, {length, "string"}}}, + {"namelen", {c_only, {length, "name"}}}]}. +{"glDeleteNamedStringARB", [{"namelen", {c_only, {length, "name"}}}]}. +{"glIsNamedStringARB", [{"namelen", {c_only, {length, "name"}}}]}. +{"glGetNamedStringARB",[{"namelen", {c_only, {length, "name"}}}, + {"stringlen",[skip,{single, true}]}, + {"string", {string,"bufSize","stringlen"}}]}. +{"glGetNamedStringivARB",[{"namelen", {c_only, {length, "name"}}}, + {"params", [out, {single, true}]}]}. +{"glCompileShaderIncludeARB", [{"length", {c_only,{constant,"NULL"}}}, + {"count", {c_only,{length,"path"}}}, + {"path", {single,list}}]}. + + +{"glGenSamplers", {"samplers", {single, {list,"count","count"}}}}. +{"glDeleteSamplers", [{"count", {c_only, {length, "samplers"}}}, + {"samplers", {single, list}}]}. +{"glGetSamplerParameter", {"params", {single, {list, 4}}}}. +{"glSamplerParameterI", {"param", {single, list}}}. +{"glSamplerParameterfv", {"param", {single, list}}}. +{"glSamplerParameteriv", {"param", {single, list}}}. + +%{"glGetActiveSubroutineUniformiv", {"values", }}. +{"glGetActiveSubroutineUniformName", [{"length",[skip,{single, true}]}, + {"name", {string,"bufsize","length"}}]}. +{"glGetActiveSubroutineName", [{"length",[skip,{single, true}]}, + {"name", {string,"bufsize","length"}}]}. +{"glGetProgramStageiv", {"values", {single, true}}}. +{"glUniformSubroutinesuiv", [{"count",{c_only,{length,"indices"}}},{"indices", {single, list}}]}. + +{"glGenTransformFeedbacks", {"ids", {single, {list,"n","n"}}}}. +{"glDeleteTransformFeedbacks", [{"n", {c_only, {length, "ids"}}}, + {"ids", {single, list}}]}. + +{"glPatchParameterfv", {"values", {single, list}}}. + + +{"glGetQueryIndexediv", {"params", {single, true} }}. +{"glShaderBinary", [{"count", {c_only, {length, "shaders"}}}, + {"length", {c_only, {size, "binary"}}}, + {"shaders", {single, list}}, + {"binary", binary} + ]}. +{"glGetShaderPrecisionFormat", [{"range", {single, {tuple, 2}}}, + {"precision", {single, true}}]}. + +{"glGetProgramBinary", [{"length",[skip,{single, true}]}, + {"binary", [out, {binary, "bufSize", "length"}]}, + {"binaryFormat", {single, true}}]}. +{"glProgramBinary", [{"binary", binary}, {"length", {c_only, {size, "binary"}}}]}. + +{"glGenProgramPipelines", {"pipelines", {single, {list,"n","n"}}}}. +{"glDeleteProgramPipelines", [{"n", {c_only, {length, "pipelines"}}}, + {"pipelines", {single, list}}]}. + +{"glCreateShaderProgramv", [{"count", {c_only, {length, "strings"}}}, + {"strings", {single, list}}]}. +{"glGetProgramPipelineInfoLog", [{"length", [skip,{single, true}]}, + {"infoLog", {string,"bufSize","length"}}]}. +{"glGetProgramPipelineiv", {"params", {single, true}}}. + + +%% {"glCreateSyncFromCLeventARB", {"context", }}. + +{"glDebugMessageControlARB", [{"count", {c_only, {length, "ids"}}}, + {"ids", {single, list}}]}. +{"glDebugMessageInsertARB", {"length", {c_only, {length, "buf"}}}}. +{"glGetDebugMessageLogARB", [{"sources", {single, {list, "count", "result"}}}, + {"types", {single, {list, "count", "result"}}}, + {"ids", {single, {list, "count", "result"}}}, + {"severities", {single, {list, "count", "result"}}}, + {"lengths", [{c_only, undefined}, {single, {list, "count", "result"}}]}, + {"messageLog", [{string, "bufsize", "lengths"}, + {single, {list, "bufsize", "result"}}]}]}. + + +{"glUniformMatrix2dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,4}}]}]}. +{"glUniformMatrix3dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,9}}]}]}. +{"glUniformMatrix4dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,16}}]}]}. +{"glUniformMatrix2x3dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,6}}]}]}. +{"glUniformMatrix3x2dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,6}}]}]}. +{"glUniformMatrix2x4dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,8}}]}]}. +{"glUniformMatrix4x2dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,8}}]}]}. +{"glUniformMatrix3x4dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,12}}]}]}. +{"glUniformMatrix4x3dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,12}}]}]}. + +{"glProgramUniform1", [{"count",{c_only,{length,"value"}}}, {"value", [{single,list}]}]}. +{"glProgramUniform2", [{"count",{c_only,{length,"value"}}}, {"value", [{single,{tuple_list,2}}]}]}. +{"glProgramUniform3", [{"count",{c_only,{length,"value"}}}, {"value", [{single,{tuple_list,3}}]}]}. +{"glProgramUniform4", [{"count",{c_only,{length,"value"}}}, {"value", [{single,{tuple_list,4}}]}]}. + +{"glProgramUniformMatrix2fv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,4}}]}]}. +{"glProgramUniformMatrix2dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,4}}]}]}. +{"glProgramUniformMatrix3dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,9}}]}]}. +{"glProgramUniformMatrix3fv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,9}}]}]}. +{"glProgramUniformMatrix4dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,16}}]}]}. +{"glProgramUniformMatrix4fv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,16}}]}]}. +{"glProgramUniformMatrix2x3fv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,6}}]}]}. +{"glProgramUniformMatrix3x2fv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,6}}]}]}. +{"glProgramUniformMatrix2x4fv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,8}}]}]}. +{"glProgramUniformMatrix4x2fv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,8}}]}]}. +{"glProgramUniformMatrix3x4fv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,12}}]}]}. +{"glProgramUniformMatrix4x3fv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,12}}]}]}. + +{"glProgramUniformMatrix2x3dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,6}}]}]}. +{"glProgramUniformMatrix3x2dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,6}}]}]}. +{"glProgramUniformMatrix2x4dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,8}}]}]}. +{"glProgramUniformMatrix4x2dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,8}}]}]}. +{"glProgramUniformMatrix3x4dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,12}}]}]}. +{"glProgramUniformMatrix4x3dv", [{"count",{c_only,{length,"value"}}},{"value", [{single,{tuple_list,12}}]}]}. + +{"glViewportArrayv", [{"count",{c_only,{length,"v"}}}, {"v", [{single,{tuple_list,4}}]}]}. +{"glViewportIndexedfv", {"v", {single,{tuple,4}}}}. +{"glScissorArrayv", [{"count",{c_only,{length,"v"}}}, {"v", [{single,{tuple_list,4}}]}]}. +{"glScissorIndexedv", {"v", {single,{tuple,4}}}}. +{"glDepthRangeArrayv", [{"count",{c_only,{length,"v"}}}, {"v", [{single,{tuple_list,2}}]}]}. + + diff --git a/lib/wx/api_gen/wx_doxygen.conf b/lib/wx/api_gen/wx_doxygen.conf index 1fc57486e6..df150fd154 100644 --- a/lib/wx/api_gen/wx_doxygen.conf +++ b/lib/wx/api_gen/wx_doxygen.conf @@ -8,7 +8,7 @@ PROJECT_NUMBER = 0.1 OUTPUT_DIRECTORY = ./ CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English -USE_WINDOWS_ENCODING = NO +#USE_WINDOWS_ENCODING = NO BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ABBREVIATE_BRIEF = @@ -20,7 +20,7 @@ STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO +# DETAILS_AT_TOP = NO INHERIT_DOCS = YES DISTRIBUTE_GROUP_DOC = NO SEPARATE_MEMBER_PAGES = NO @@ -73,11 +73,11 @@ WARN_LOGFILE = # configuration options related to the input files #--------------------------------------------------------------------------- INPUT = @WXGTK_DIR@/wx/ wx_extra/ -#FILE_PATTERNS = *.h +# FILE_PATTERNS = *.h RECURSIVE = YES EXCLUDE = EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = mac/* mgl/* msw/* os2/* x11/* gtk1/* cocoa/* motif/* msdos/* palmos/* private/* +EXCLUDE_PATTERNS = mac/* mgl/* msw/* os2/* x11/* gtk1/* cocoa/* motif/* msdos/* palmos/* private/* vms_x_fix.h EXAMPLE_PATH = EXAMPLE_PATTERNS = EXAMPLE_RECURSIVE = NO @@ -176,10 +176,11 @@ PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = NO +EXPAND_ONLY_PREDEF = YES SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = + PREDEFINED = \ wxUSE_MENUS=1 \ wxUSE_TOOLBAR=1 \ @@ -215,6 +216,7 @@ PREDEFINED = \ wxUSE_LISTBOX=1 \ wxUSE_BMPBUTTON=1 \ wxUSE_CHECKBOX=1 \ + wxUSE_CHECKLISTBOX=1 \ wxUSE_TREECTRL=1 \ wxUSE_LISTCTRL=1 \ wxUSE_BOOKCTRL=1 \ @@ -251,15 +253,17 @@ PREDEFINED = \ wxUSE_CLIPBOARD=1 \ wxABI_VERSION=20809 \ __WXGTK24__=1 \ + __WXGTK20__=1 \ __WXGTK__=1 \ + wxCHECKLBOX_CHECKED="" \ WXDLLEXPORT="" # WXWIN_COMPATIBILITY_2_6=1 \ - -EXPAND_AS_DEFINED = YES + +EXPAND_AS_DEFINED = WX_FORWARD_TO_SCROLL_HELPER SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- -# Configuration::additions related to external references +# Configuration::additions related to external references #--------------------------------------------------------------------------- TAGFILES = GENERATE_TAGFILE = @@ -285,9 +289,6 @@ DIRECTORY_GRAPH = YES DOT_IMAGE_FORMAT = png DOT_PATH = DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1024 -MAX_DOT_GRAPH_DEPTH = 0 DOT_TRANSPARENT = NO DOT_MULTI_TARGETS = NO GENERATE_LEGEND = YES diff --git a/lib/wx/api_gen/wx_extra/wxListCtrl.c_src b/lib/wx/api_gen/wx_extra/wxListCtrl.c_src index cd3074e481..54d6fafd01 100644 --- a/lib/wx/api_gen/wx_extra/wxListCtrl.c_src +++ b/lib/wx/api_gen/wx_extra/wxListCtrl.c_src @@ -1,3 +1,161 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2011. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + + +<<wxListCtrl_class +class EwxListCtrl : public wxListCtrl { + public: ~EwxListCtrl(); + EwxListCtrl(wxWindow * parent,wxWindowID winid,const wxPoint& pos,const wxSize& size,long style,const wxValidator& validator) : wxListCtrl(parent,winid,pos,size,style,validator) {}; + EwxListCtrl() : wxListCtrl() {}; + + int onGetItemText; + int onGetItemAttr; + int onGetItemColumnImage; + ErlDrvPort port; + + private: + virtual wxString OnGetItemText(long item, long col) const; + virtual wxListItemAttr* OnGetItemAttr(long item) const; + virtual int OnGetItemImage(long item) const; + virtual int OnGetItemColumnImage(long item, long column) const; +}; +wxListCtrl_class>> + +<<wxListCtrl_new_0 +case ~s: { // wxListCtrl::wxListCtrl + wxListCtrl * Result = new EwxListCtrl(); + newPtr((void *) Result, 0, memenv); + rt.addRef(getRef((void *)Result,memenv), "wxListCtrl"); + break; +} +wxListCtrl_new_0>> + +<<wxListCtrl_new_2 +case ~s: { // wxListCtrl::wxListCtrl + wxWindowID winid=wxID_ANY; + wxPoint pos= wxDefaultPosition; + wxSize size= wxDefaultSize; + long style=wxLC_ICON; + const wxValidator * validator= &wxDefaultValidator; + wxWindow *parent = (wxWindow *) getPtr(bp,memenv); bp += 4; + int onGetItemText = 0, onGetItemAttr = 0, onGetItemColumnImage = 0; + + bp += 4; /* Align */ + while( * (int*) bp) { switch (* (int*) bp) { + case 1: {bp += 4; + winid = (wxWindowID)*(int *) bp; bp += 4; + } break; + case 2: {bp += 4; + int * posX = (int *) bp; bp += 4; + int * posY = (int *) bp; bp += 4; + pos = wxPoint(*posX,*posY); + bp += 4; /* Align */ + } break; + case 3: {bp += 4; + int * sizeW = (int *) bp; bp += 4; + int * sizeH = (int *) bp; bp += 4; + size = wxSize(*sizeW,*sizeH); + bp += 4; /* Align */ + } break; + case 4: {bp += 4; + style = (long)*(int *) bp; bp += 4; + } break; + case 5: {bp += 4; +validator = (wxValidator *) getPtr(bp,memenv); bp += 4; + } break; + case 6: {bp += 4; + onGetItemText = *(int *) bp; bp += 4; + } break; + case 7: {bp += 4; + onGetItemAttr = *(int *) bp; bp += 4; + } break; + case 8: {bp += 4; + onGetItemColumnImage = *(int *) bp; bp += 4; + } break; + }}; + EwxListCtrl * Result = new EwxListCtrl(parent,winid,pos,size,style,*validator); + Result->onGetItemText = onGetItemText; + Result->onGetItemAttr = onGetItemAttr; + Result->onGetItemColumnImage = onGetItemColumnImage; + Result->port = Ecmd.port; + newPtr((void *) Result, 0, memenv); + rt.addRef(getRef((void *)Result,memenv), "wxListCtrl"); + break; +} +wxListCtrl_new_2>> + +<<Create +case ~s: { // wxListCtrl::Create + wxWindowID winid=wxID_ANY; + wxPoint pos= wxDefaultPosition; + wxSize size= wxDefaultSize; + long style=wxLC_ICON; + const wxValidator * validator= &wxDefaultValidator; + EwxListCtrl *This = (EwxListCtrl *) getPtr(bp,memenv); bp += 4; + wxWindow *parent = (wxWindow *) getPtr(bp,memenv); bp += 4; + int onGetItemText = 0, onGetItemAttr = 0, onGetItemColumnImage = 0; + + bp += 4; /* Align */ + while( * (int*) bp) { switch (* (int*) bp) { + case 1: {bp += 4; + winid = (wxWindowID)*(int *) bp; bp += 4; + } break; + case 2: {bp += 4; + int * posX = (int *) bp; bp += 4; + int * posY = (int *) bp; bp += 4; + pos = wxPoint(*posX,*posY); + bp += 4; /* Align */ + } break; + case 3: {bp += 4; + int * sizeW = (int *) bp; bp += 4; + int * sizeH = (int *) bp; bp += 4; + size = wxSize(*sizeW,*sizeH); + bp += 4; /* Align */ + } break; + case 4: {bp += 4; + style = (long)*(int *) bp; bp += 4; + } break; + case 5: {bp += 4; +validator = (wxValidator *) getPtr(bp,memenv); bp += 4; + } break; + case 6: {bp += 4; + onGetItemText = *(int *) bp; bp += 4; + } break; + case 7: {bp += 4; + onGetItemAttr = *(int *) bp; bp += 4; + } break; + case 8: {bp += 4; + onGetItemColumnImage = *(int *) bp; bp += 4; + } break; + }}; + if(!This) throw wxe_badarg(0); + bool Result = This->Create(parent,winid,pos,size,style,*validator); + This->onGetItemText = onGetItemText; + This->onGetItemAttr = onGetItemAttr; + This->onGetItemColumnImage = onGetItemColumnImage; + This->port = Ecmd.port; + + rt.addBool(Result); + break; +} +Create>> + <<SortItems case ~s: { // wxListCtrl::SortItems taylormade wxListCtrl *This = (wxListCtrl *) getPtr(bp,memenv); bp += 4; @@ -22,3 +180,6 @@ case ~s: { // wxListCtrl::SortItems taylormade break; } SortItems>> + + + diff --git a/lib/wx/api_gen/wx_extra/wxListCtrl.erl b/lib/wx/api_gen/wx_extra/wxListCtrl.erl index e6470182cb..99255bc53f 100644 --- a/lib/wx/api_gen/wx_extra/wxListCtrl.erl +++ b/lib/wx/api_gen/wx_extra/wxListCtrl.erl @@ -1,32 +1,33 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2011. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% + <<EXPORT:SortItems sortItems/2 SortItems:EXPORT>> <<SortItems %% @spec (This::wxListCtrl(), SortCallBack::function()) -> boolean() %% @doc Sort the items in the list control<br /> -%% <pre>SortCalBack(Item1,Item2) -> integer()</pre> +%% <pre>SortCallBack(Item1,Item2) -> integer()</pre> %% <br /> SortCallBack receives the client data associated with two items %% to compare, and should return 0 if the items are equal, a negative %% value if the first item is less than the second one and a positive %% value if the first item is greater than the second one. -%% <br /> NOTE: The callback may not call other processes. +%% <br /> NOTE: The callback may not call other (wx) processes. sortItems(#wx_ref{type=ThisT,ref=ThisRef}, SortCallBack) when is_function(SortCallBack, 2) -> ?CLASS(ThisT,wxListCtrl), @@ -37,3 +38,100 @@ sortItems(#wx_ref{type=ThisT,ref=ThisRef}, SortCallBack) SortId = wxe_util:get_cbId(Sort), wxe_util:call(~s, <<ThisRef:32/?UI,SortId:32/?UI>>). SortItems>> + +<<EXPORT:wxListCtrl new/0, new/1, new/2 wxListCtrl:EXPORT>> + +<<wxListCtrl_new_0 +%% @spec () -> wxListCtrl() +%% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxlistctrl.html#wxlistctrlwxlistctrl">external documentation</a>. +new() -> + wxe_util:construct(~s, <<>>). +wxListCtrl_new_0>> + +<<wxListCtrl_new_2 +%% @spec (Parent::wxWindow:wxWindow()) -> wxListCtrl() +%% @equiv new(Parent, []) +new(Parent) + when is_record(Parent, wx_ref) -> + new(Parent, []). + +%% @spec (Parent::wxWindow:wxWindow(), [Option]) -> wxListCtrl() +%% Option = {winid, integer()} | +%% {pos, {X::integer(),Y::integer()}} | +%% {size, {W::integer(),H::integer()}} | +%% {style, integer()} | +%% {validator, wx:wx()} | +%% {onGetItemText, OnGetItemText} | +%% {onGetItemAttr, OnGetItemAttr} | +%% {onGetItemColumnImage, OnGetItemColumnImage} +%% +%% OnGetItemText = (This, Item, Column) -> wxString() +%% OnGetItemAttr = (This, Item) -> wxListItemAttr() +%% OnGetItemColumnImage = (This, Item, Column) -> integer() +%% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxlistctrl.html#wxlistctrlwxlistctrl">external documentation</a>. + +new(#wx_ref{type=ParentT,ref=ParentRef}, Options) + when is_list(Options)-> + ?CLASS(ParentT,wxWindow), + MOpts = fun({winid, Winid}, Acc) -> [<<1:32/?UI,Winid:32/?UI>>|Acc]; + ({pos, {PosX,PosY}}, Acc) -> [<<2:32/?UI,PosX:32/?UI,PosY:32/?UI,0:32>>|Acc]; + ({size, {SizeW,SizeH}}, Acc) -> [<<3:32/?UI,SizeW:32/?UI,SizeH:32/?UI,0:32>>|Acc]; + ({style, Style}, Acc) -> [<<4:32/?UI,Style:32/?UI>>|Acc]; + ({validator, #wx_ref{type=ValidatorT,ref=ValidatorRef}}, Acc) -> + ?CLASS(ValidatorT,wx),[<<5:32/?UI,ValidatorRef:32/?UI>>|Acc]; + ({onGetItemText, F}, Acc) when is_function(F) -> + Fun = fun([This,Item,Col]) -> unicode:characters_to_binary([F(This,Item,Col),0]) end, + [<<6:32/?UI,(wxe_util:get_cbId(Fun)):32/?UI>>|Acc]; + ({onGetItemAttr, F}, Acc) when is_function(F) -> + Fun = fun([This,Item]) -> + #wx_ref{type=wxListItemAttr,ref=ThisRef} = F(This,Item), + <<ThisRef:32/?UI>> + end, + [<<7:32/?UI,(wxe_util:get_cbId(Fun)):32/?UI>>|Acc]; + ({onGetItemColumnImage, F}, Acc) when is_function(F) -> + Fun = fun([This,Item, Col]) -> <<(F(This,Item,Col)):32/?I>> end, + [<<8:32/?UI,(wxe_util:get_cbId(Fun)):32/?UI>>|Acc]; + (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, + BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), + wxe_util:construct(~s, <<ParentRef:32/?UI, 0:32,BinOpt/binary>>). + +wxListCtrl_new_2>> + +<<EXPORT:Create create/2, create/3 Create:EXPORT>> + +<<Create +%% @spec (This::wxListCtrl(), Parent::wxWindow:wxWindow()) -> bool() +%% @equiv create(This,Parent, []) +create(This,Parent) + when is_record(This, wx_ref),is_record(Parent, wx_ref) -> + create(This,Parent, []). + +%% @spec (This::wxListCtrl(), Parent::wxWindow:wxWindow(), [Option]) -> bool() +%% Option = {winid, integer()} | +%% {pos, {X::integer(),Y::integer()}} | +%% {size, {W::integer(),H::integer()}} | +%% {style, integer()} | +%% {validator, wx:wx()} | +%% {onGetItemText, OnGetItemText} | +%% {onGetItemAttr, OnGetItemAttr} | +%% {onGetItemColumnImage, OnGetItemColumnImage} +%% +%% OnGetItemText = (This, Item, Column) -> wxString() +%% OnGetItemAttr = (This, Item) -> wxListItemAttr() +%% OnGetItemColumnImage = (This, Item, Column) -> integer() +%% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxlistctrl.html#wxlistctrlcreate">external documentation</a>. +create(#wx_ref{type=ThisT,ref=ThisRef},#wx_ref{type=ParentT,ref=ParentRef}, Options) + when is_list(Options) -> + ?CLASS(ThisT,wxListCtrl), + ?CLASS(ParentT,wxWindow), + MOpts = fun({winid, Winid}, Acc) -> [<<1:32/?UI,Winid:32/?UI>>|Acc]; + ({pos, {PosX,PosY}}, Acc) -> [<<2:32/?UI,PosX:32/?UI,PosY:32/?UI,0:32>>|Acc]; + ({size, {SizeW,SizeH}}, Acc) -> [<<3:32/?UI,SizeW:32/?UI,SizeH:32/?UI,0:32>>|Acc]; + ({style, Style}, Acc) -> [<<4:32/?UI,Style:32/?UI>>|Acc]; + ({validator, #wx_ref{type=ValidatorT,ref=ValidatorRef}}, Acc) -> ?CLASS(ValidatorT,wx),[<<5:32/?UI,ValidatorRef:32/?UI>>|Acc]; + (BadOpt, _) -> erlang:error({badoption, BadOpt}) end, + BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)), + wxe_util:call(~s, + <<ThisRef:32/?UI,ParentRef:32/?UI, BinOpt/binary>>). + +Create>> diff --git a/lib/wx/api_gen/wx_gen.erl b/lib/wx/api_gen/wx_gen.erl index 2ed4476440..209de48496 100644 --- a/lib/wx/api_gen/wx_gen.erl +++ b/lib/wx/api_gen/wx_gen.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% Copyright Ericsson AB 2008-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -30,6 +30,12 @@ -compile(export_all). +-define(DBGCF(Class, Func, Format, Args), + case {get(current_class), get(current_func)} of + {Class, Func} -> io:format("~p:~p: " ++ Format, [?MODULE,?LINE] ++ Args); + _ -> ok + end). + code() -> safe(fun gen_code/0,true). xml() -> safe(fun gen_xml/0,true). @@ -38,7 +44,7 @@ devcode() -> erase(),safe(fun gen_code/0,false). safe(What, QuitOnErr) -> try What(), - io:format("Completed succesfully~n~n", []), + io:format("Completed successfully~n~n", []), QuitOnErr andalso gen_util:halt(0) catch Err:Reason -> io:format("Error in ~p ~p~n", [get(current_class),get(current_func)]), @@ -255,19 +261,24 @@ parse_attr(Defs, Class, Ev, Info = #hs{acc=AccList0}) -> parse_attr1([{{attr,_}, #xmlElement{content=C, attributes=Attrs}}|R], AttrList0, Opts, Res) -> Parse = fun(Con, Ac) -> parse_param(Con, Opts, Ac) end, Param0 = foldl(Parse, #param{}, drop_empty(C)), - case keysearch(prot, #xmlAttribute.name, Attrs) of - {value, #xmlAttribute{value = "public"}} -> - {Acc,AttrList} = attr_acc(Param0, AttrList0), - parse_attr1(R,AttrList,Opts, - [Param0#param{in=false,prot=public,acc=Acc}|Res]); - {value, #xmlAttribute{value = "protected"}} -> - {Acc,AttrList} = attr_acc(Param0, AttrList0), - parse_attr1(R,AttrList,Opts, - [Param0#param{in=false,prot=protected,acc=Acc}|Res]); - {value, #xmlAttribute{value = "private"}} -> - {Acc,AttrList} = attr_acc(Param0, AttrList0), - parse_attr1(R,AttrList,Opts, - [Param0#param{in=false,prot=private,acc=Acc}|Res]) + case Param0 of + #param{where=nowhere} -> + parse_attr1(R,AttrList0,Opts,Res); + _ -> + case keysearch(prot, #xmlAttribute.name, Attrs) of + {value, #xmlAttribute{value = "public"}} -> + {Acc,AttrList} = attr_acc(Param0, AttrList0), + parse_attr1(R,AttrList,Opts, + [Param0#param{in=false,prot=public,acc=Acc}|Res]); + {value, #xmlAttribute{value = "protected"}} -> + {Acc,AttrList} = attr_acc(Param0, AttrList0), + parse_attr1(R,AttrList,Opts, + [Param0#param{in=false,prot=protected,acc=Acc}|Res]); + {value, #xmlAttribute{value = "private"}} -> + {Acc,AttrList} = attr_acc(Param0, AttrList0), + parse_attr1(R,AttrList,Opts, + [Param0#param{in=false,prot=private,acc=Acc}|Res]) + end end; parse_attr1([{_Id,_}|R],AttrList,Info, Res) -> parse_attr1(R,AttrList,Info, Res); @@ -591,17 +602,17 @@ parse_param(#xmlElement{name=array,content=C},_Opts, T = #param{type=Type0}) -> [#xmlText{value=RealVar}] = C, [Name] = string:tokens(RealVar, "() "), T#param{name=Name}; -%% #type{mod=[const]} -> -%% T#param{type=Type0#type{single=array, by_val=true}}; -%% _ -> -%% T#param{type=Type0#type{single=array, by_val=false}} _ -> T#param{type=Type0#type{single=array, by_val=true}} end; parse_param(#xmlElement{name=name,content=[C]}, _, T) -> %% Attributes have this - #xmlText{value=Name} = C, - T#param{name=Name}; + case C of + #xmlText{value=Name="ms_classInfo"} -> + T#param{name=Name, where=nowhere}; + #xmlText{value=Name} -> + T#param{name=Name} + end; %% Skipped: Attributes have this parse_param(#xmlElement{name=definition}, _, T) -> T; parse_param(#xmlElement{name=argsstring}, _, T) -> T; @@ -610,6 +621,7 @@ parse_param(#xmlElement{name=detaileddescription}, _, T) -> T; parse_param(#xmlElement{name=inbodydescription}, _, T) -> T; parse_param(#xmlElement{name=location}, _, T) -> T; parse_param(#xmlElement{name=referencedby}, _, T) -> T; +parse_param(#xmlElement{name=reimplements}, _, T) -> T; parse_param(Other=#xmlElement{name=Name}, _, T) -> io:format("Unhandled Param ~p ~p ~n in ~p~n", [Name,Other,T]), ?error(unhandled_param). @@ -881,7 +893,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 -> @@ -951,17 +963,17 @@ erl_skip_opt(All=[Ms=[{_,{Len,_,_},_}|_]|R],Acc1=[{_,{N,_,_},_}|_], Acc2) -> end; erl_skip_opt([],Acc1,Acc2) -> [strip_ti(Acc1)|Acc2]. -erl_skip_opt2([F={_,{N,In,_},M=#method{where=Where}}|Ms],Acc1,Acc2,Check) -> +erl_skip_opt2([F={_,{N,In,_},M=#method{where=Where}}|Ms],Acc1,Acc2,Check) -> case N > 0 andalso lists:last(In) =:= opt_list of - true when Where =/= merged_c, Where =/= taylormade -> - case Check of - [] -> + true when Where =/= merged_c, Where =/= taylormade -> + case Check of + [] -> erl_skip_opt2(Ms,[F|Acc1],[M#method{where=erl_no_opt}|Acc2],[]); - _ -> + _ -> Skipped = reverse(tl(reverse(In))), T = fun({_,{_,Args,_},_}) -> true =:= types_differ(Skipped,Args) end, case lists:all(T, Check) of - true -> + true -> erl_skip_opt2(Ms,[F|Acc1], [M#method{where=erl_no_opt}|Acc2], Check); @@ -970,7 +982,7 @@ erl_skip_opt2([F={_,{N,In,_},M=#method{where=Where}}|Ms],Acc1,Acc2,Check) -> end end; _ -> - erl_skip_opt2(Ms,[F|Acc1],Acc2,[]) + erl_skip_opt2(Ms,[F|Acc1],Acc2,Check) end; erl_skip_opt2([],Acc1,Acc2,_) -> {Acc1,Acc2}. @@ -1019,7 +1031,6 @@ types_differ([{class,C1}|R1], [{class,C2}|R2]) -> true -> true; false -> -%% _ -> {class,C1,C2}; {class,C1,C2} -> {class,C1,C2}; @@ -1274,11 +1285,11 @@ extract_enum(#xmlElement{name=memberdef,content=C}, Class, File) -> undefined -> %% io:format("1Enum name ~p~n", [Name]), %% [io:format(" ~s ~p~n", [D,V]) || {D,V} <- Vals], - put({enum, Name}, #enum{vals=Vals}); + put({enum, Name}, #enum{vals=Vals, from={File,Class,Name0}}); E = #enum{vals=undefined} -> %% io:format("2Enum name ~p~n", [Name]), %% [io:format(" ~s ~p~n", [D,V]) || {D,V} <- Vals], - put({enum, Name}, E#enum{vals=Vals}); + put({enum, Name}, E#enum{vals=Vals, from={File,Class,Name0}}); #enum{vals=Vals} -> ok; %% io:format("Same? ~p ~n", [PVals == Vals]) #enum{vals=OldVals} -> @@ -1352,7 +1363,7 @@ extract_defs(Defs, File) -> {Vals,_Skip} -> %% io:format("Defs file ~p~n", [File]), %% [io:format(" ~s ~p~n", [D,V]) || {D,V} <- Vals, not is_integer(V)] - put({enum, {define,"From " ++ File ++ ".h"}}, #enum{vals=Vals}) + put({enum, {define,"From " ++ File ++ ".h"}}, #enum{vals=Vals, from={File, undefined, "@define"}}) end. extract_defs2(#xmlElement{name=memberdef,content=C},{Acc,Skip}) -> diff --git a/lib/wx/api_gen/wx_gen.hrl b/lib/wx/api_gen/wx_gen.hrl index b34d399358..426e3adfae 100644 --- a/lib/wx/api_gen/wx_gen.hrl +++ b/lib/wx/api_gen/wx_gen.hrl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2008-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% -record(class, { @@ -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, @@ -72,7 +72,7 @@ } ). --record(enum, {skip="", as_atom=false, vals}). +-record(enum, {from, skip="", as_atom=false, vals}). -record(const,{name,val,enum,is_const}). -define(error(What), diff --git a/lib/wx/api_gen/wx_gen_cpp.erl b/lib/wx/api_gen/wx_gen_cpp.erl index 9e9f8799c7..4632fdbffe 100644 --- a/lib/wx/api_gen/wx_gen_cpp.erl +++ b/lib/wx/api_gen/wx_gen_cpp.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% Copyright Ericsson AB 2008-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -19,7 +19,7 @@ %%%------------------------------------------------------------------- %%% File : wx_gen_cpp.erl %%% Author : Dan Gudmundsson <[email protected]> -%%% Description : +%%% Description : %%% %%% Created : 19 Feb 2007 by Dan Gudmundsson <[email protected]> %%%------------------------------------------------------------------- @@ -35,7 +35,7 @@ args/3, strip_name/2]). -import(wx_gen, [next_id/1]). -gen(Defs) -> +gen(Defs) -> open_write("../c_src/gen/wxe_derived_dest.h"), c_copyright(), w("~n/***** This file is generated do not edit ****/~n~n", []), @@ -49,48 +49,26 @@ gen(Defs) -> open_write("../c_src/gen/wxe_macros.h"), c_copyright(), - gen_macros(), + gen_macros(), close(), open_write("../c_src/gen/wxe_init.cpp"), c_copyright(), build_enums(), close(), - + build_events(), Res. - + gen_derived_dest(Defs) -> [gen_derived_dest_2(Class) || Class <- Defs], - - UglySkipList = ["wxCaret", "wxCalendarDateAttr", - "wxFileDataObject", "wxTextDataObject", "wxBitmapDataObject" - ], - - ?WTC("gen_derived_dest"), - w("void WxeApp::delete_object(void *ptr, wxeRefData *refd) {~n", []), - w(" switch(refd->type) {~n", []), - Case = fun(#class{name=Class, id=Id, abstract=IsAbs, parent=P}) when P /= "static" -> - UglyWorkaround = lists:member(Class, UglySkipList), - case hd(reverse(wx_gen_erl:parents(Class))) of - root when IsAbs == false, UglyWorkaround == false -> - w(" case ~p: delete (~s *) ptr; break;~n", [Id, Class]); - root when IsAbs == false, UglyWorkaround == true -> - w(" case ~p: /* delete (~s *) ptr;" - "These objects must be deleted by owner object */ " - "break;~n", [Id, Class]); - _ -> ok - end; - (_) -> ok - end, - [Case(Class) || Class <- Defs], - w(" default: delete (wxObject *) ptr;~n", []), - w("}}~n~n", []). + ok. gen_derived_dest_2(C=#class{name=Class}) -> - case is_derived(C) of - true -> - ?WTC("gen_derived_dest_2"), + ?WTC("gen_derived_dest_2"), + Derived = is_derived(C), + TaylorMade = taylormade_class(C), + if Derived andalso (TaylorMade =:= false) -> w("class E~s : public ~s {~n",[Class,Class]), case Class of "wxGLCanvas" -> %% Special for cleaning up gl context @@ -101,15 +79,32 @@ gen_derived_dest_2(C=#class{name=Class}) -> end, gen_constructors(C), w("};~n~n", []); - false -> + TaylorMade /= false -> + w("~s~n", [TaylorMade]); + true -> ignore end. +taylormade_class(#class{name=CName, methods=Ms}) -> + TaylorMade = lists:any(fun([#method{where=taylormade}|_]) -> true; + (_) -> false + end, Ms), + case TaylorMade of + false -> false; + true -> + {ok, Bin} = file:read_file(filename:join([wx_extra, CName ++".c_src"])), + Src = binary_to_list(Bin), + case gen_util:get_taylor_made(Src, CName ++ "_class") of + nomatch -> false; + {match, [Str0]} -> Str0 + end + end. + gen_constructors(#class{name=Class, methods=Ms0}) -> Ms = lists:append(Ms0), Cs = lists:filter(fun(#method{method_type=MT}) -> MT =:= constructor end, Ms), [gen_constructor(Class, Const) || Const <- Cs]. - + gen_constructor(_Class, #method{where=merged_c}) -> ok; gen_constructor(_Class, #method{where=erl_no_opt}) -> ok; gen_constructor(Class, _M=#method{params=Ps}) -> @@ -119,7 +114,7 @@ gen_constructor(Class, _M=#method{params=Ps}) -> HaveMergedType = fun(#param{type={merged,_,_,_,_,_,_}}) -> true; (_) -> false end, ?WTC("gen_constructor"), case lists:any(HaveMergedType, Ps) of - false -> + false -> w(" E~s(~s) : ~s(~s) {};~n", [Class,args(Gen1,",",Ps),Class,args(CallA,",",Ps)]); true -> @@ -141,9 +136,9 @@ gen_type(#type{name=Type, ref=undefined, single=array, mod=Mod},_) -> mods(Mod) ++ to_string(Type) ++ " * "; gen_type(#type{name=Type, ref=undefined, mod=Mod},_) -> mods(Mod) ++ to_string(Type) ++ " "; -gen_type({merged, _, T1, _,_, _T2,_}, 1) -> +gen_type({merged, _, T1, _,_, _T2,_}, 1) -> gen_type(T1,error); -gen_type({merged, _, _T1,_, _, T2,_}, 2) -> +gen_type({merged, _, _T1,_, _, T2,_}, 2) -> gen_type(T2,error). gen_funcs(Defs) -> @@ -152,6 +147,7 @@ gen_funcs(Defs) -> w("#include \"../wxe_impl.h\"~n"), w("#include \"../wxe_events.h\"~n"), w("#include \"../wxe_return.h\"~n"), + w("#include \"../wxe_gl.h\"~n"), w("#include \"wxe_macros.h\"~n"), w("#include \"wxe_derived_dest.h\"~n~n"), @@ -167,7 +163,7 @@ gen_funcs(Defs) -> %% w(" case WXE_REMOVE_PORT:~n", []), %% w(" { destroyMemEnv(Ecmd.port); } break;~n", []), w(" case DESTROY_OBJECT: {~n"), - w(" wxObject *This = (wxObject *) getPtr(bp,memenv); "), + w(" wxObject *This = (wxObject *) getPtr(bp,memenv); "), w(" if(This) {"), w(" ((WxeApp *) wxTheApp)->clearPtr((void *) This);~n"), w(" delete This; }~n } break;~n"), @@ -176,6 +172,9 @@ gen_funcs(Defs) -> " rt.addAtom(\"ok\");~n" " break;~n" " }~n"), + w(" case WXE_BIN_INCR:~n driver_binary_inc_refc(Ecmd.bin[0]->bin);~n break;~n",[]), + w(" case WXE_BIN_DECR:~n driver_binary_dec_refc(Ecmd.bin[0]->bin);~n break;~n",[]), + w(" case WXE_INIT_OPENGL:~n wxe_initOpenGL(rt, bp);~n break;~n",[]), Res = [gen_class(Class) || Class <- Defs], @@ -199,16 +198,39 @@ gen_funcs(Defs) -> w(" error.addTupleCount(2);~n"), w(" error.addTupleCount(3);~n"), w(" error.send();~n"), - w("}} /* The End */~n"), + w("}} /* The End */~n~n~n"), + + UglySkipList = ["wxCaret", "wxCalendarDateAttr", + "wxFileDataObject", "wxTextDataObject", "wxBitmapDataObject" + ], + + w("void WxeApp::delete_object(void *ptr, wxeRefData *refd) {~n", []), + w(" switch(refd->type) {~n", []), + Case = fun(#class{name=Class, id=Id, abstract=IsAbs, parent=P}) when P /= "static" -> + UglyWorkaround = lists:member(Class, UglySkipList), + case hd(reverse(wx_gen_erl:parents(Class))) of + root when IsAbs == false, UglyWorkaround == false -> + w(" case ~p: delete (~s *) ptr; break;~n", [Id, Class]); + root when IsAbs == false, UglyWorkaround == true -> + w(" case ~p: /* delete (~s *) ptr;" + "These objects must be deleted by owner object */ " + "break;~n", [Id, Class]); + _ -> ok + end; + (_) -> ok + end, + [Case(Class) || Class <- Defs], + w(" default: delete (wxObject *) ptr;~n", []), + w("}}~n~n", []), Res. - + gen_class(C=#class{name=Name,methods=Ms,options=Opts}) -> put(current_class, Name), - NewMs = + NewMs = case lists:member(taylormade, Opts) of true -> {ok, Bin} = file:read_file(filename:join([wx_extra,Name++".c_src"])), - ?WTC("gen_class"), + ?WTC("gen_class"), w("~s~n", [binary_to_list(Bin)]), Ms; false -> @@ -216,13 +238,13 @@ gen_class(C=#class{name=Name,methods=Ms,options=Opts}) -> {value, {ifdef, What}} -> w("#if ~p~n",[What]), Methods = lists:flatten(Ms), - MsR = [gen_method(Name,M) || + MsR = [gen_method(Name,M) || M <- lists:keysort(#method.id, Methods)], w("#endif // ~p~n",[What]), MsR; false -> Methods = lists:flatten(Ms), - [gen_method(Name,M) || + [gen_method(Name,M) || M <- lists:keysort(#method.id, Methods)] end end, @@ -230,15 +252,19 @@ gen_class(C=#class{name=Name,methods=Ms,options=Opts}) -> C#class{methods=NewMs}. gen_method(_CName, M=#method{where=erl_no_opt}) -> M; -gen_method(CName, M=#method{where=taylormade, name=Name, id=Id}) -> +gen_method(CName, M=#method{where=taylormade, name=Name, id=Id}) -> {ok, Bin} = file:read_file(filename:join([wx_extra, CName ++".c_src"])), - Str0 = binary_to_list(Bin), + Src = binary_to_list(Bin), %% io:format("C++ Class ~p ~p~n", [CName, Name]), - - {match, [Str1]} = re:run(Str0, "<<"++Name++"(.*)"++Name++">>", - [dotall, {capture, all_but_first, list}]), + Str = case gen_util:get_taylor_made(Src, Name) of + nomatch -> + {match, [Str0]} = gen_util:get_taylor_made(Src, wx_gen_erl:get_unique_name(Id)), + Str0; + {match, [Str0]} -> + Str0 + end, ?WTC("gen_method"), - w(Str1, [wx_gen_erl:get_unique_name(Id)]), + w(Str, [wx_gen_erl:get_unique_name(Id)]), M; gen_method(CName, M=#method{name=N,params=[Ps],method_type=destructor,id=MethodId}) -> case hd(reverse(wx_gen_erl:parents(CName))) of @@ -249,7 +275,7 @@ gen_method(CName, M=#method{name=N,params=[Ps],method_type=destructor,id=MethodI w(" if(This) {", []), w(" ((WxeApp *) wxTheApp)->clearPtr((void *) This);~n", []), w(" delete This;}~n", []), - free_args(), + free_args(), w(" break;~n}~n", []); object -> %% Use default ignore @@ -262,16 +288,16 @@ gen_method(CName, M=#method{name=N,params=Ps0,type=T,method_type=MT,id=MethodId w("case ~s: { // ~s::~s~n", [wx_gen_erl:get_unique_name(MethodId),CName,N]), Ps1 = declare_variables(void, Ps0), {Ps2,Align} = decode_arguments(Ps1), - Opts = [Opt || Opt = #param{def=Def,in=In,where=Where} <- Ps2, + 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 - undefined -> 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 - undefined -> skip; + case gen_util:get_hook(c, M#method.post_hook) of + ignore -> skip; Post -> w(" ~s;~n", [Post]) end, free_args(), @@ -288,7 +314,7 @@ declare_variables(T, Ps) -> declare_var(P = #param{where=erl}) -> P; declare_var(P = #param{where=this}) -> P; -declare_var(P = #param{name=Name,def=Def,type=Type,in=true}) when Def =/= none -> +declare_var(P = #param{name=Name,def=Def,type=Type,in=true}) when Def =/= none -> declare_type(Name, true, Def, Type), P; declare_var(P = #param{in=In}) when In =/= false -> P; @@ -300,7 +326,7 @@ declare_type(N,false,_,#type{name="wxArrayInt"}) -> w(" wxArrayInt ~s;~n", [N]); declare_type(N,false,_,#type{name="wxArrayString"}) -> w(" wxArrayString ~s;~n", [N]); -declare_type(N,false,_,#type{base=Base,single=true,name=Type,by_val=false,mod=Mod}) +declare_type(N,false,_,#type{base=Base,single=true,name=Type,by_val=false,mod=Mod}) when Base =:= int; Base =:= long; Base =:= float; Base =:= double -> w(" ~s~s ~s;~n", [mods(Mod),Type,N]); declare_type(N,false,_,#type{base={enum,_},single=true,name=Type,by_val=false,mod=Mod}) -> @@ -311,7 +337,7 @@ declare_type(N,false,_,#type{name="wxDateTime"}) -> w(" wxDateTime ~s;~n", [N]); declare_type(N,false,_,#type{name=Type, base=int64, ref=reference}) -> w(" ~s ~s;~n", [Type,N]); -declare_type(N,true,Def,#type{base=Base,single=true,name=Type,by_val=true}) +declare_type(N,true,Def,#type{base=Base,single=true,name=Type,by_val=true}) when Base =:= int; Base =:= long; Base =:= float; Base =:= double; Base =:= bool -> w(" ~s ~s=~s;~n", [Type,N,Def]); declare_type(N,true,Def,#type{base={comp,_,_},single=true,name=Type,mod=Mod,ref={pointer,1}}) -> @@ -324,7 +350,7 @@ declare_type(N,true,Def,#type{base={class,_},single=true,name=Type,ref={pointer, w(" ~s~s * ~s=~s;~n", [mods(Mod),Type,N,Def]); declare_type(N,true,Def,#type{base={class,_},single=true,name=Type,ref=reference,mod=Mod}) -> w(" ~s~s * ~s= &~s;~n", [mods(Mod),Type,N,Def]); -declare_type(N,true,Def,#type{base=Base,single=true,name=Type,by_val=false,ref={pointer,1}}) +declare_type(N,true,Def,#type{base=Base,single=true,name=Type,by_val=false,ref={pointer,1}}) when Base =:= int; Base =:= long; Base =:= float; Base =:= double; Base =:= bool -> w(" ~s *~s=~s;~n", [Type,N,Def]); declare_type(N,true,Def,#type{single=true,name="wxArtClient"}) -> @@ -341,7 +367,7 @@ declare_type(N,true,Def,#type{name=Type, ref={pointer,2}}) -> %% xxxx w(" ~s ** ~s = ~s;~n", [Type,N,Def]); declare_type(N,true,Def,#type{name=Type, single=array, ref={pointer,1}}) -> - w(" int * ~sLen = 0;~n", [N]), + w(" int * ~sLen = 0;~n", [N]), w(" ~s * ~s = ~s;~n", [Type,N,Def]); declare_type(N,true,"",#type{name="wxArrayString", single=array, ref=reference}) -> w(" wxArrayString ~s;~n", [N]); @@ -359,12 +385,12 @@ decode_options(Opts, Align) -> decode_opt(#param{name=Name,type=Type}, N) -> w(" case ~p: {bp += 4;~n", [N]), - Align = decode_arg(Name,Type,opt,1), + Align = decode_arg(Name,Type,opt,1), align(Align, 64), w(" } break;~n", []), N+1. -decode_arguments(Ps0) -> +decode_arguments(Ps0) -> lists:mapfoldl(fun decode_arg/2,0,Ps0). store_free(N) -> @@ -376,7 +402,7 @@ store_free(N) -> free_args() -> case get(free_args) of undefined -> ignore; - List -> + List -> erase(free_args), [w(" driver_free(~s);~n", [Arg]) || Arg <- List] end. @@ -384,7 +410,7 @@ free_args() -> decode_arg(P = #param{where=erl},A) -> {P,A}; decode_arg(P = #param{where=c},A) -> {P,A}; decode_arg(P = #param{in=false},A) -> {P,A}; -decode_arg(P = #param{def=Def},A) when Def =/= none -> {P,A}; +decode_arg(P = #param{def=Def},A) when Def =/= none -> {P,A}; decode_arg(P = #param{name=Name,type=Type},A0) -> A = decode_arg(Name, Type, arg, A0), {P, A}. @@ -422,22 +448,22 @@ decode_arg(N,#type{base=float,single=true,name=Type},arg,A0) -> align(A0,32); decode_arg(N,#type{base=double,single=true,name=Type},Arg,A0) -> A = align(A0,64), - case Arg of + case Arg of arg -> w(" ~s * ~s = (~s *) bp; bp += 8;~n", [Type,N,Type]); opt -> w(" ~s = * (~s *) bp; bp += 8;~n", [N,Type]) end, A; decode_arg(N,#type{base=bool,single=true,name=Type},Arg,A0) -> - case Arg of + case Arg of arg -> w(" bool * ~s = (~s *) bp; bp += 4;~n", [N,Type]); opt -> w(" ~s = *(~s *) bp; bp += 4;~n", [N,Type]) end, align(A0,32); decode_arg(N,#type{base={enum,Type},single=true},Arg,A0) -> - wa(" ~s ", [enum_type(Type)], "~s = *(~s *) bp; bp += 4;;~n",[N, enum_type(Type)], Arg), + wa(" ~s ", [enum_type(Type)], "~s = *(~s *) bp; bp += 4;;~n",[N, enum_type(Type)], Arg), align(A0,32); decode_arg(N,#type{base={comp,"wxDateTime",List},single=true,name=Type,ref=Ref},Arg,A0) -> - Decl = fun({int,Spec}) -> + Decl = fun({int,Spec}) -> w(" int * ~s~s = (int *) bp; bp += 4;~n", [N,Spec]) end, align(A0,32), @@ -448,15 +474,15 @@ decode_arg(N,#type{base={comp,"wxDateTime",List},single=true,name=Type,ref=Ref}, end, case Arg of arg -> w(" ~s ~s = ~s(~s);~n", [Type,N,Type,args(Name, ",", List)]); - opt when Ref =:= {pointer,1} -> - w(" ~sTmp = ~s(~s); ~s = & ~sTmp;~n", + opt when Ref =:= {pointer,1} -> + w(" ~sTmp = ~s(~s); ~s = & ~sTmp;~n", [N,Type,args(Name, ",", List), N,N]); opt -> w(" ~s = ~s(~s);~n", [N,Type,args(Name, ",", List)]) end, (A0+length(List)) rem 2; decode_arg(N,#type{base={comp,_,List},single=true,name=Type,ref=Ref},Arg,A0) -> - Decl = fun({int,Spec}) -> + Decl = fun({int,Spec}) -> w(" int * ~s~s = (int *) bp; bp += 4;~n", [N,Spec]); ({double, Spec}) -> w(" wxDouble * ~s~s = (wxDouble *) bp; bp += 8;~n", [N,Spec]) @@ -469,8 +495,8 @@ decode_arg(N,#type{base={comp,_,List},single=true,name=Type,ref=Ref},Arg,A0) -> Name = fun({_,Spec}) -> "*"++N++Spec end, case Arg of arg -> w(" ~s ~s = ~s(~s);~n", [Type,N,Type,args(Name, ",", List)]); - opt when Ref =:= {pointer,1} -> - w(" ~sTmp = ~s(~s); ~s = & ~sTmp;~n", + opt when Ref =:= {pointer,1} -> + w(" ~sTmp = ~s(~s); ~s = & ~sTmp;~n", [N,Type,args(Name, ",", List), N,N]); opt -> w(" ~s = ~s(~s);~n", [N,Type,args(Name, ",", List)]) @@ -479,7 +505,7 @@ decode_arg(N,#type{base={comp,_,List},single=true,name=Type,ref=Ref},Arg,A0) -> {int, _} -> (A0+length(List)) rem 2; {double, _} -> 0 end; - + decode_arg(N,#type{name=Class="wxTreeItemId",single=true},Arg,A0) -> A = align(A0,64), wa(" ~s ",[Class],"~s = wxTreeItemId((void *) *(wxUint64 *) bp); bp += 8;~n",[N],Arg), @@ -488,7 +514,7 @@ decode_arg(N,#type{name=Class="wxTreeItemIdValue",single=true},Arg,A0) -> A = align(A0,64), wa(" ~s ",[Class],"~s = (~s) * (wxUint64 *) bp; bp += 8;~n",[N,Class],Arg), A; -decode_arg(N,#type{name="wxChar", single=S},Arg,A0) +decode_arg(N,#type{name="wxChar", single=S},Arg,A0) when S =/= true -> w(" int * ~sLen = (int *) bp; bp += 4;~n", [N]), wa(" wxString", []," ~s = wxString(bp, wxConvUTF8);~n", [N],Arg), @@ -497,7 +523,7 @@ decode_arg(N,#type{name="wxChar", single=S},Arg,A0) decode_arg(N,#type{base=string, name="wxFileName"},Arg,A0) -> w(" int * ~sLen = (int *) bp; bp += 4;~n", [N]), wa(" wxString", []," ~sStr = wxString(bp, wxConvUTF8);~n", [N],Arg), - w(" bp += *~sLen+((8-((~p+ *~sLen) & 7)) & 7);~n", [N,4*((A0+1) rem 2),N]), + w(" bp += *~sLen+((8-((~p+ *~sLen) & 7)) & 7);~n", [N,4*((A0+1) rem 2),N]), w(" wxFileName ~s = wxFileName(~sStr);~n",[N,N]), 0; decode_arg(N,#type{base=string},Arg,A0) -> @@ -537,7 +563,7 @@ decode_arg(N,#type{name="wxArrayDouble"},arg,A0) -> decode_arg(_N,#type{base=eventType},_Arg,A0) -> %% w(" int * ~sLen = (int *) bp; bp += 4;~n", [N]), %% case Arg of -%% arg -> +%% arg -> %% w(" int ~s = wxeEventTypeFromAtom(bp);bp += *~sLen;~n",[N,N]), %% w(" char *class_name = bp;~n", []), %% w(" wxeCallbackData * Evt_cb = new wxeCallbackData(Ecmd.caller,This,class_name);~n", @@ -547,7 +573,7 @@ decode_arg(_N,#type{base=eventType},_Arg,A0) -> decode_arg(N,#type{name=Type,base=binary,mod=Mod0},Arg,A0) -> Mod = mods([M || M <- Mod0]), case Arg of - arg -> + arg -> w(" ~s~s * ~s = (~s~s*) Ecmd.bin[~p]->base;~n", [Mod,Type,N,Mod,Type, next_id(bin_count)]); opt -> @@ -560,10 +586,10 @@ decode_arg(N,#type{base={term,"wxTreeItemData"},mod=Mod0},Arg,A0) -> Type = "wxETreeItemData", BinCnt = next_id(bin_count), case Arg of - arg -> + arg -> w(" ~s~s * ~s = new ~s(Ecmd.bin[~p]->size, Ecmd.bin[~p]->base);~n", [Mod,Type,N,Type,BinCnt,BinCnt]); - opt -> + opt -> w(" ~s = new ~s(Ecmd.bin[~p]->size, Ecmd.bin[~p]->base);~n", [N,Type,BinCnt,BinCnt]) end, @@ -572,10 +598,10 @@ decode_arg(N,#type{name=Type,base={term,_},mod=Mod0},Arg,A0) -> Mod = mods([M || M <- Mod0]), BinCnt = next_id(bin_count), case Arg of - arg -> + arg -> w(" ~s~s * ~s = new ~s(Ecmd.bin[~p]);~n", [Mod,Type,N,Type,BinCnt]); - opt -> + opt -> w(" ~s = new ~s(Ecmd.bin[~p]);~n", [N,Type,BinCnt]) end, @@ -584,17 +610,17 @@ decode_arg(N,#type{single=array,base=int},Arg,A0) -> case Arg of arg -> w(" int * ~sLen = (int *) bp; bp += 4;~n", [N]), - w(" int * ~s = (int *) bp; bp += *~sLen*4+((~p+ *~sLen)%2 )*4;~n", + w(" int * ~s = (int *) bp; bp += *~sLen*4+((~p+ *~sLen)%2 )*4;~n", [N,N,(A0+1) rem 2,N]); - opt -> + opt -> w(" ~sLen = (int *) bp; bp += 4;~n", [N]), - w(" ~s = (int *) bp; bp += *~sLen*4+((~p+ *~sLen)%2 )*4;~n", + w(" ~s = (int *) bp; bp += *~sLen*4+((~p+ *~sLen)%2 )*4;~n", [N,N,(A0+1) rem 2,N]) end, 0; decode_arg(N,#type{by_val=true,single=array,base={comp,Class="wxPoint",_}},arg,A0) -> - w(" int * ~sLen = (int *) bp; bp += 4;~n", [N]), - w(" ~s *~s;~n",[Class,N]), + w(" int * ~sLen = (int *) bp; bp += 4;~n", [N]), + w(" ~s *~s;~n",[Class,N]), w(" ~s = (~s *) driver_alloc(sizeof(~s) * *~sLen);~n",[N,Class,Class,N]), store_free(N), w(" for(int i=0; i < *~sLen; i++) {~n", [N]), @@ -625,13 +651,13 @@ decode_arg(Name,T, Arg,_A) -> align(0, 32) -> 1; align(1, 32) -> 0; align(0, 64) -> 0; -align(1, 64) -> +align(1, 64) -> w(" bp += 4; /* Align */~n"), 0; align(N,Sz) -> align(N rem 2, Sz). -call_wx(_N,{constructor,_},#type{base={class,RClass}},Ps) -> +call_wx(_N,{constructor,_},#type{base={class,RClass}},Ps) -> #class{id=Id} = ClassDef = get({class,RClass}), Class = case is_derived(ClassDef) of true -> "E" ++ RClass; @@ -644,8 +670,8 @@ call_wx(_N,{constructor,_},#type{base={class,RClass}},Ps) -> case is_dialog(RClass) of true -> 2; %% Dialogs must be closed first event before windows false -> 0 - end; - false -> + end; + false -> case hd(reverse(wx_gen_erl:parents(RClass))) of root -> Id; _ -> 1 @@ -678,10 +704,10 @@ call_wx(N,{static,Class},Type,Ps) -> return_res(void) -> {"", ""}; return_res(Type = #type{mod=Mod}) -> case lists:member(const, Mod) of - true -> - {Beg, End} = return_res1(Type), + true -> + {Beg, End} = return_res1(Type), {"const " ++ Beg, End}; - _ -> + _ -> return_res1(Type) end. @@ -691,8 +717,8 @@ return_res1(#type{name=Type,ref={pointer,_}}) -> {Type ++ " * Result = (" ++ Type ++ "*)", ""}; return_res1(#type{name=Type,single=true,ref=reference}) -> {Type ++ " * Result = &", ""}; -return_res1(#type{name=Type,single=true,by_val=true}) - when is_atom(Type) -> +return_res1(#type{name=Type,single=true,by_val=true}) + when is_atom(Type) -> {atom_to_list(Type) ++ " Result = ", ""}; return_res1(#type{name=Type="wxArrayInt"}) -> {Type ++ " Result = ", ""}; @@ -701,19 +727,19 @@ return_res1(#type{name=Type,base={class,_},single=list,ref=reference}) -> return_res1(#type{name=Type,base={comp,_,_},single=array,by_val=true}) -> {Type ++ " Result = ", ""}; return_res1(#type{name=Type,single=true,by_val=true, base={class, _}}) -> - %% Memory leak !!!!!! XXXX BUGBUG FIXME or doument!! - case Type of + %% Memory leak !!!!!! XXXX BUGBUG FIXME or doument!! + case Type of "wxImage" -> ok; "wxFont" -> ok; "wxBitmap" -> ok; "wxIcon" -> ok; "wxGraphics" ++ _ -> ok; _ -> - io:format("~s::~s Building return value of temp ~s~n", + io:format("~s::~s Building return value of temp ~s~n", [get(current_class),get(current_func),Type]) end, %% #class{id=Id} = get({class,Type}), - {Type ++ " * Result = new " ++ Type ++ "(", "); newPtr((void *) Result," + {Type ++ " * Result = new " ++ Type ++ "(", "); newPtr((void *) Result," ++ "3, memenv);"}; return_res1(#type{base={enum,_Type},single=true,by_val=true}) -> {"int Result = " , ""}; @@ -726,7 +752,7 @@ return_res1(#type{name=Type,single=true,by_val=true}) -> filter(Ps) -> lists:filter(fun filter_arg/1, Ps). -filter_arg(#param{where=erl}) -> false; +filter_arg(#param{where=erl}) -> false; filter_arg(#param{where=this}) -> false; filter_arg(#param{}) -> true. %%filter_arg(#param{def=Def, in=In}) -> Def =:= none orelse In =:= false. @@ -735,20 +761,20 @@ filter_arg(#param{}) -> true. call_arg(#param{where=c, alt={length,Alt}}) when is_list(Alt) -> "*" ++ Alt ++ "Len"; call_arg(#param{where=c, alt={size,Id}}) when is_integer(Id) -> - %% It's a binary + %% It's a binary "Ecmd.bin["++ integer_to_list(Id) ++ "]->size"; -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 -> +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; _ -> N end; -call_arg(#param{name=N,type=#type{base={enum,Type}, by_val=true,single=true}}) -> +call_arg(#param{name=N,type=#type{base={enum,Type}, by_val=true,single=true}}) -> "(" ++ enum_type(Type) ++") " ++ N; 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}}) -> +call_arg(#param{name=N,type=#type{base=eventType}}) -> N ++ ", (wxObjectEventFunction)(wxEventFunction) &WxeApp::handle_evt, Evt_cb, this"; call_arg(#param{name=N,type=#type{by_val=true, single=_False}}) -> N; call_arg(#param{name=N,def=Def,type=#type{by_val=false, ref={pointer,2}}}) @@ -756,20 +782,20 @@ call_arg(#param{name=N,def=Def,type=#type{by_val=false, ref={pointer,2}}}) call_arg(#param{name=N,type=#type{by_val=false, ref={pointer,2}}}) -> "&" ++ N; call_arg(#param{name=N,in=false,type=#type{ref=reference, single=true}}) -> N; call_arg(#param{name=N,in=false,type=#type{by_val=false, single=true}}) -> "&" ++ N; -call_arg(#param{name=N,def=Def,type=#type{base={comp,_,_},ref={pointer,1},single=true}}) +call_arg(#param{name=N,def=Def,type=#type{base={comp,_,_},ref={pointer,1},single=true}}) when Def =:= none -> "&" ++N; call_arg(#param{name=N,type=#type{by_val=false}}) -> N; call_arg(#param{name=N,type={merged,_,#type{base={class,_},single=true, by_val=ByVal, - ref=Ref},_,_,_,_}}) - when ByVal =:= true; Ref =:= reference -> + ref=Ref},_,_,_,_}}) + when ByVal =:= true; Ref =:= reference -> "*" ++ N; -call_arg(#param{def=Def, type=void}) when Def =/= none -> Def; +call_arg(#param{def=Def, type=void}) when Def =/= none -> Def; call_arg(#param{name=N,type=#type{base={ref,_},by_val=true,single=true}}) -> N; call_arg(#param{name=N,type={merged,_,_,_,_,_,_}}) -> N. -%% call_arg(#param{name=N,type=#type{base=Tuple,ref=reference}}) +%% call_arg(#param{name=N,type=#type{base=Tuple,ref=reference}}) %% when is_tuple(Tuple) -> "&" ++ N; to_string(Type) when is_atom(Type) -> atom_to_list(Type); @@ -777,19 +803,19 @@ to_string(Type) when is_list(Type) -> Type. virtual_dest(#class{abstract=true, parent="root"}) -> false; virtual_dest(#class{abstract=true, parent="object"}) -> true; -virtual_dest(#class{abstract=true, parent=Parent}) -> +virtual_dest(#class{abstract=true, parent=Parent}) -> virtual_dest(get({class,Parent})); virtual_dest(#class{methods=Ms, parent=Parent}) -> case lists:keysearch(destructor,#method.method_type, lists:append(Ms)) of {value, #method{method_type=destructor, virtual=Virtual}} -> case Virtual of - undefined -> + undefined -> case get({class,Parent}) of - undefined -> + undefined -> case Parent of - "object" -> + "object" -> true; - "root" -> + "root" -> false; _ -> io:format("Error: ~p~n",[Parent]), @@ -798,10 +824,10 @@ virtual_dest(#class{methods=Ms, parent=Parent}) -> PClass -> virtual_dest(PClass) end; - _ -> + _ -> Virtual end; - false -> + false -> false end. @@ -815,24 +841,24 @@ is_derived(#class{abstract=true}) -> false; is_derived(C = #class{}) -> virtual_dest(C). is_window(Class) -> - lists:member("wxWindow", wx_gen_erl:parents(Class)). + lists:member("wxWindow", wx_gen_erl:parents(Class)). is_dialog(Class) -> lists:member("wxDialog", wx_gen_erl:parents(Class)). - + build_return_vals(Type,Ps) -> HaveType = case Type of void -> 0; _ -> 1 end, NoOut = lists:sum([1 || #param{in=In} <- Ps, In =/= true]) + HaveType, OutTupSz = if NoOut > 1 -> NoOut; true -> 0 end, - + build_ret_types(Type,Ps), - if + if OutTupSz > 1 -> w(" rt.addTupleCount(~p);~n",[OutTupSz]); true -> ignore - end, + end, Ps. -build_ret_types(void,Ps) -> +build_ret_types(void,Ps) -> Calc = fun(#param{name=N,in=False,type=T}, Free) when False =/= true -> case build_ret(N, False, T) of ok -> Free; @@ -841,7 +867,7 @@ build_ret_types(void,Ps) -> (_, Free) -> Free end, lists:foldl(Calc, [], Ps); -build_ret_types(Type,Ps) -> +build_ret_types(Type,Ps) -> Free = case build_ret("Result", out, Type) of ok -> []; FreeStr -> [FreeStr] @@ -850,8 +876,8 @@ build_ret_types(Type,Ps) -> case build_ret(N, False, T) of ok -> FreeAcc; FreeMe -> [FreeMe|FreeAcc] - end; - (_, FreeAcc) -> FreeAcc + end; + (_, FreeAcc) -> FreeAcc end, lists:foldl(Calc, Free, Ps). @@ -894,17 +920,17 @@ build_ret(Name,_,#type{name="wxArrayInt"}) -> build_ret(Name,_,#type{base={comp,_,_},single=array}) -> w(" for(unsigned int i=0; i < ~s.GetCount(); i++) {~n", [Name]), w(" rt.add(~s[i]);~n }~n",[Name]), - w(" rt.endList(~s.GetCount());~n",[Name]); + w(" rt.endList(~s.GetCount());~n",[Name]); build_ret(Name,_,#type{name=List,single=list,base={class,Class}}) -> w(" int i=0;~n"), w(" for(~s::const_iterator it = ~s.begin(); it != ~s.end(); ++it) {~n", [List, Name, Name]), w(" ~s * ~sTmp = *it;~n", [Class,Name]), w(" rt.addRef(getRef((void *)~sTmp,memenv), \"~s\"); i++;}~n",[Name,Class]), - w(" rt.endList(~s.GetCount());~n",[Name]); - + w(" rt.endList(~s.GetCount());~n",[Name]); + build_ret(Name,_,#type{name="wxArrayTreeItemIds"}) -> - w(" for(unsigned int i=0; i < ~s.GetCount(); i++) {~n", [Name]), + w(" for(unsigned int i=0; i < ~s.GetCount(); i++) {~n", [Name]), w(" rt.add((wxUIntPtr *)~s[i].m_pItem);}~n",[Name]), w(" rt.endList(~s.GetCount());~n",[Name]); @@ -919,10 +945,10 @@ build_ret(Name,_,#type{name="wxArrayString", single=array}) -> w(" rt.add(~s);~n", [Name]); build_ret(Name,In,T) -> ?error({nyi, Name,In, T}). - + mods([const|R]) -> "const " ++ mods(R); mods([unsigned|R]) -> "unsigned " ++ mods(R); -mods([]) -> "". +mods([]) -> "". build_enums() -> Tree = get(consts), @@ -931,13 +957,13 @@ build_enums() -> w("#include \"../wxe_impl.h\"~n"), w("#include \"wxe_macros.h\"~n"), w("#include \"../wxe_return.h\"~n"), - w("void WxeApp::init_nonconsts(wxeMemEnv *memenv, ErlDrvTermData caller) {~n"), + w("void WxeApp::init_nonconsts(wxeMemEnv *memenv, ErlDrvTermData caller) {~n"), NotConsts = [NC || NC = #const{is_const=false} <- gb_trees:values(Tree)], Size = length(NotConsts), GVars = get(gvars), GSize = length(GVars), w(" wxeReturn rt = wxeReturn(WXE_DRV_PORT, caller);~n"), - w(" rt.addAtom((char*)\"wx_consts\");~n"), + w(" rt.addAtom((char*)\"wx_consts\");~n"), [build_enum(NConst) || NConst <- lists:keysort(#const.val, NotConsts)], _Cnt = foldl(fun(Gvar, I) -> build_gvar(Gvar,I) end, 0, lists:sort(GVars)), w(" rt.endList(~p);~n", [Size+GSize]), @@ -964,9 +990,9 @@ build_gvar({Name, Class, _Id}, Cnt) -> Cnt+1. gen_macros() -> - w("#include <wx/caret.h>~n"), %% Arrg wxw forgot?? some files - w("#include <wx/tooltip.h>~n"), - w("#include <wx/gbsizer.h>~n"), + w("#include <wx/caret.h>~n"), %% Arrg wxw forgot?? some files + w("#include <wx/tooltip.h>~n"), + w("#include <wx/gbsizer.h>~n"), w("#include <wx/splash.h>~n"), w("#include <wx/grid.h>~n"), w("#include <wx/image.h>~n"), @@ -991,15 +1017,15 @@ gen_macros() -> w("#include <wx/stc/stc.h>~n"), w("#include <wx/minifram.h>~n"), w("#include <wx/sashwin.h>~n"), - w("#include <wx/laywin.h>~n"), - w("#include <wx/graphics.h>~n"), - w("#include <wx/aui/aui.h>~n"), - w("#include <wx/datectrl.h>~n"), - w("#include <wx/filepicker.h>~n"), - w("#include <wx/fontpicker.h>~n"), - w("#include <wx/clrpicker.h>~n"), - w("#include <wx/statline.h>~n"), - w("#include <wx/clipbrd.h>~n"), + w("#include <wx/laywin.h>~n"), + w("#include <wx/graphics.h>~n"), + w("#include <wx/aui/aui.h>~n"), + w("#include <wx/datectrl.h>~n"), + w("#include <wx/filepicker.h>~n"), + w("#include <wx/fontpicker.h>~n"), + w("#include <wx/clrpicker.h>~n"), + w("#include <wx/statline.h>~n"), + w("#include <wx/clipbrd.h>~n"), w("#include <wx/splitter.h>~n"), w("#include <wx/choicebk.h>~n"), w("#include <wx/toolbook.h>~n"), @@ -1008,9 +1034,14 @@ gen_macros() -> w("#include <wx/html/htmlwin.h>~n"), w("#include <wx/html/htmlcell.h>~n"), w("#include <wx/filename.h>~n"), - + + w("~n~n", []), + w("#ifndef wxICON_DEFAULT_BITMAP_TYPE~n",[]), + w(" #define wxICON_DEFAULT_BITMAP_TYPE wxBITMAP_TYPE_ICO_RESOURCE~n",[]), + w("#endif~n", []), w("~n~n", []), - [w("#define ~s_~s ~p~n", [Class,Name,Id]) || + + [w("#define ~s_~s ~p~n", [Class,Name,Id]) || {Class,Name,_,Id} <- wx_gen_erl:get_unique_names()], w("~n~n"). @@ -1023,29 +1054,29 @@ build_events() -> w("#include \"wxe_macros.h\"~n"), w("#include \"../wxe_events.h\"~n~n"), w("#include \"../wxe_return.h\"~n~n"), - + w("wxeEtype::wxeEtype(const char *name, int Id) {eName = name;cID = Id;}~n~n"), w("WX_DECLARE_HASH_MAP(int, wxeEtype*, wxIntegerHash, wxIntegerEqual, wxeETmap );~n~n"), - + w("wxeETmap etmap;~n~n"), - + w( "int wxeEventTypeFromAtom(char *etype_atom) { wxeETmap::iterator it; for(it = etmap.begin(); it != etmap.end(); ++it) { wxeEtype * value = it->second; - if(strcmp(value->eName, etype_atom) == 0) { - if(it->first > wxEVT_USER_FIRST) { + if(strcmp(value->eName, etype_atom) == 0) { + if(it->first > wxEVT_USER_FIRST) { return it->first - wxEVT_USER_FIRST; } else { return it->first; } } - } - return -1; + } + return -1; } -"), +"), Evs0 = [C || {_,C=#class{event=Evs}} <- get(), Evs =/= false], Evs = lists:keysort(#class.id, Evs0), @@ -1058,7 +1089,7 @@ initEventTable(Evs) -> w(" struct { ",[]), w("int ev_type; int class_id; const char * ev_name;} event_types[] =~n {~n",[]), - lists:foreach(fun(Ev) -> init_event_classes(Ev) end, + lists:foreach(fun(Ev) -> init_event_classes(Ev) end, [#class{id=0,event=[wxEVT_NULL]}|Evs]), w(" {-1, 0, ""}~n };~n",[]), w(" for(int i=0; event_types[i].ev_type != -1; i++) {~n",[]), @@ -1076,7 +1107,7 @@ initEventTable(Evs) -> " }~n" " }~n", []), w("}~n~n"). - + init_event_classes(#class{event=ETs, id=Id}) -> F = fun({Eev, Cev, OtherClass}) -> w(" {~w + wxEVT_USER_FIRST, ~w, ~p},~n", @@ -1096,7 +1127,7 @@ find_id(OtherClass) -> Class = get({class,atom_to_list(OtherClass)}), %%{value, Class} = lists:keysearch(atom_to_list(OtherClass), #class.name, All), Class#class.id. - + encode_events(Evs) -> ?WTC("encode_events"), w("void wxeEvtListener::forward(wxEvent& event)~n" @@ -1123,7 +1154,7 @@ encode_events(Evs) -> " wxeMemEnv *memenv = app->getMemEnv(port);~n" " if(!memenv) return 0;~n~n" " wxeReturn rt = wxeReturn(port, cb->listener);~n"), - + w("~n rt.addAtom((char*)\"wx\");~n" " rt.addInt((int) event->GetId());~n" " rt.addRef(getRef((void *)(cb->obj), memenv), cb->class_name);~n" @@ -1146,15 +1177,15 @@ encode_events(Evs) -> w(" app->clearPtr((void *) event);~n"), w(" } else {~n"), w(" send_res = rt.send();~n"), - w(" if(cb->skip) event->Skip();~n"), + w(" if(cb->skip) event->Skip();~n"), w(" };~n"), w(" return send_res;~n"), w(" }~n"). encode_event(C = #class{name=Class, id=Id, options=Opts}) -> ?WTC("encode_event"), - case proplists:get_value("mixed_event", Opts) of - undefined -> + case proplists:get_value("mixed_event", Opts) of + undefined -> w("case ~p: {// ~s~n", [Id,Class]), encode_event2(C), ok; @@ -1180,10 +1211,10 @@ encode_event2(Class = #class{name=Name}) -> build_event_attrs(ClassRec = #class{name=Class}) -> Attrs0 = wx_gen_erl:filter_attrs(ClassRec), - Rename = - fun(Att = #param{name=Name,prot=public,acc=undefined}, {All,Use}) -> + Rename = + fun(Att = #param{name=Name,prot=public,acc=undefined}, {All,Use}) -> {[Att#param{name= "ev->" ++ Name}|All],Use}; - (Att = #param{acc=Acc}, {All,_}) -> + (Att = #param{acc=Acc}, {All,_}) -> {[Att#param{name= "ev->" ++ Acc}|All], true} end, case foldr(Rename,{[],false},Attrs0) of @@ -1193,9 +1224,9 @@ build_event_attrs(ClassRec = #class{name=Class}) -> %% Attrs; {Attrs,_} -> w(" ~s * ev = (~s *) event;~n",[Class,Class]), - FixClass = + FixClass = fun(P=#param{name=N,acc=Acc,type=#type{single=Single,by_val=ByVal, - base={class,C}}}) + base={class,C}}}) when Acc =/= undefined -> Var = var_name(N), if Single, ByVal -> @@ -1206,17 +1237,17 @@ build_event_attrs(ClassRec = #class{name=Class}) -> end, P#param{name=Var}; (P) -> P - end, + end, lists:map(FixClass, Attrs) end. -var_name("ev->" ++ Name0) -> +var_name("ev->" ++ Name0) -> case reverse(Name0) of ")(" ++ Name -> reverse(Name); _ -> Name0 end; var_name(Name) -> Name. - + enum_name({Class,Type}) -> uppercase_all(Class ++ "_" ++ Type); enum_name(Type) -> diff --git a/lib/wx/api_gen/wx_gen_erl.erl b/lib/wx/api_gen/wx_gen_erl.erl index d75442d307..e882ae87ca 100644 --- a/lib/wx/api_gen/wx_gen_erl.erl +++ b/lib/wx/api_gen/wx_gen_erl.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% Copyright Ericsson AB 2008-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -19,7 +19,7 @@ %%%------------------------------------------------------------------- %%% File : wx_gen_erl.erl %%% Author : Dan Gudmundsson <[email protected]> -%%% Description : +%%% Description : %%% %%% Created : 25 Jan 2007 by Dan Gudmundsson <[email protected]> %%%------------------------------------------------------------------- @@ -32,7 +32,7 @@ -import(lists, [foldl/3,foldr/3,reverse/1, keysearch/3, map/2, filter/2]). -import(gen_util, [lowercase/1, lowercase_all/1, uppercase/1, uppercase_all/1, - open_write/1, close/0, erl_copyright/0, w/2, + open_write/1, close/0, erl_copyright/0, w/2, args/3, args/4, strip_name/2]). gen(Defs) -> @@ -42,9 +42,9 @@ gen(Defs) -> gen_enums_ints(), [gen_class(Class) || Class <- Defs], gen_funcnames(). - + gen_class(Class) -> - try + try gen_class1(Class) catch throw:skipped -> Class @@ -52,10 +52,10 @@ gen_class(Class) -> gen_class1(C=#class{name=Name,parent="static",methods=Ms,options=_Opts}) -> open_write("../src/gen/wx_misc.erl"), - put(current_class, Name), + put(current_class, Name), erl_copyright(), w("", []), - w("%% This file is generated DO NOT EDIT~n~n", []), + w("%% This file is generated DO NOT EDIT~n~n", []), w("%% @doc See external documentation: " "<a href=\"http://www.wxwidgets.org/manuals/stable/wx_miscellany.html\">Misc</a>.\n\n",[]), @@ -67,8 +67,8 @@ gen_class1(C=#class{name=Name,parent="static",methods=Ms,options=_Opts}) -> Exp = fun(M) -> gen_export(C,M) end, ExportList = lists:usort(lists:append(lists:map(Exp,reverse(Ms)))), w("-export([~s]).~n~n", [args(fun(EF) -> EF end, ",", ExportList, 60)]), - - + + Gen = fun(M) -> gen_method(Name,M) end, NewMs = lists:map(Gen,reverse(Ms)), close(), @@ -79,13 +79,13 @@ gen_class1(C=#class{name=Name,parent=Parent,methods=Ms,options=Opts}) -> case Opts of ["ignore"] -> throw(skipped); _ -> ok - end, + end, open_write("../src/gen/"++Name++".erl"), - put(current_class, Name), + put(current_class, Name), erl_copyright(), w("", []), - w("%% This file is generated DO NOT EDIT~n~n", []), - + w("%% This file is generated DO NOT EDIT~n~n", []), + case lists:member(taylormade, Opts) of true -> {ok, Bin} = file:read_file(filename:join([wx_extra, Name++".erl"])), @@ -95,33 +95,33 @@ gen_class1(C=#class{name=Name,parent=Parent,methods=Ms,options=Opts}) -> w("%% @doc See external documentation: " "<a href=\"http://www.wxwidgets.org/manuals/stable/wx_~s.html\">~s</a>.\n", [lowercase_all(Name), Name]), - + case C#class.doc of undefined -> ignore; Str -> w("%%~n%% ~s~n~n%%~n", [Str]) end, - + case C#class.event of false -> ignore; Evs -> EvTypes = [event_type_name(Ev) || Ev <- Evs], EvStr = args(fun(Ev) -> "<em>"++Ev++"</em>" end, ", ", EvTypes), - + w("%% <dl><dt>Use {@link wxEvtHandler:connect/3.} with EventType:</dt>~n",[]), w("%% <dd>~s</dd></dl>~n", [EvStr]), - w("%% See also the message variant {@link wxEvtHandler:~s(). #~s{}} event record type.~n", + w("%% See also the message variant {@link wxEvtHandler:~s(). #~s{}} event record type.~n", [event_rec_name(Name),event_rec_name(Name)]), w("%%~n",[]), ok end, - + Parents = parents(Parent), case [P || P <- Parents, P =/= root, P =/= object] of [] -> ignore; - Ps -> + Ps -> w("%% <p>This class is derived (and can use functions) from:~n", []), [w("%% <br />{@link ~s}~n", [P]) || P <- Ps], - w("%% </p>~n",[]) + w("%% </p>~n",[]) end, w("%% @type ~s(). An object reference, The representation is internal~n",[Name]), w("%% and can be changed without notice. It can't be used for comparsion~n", []), @@ -137,17 +137,17 @@ gen_class1(C=#class{name=Name,parent=Parent,methods=Ms,options=Opts}) -> Done0 = ["Destroy", "New", "Create", "destroy", "new", "create"], Done = gb_sets:from_list(Done0 ++ [M|| #method{name=M} <- lists:append(Ms)]), {_, InExported} = gen_inherited(Parents, Done, []), - w("-export([~s]).~n~n", [args(fun(EF) -> EF end, ",", - lists:usort(["parent_class/1"|InExported]), + w("-export([~s]).~n~n", [args(fun(EF) -> EF end, ",", + lists:usort(["parent_class/1"|InExported]), 60)]), - + w("%% @hidden~n", []), parents_check(Parents), - + Gen = fun(M) -> gen_method(Name,M) end, NewMs = lists:map(Gen,reverse(Ms)), - gen_dest(C, Ms), - + gen_dest(C, Ms), + gen_inherited(Parents, Done, true) end, @@ -203,26 +203,26 @@ gen_export(#class{name=Class,abstract=Abs},Ms0) -> [] -> []; [M=#method{where=taylormade}|_] -> [taylormade_export(Class, M)]; - Ms -> + Ms -> GetF = fun(#method{method_type=constructor,where=W,params=Ps}) -> {Args,Opts} = split_optional(Ps), - OptLen = case Opts of - [] -> 0; + OptLen = case Opts of + [] -> 0; _ when W =:= erl_no_opt -> 0; - _ -> 1 + _ -> 1 end, "new/" ++ integer_to_list(length(Args)+OptLen); (#method{method_type=destructor}) -> - case Abs of - true -> []; + case Abs of + true -> []; _ -> "destroy/1" end; (#method{name=N,alias=A,where=W, params=Ps}) -> {Args,Opts} = split_optional(Ps), - OptLen = case Opts of - [] -> 0; + OptLen = case Opts of + [] -> 0; _ when W =:= erl_no_opt -> 0; - _ -> 1 + _ -> 1 end, erl_func_name(N,A) ++ "/" ++ integer_to_list(length(Args) + OptLen) end, @@ -235,10 +235,10 @@ gen_method(Class,Ms0) -> Res = filter(RemoveC, Ms0), case Res of [] -> Ms0; - [M=#method{where=taylormade}|_] -> - taylormade_func(Class, M), + [#method{where=taylormade}|_] -> + taylormade_func(Class, Res), Ms0; - Ms -> + Ms -> gen_doc(Class,Ms), gen_method1(Ms), Ms0 @@ -270,14 +270,31 @@ 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 gen_util:get_hook(erl, M#method.pre_hook) of + ignore -> skip; + Pre -> w(" ~s~n", [Pre]) + end, + + case gen_util:get_hook(erl, M#method.post_hook) of + ignore -> skip; + _ -> w(" _Result =", []) + end, + case have_return_vals(T, Ps) of _ when MT =:= constructor -> w(" wxe_util:construct(~s,~n <<~s~s>>)", [MId, MArgs,MOpts]); true -> w(" wxe_util:call(~s,~n <<~s~s>>)", [MId, MArgs,MOpts]); - false -> + false -> w(" wxe_util:cast(~s,~n <<~s~s>>)", [MId, MArgs,MOpts]) end, + 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), M. @@ -289,9 +306,9 @@ gen_dest(#class{name=CName,abstract=Abs}, Ms) -> case lists:keysearch(destructor,#method.method_type, lists:append(Ms)) of {value, #method{method_type=destructor, id=Id}} -> case hd(reverse(parents(CName))) of - object -> + object -> gen_dest2(CName, object); - root -> + root -> gen_dest2(CName, Id) end; false -> @@ -303,7 +320,7 @@ gen_dest2(Class, Id) -> w("%% @spec (This::~s()) -> ok~n", [Class]), w("%% @doc Destroys this object, do not use object again~n", []), w("destroy(Obj=#wx_ref{type=Type}) ->~n", []), - w(" ?CLASS(Type,~s),~n",[Class]), + w(" ?CLASS(Type,~s),~n",[Class]), case Id of object -> w(" wxe_util:destroy(?DESTROY_OBJECT,Obj),~n ok.~n", []); @@ -324,14 +341,14 @@ gen_inherited([Parent|Ps], Done0, Exported0) -> gen_inherited(Ps, gb_sets:union(Done,Done0), Exported). gen_inherited_ms([[#method{name=Name,alias=A,params=Ps0,where=W,method_type=MT}|_]|R], - Class,Skip,Done, Exported) - when W =/= merged_c -> + Class,Skip,Done, Exported) + when W =/= merged_c -> case gb_sets:is_member(Name,Skip) of false when MT =:= member, Exported =:= true -> Ps = [patch_param(P,all) || P <- Ps0], Opts = if W =:= erl_no_opt -> []; - true -> - [Opt || Opt = #param{def=Def,in=In, where=Where} <- Ps, + true -> + [Opt || Opt = #param{def=Def,in=In, where=Where} <- Ps, Def =/= none, In =/= false, Where =/= c] end, w("%% @hidden~n", []), @@ -342,10 +359,10 @@ gen_inherited_ms([[#method{name=Name,alias=A,params=Ps0,where=W,method_type=MT}| gen_inherited_ms(R,Class, Skip, gb_sets:add(Name,Done), Exported); false when MT =:= member, is_list(Exported) -> {Args,Opts} = split_optional(Ps0), - OptLen = case Opts of - [] -> 0; + OptLen = case Opts of + [] -> 0; _ when W =:= erl_no_opt -> 0; - _ -> 1 + _ -> 1 end, Export = erl_func_name(Name,A) ++ "/" ++ integer_to_list(length(Args) + OptLen), gen_inherited_ms(R,Class,Skip, gb_sets:add(Name,Done), [Export|Exported]); @@ -357,17 +374,21 @@ gen_inherited_ms([[_|Check]|R],Class,Skip, Done0,Exp) -> gen_inherited_ms([[]|R],Class,Skip,Done0,Exp) -> gen_inherited_ms(R,Class,Skip,Done0,Exp); gen_inherited_ms([], _, _Skip, Done,Exp) -> {Done,Exp}. - + %%%%%%%%%%%%%%% -taylormade_func(Class, #method{name=Name, id=Id}) -> +taylormade_func(Class, [#method{name=Name, id=Id}|_]) -> {ok, Bin} = file:read_file(filename:join([wx_extra, Class ++".erl"])), - Str0 = binary_to_list(Bin), - {match, [Str1]} = re:run(Str0, "<<"++Name++"(.*)"++Name++">>", - [dotall, {capture, all_but_first, list}]), - - w(Str1, ["?" ++ get_unique_name(Id)]), + Src = binary_to_list(Bin), + Str = case gen_util:get_taylor_made(Src, Name) of + nomatch -> + {match, [Str0]} = gen_util:get_taylor_made(Src, get_unique_name(Id)), + Str0; + {match, [Str0]} -> + Str0 + end, + w(Str, ["?" ++ get_unique_name(Id)]), ok. taylormade_export(Class, #method{name=Name}) -> @@ -381,12 +402,12 @@ taylormade_export(Class, #method{name=Name}) -> arg_type_tests([P|Ps], Mid0) -> case arg_type_test(P,"\n",Mid0) of - Mid0 -> + Mid0 -> arg_type_tests(Ps, Mid0); Mid -> %% Already checked the other args Mid end; -arg_type_tests([],Mid) -> Mid. +arg_type_tests([],Mid) -> Mid. arg_type_test(#param{where=c}, _, Acc) -> Acc; @@ -395,7 +416,7 @@ arg_type_test(#param{name=Name0,in=In,type=#type{base={class,T},single=true},def Name = erl_arg_name(Name0), w(" ?CLASS(~sT,~s),~s", [Name,T,EOS]), Acc; -arg_type_test(#param{name=Name0,in=In,type=#type{base={class,T}}, def=none},EOS,Acc) +arg_type_test(#param{name=Name0,in=In,type=#type{base={class,T}}, def=none},EOS,Acc) when In =/= false -> Name = erl_arg_name(Name0), w(" [?CLASS(~sT,~s) || #wx_ref{type=~sT} <- ~s],~s", [Name,T,Name,Name,EOS]), @@ -403,35 +424,35 @@ arg_type_test(#param{name=Name0,in=In,type=#type{base={class,T}}, def=none},EOS, arg_type_test(#param{name=Name0,def=none,in=In, type={merged, M1, #type{base={class,T1},single=true},Ps1, - M2, #type{base={class,T2},single=true},Ps2}}, EOS, _Acc) + M2, #type{base={class,T2},single=true},Ps2}}, EOS, _Acc) when In =/= false -> Name = erl_arg_name(Name0), Opname = Name++"OP", w(" ~s = case ?CLASS_T(~sT,~s) of~n true ->\n ", [Opname,Name,T1]), - lists:foreach(fun(Param) -> arg_type_test(Param,"\n ", ignore) end, + lists:foreach(fun(Param) -> arg_type_test(Param,"\n ", ignore) end, element(1,split_optional(Ps1))), w("?~s;~n",[get_unique_name(M1)]), w(" _ -> ?CLASS(~sT,~s),\n ",[Name,T2]), {Ps21,_} = split_optional(patchArgName(Ps2,Ps1)), - lists:foreach(fun(Param) -> arg_type_test(Param,"\n ", ignore) end, + lists:foreach(fun(Param) -> arg_type_test(Param,"\n ", ignore) end, Ps21), w("?~s\n end,~s",[get_unique_name(M2),EOS]), Opname; -arg_type_test(#param{name=Name0, type=#type{base=eventType}}, EOS, Acc) -> +arg_type_test(#param{name=Name0, type=#type{base=eventType}}, EOS, Acc) -> Name = erl_arg_name(Name0), w(" ~sBin = list_to_binary([atom_to_list(~s)|[0]]),~s", [Name,Name,EOS]), w(" ThisTypeBin = list_to_binary([atom_to_list(ThisT)|[0]]),~s", [EOS]), Acc; -arg_type_test(#param{name=Name0,def=none,type=#type{base={term,_}}}, EOS, Acc) -> +arg_type_test(#param{name=Name0,def=none,type=#type{base={term,_}}}, EOS, Acc) -> Name = erl_arg_name(Name0), w(" wxe_util:send_bin(term_to_binary(~s)),~s", [Name,EOS]), Acc; -arg_type_test(#param{name=Name0,type=#type{base=binary}},EOS,Acc) -> +arg_type_test(#param{name=Name0,type=#type{base=binary}},EOS,Acc) -> Name = erl_arg_name(Name0), w(" wxe_util:send_bin(~s),~s", [Name,EOS]), Acc; -arg_type_test(#param{name=Name0,type=#type{name=Type,base=Base,single=Single}},EOS,Acc) -> - if +arg_type_test(#param{name=Name0,type=#type{name=Type,base=Base,single=Single}},EOS,Acc) -> + if Type =:= "wxArtClient", Single =:= true -> Name = erl_arg_name(Name0), w(" ~s_UC = unicode:characters_to_binary([~s, $_, $C,0]),~s", @@ -441,11 +462,11 @@ arg_type_test(#param{name=Name0,type=#type{name=Type,base=Base,single=Single}},E w(" ~s_UC = unicode:characters_to_binary([~s,0]),~s", [Name,Name,EOS]); Type =:= "wxArrayString" -> Name = erl_arg_name(Name0), - w(" ~s_UCA = [unicode:characters_to_binary([~sTemp,0]) || ~s", + w(" ~s_UCA = [unicode:characters_to_binary([~sTemp,0]) || ~s", [Name,Name, EOS]), w(" ~sTemp <- ~s],~s", [Name,Name,EOS]); true -> %% Not a string - ignore + ignore end, Acc; arg_type_test(_,_,Acc) -> Acc. @@ -459,10 +480,10 @@ have_return_vals(void, Ps) -> have_return_vals(#type{}, _) -> true. gen_function_clause(Name0,MT,Ps,Optional,Variant) -> - PArg = fun(Arg) -> + PArg = fun(Arg) -> case lists:member(name_only, Variant) of true -> func_arg_name(Arg); - false -> + false -> case lists:member(name_type, Variant) of true -> Name = func_arg_name(Arg), @@ -478,17 +499,17 @@ gen_function_clause(Name0,MT,Ps,Optional,Variant) -> Args = args(PArg, ",", Ps), Name = case MT of constructor -> "new"; _ -> Name0 end, w("~s(~s",[Name,Args]), - Opts = case Optional of + Opts = case Optional of [] -> ""; empty_list when Args =:= [] -> "[]"; empty_list -> ", []"; _ when Args =:= [] -> "Options"; - _ -> ", Options" + _ -> ", Options" end, w("~s)", [Opts]), case lists:member(no_guards, Variant) of true -> ok; - false -> + false -> Guards = args(fun guard_test/1, ",", Ps), if Guards =:= [], Opts =:= "" -> w(" ->~n", []); @@ -500,10 +521,10 @@ gen_function_clause(Name0,MT,Ps,Optional,Variant) -> split_optional(Ps) -> split_optional(Ps, [], []). -split_optional([P=#param{def=Def,in=In, where=Where}|Ps], Standard, Opts) +split_optional([P=#param{def=Def,in=In, where=Where}|Ps], Standard, Opts) when Def =/= none, In =/= false, Where =/= c -> split_optional(Ps, Standard, [P|Opts]); -split_optional([P=#param{def=Def,in=In, where=Where}|Ps], Standard, Opts) +split_optional([P=#param{def=Def,in=In, where=Where}|Ps], Standard, Opts) when Def =:= none, In =/= false, Where =/= c -> split_optional(Ps, [P|Standard], Opts); split_optional([_|Ps], Standard, Opts) -> @@ -515,24 +536,24 @@ patch_param(P=#param{type=#type{base=Tuple}}, all) when is_tuple(Tuple) -> P#param{type={class,ignore}}; patch_param(P=#param{type={merged,_,_,_,_,_,_}}, _) -> P#param{type={class,ignore}}; -patch_param(P=#param{type=#type{base={class,_}}},_) -> +patch_param(P=#param{type=#type{base={class,_}}},_) -> P#param{type={class,ignore}}; -patch_param(P=#param{type=#type{base={ref,_}}},_) -> +patch_param(P=#param{type=#type{base={ref,_}}},_) -> P#param{type={class,ignore}}; patch_param(P,_) -> P. func_arg_name(#param{def=Def}) when Def =/= none -> skip; func_arg_name(#param{in=false}) -> skip; func_arg_name(#param{where=c}) -> skip; -func_arg_name(#param{name=Name}) -> +func_arg_name(#param{name=Name}) -> erl_arg_name(Name). func_arg(#param{def=Def}) when Def =/= none -> skip; func_arg(#param{in=false}) -> skip; func_arg(#param{where=c}) -> skip; -func_arg(#param{name=Name,type=#type{base=string}}) -> +func_arg(#param{name=Name,type=#type{base=string}}) -> erl_arg_name(Name); -func_arg(#param{name=Name,type=#type{name="wxArrayString"}}) -> +func_arg(#param{name=Name,type=#type{name="wxArrayString"}}) -> erl_arg_name(Name); func_arg(#param{name=Name0,type=#type{base={class,_CN}, single=true}}) -> Name = erl_arg_name(Name0), @@ -553,7 +574,7 @@ func_arg(#param{name=Name,type=#type{base={comp,"wxDateTime",_Tup}, single=true} func_arg(#param{name=Name,type=#type{name="wxArtClient", single=true}}) -> erl_arg_name(Name); func_arg(#param{name=Name,type=#type{base={comp,_,Tup}, single=true}}) -> - N = erl_arg_name(Name), + N = erl_arg_name(Name), Doc = fun({_,V}) -> erl_arg_name(N)++V end, "{" ++ args(Doc, ",", Tup) ++ "}"; func_arg(#param{name=Name}) -> @@ -570,7 +591,7 @@ guard_test(#param{name=N, type=#type{name="wxArtClient"}}) -> "is_list(" ++ erl_arg_name(N) ++")"; guard_test(#param{name=N, type=#type{name="wxArrayString"}}) -> "is_list(" ++ erl_arg_name(N) ++")"; -guard_test(#param{name=Name,type=#type{single=Single}}) +guard_test(#param{name=Name,type=#type{single=Single}}) when Single =/= true-> "is_list(" ++ erl_arg_name(Name) ++ ")"; guard_test(#param{name=N,type=#type{base=int}}) -> @@ -620,42 +641,42 @@ gen_doc(_Class,[#method{name=N,alias=A,params=Ps,type=T,where=erl_no_opt,method_ gen_function_clause(erl_func_name(N,A),MT,Ps,empty_list,[no_guards,name_only]); gen_doc(Class,[#method{name=N,params=Ps,type=T}])-> {_, Optional} = split_optional(Ps), - NonDef = [Arg || Arg = #param{def=Def,in=In, where=Where} <- Ps, + NonDef = [Arg || Arg = #param{def=Def,in=In, where=Where} <- Ps, Def =:= none, In =/= false, Where =/= c], OptsType = case Optional of [] -> ""; _ when NonDef =:= [] -> "[Option]"; - _ -> ", [Option]" + _ -> ", [Option]" end, w("%% @spec (~s~s) -> ~s~n", [doc_arg_types(Ps),OptsType,doc_return_types(T,Ps)]), doc_optional(Optional, normal), - DocEnum = doc_enum(T,Ps, normal), + DocEnum = doc_enum(T,Ps, normal), case Class of "utils" -> w("%% @doc See <a href=\"http://www.wxwidgets.org/manuals/stable/wx_miscellany.html#~s\">" - "external documentation</a>.~n", + "external documentation</a>.~n", [lowercase_all(N)]); _ -> w("%% @doc See <a href=\"http://www.wxwidgets.org/manuals/stable/wx_~s.html#~s~s\">" - "external documentation</a>.~n", + "external documentation</a>.~n", [lowercase_all(Class),lowercase_all(Class),lowercase_all(N)]) end, doc_enum_desc(DocEnum); gen_doc(Class, Cs = [#method{name=N, alias=A,method_type=MT}|_]) -> - GetRet = fun(#method{params=Ps,type=T}) -> + GetRet = fun(#method{params=Ps,type=T}) -> doc_return_types(T,Ps) end, - GetArgs = fun(#method{params=Ps, where=Where}) -> + GetArgs = fun(#method{params=Ps, where=Where}) -> Opt = case Where of erl_no_opt -> []; - _ -> + _ -> case split_optional(Ps) of {_, []} -> []; _ -> ["[Option]"] end end, - [doc_arg_type(P) || + [doc_arg_type(P) || P=#param{in=In,def=none,where=W} <- Ps, In =/= false, W =/= c] ++ Opt end, @@ -665,16 +686,16 @@ gen_doc(Class, Cs = [#method{name=N, alias=A,method_type=MT}|_]) -> case Class of "utils" -> w("%% @doc See <a href=\"http://www.wxwidgets.org/manuals/stable/wx_miscellany.html#~s\">" - "external documentation</a>.~n", + "external documentation</a>.~n", [lowercase_all(N)]); _ -> w("%% @doc See <a href=\"http://www.wxwidgets.org/manuals/stable/wx_~s.html#~s~s\">" - "external documentation</a>.~n", + "external documentation</a>.~n", [lowercase_all(Class),lowercase_all(Class),lowercase_all(N)]) end, Name = case MT of constructor -> "new"; _ -> erl_func_name(N,A) end, w("%% <br /> Alternatives:~n",[]), - [gen_doc2(Name, Clause) || Clause <- Cs], + [gen_doc2(Name, Clause) || Clause <- Cs], ok. gen_doc2(Name,#method{params=Ps,where=erl_no_opt,method_type=MT}) -> @@ -687,11 +708,11 @@ gen_doc2(Name,#method{params=Ps,type=T}) -> OptsType = case Optional of [] -> ""; _ when NonDef =:= [] -> "[Option]"; - _ -> ", [Option]" + _ -> ", [Option]" end, w("%% <p><c>~n",[]), w("%% ~s(~s~s) -> ~s </c>~n", - [Name,doc_arg_types(Ps),OptsType,doc_return_types(T,Ps)]), + [Name,doc_arg_types(Ps),OptsType,doc_return_types(T,Ps)]), doc_optional(Optional, xhtml), DocEnum = doc_enum(T,Ps, xhtml), doc_enum_desc(DocEnum), @@ -700,7 +721,7 @@ gen_doc2(Name,#method{params=Ps,type=T}) -> doc_arg(ArgList) -> case all_eq(ArgList) of true -> hd(ArgList); - false -> + false -> Get = fun(Str) -> [_Name|Types] = string:tokens(Str, ":"), case Types of @@ -717,12 +738,12 @@ doc_arg(ArgList) -> doc_ret(ArgList) -> case all_eq(ArgList) of true -> hd(ArgList); - false -> + false -> args(fun(A) -> A end, "|", ArgList) end. unique([], U) -> reverse(U); -unique([H|R], U) -> +unique([H|R], U) -> case lists:member(H,U) of false -> unique(R,[H|U]); true -> unique(R,U) @@ -739,7 +760,7 @@ zip(List) -> zip([[F|L1]|List], Rest, AccL, Acc) -> zip(List, [L1|Rest], [F|AccL], Acc); -zip(Empty, Rest, AccL, Acc) -> +zip(Empty, Rest, AccL, Acc) -> true = empty(Empty), case empty(Rest) andalso empty(AccL) of true -> reverse(Acc); @@ -762,7 +783,7 @@ doc_arg_type(_) -> skip. doc_arg_type2(T=#type{single=Single}) when Single =:= array; Single =:= list -> "[" ++ doc_arg_type3(T) ++ "]"; -doc_arg_type2(T) -> +doc_arg_type2(T) -> doc_arg_type3(T). doc_arg_type3(#type{base=string}) -> "string()"; @@ -782,8 +803,8 @@ doc_arg_type3(#type{base={binary,_}}) -> "binary()"; doc_arg_type3(#type{base=eventType}) -> "atom()"; doc_arg_type3(#type{base={ref,N}}) -> N++"()"; doc_arg_type3(#type{base={term,_N}}) -> "term()"; -doc_arg_type3(T=#type{base={class,N}}) -> - check_class(T), +doc_arg_type3(T=#type{base={class,N}}) -> + check_class(T), case get(current_class) of N -> N ++ "()"; _ -> N++":" ++ N++"()" @@ -792,7 +813,7 @@ doc_arg_type3({merged,_,T1=#type{base={class,N1}},_,_,T2=#type{base={class,N2}}, check_class(T1), check_class(T2), Curr = get(current_class), - if + if N1 =:= Curr, N2 =:= Curr -> N1++"() | "++ N2++"()"; N1 =:= Curr -> N1++"() | "++ N2++":" ++ N2++"()"; N2 =:= Curr -> N1++":" ++ N1++"() | "++ N2++"()"; @@ -807,7 +828,7 @@ doc_arg_type3(#type{base={comp,_,{record,Name}}}) -> "wx:" ++ atom_to_list(Name) ++ "()"; doc_arg_type3(#type{base={comp,_,Tup}}) -> Doc = fun({int,V}) -> V ++ "::integer()"; - ({double,V}) -> V ++ "::float()" + ({double,V}) -> V ++ "::float()" end, "{" ++ args(Doc, ",", Tup) ++ "}"; doc_arg_type3(T) -> ?error({unknown_type,T}). @@ -817,7 +838,7 @@ doc_return_types(T, Ps) -> doc_return_types2(void, []) -> "ok"; doc_return_types2(void, [#param{type=T}]) -> doc_arg_type2(T); doc_return_types2(T, []) -> doc_arg_type2(T); -doc_return_types2(void, Ps) -> +doc_return_types2(void, Ps) -> "{" ++ args(fun doc_arg_type/1,",",Ps) ++ "}"; doc_return_types2(T, Ps) -> "{" ++ doc_arg_type2(T) ++ "," ++ args(fun doc_arg_type/1,",",Ps) ++ "}". @@ -870,7 +891,7 @@ check_name(Name) -> Name. marshal_opts([], _,_) -> ""; %% No opts skip this! marshal_opts(Opts, Align, Args) -> - w(" MOpts = fun", []), + w(" MOpts = fun", []), marshal_opts1(Opts,1), w(";~n (BadOpt, _) -> erlang:error({badoption, BadOpt}) end,~n", []), w(" BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),~n", []), @@ -879,7 +900,7 @@ marshal_opts(Opts, Align, Args) -> [] -> Str; % All Args are optional _ -> ", " ++ Str end. - + marshal_opts1([P],N) -> marshal_opt(P,N); marshal_opts1([P|R],N) -> @@ -892,15 +913,15 @@ marshal_opt(P0=#param{name=Name,type=Type},N) -> {Arg,Align} = marshal_arg(Type,erl_arg_name(Name),1), AStr = if Align =:= 0 -> ""; Align =:= 1 -> ",0:32" - end, - w("({~s, ~s}, Acc) -> ", [erl_option_name(Name), func_arg(P)]), + end, + w("({~s, ~s}, Acc) -> ", [erl_option_name(Name), func_arg(P)]), arg_type_test(P,"",[]), case Arg of - skip -> + skip -> w("[<<~p:32/?UI~s>>|Acc]", [N, AStr]); - _ -> + _ -> w("[<<~p:32/?UI,~s~s>>|Acc]", [N, Arg,AStr]) - end. + end. marshal_args(Ps) -> marshal_args(Ps, [], 0). @@ -940,23 +961,23 @@ marshal_arg(#type{single=true,base={enum,_Enum}}, Name, Align) -> marshal_arg(#type{single=true,base=bool}, Name, Align) -> align(32, Align, "(wxe_util:from_bool(" ++ Name ++ ")):32/?UI"); -marshal_arg(#type{name="wxChar", single=Single}, Name, Align0) +marshal_arg(#type{name="wxChar", single=Single}, Name, Align0) when Single =/= true -> - {Str,Align} = + {Str,Align} = align(32,Align0, "(byte_size("++Name++"_UC)):32/?UI,(" ++ Name ++ "_UC)/binary"), MsgSize = "(" ++ integer_to_list(Align*4)++"+byte_size("++Name++"_UC))", {Str++", 0:(((8- (" ++ MsgSize ++" band 16#7)) band 16#7))/unit:8",0}; marshal_arg(#type{base=string}, Name, Align0) -> - {Str,Align} = + {Str,Align} = align(32,Align0, "(byte_size("++Name++"_UC)):32/?UI,(" ++ Name ++ "_UC)/binary"), MsgSize = "(" ++ integer_to_list(Align*4)++"+byte_size("++Name++"_UC))", {Str++", 0:(((8- (" ++ MsgSize ++" band 16#7)) band 16#7))/unit:8",0}; marshal_arg(#type{name="wxArrayString"}, Name, Align0) -> - InnerBin = "<<(byte_size(UC_Str)):32/?UI, UC_Str/binary>>", + InnerBin = "<<(byte_size(UC_Str)):32/?UI, UC_Str/binary>>", Outer = "(<< " ++ InnerBin ++ "|| UC_Str <- "++ Name ++"_UCA>>)/binary", Str0 = "(length("++Name++"_UCA)):32/?UI, " ++ Outer, {Str,Align} = align(32,Align0,Str0), - MsgSize = "("++integer_to_list(Align*4) ++ + MsgSize = "("++integer_to_list(Align*4) ++ " + lists:sum([byte_size(S)+4||S<-" ++ Name ++"_UCA]))", AStr = ", 0:(((8- (" ++ MsgSize ++" band 16#7)) band 16#7))/unit:8", {Str ++ AStr, 0}; @@ -980,15 +1001,15 @@ marshal_arg(#type{base={term,_}}, _Name, Align0) -> {skip,Align0}; marshal_arg(#type{base=binary}, _Name, Align0) -> {skip,Align0}; -marshal_arg(#type{base=Base, single=Single}, Name, Align0) +marshal_arg(#type{base=Base, single=Single}, Name, Align0) when Single =/= true -> - case Base of - int -> + case Base of + int -> Str0 = "(length("++Name++")):32/?UI,\n" " (<< <<C:32/?I>> || C <- "++Name++">>)/binary", {Str,Align} = align(32,Align0, Str0), {Str ++ ", 0:((("++integer_to_list(Align)++"+length("++Name++ ")) rem 2)*32)", 0}; - {ObjRef,_} when ObjRef =:= class; ObjRef =:= ref -> + {ObjRef,_} when ObjRef =:= class; ObjRef =:= ref -> Str0 = "(length("++Name++")):32/?UI,", Str1 = "\n (<< <<(C#wx_ref.ref):32/?UI>> || C <- "++Name++">>)/binary", {Str2,Align} = align(32, Align0, Str1), @@ -1016,7 +1037,7 @@ align(64, 0, Str) -> {Str, 0}; align(64, 1, Str) -> {"0:32," ++ Str,0}; align(Sz, W, Str) -> align(Sz, W rem 2, Str). -enum_name(Name) -> +enum_name(Name) -> case string:tokens(Name, ":") of [Name] -> Name; [C,N] -> C ++ "_" ++ N @@ -1035,29 +1056,34 @@ gen_enums_ints() -> " href, target %% string()~n" " }).~n", []), w("~n%% Hardcoded Defines~n", []), - Enums = [E || E = {{enum,_},#enum{as_atom=false}} <- get()], - w("-define(wxDefaultSize, {-1,-1}).~n", []), - w("-define(wxDefaultPosition, {-1,-1}).~n", []), + Enums = [E || {{enum,_},E = #enum{as_atom=false}} <- get()], + w("-define(wxDefaultSize, {-1,-1}).~n", []), + w("-define(wxDefaultPosition, {-1,-1}).~n", []), w("~n%% Global Variables~n", []), - [w("-define(~s, wxe_util:get_const(~s)).~n", [Gvar, Gvar]) || + [w("-define(~s, wxe_util:get_const(~s)).~n", [Gvar, Gvar]) || {Gvar,_,_Id} <- get(gvars)], w("~n%% Enum and defines~n", []), - foldl(fun({{enum,Type},Enum= #enum{as_atom=false}}, Done) -> - build_enum_ints(Type,Enum,Done); + foldl(fun(Enum= #enum{vals=Vals}, Done) when Vals =/= [] -> + build_enum_ints(Enum,Done); (_,Done) -> Done end, gb_sets:empty(), lists:sort(Enums)), close(). -build_enum_ints(Type,#enum{vals=Vals},Done) -> - case Type of - [$@|_] -> ok; % anonymous - {Class,[$@|_]} when Vals =/= [] -> w("% From class ~s~n", [Class]); - {Class,Enum} when Vals =/= [] -> w("% From ~s::~s~n", [Class,Enum]); - _ when Vals =/= [] -> w("% Type ~s~n", [Type]); - _ -> ok +build_enum_ints(#enum{from=From, vals=Vals},Done) -> + case From of + {File, undefined, [$@|_]} -> + w("% From \"~s.h\"~n",[File]); + {File, undefined, Name} -> + w("% From \"~s.h\": ~s~n",[File, Name]); + {_File, Class,[$@|_]} -> + w("% From class ~s~n",[Class]); + {_File, Class, Name} -> + w("% From class ~s::~s~n",[Class, Name]) end, - - Format = fun(#const{name=Name,val=Value,is_const=true}) when is_integer(Value) -> + + 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) -> w("-define(~s, ~p).~n", [enum_name(Name),Value]); (#const{name=Name,val=Value,is_const=false}) when is_integer(Value) -> w("-define(~s, wxe_util:get_const(~s)).~n", [enum_name(Name),enum_name(Name)]); @@ -1078,12 +1104,12 @@ build_enum_ints(Type,#enum{vals=Vals},Done) -> Consts = get(consts), Write = fun({Name,_What}, Skip) -> case gb_sets:is_member(Name,Skip) of - true -> + true -> Skip; false -> case gb_trees:lookup(Name, Consts) of {value, Const} -> - Format(Const), + Format(Const), gb_sets:add(Name,Skip); none -> Skip end @@ -1097,8 +1123,8 @@ gen_event_recs() -> w("", []), w("%% This file is generated DO NOT EDIT~n~n", []), w("%% All event messages are encapsulated in a wx record~n" - "%% they contain the widget id and a specialized event record.~n" - "%% Each event record may be sent for one or more event types.~n" + "%% they contain the widget id and a specialized event record.~n" + "%% Each event record may be sent for one or more event types.~n" "%% The mapping to wxWidgets is one record per class.~n~n",[]), w("%% @type wx() = #wx{id=integer(), obj=wx:wxObject(), userData=term(), event=Rec}. Rec is a event record.~n",[]), w("-record(wx, {id, %% Integer Identity of object.~n" @@ -1108,7 +1134,7 @@ gen_event_recs() -> w("%% Here comes the definitions of all event records.~n" "%% they contain the event type and possible some extra information.~n~n",[]), Types = [build_event_rec(C) || {_,C=#class{event=Evs}} <- get(), Evs =/= false], - w("%% @type wxEventType() = ~s.~n", + w("%% @type wxEventType() = ~s.~n", [args(fun(Ev) -> Ev end, " | ", lists:sort(lists:append(Types)))]), %% close(), closed in gen_enums_ints ok. @@ -1123,22 +1149,22 @@ find_inherited_attr(Param = {PName,_}, Name) -> end. filter_attrs(#class{name=Name, parent=Parent,attributes=Attrs}) -> - Attr1 = lists:foldl(fun(#param{acc=skip},Acc) -> Acc; + Attr1 = lists:foldl(fun(#param{acc=skip},Acc) -> Acc; (P=#param{prot=public},Acc) -> [P|Acc]; - (#param{acc=undefined},Acc) -> Acc; + (#param{acc=undefined},Acc) -> Acc; ({inherited, PName},Acc) -> case find_inherited_attr(PName, Parent) of - undefined -> + undefined -> io:format("~p:~p: Missing Event Attr ~p in ~p~n", [?MODULE,?LINE, PName, Name]), Acc; - P -> + P -> [P|Acc] end; (P, Acc) -> [P|Acc] end, [], Attrs), lists:reverse(Attr1). - + build_event_rec(Class=#class{name=Name, event=Evs}) -> EvTypes = [event_type_name(Ev) || Ev <- Evs], Str = args(fun(Ev) -> "<em>"++Ev++"</em>" end, ", ", EvTypes), @@ -1146,26 +1172,26 @@ build_event_rec(Class=#class{name=Name, event=Evs}) -> Rec = event_rec_name(Name), GetName = fun(#param{name=N}) ->event_attr_name(N) end, GetType = fun(#param{name=N,type=T}) -> - event_attr_name(N) ++ "=" ++ doc_arg_type2(T) + event_attr_name(N) ++ "=" ++ doc_arg_type2(T) end, case Attr =:= [] of - true -> + true -> w("%% @type ~s() = #~s{type=wxEventType()}.~n", [Rec,Rec]), w("%% <dl><dt>EventType:</dt> <dd>~s</dd></dl>~n",[Str]), -%% case is_command_event(Name) of +%% case is_command_event(Name) of %% true -> w("%% This event skips other event handlers.~n",[]); %% false -> w("%% This event will be handled by other handlers~n",[]) %% end, w("%% Callback event: {@link ~s}~n", [Name]), w("-record(~s, {type}).~n~n", [Rec]); false -> - w("%% @type ~s() = #~s{type=wxEventType(),~s}.~n", + w("%% @type ~s() = #~s{type=wxEventType(),~s}.~n", [Rec,Rec,args(GetType,",",Attr)]), w("%% <dl><dt>EventType:</dt> <dd>~s</dd></dl>~n",[Str]), -%% case is_command_event(Name) of +%% case is_command_event(Name) of %% true -> w("%% This event skips other event handlers.~n",[]); %% false -> w("%% This event will be handled by other handlers~n",[]) -%% end, +%% end, w("%% Callback event: {@link ~s}~n", [Name]), w("-record(~s,{type, ~s}).~n~n", [Rec,args(GetName,",",Attr)]) end, @@ -1176,7 +1202,7 @@ is_command_event(Name) -> true -> true; false -> false end. - + event_rec_name(Name0 = "wx" ++ _) -> "tnevE" ++ Name1 = reverse(Name0), reverse(Name1). @@ -1193,7 +1219,7 @@ event_attr_name(Attr) -> lowercase(Attr). -gen_funcnames() -> +gen_funcnames() -> open_write("../src/gen/wxe_debug.hrl"), erl_copyright(), w("%% This file is generated DO NOT EDIT~n~n", []), @@ -1235,7 +1261,7 @@ unique_names(Ms0, Class) -> Ms = split_list(fun(#method{name=N}, M) -> {N =:= M, N} end, undefined, Ms2), unique_names2(Ms,Class). %% by Names -unique_names2([[#method{id=Id, name=Method,alias=Alias, max_arity=A}]|Ms], Class) -> +unique_names2([[#method{id=Id, name=Method,alias=Alias, max_arity=A}]|Ms], Class) -> [{Class,uname(alias(Method,Alias),Class),A,Id} | unique_names2(Ms,Class)]; unique_names2([Ms0|RMs], Class) -> Split = fun(#method{max_arity=A}, P) -> {A =:= P, A} end, @@ -1256,11 +1282,11 @@ unique_names4([], _, _Class) -> []. alias(Method, undefined) -> Method; alias(_, Alias) -> Alias. - + uname(Class,Class) -> "new"; uname([$~ | _], _ ) -> "destruct"; uname(Name, _) -> Name. - + split_list(F, Keep, List) -> split_list(F, Keep, List, []). @@ -1275,5 +1301,5 @@ split_list(F, Keep, [M|Ms], Acc) -> end; split_list(_, _, [], []) -> []; split_list(_, _, [], Acc) -> [lists:reverse(Acc)]. - + diff --git a/lib/wx/api_gen/wxapi.conf b/lib/wx/api_gen/wxapi.conf index 4f7bbfedef..8ee4451057 100644 --- a/lib/wx/api_gen/wxapi.conf +++ b/lib/wx/api_gen/wxapi.conf @@ -2,7 +2,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% Copyright Ericsson AB 2008-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -27,7 +27,11 @@ wxFONTENCODING_UTF32,wxFONTENCODING_UTF16, wxDEFAULT_CONTROL_BORDER,wxMOD_CMD, wxMAJOR_VERSION, wxMINOR_VERSION, - wxRELEASE_NUMBER,wxSUBRELEASE_NUMBER,wxBETA_NUMBER + wxRELEASE_NUMBER,wxSUBRELEASE_NUMBER,wxBETA_NUMBER, + %% + wxALWAYS_NATIVE_DOUBLE_BUFFER, + wxGAUGE_EMULATE_INDETERMINATE_MODE, + wxTR_DEFAULT_STYLE ]}. {gvars, @@ -501,15 +505,15 @@ {"data",[in,{base,binary}]}, {"alpha",[in,{base,binary}]}, {{4,pre_hook}, - "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}, - "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', @@ -520,15 +524,15 @@ {"data",[in,{base,binary}]}, {"alpha",[in,{base,binary}]}, {{4,pre_hook}, - "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}, - "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', @@ -547,15 +551,15 @@ 'Rotate90','SaveFile','Scale','Size', {'SetAlpha', [{{2,"alpha"},[in,{base,binary}, {def, none}]}, {{2,pre_hook}, - "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, - "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', @@ -702,7 +706,7 @@ ['wxCheckBox','~wxCheckBox','Create','GetValue','Get3StateValue', 'Is3rdStateAllowedForUser','Is3State','IsChecked','SetValue', 'Set3StateValue']}. -{class, wxCheckListBox, wxListBox, [{skip,[{wxCheckListBox,8}]}], +{class, wxCheckListBox, wxListBox, [{skip,[{wxCheckListBox,8}]}], [{'wxCheckListBox',[{"pos",{def, "wxDefaultPosition"}}, {"size",{def, "wxDefaultSize"}}, {"choices",{def, ""}}]}, @@ -752,7 +756,9 @@ 'SetFirstItem']}. {class, wxListCtrl, wxControl, [], - ['wxListCtrl','~wxListCtrl','Arrange','AssignImageList','ClearAll','Create', + [{'wxListCtrl', [{where, taylormade}]}, + '~wxListCtrl','Arrange','AssignImageList','ClearAll', + {'Create',[{where, taylormade}]}, 'DeleteAllItems','DeleteColumn','DeleteItem', {'EditLabel',[{"textControlClass",nowhere}]}, 'EnsureVisible', @@ -784,6 +790,13 @@ 'SetFont','SetId','SetImage','SetMask','SetState', 'SetStateMask','SetText','SetTextColour','SetWidth']}. +{class, wxListItemAttr, root, [], + ['wxListItemAttr','~wxListItemAttr', + 'GetBackgroundColour', 'GetFont', + 'GetTextColour', 'HasBackgroundColour', 'HasFont', + 'HasTextColour', 'SetBackgroundColour', 'SetFont', 'SetTextColour' + ]}. + {class, wxImageList, object, [{skip, [{'Create',1}]}], %% No create/0 on windows ['wxImageList','~wxImageList','Add','Create','Draw','GetBitmap','GetIcon','GetImageCount', 'GetSize','Remove','RemoveAll','Replace']}. @@ -898,8 +911,8 @@ ['wxTreeCtrl','~wxTreeCtrl','AddRoot','AppendItem', %% Not on Windows 'AssignButtonsImageList','GetButtonsImageList','SetButtonsImageList' 'AssignImageList','AssignStateImageList','Collapse','CollapseAndReset', - 'Create','Delete','DeleteAllItems','DeleteChildren',{'EditLabel',1}, - %'EndEditLabel', + 'Create','Delete','DeleteAllItems','DeleteChildren', + {'EditLabel', [{"textCtrlClass", [nowhere]}]}, %'EndEditLabel', 'EnsureVisible','Expand','GetBoundingRect', 'GetChildrenCount','GetCount','GetEditControl', {'GetFirstChild',[{"cookie", out}]}, {'GetNextChild',[{"cookie", [both]}]}, @@ -1144,7 +1157,8 @@ [{skip, [{'SetCurrent', 2}]}], %% NA MAC [{'wxGLCanvas', [{"attribList", [in, {single,array}]}]}, 'GetContext', - {'SetCurrent', [{post_hook,"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']}. @@ -1686,7 +1700,7 @@ {class, wxSplitterEvent, wxNotifyEvent, - [ + [{acc, [{x, skip}, {y, skip}, {pos, skip}, {win, skip}, {pt, skip}]}, %% arrgh doxygen bugs {event, [wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED, wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING, @@ -1736,6 +1750,11 @@ %% 'GetItemRect', 'SetItemRect', 'GetToolId', 'SetToolId' %% ]}. +{class, wxSystemSettings, object, [], + [ + 'GetColour','GetFont','GetMetric','GetScreenType' + ]}. + {class, wxAuiNotebookEvent, wxNotifyEvent, [{acc, [{old_selection, "GetOldSelection()"}, {selection, "GetSelection()"}, |