diff options
Diffstat (limited to 'lib/wx/api_gen')
-rw-r--r-- | lib/wx/api_gen/Makefile | 4 | ||||
-rw-r--r-- | lib/wx/api_gen/README | 15 | ||||
-rw-r--r-- | lib/wx/api_gen/gen_util.erl | 14 | ||||
-rw-r--r-- | lib/wx/api_gen/gl_gen.erl | 11 | ||||
-rw-r--r-- | lib/wx/api_gen/gl_gen_erl.erl | 432 | ||||
-rw-r--r-- | lib/wx/api_gen/gl_scan_doc.erl | 286 | ||||
-rw-r--r-- | lib/wx/api_gen/glapi.conf | 8 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_extra/wxEvtHandler.erl | 26 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen.erl | 9 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen_cpp.erl | 37 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen_erl.erl | 506 | ||||
-rw-r--r-- | lib/wx/api_gen/wxapi.conf | 60 |
12 files changed, 950 insertions, 458 deletions
diff --git a/lib/wx/api_gen/Makefile b/lib/wx/api_gen/Makefile index 756ec598ce..8adb485ba9 100644 --- a/lib/wx/api_gen/Makefile +++ b/lib/wx/api_gen/Makefile @@ -1,7 +1,7 @@ # # %CopyrightBegin% # -# Copyright Ericsson AB 2008-2010. All Rights Reserved. +# Copyright Ericsson AB 2008-2012. 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,7 +30,7 @@ ERL_COMPILE_FLAGS=+debug_info +warn_unused_vars COMPILER = gen_util wx_gen wx_gen_erl wx_gen_cpp COMPILER_T = $(COMPILER:%=$(EBIN)/%.beam) -GL_COMP = gl_gen gl_gen_erl gl_gen_c +GL_COMP = gl_gen gl_gen_erl gl_gen_c gl_scan_doc GL_COMP_T = $(GL_COMP:%=$(EBIN)/%.beam) TARGET_EDIR = ../src/gen diff --git a/lib/wx/api_gen/README b/lib/wx/api_gen/README index 10b5209789..dd0c49d227 100644 --- a/lib/wx/api_gen/README +++ b/lib/wx/api_gen/README @@ -1,6 +1,6 @@ API GENERATION: - Most of the code in wx is generated. - Users of wxErlang should not normally need to regenerate the generated code, + 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. Code checked in is currently generated from wxwidgets 2.8.10. @@ -10,6 +10,8 @@ REQUIREMENTS: used to parse wxWidgets c++ headers and generate xml files (in wx_xml/). + 2012-02-09 doxygen 1.7.4 is working fine + 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. @@ -32,5 +34,12 @@ RUNNING: I keep the opengl headers separate so I don't go backwards in version when generating the code from another machine. + Also gl.h from different vendors differ so keep it consistent, + I have used mesa's gl.h and the glext.h from opengl.org + (version see GL_GLEXT_VERSION in gl.hrl) + + I also get the xml documentation from opengl.org (subversion) and place it in + api_gen/gl_man2 (all old functions) and api_gen/gl_man4 (all the new functions). + CONTRIBUTION: - Send me patches or update the svn version. + Send me patches diff --git a/lib/wx/api_gen/gen_util.erl b/lib/wx/api_gen/gen_util.erl index df5b4c3405..4638d4c7ea 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-2011. All Rights Reserved. +%% Copyright Ericsson AB 2008-2012. 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 @@ -96,8 +96,8 @@ check_diff(Diff) -> [<<>>] -> ok; _ -> throw(diff) end, - <<_, _, "%% Copyright", _/binary>> = D1, - <<_, _, "%% Copyright", _/binary>> = D2, + copyright(D1), + copyright(D2), copyright catch throw:_ -> diff; @@ -108,6 +108,10 @@ check_diff(Diff) -> diff end. +copyright(<<_, _, "%% Copyright", _/binary>>) -> ok; +copyright(<<_, _, " * Copyright", _/binary>>) -> ok; +copyright(_) -> throw(diff). + w(Str) -> w(Str, []). w(Str,Args) -> @@ -217,7 +221,7 @@ erl_copyright() -> w("%%~n",[]), w("%% %CopyrightBegin%~n",[]), w("%%~n",[]), - w("%% Copyright Ericsson AB ~p-2011. All Rights Reserved.~n", + w("%% Copyright Ericsson AB ~p-2012. All Rights Reserved.~n", [StartYear]), w("%%~n",[]), w("%% The contents of this file are subject to the Erlang Public License,~n",[]), @@ -237,7 +241,7 @@ c_copyright() -> w("/*~n",[]), w(" * %CopyrightBegin%~n",[]), w(" *~n",[]), - w(" * Copyright Ericsson AB 2008-2011. All Rights Reserved.~n",[]), + w(" * Copyright Ericsson AB 2008-2012. 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_gen.erl b/lib/wx/api_gen/gl_gen.erl index 8998d341e7..ce0cb922e9 100644 --- a/lib/wx/api_gen/gl_gen.erl +++ b/lib/wx/api_gen/gl_gen.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2011. All Rights Reserved. +%% Copyright Ericsson AB 2008-2012. 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 @@ -62,11 +62,11 @@ gen_code() -> GLDefs = parse_gl_defs(Opts), {GLUDefines,GLUFuncs} = setup(GLUDefs, Opts), {GLDefines,GLFuncs} = setup(GLDefs, Opts), + gl_gen_erl:gl_defines(GLDefines), + gl_gen_erl:gl_api(GLFuncs), gl_gen_erl:glu_defines(GLUDefines), gl_gen_erl:glu_api(GLUFuncs), - gl_gen_erl:gl_defines(GLDefines), - gl_gen_erl:gl_api(GLFuncs), %%gl_gen_erl:gen_debug(GLFuncs,GLUFuncs), gl_gen_c:gen(GLFuncs,GLUFuncs), ok. @@ -360,7 +360,9 @@ extract_type_info2("**", Acc) -> [{by_ref,{pointer,2}}|Acc]; extract_type_info2(Type, Acc) -> [Type|Acc]. parse_type2(["void"], _T, _Opts) -> void; -parse_type2([N="void"|R], T, Opts) -> +parse_type2([N="void", const|R], T, Opts) -> + parse_type2([const|R],T#type{name=N, base=idx_binary},Opts); +parse_type2([N="void"|R], T, Opts) -> parse_type2(R,T#type{name=N},Opts); parse_type2([const|R],T=#type{mod=Mod},Opts) -> parse_type2(R,T#type{mod=[const|Mod]},Opts); @@ -676,6 +678,7 @@ get_extension(ExtName,_Opts) -> "IGP" ++ Name -> {reverse(Name),"PGI"}; "PH" ++ Name -> {reverse(Name),"HP"}; "YDEMERG" ++ Name -> {reverse(Name),"GREMEDY"}; + "SEO" ++ Name -> {reverse(Name),"OES"}; %%["" ++ Name] -> {Name; %% _ -> {ExtName, ""} end. diff --git a/lib/wx/api_gen/gl_gen_erl.erl b/lib/wx/api_gen/gl_gen_erl.erl index f292c8723e..f77b2d8e24 100644 --- a/lib/wx/api_gen/gl_gen_erl.erl +++ b/lib/wx/api_gen/gl_gen_erl.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% Copyright Ericsson AB 2008-2012. 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 : gl_gen_erl.erl %%% Author : Dan Gudmundsson <[email protected]> -%%% Description : +%%% Description : %%% %%% Created : 18 Apr 2007 by Dan Gudmundsson <[email protected]> %%%------------------------------------------------------------------- @@ -31,7 +31,7 @@ -import(lists, [foldl/3,foldr/3,reverse/1, keysearch/3, map/2, filter/2, max/1]). -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]). gl_defines(Defs) -> @@ -40,7 +40,7 @@ gl_defines(Defs) -> w("~n%% OPENGL DEFINITIONS~n~n", []), w("%% This file is generated DO NOT EDIT~n~n", []), [gen_define(Def) || Def=#def{} <- Defs], - close(), + close(), ok. glu_defines(Defs) -> @@ -50,36 +50,38 @@ glu_defines(Defs) -> w("%% This file is generated DO NOT EDIT~n~n", []), [gen_define(Def) || Def=#def{} <- Defs], close(), - ok. + ok. gen_define(#def{name=N, val=Val, type=int}) -> w("-define(~s, ~p).~n", [N,Val]); gen_define(#def{name=N, val=Val, type=hex}) -> w("-define(~s, ~.16#).~n", [N,Val]); gen_define(#def{name=N, val=Val, type=string}) -> - w("-define(~s, ?~s).~n", [N,Val]). + w("-define(~s, ?~s).~n", [N,Val]); +gen_define(#def{name="GLEXT_64_TYPES"++_, val=undefined, type=undefined}) -> + ok. types() -> [{"GLenum", "32/native-unsigned"}, {"GLboolean", "8/native-unsigned"}, {"GLbitfield","32/native-unsigned"}, % %%{"GLvoid",":void "},% - {"GLbyte", "8/native-signed"}, % 1-byte signed - {"GLshort", "16/native-signed"}, % 2-byte signed - {"GLint", "32/native-signed"}, % 4-byte signed - {"GLubyte", "8/native-unsigned"}, % 1-byte unsigned - {"GLushort", "16/native-unsigned"}, % 2-byte unsigned - {"GLuint", "32/native-unsigned"}, % 4-byte unsigned - {"GLsizei", "32/native-signed"}, % 4-byte signed - {"GLfloat", "32/native-float"}, % single precision float - {"GLclampf", "32/native-float"}, % single precision float in [0,1] - {"GLdouble", "64/native-float"}, % double precision float - {"GLclampd", "64/native-float"}, % double precision float in [0,1] + {"GLbyte", "8/native-signed"}, % 1-byte signed + {"GLshort", "16/native-signed"}, % 2-byte signed + {"GLint", "32/native-signed"}, % 4-byte signed + {"GLubyte", "8/native-unsigned"}, % 1-byte unsigned + {"GLushort", "16/native-unsigned"}, % 2-byte unsigned + {"GLuint", "32/native-unsigned"}, % 4-byte unsigned + {"GLsizei", "32/native-signed"}, % 4-byte signed + {"GLfloat", "32/native-float"}, % single precision float + {"GLclampf", "32/native-float"}, % single precision float in [0,1] + {"GLdouble", "64/native-float"}, % double precision float + {"GLclampd", "64/native-float"}, % double precision float in [0,1] {"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 - + {"GLsync", "64/native-unsigned"}, % Pointer to record {"GLuint64", "64/native-unsigned"}, {"GLint64", "64/native-signed"} @@ -94,20 +96,17 @@ 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 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("-module(gl).~n~n",[]), w("-compile(inline).~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", []), @@ -140,10 +139,10 @@ gl_api(Fs) -> w(" erlang:port_command(Port,Bin)~n", []), w(" end.~n", []), w("~n", []), - + w("~n%% API~n~n", []), [gen_funcs(F) || F <- Fs], - close(), + close(), ok. glu_api(Fs) -> @@ -155,28 +154,24 @@ 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 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("-module(glu).~n",[]), w("-compile(inline).~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",[]), - w("%% Vec3 = {float(),float(),float()}~n",[]), - w("%% Triangles = [VertexIndex::integer()]~n",[]), - w("%% VertexPos = binary()~n",[]), + %% w("%% @spec (Vec3, [Vec3]) -> {Triangles, VertexPos}~n",[]), + %% w("%% Vec3 = {float(),float(),float()}~n",[]), + %% w("%% Triangles = [VertexIndex::integer()]~n",[]), + %% w("%% VertexPos = binary()~n",[]), w("%% @doc General purpose polygon triangulation.~n",[]), w("%% The first argument is the normal and the second a list of~n" "%% vertex positions. Returned is a list of indecies of the vertices~n" @@ -184,6 +179,9 @@ glu_api(Fs) -> "%% vertex positions, it starts with the vertices in Vs and~n" "%% may contain newly created vertices in the end.~n", []), + w("-spec tesselate(Normal, [Vs]) -> {Triangles, VertexPos}~n", []), + w(" when Normal :: vertex(), Vs :: vertex(),~n", []), + w(" Triangles :: [integer()], VertexPos :: binary().~n", []), w("tesselate({Nx,Ny,Nz}, Vs) ->~n",[]), w(" call(5000, <<(length(Vs)):32/native,0:32,~n" " Nx:?GLdouble,Ny:?GLdouble,Nz:?GLdouble,~n" @@ -215,15 +213,21 @@ gen_funcs(F) -> erase(current_func), w(".~n~n",[]). -gen_types(Where) -> +gen_types(Where) -> case Where of - glu -> ignore; + glu -> + w("-type vertex() :: {float(), float(), float()}.~n", []), + w("-type enum() :: non_neg_integer(). %% See wx/include/gl.hrl or glu.hrl~n", []); gl -> - w("-type clamp() :: float().~n", []), - w("-type offset() :: non_neg_integer().~n", []) + w("-type enum() :: non_neg_integer(). %% See wx/include/gl.hrl~n", []), + w("-type clamp() :: float(). %% 0.0..1.0~n", []), + w("-type offset() :: non_neg_integer(). %% Offset in memory block~n", []) end, - w("-type enum() :: non_neg_integer().~n", []), - w("-type mem() :: binary() | tuple().~n", []), + w("-type matrix() :: {float(),float(),float(),float(),~n", []), + w(" float(),float(),float(),float(),~n", []), + w(" float(),float(),float(),float(),~n", []), + w(" float(),float(),float(),float()}.~n", []), + w("-type mem() :: binary() | tuple(). %% Memory block~n", []), ok. gen_export(F) -> @@ -238,43 +242,182 @@ gen_export_1([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}}) -> - #func{params=As0} = get(Vec), +gen_export2(#func{name=Name,alt=Alt={vector,VecPos,Vec}}) -> + #func{params=As0} = get(Vec), {As1,_As2} = lists:split(VecPos, As0), Args = lists:filter(fun(Arg) -> func_arg(Arg) =/= skip end, As1), - erl_func_name(Name) ++ "/" ++ integer_to_list(length(Args) +1); -gen_export2(#func{name=Name,params=As0}) -> + Export = erl_func_name(Name) ++ "/" ++ integer_to_list(length(Args) +1), + DocN = doc_name(Name,Alt), + (get({export_arg,DocN}) == undefined) andalso put({export_arg, DocN}, Export), + Export; +gen_export2(#func{name=Name,params=As0, alt=Alt}) -> Args = lists:filter(fun(Arg) -> func_arg(Arg) =/= skip end, As0), - erl_func_name(Name) ++ "/" ++ integer_to_list(length(Args)). + Export = erl_func_name(Name) ++ "/" ++ integer_to_list(length(Args)), + DocN = doc_name(Name,Alt), + (get({export_arg,DocN}) == undefined) andalso put({export_arg, DocN}, Export), + Export. -gen_doc([#func{name=Name, alt={vector,VecPos,Vec}}]) -> - #func{type=T,params=As} = get(Vec), +gen_doc([#func{name=Name, params=Orig, alt={vector,VecPos,Vec}}]) -> + #func{type=T,params=As} = get(Vec), {As1,As2} = lists:split(VecPos, As), + #arg{name=OrigName} = lists:last(Orig), 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, 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),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)]), - w("-spec ~s(~s) -> ~s.~n", - [erl_func_name(Name), doc_arg_types(As, spec), doc_return_types(T,As, spec)]). + SA1 = case doc_arg_types(As1) of [] -> []; E -> E++"," end, + SA2 = doc_arg_types(As2), + w("-spec ~s(~s~s) -> ~s when ~s :: {~s}.~n", + [erl_func_name(Name), SA1, erl_arg_name(OrigName), + doc_return_types(T,As), erl_arg_name(OrigName), SA2]); + +gen_doc([F=#func{name=Name,type=T,params=As, alt=Alt}|_]) -> + gen_doc(Name, Alt, gen_export2(F)), + Ps = [Arg || #arg{name=Arg, in=In, where=Where} <- As, + In =/= false, Where =/= c], + Args = args(fun erl_arg_name/1, ", ", Ps), + case Args of + [] -> + w("-spec ~s(~s) -> ~s.~n", + [erl_func_name(Name), Args, doc_return_types(T,As)]); + _ -> w("-spec ~s(~s) -> ~s when ~s.~n", + [erl_func_name(Name), Args, doc_return_types(T,As), doc_arg_types(As)]) + end. + +-define(LINE_LEN, 90). + +gen_doc(Name0, Alt, Export) -> + Name = doc_name(Name0, Alt), + case get({doc, Name}) of + undefined -> + GLDoc = "http://www.opengl.org/sdk/docs/man/xhtml/", + case parse_doc(Name, _Dir1 ="gl_man4", _Dir2="gl_man2") of + {error, _} -> + case reverse(Name) of + "BRA" ++ _ -> ok; + "TXE" ++ _ -> ok; + _ -> + %% io:format("Missing doc: no ~s.xml (~s) found in ~s or ~s~n", + %% [Name, Name0, Dir1, Dir2]), + ok + end, + w("%% @doc ~s~n%%~n%% See <a href=\"~s~s.xml\">external</a> documentation.~n", + [Name, GLDoc, Name]); + Doc -> + put({doc, Name}, Export), + format_doc(Doc, ?LINE_LEN), + w("~n%%~n%% See <a href=\"~s~s.xml\">external</a> documentation.~n", + [GLDoc, Name]) + end; + Where -> + w("%% @doc ~n", []), + w("%% See {@link ~s}~n", [Where]) + end. +parse_doc(Name, Dir1, Dir2) -> + case gl_scan_doc:file(filename:join(Dir1, Name++".xml"), []) of + {error, {_, "no such" ++ _}} -> + gl_scan_doc:file(filename:join(Dir2, Name++".xml"), []); + Doc -> + Doc + end. + +format_doc(Strs, Count) when Count < 0 -> + w("~n%% ", []), + format_doc(Strs, ?LINE_LEN); +format_doc([{constant, Const}|Rest], Count) -> + w("`?~s'", [Const]), + format_doc(Rest, Count-length(Const)-8); +format_doc([{emphasis, Const}|Rest], Count) -> + w("`~s'", [Const]), + format_doc(Rest, Count-length(Const)-7); +format_doc([{function, Func}|Rest], Count) -> + case Func of + "glu" ++ _ -> + w("``glu:~s''", [erl_func_name(Func)]); + "gl" ++ _ -> + w("``gl:~s''", [erl_func_name(Func)]); + _ -> + w("`~s'", [Func]) + end, + format_doc(Rest, Count-length(Func)-7); +format_doc([{reffunc, Func}|Rest], Count) -> + Out = fun(Export) -> + case Func of + "glu" ++ _ -> w(" {@link glu:~s} ", [Export]); + "gl" ++ _ -> w(" {@link gl:~s} ", [Export]) + end + end, + case get({export_arg, Func}) of + undefined -> + case get({export_arg, doc_name(Func, undefined)}) of + undefined -> + %% io:format("Func ~p undefined (~p) ~n", + %% [Func, doc_name(Func, undef)]), + w("see `~s'", [Func]); + Export -> Out(Export) + end; + Export -> + Out(Export) + end, + format_doc(Rest, Count-length(Func)-10); +format_doc([{parameter, Param}|Rest], Count) -> + w(" `~s' ", [erl_arg_name(Param)]), + format_doc(Rest, Count-length(Param)-7); +format_doc([{equation, Eq}|Rest], Count) -> +%% w("```", []), + format_doc([Eq], Count), +%% w("'''", []), + format_doc(Rest, Count); +format_doc([{fenced, Open, Close, Eq}|Rest], Count) -> + w(Open, []), + format_doc(Eq, Count), + w(Close, []), + format_doc(Rest, Count); + +format_doc([{code, Code}|Rest], Count) -> + w("``~s''", [Code]), + format_doc(Rest, Count-length(Code)-7); + +format_doc([para|Rest], _Count) -> + w("~n%%~n%% ", []), + format_doc(Rest, ?LINE_LEN); +format_doc([break|Rest], _Count) -> + w("<br />~n%% ", []), + format_doc(Rest, ?LINE_LEN); +format_doc([{purpose, Purpose}, para | Doc], _Count) -> + w("%% @doc ~s~n%%~n%% ", [uppercase(Purpose)]), + format_doc(Doc, ?LINE_LEN); +format_doc([{purpose, Purpose} | Doc], _Count) -> + w("%% @doc ~s~n%%~n%% ", [Purpose]), + format_doc(Doc, ?LINE_LEN); +format_doc([listentry|Rest], _Count) -> + w("~n%%~n%% ", []), + format_doc(Rest, ?LINE_LEN); +format_doc([Str|Rest], Count) -> + case length(Str) of + Len when Len < Count -> + w("~s", [Str]), + format_doc(Rest, Count-Len); + _ -> + {Str1, Str2} = split(Str, Count, []), + w("~s~n%% ", [Str1]), + format_doc([Str2|Rest], ?LINE_LEN) + end; +format_doc([], _) -> ok. + +split([$ |Str], Count, Acc) when Count =< 5 -> + {reverse(Acc), Str}; +split([Chr|Str], Count, Acc) -> + split(Str, Count-1, [Chr|Acc]); +split([], _, Acc) -> + {reverse(Acc), []}. gen_func(#func{name=Name,alt={vector,VecPos,Vec}}) -> - #func{params=As} = get(Vec), + #func{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("~s(~s{~s}) ->", [erl_func_name(Name),Args1,Args2]), w(" ~s(~s)", [erl_func_name(Vec), Args1++Args2]); gen_func(_F=#func{name=Name,type=T,params=As,id=MId}) -> @@ -290,7 +433,7 @@ gen_func(_F=#func{name=Name,type=T,params=As,id=MId}) -> w(" cast(~p, <<~s>>)", [MId, StrArgs]) end. -func_arg(#arg{in=In,where=W,name=Name,type=Type}) +func_arg(#arg{in=In,where=W,name=Name,type=Type}) when In =/= false, W =/= c -> case Type of #type{single={tuple,TSz0}} when TSz0 =/= undefined -> @@ -305,45 +448,39 @@ func_arg(#arg{in=In,where=W,name=Name,type=Type}) end; func_arg(_) -> skip. -doc_arg_types(Ps0, Type) -> +doc_arg_types(Ps0) -> Ps = [P || P=#arg{in=In, where=Where} <- Ps0,In =/= false, Where =/= c], - args(fun(Arg) -> doc_arg_type(Arg, Type) end, ",", Ps). + args(fun(Arg) -> doc_arg_type(Arg) end, ",", Ps). -doc_return_types(T, Ps0, Type) -> +doc_return_types(T, Ps0) -> Ps = [P || P=#arg{in=In, where=Where} <- Ps0,In =/= true, Where =/= c], - 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) + 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(Arg) -> doc_arg_type(Arg) end,",",Ps) ++ "}"; +doc_return_types2(T, Ps) -> + "{" ++ doc_arg_type2(T) ++ "," ++ + args(fun(Arg) -> doc_arg_type(Arg) end,",",Ps) ++ "}". + +doc_arg_type(#arg{name=Name,type=T}) -> + try + erl_arg_name(Name) ++ " :: " ++ 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(#type{base=float, single={tuple,16}}) -> + "matrix()"; 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}) -> @@ -365,21 +502,21 @@ doc_arg_type3(#type{base=bool}) -> "0|1"; doc_arg_type3(#type{base=binary}) -> "binary()"; doc_arg_type3(#type{base=memory}) -> "mem()". -guard_test(As) -> - Str = args(fun(#arg{name=N,type=#type{base=guard_int}}) -> - " is_integer("++erl_arg_name(N)++")"; - (_) -> +guard_test(As) -> + Str = args(fun(#arg{name=N,type=#type{base=guard_int}}) -> + " is_integer("++erl_arg_name(N)++")"; + (_) -> skip end, ",", As), case Str of [] -> []; Other -> " when " ++ Other - end. + end. -pre_marshal([#arg{name=N,in=true,type=#type{base=binary}}|R]) -> +pre_marshal([#arg{name=N,in=true,type=#type{base=binary}}|R]) -> w(" send_bin(~s),~n", [erl_arg_name(N)]), pre_marshal(R); -pre_marshal([#arg{name=N,type=#type{base=memory}}|R]) -> +pre_marshal([#arg{name=N,type=#type{base=memory}}|R]) -> 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]) -> @@ -412,14 +549,14 @@ marshal_arg(#type{size=Sz,name=Type,single={tuple,undefined}},Name,A0) -> " (<< <<C:?"++Type++ ">> ||" "C <- tuple_to_list("++Name++")>>)/binary", case Sz of - 4 -> + 4 -> {Str,Align} = align(4,A0,Str0), {Str++",0:((("++integer_to_list(Align div 4)++ "+size("++Name++")) rem 2)*32)",0}; - 8 -> + 8 -> align(8,A0,Str0) end; -marshal_arg(#type{size=BSz,name=Type,single={tuple,TSz}},Name,A0) +marshal_arg(#type{size=BSz,name=Type,single={tuple,TSz}},Name,A0) when is_integer(TSz) -> NameId = hd(Name), Names = [[NameId|integer_to_list(Id)] || Id <- lists:seq(1,TSz)], @@ -427,7 +564,7 @@ marshal_arg(#type{size=BSz,name=Type,single={tuple,TSz}},Name,A0) align(BSz,TSz,A0,All); marshal_arg(#type{size=BSz,name=Type,single={tuple,matrix12}},Name,A0) -> - NameId = hd(Name), + NameId = hd(Name), Ns0 = [[NameId|integer_to_list(Id)] || Id <- lists:seq(1,3)], Ns1 = [[NameId|integer_to_list(Id)] || Id <- lists:seq(4,6)], Ns2 = [[NameId|integer_to_list(Id)] || Id <- lists:seq(7,9)], @@ -436,7 +573,7 @@ marshal_arg(#type{size=BSz,name=Type,single={tuple,matrix12}},Name,A0) -> Ns0 ++ ["0"] ++ Ns1 ++ ["0"] ++ Ns2 ++ ["0"] ++ Ns3 ++ ["1"]), align(BSz,16,A0,All); -marshal_arg(#type{size=Sz,name=Type,base=Base,single=list},Name,A0) +marshal_arg(#type{size=Sz,name=Type,base=Base,single=list},Name,A0) when Base =:= float; Base =:= int -> KeepA = case Sz of 8 -> "0:32,"; _ -> "" end, Str0 = "(length("++Name++")):?GLuint,"++KeepA++"\n" @@ -459,14 +596,14 @@ marshal_arg(#type{base=string,single=true,ref={pointer,1}},Name,A0) -> align_after(1,A0,1,1,Name,Str); marshal_arg(#type{base=string,single=list,ref={pointer,2}},Name,A0) -> - Str0 = + Str0 = "(length("++Name++")):?GLuint," "(size("++Name ++ "Temp)):?GLuint," "(" ++ Name ++ "Temp)/binary", {Str,A} = align(4,A0,Str0), - {Str ++ ",0:((8-((size("++Name++"Temp)+"++ + {Str ++ ",0:((8-((size("++Name++"Temp)+"++ integer_to_list(A) ++") rem 8)) rem 8)", 0}; - + marshal_arg(#type{size=Sz,name=Type,single={tuple_list,TSz}},Name,A0) -> NameId = hd(Name), Names = [[NameId|integer_to_list(Id)] || Id <- lists:seq(1,TSz)], @@ -508,11 +645,11 @@ align(8,_,6,Str) -> {"0:16,"++Str, 0}; align(8,_,7,Str) -> {"0:8," ++Str, 0}. align_after(8,0,_Add,_Multiplier,_Name,Str) -> {Str,0}; -align_after(4,0,Add,Mult,Name,Str) -> +align_after(4,0,Add,Mult,Name,Str) -> Extra = extra_align(Add,Mult), Align = ",0:(((length("++Name++")"++Extra++") rem 2)*32)", {Str ++ Align,0}; -align_after(4,4,Add,Mult,Name,Str) -> +align_after(4,4,Add,Mult,Name,Str) -> Extra = extra_align(Add,Mult), Align = ",0:(((1+length("++Name++")"++Extra++") rem 2)*32)", {Str ++ Align,0}; @@ -531,14 +668,14 @@ align_after(Sz,A,Add,Mult,Name,Str) -> extra_align(0,1) -> ""; extra_align(0,M) when M > 1 -> "* " ++ integer_to_list(M); extra_align(A,1) when A > 0 -> "+ " ++ integer_to_list(A); -extra_align(A,M) when A > 0,M>1 -> +extra_align(A,M) when A > 0,M>1 -> "* " ++ integer_to_list(M) ++ "+ " ++ integer_to_list(A). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% have_return_vals(void, Ps) -> - lists:any(fun(#arg{in=In, type=#type{base=B}}) -> - In =/= true orelse B =:= memory + lists:any(fun(#arg{in=In, type=#type{base=B}}) -> + In =/= true orelse B =:= memory end, Ps); have_return_vals(#type{}, _) -> true. @@ -550,21 +687,28 @@ erl_arg_name(Name) -> uppercase(Name). check_name("begin") -> "'begin'"; check_name("end") -> "'end'"; check_name(Other) -> Other. - - -doc_name(Name0, Alt) -> - Name = doc_name2(Name0,Alt), -%% case lists:member(lists:last(Name0), "uvbisdf987654312") of -%% true -> io:format("~s ~s~n", [Name0,Name]); -%% false -> ignore -%% end, - Name. - -doc_name2(N="glGetBufferParameteriv", _) -> N; -doc_name2(N="glEnd", _) -> N; -doc_name2(Name, {has_vector,_,_}) -> + +doc_name(N="glGetBufferParameteriv", _) -> N; +doc_name("glEnd"++What, _) -> "glBegin"++What; +doc_name("glDisable" ++ What, _) -> "glEnable" ++ What; +doc_name("glPop" ++ What, _) -> "glPush" ++ What; +doc_name("glGetBooleanv", _) -> "glGet"; +doc_name("glGetBooleani_v", _) -> "glGet"; +doc_name("glGetIntegerv", _) -> "glGet"; +doc_name("glGetIntegeri_v", _) -> "glGet"; +doc_name("glGetInteger64v", _) -> "glGet"; +doc_name("glGetInteger64i_v", _) -> "glGet"; +doc_name("glGetFloatv", _) -> "glGet"; +doc_name("glGetDoublev", _) -> "glGet"; +doc_name("glGetFloati_v", _) -> "glGet"; +doc_name("glGetDoublei_v", _) -> "glGet"; +doc_name("glUniformMatr" ++ _, _) -> "glUniform"; +doc_name("glTexSubImage" ++ _, _) -> "glTexSubImage"; +doc_name("glFramebufferText" ++ _, _) -> "glFramebufferTexture"; +doc_name("glProgramUniformMatr" ++ _, _) -> "glProgramUniform"; +doc_name(Name, {has_vector,_,_}) -> strip_hard(reverse(Name)); -doc_name2(Name, _) -> +doc_name(Name, _) -> reverse(strip(reverse(Name))). strip_hard(Rev) -> @@ -583,6 +727,21 @@ strip([$v,$s,$N,N|R]) when N > 47, N < 58 -> R; strip([$v,$d,$N,N|R]) when N > 47, N < 58 -> R; strip([$v,$f,$N,N|R]) when N > 47, N < 58 -> R; strip([$b,$u,$N,N|R]) when N > 47, N < 58 -> R; +strip([$v,$b,$I,N|R]) when N > 47, N < 58 -> R; +strip([$v,$i,$I,N|R]) when N > 47, N < 58 -> R; +strip([$v,$s,$I,N|R]) when N > 47, N < 58 -> R; +strip([$v,$d,$I,N|R]) when N > 47, N < 58 -> R; +strip([$v,$f,$I,N|R]) when N > 47, N < 58 -> R; +strip([$b,$u,$I,N|R]) when N > 47, N < 58 -> R; + +strip([$v,$b,$u,N,$I|R]) when N > 47, N < 58 ->R; +strip([$v,$i,$u,N,$I|R]) when N > 47, N < 58 ->R; +strip([$v,$s,$u,N,$I|R]) when N > 47, N < 58 ->R; +strip([$v,$b,N,$I|R]) when N > 47, N < 58 -> R; +strip([$v,$i,N,$I|R]) when N > 47, N < 58 -> R; +strip([$v,$s,N,$I|R]) when N > 47, N < 58 -> R; +strip([$v,$d,N,$I|R]) when N > 47, N < 58 -> R; +strip([$v,$f,N,$I|R]) when N > 47, N < 58 -> R; strip([$v,$b,$u,N|R]) when N > 47, N < 58 ->R; strip([$v,$i,$u,N|R]) when N > 47, N < 58 ->R; @@ -593,6 +752,15 @@ strip([$v,$s,N|R]) when N > 47, N < 58 -> R; strip([$v,$d,N|R]) when N > 47, N < 58 -> R; strip([$v,$f,N|R]) when N > 47, N < 58 -> R; +strip([$b,$u,N,$I|R]) when N > 47, N < 58 ->R; +strip([$i,$u,N,$I|R]) when N > 47, N < 58 ->R; +strip([$s,$u,N,$I|R]) when N > 47, N < 58 ->R; +strip([$b,N,$I|R]) when N > 47, N < 58 -> R; +strip([$i,N,$I|R]) when N > 47, N < 58 -> R; +strip([$s,N,$I|R]) when N > 47, N < 58 -> R; +strip([$d,N,$I|R]) when N > 47, N < 58 -> R; +strip([$f,N,$I|R]) when N > 47, N < 58 -> R; + strip([$b,$u,N|R]) when N > 47, N < 58 ->R; strip([$i,$u,N|R]) when N > 47, N < 58 ->R; strip([$s,$u,N|R]) when N > 47, N < 58 ->R; @@ -606,6 +774,7 @@ strip([$v,$b,$u|R]) -> R; strip([$v,$i,$u|R]) -> R; strip([$v,$s,$u|R]) -> R; strip([$v,$b|R]) -> R; +strip([$v,$i,$I|R]) -> R; strip([$v,$i|R]) -> R; strip([$v,$s|R]) -> R; strip([$v,$d|R]) -> R; @@ -629,6 +798,12 @@ strip([$i,$n|R]) -> [$n|R]; strip([$f,$n|R]) -> [$n|R]; strip([$d,$n|R]) -> [$n|R]; +%% strip([$D,$3|R]) -> R; +%% strip([$D,$2|R]) -> R; +%% strip([$D,$1|R]) -> R; + +strip([$I|R]) -> R; +strip([$L|R]) -> R; strip([$v,R]) -> R; strip([N|R]) when N > 47, N < 58 -> R; strip([_|R="tceRlg"]) -> R; @@ -656,7 +831,6 @@ gen_debug(GL, GLU) -> w("].~n~n", []), close(). - printd([F|R],Mod) when is_list(F) -> printd(F,Mod), printd(R,Mod); @@ -667,6 +841,6 @@ printd(F,Mod) -> #func{where=erl} -> ok; #func{id=Id, name=Method} -> w(" {~p, {~s, ~s, 0}},~n", [Id, Mod, erl_func_name(Method)]); - _Other -> - io:format("F= ~p => ~p~n", [F, _Other]) + _Other -> + io:format("F= ~p => ~p~n", [F, _Other]) end. diff --git a/lib/wx/api_gen/gl_scan_doc.erl b/lib/wx/api_gen/gl_scan_doc.erl new file mode 100644 index 0000000000..fc7b7cf275 --- /dev/null +++ b/lib/wx/api_gen/gl_scan_doc.erl @@ -0,0 +1,286 @@ +%%-*-erlang-*- +%%-------------------------------------------------------------------- +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2012. 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% +%%---------------------------------------------------------------------- +-module(gl_scan_doc). + +-export([file/2]). +-export([event/3]). + +-compile(export_all). + +-define(error(Reason), + throw({gl_output_error, Reason})). + +-record(state, {type=undefined, gen_output=false, str=[]}). + +file(FileName, Options0) -> + {Options2, State} = parse_options(Options0), + Options = [skip_external_dtd, {event_fun, fun event/3}, {event_state, State}|Options2], + case xmerl_sax_parser:file(FileName, Options) of + {ok, #state{str=Str}, _} -> lists:reverse(Str); + Else -> Else + end. + +event(Event, _LineNo, State) -> + gen_output(Event, State). + +parse_options(Options) -> + parse_options(Options, #state{}). + +parse_options(Options, State) -> + {Options, State}. + +%% Element +%%---------------------------------------------------------------------- +gen_output({characters, String0}, #state{gen_output=true, type=Type, str=Str} = State) -> + case fix_str(strip_white_space(String0)) of + [] -> State; + String -> + Add = case Type of + mi -> case hd(Str) of + "/" -> String; + "*" -> String; + "+" -> String; + "-" -> String; + {fenced,_,_} -> String; + _ -> + [$ |String] + end; + constant -> {constant, String}; + emphasis -> {emphasis, String}; + function -> {function, String}; + reffunc -> {reffunc, String}; + purpose -> {purpose, String}; + parameter -> {parameter, String}; + equation -> {equation, String}; + _ -> String + end, + State#state{str=[Add|Str]} + end; + +gen_output({startElement, _Uri, "function", _QName, _Attributes}, #state{gen_output=true} = State) -> + State#state{type=function}; +gen_output({endElement, _Uri, "function", _QName}, #state{gen_output=true} = State) -> + State#state{type=undefined}; + +gen_output({startElement, _Uri, "constant", _QName, _Attributes}, #state{gen_output=true} = State) -> + State#state{type=constant}; +gen_output({endElement, _Uri, "constant", _QName}, #state{gen_output=true} = State) -> + State#state{type=undefined}; + +gen_output({startElement, _Uri, "parameter", _QName, _Attributes}, #state{gen_output=true} = State) -> + State#state{type=parameter}; +gen_output({endElement, _Uri, "parameter", _QName}, #state{gen_output=true} = State) -> + State#state{type=undefined}; + +gen_output({startElement, _Uri, "emphasis", _QName, _Attributes}, #state{gen_output=true} = State) -> + State#state{type=emphasis}; +gen_output({endElement, _Uri, "emphasis", _QName}, #state{gen_output=true} = State) -> + State#state{type=undefined}; + +gen_output(startDocument, State) -> + State; +gen_output(endDocument, State) -> + State; + +gen_output({startElement, _Uri, "refentrytitle", _QName, _Attributes}, #state{gen_output=true} = State) -> + State#state{type=reffunc}; +gen_output({endElement, _Uri, "refentrytitle", _QName}, #state{gen_output=true} = State) -> + State#state{type=undefined}; + +gen_output({startElement, _Uri, "refpurpose", _QName, _Attributes}, State) -> + State#state{gen_output=true, type=purpose}; +gen_output({endElement, _Uri, "refpurpose", _QName}, State) -> + State#state{gen_output=false, type=undefined}; + +gen_output({startElement, _Uri, "refsect1", _QName, [{_, _, "id", "description"}]}, State) -> + State#state{gen_output=true}; +gen_output({endElement, _Uri, "refsect1", _QName}, State) -> + State#state{gen_output=false}; + +gen_output({startElement, _Uri, "title", _QName, _Attributes}, #state{gen_output=true} = State) -> + State#state{gen_output=skip}; +gen_output({endElement, _Uri, "title", _QName}, #state{gen_output=skip} = State) -> + State#state{gen_output=true}; + +%% gen_output({startElement, _Uri, "inlineequation", _QName, _Attributes}, #state{gen_output=true} = State) -> +%% State#state{type=equation}; +%% gen_output({endElement, _Uri, "inlineequation", _QName}, #state{gen_output=skip} = State) -> +%% State#state{type=undefined}; +%% gen_output({startElement, _Uri, "informalequation", _QName, _Attributes}, #state{gen_output=true} = State) -> +%% State#state{type=equation}; +%% gen_output({endElement, _Uri, "informalequation", _QName}, #state{gen_output=skip} = State) -> +%% State#state{type=undefined}; +gen_output({startElement, _Uri, "mfenced", _QName, Attributes}, #state{gen_output=true, str=Str} = State) -> + Fenc = get_fenc(Attributes, "(", ")"), + State#state{str=[Fenc|Str]}; +gen_output({endElement, _Uri, "mfenced", _QName}, #state{gen_output=true, str=Str0} = State) -> + Check = fun(What) -> case What of {fenced,_,_} ->false; _ -> true end end, + {Fenced, [{fenced, Open, Close}|Str]} = lists:splitwith(Check, Str0), + State#state{str=[{fenced, Open, Close, lists:reverse(Fenced)}| Str]}; + +%% gen_output({startElement, _Uri, "tgroup", _QName, Attributes}, #state{gen_output=true, str=Str} = State) -> +%% {_, _, _, ValueStr} = lists:keyfind(3, "cols", Attributes), +%% ColSz = list_to_integer(ValueStr), +%% State#state{str=[{tgroup, ColSz}|Str]}; +%% gen_output({endElement, _Uri, "tgroup", _QName}, #state{gen_output=true, str=Str0} = State) -> +%% Check = fun(What) -> case What of {tgroup, _} ->false; _ -> true end end, +%% {Rows, [{tgroup, ColSize}|Str]} = lists:splitwith(Check, Str0), +%% State#state{str=[{tgroup, ColSize, lists:reverse(Rows)}| Str]}; + +%% gen_output({endElement, _Uri, "row", _QName}, #state{gen_output=true, str=Str} = State) -> +%% State#state{type=undefined, str=[break|Str]}; +gen_output({startElement, _Uri, "informaltable", _QName, _Attributes}, #state{gen_output=true, str=Str} = State) -> + State#state{str=["<table>"|Str]}; +gen_output({endElement, _Uri, "informaltable", _QName}, #state{gen_output=true, str=Str} = State) -> + State#state{str=["</table>"|Str]}; +gen_output({startElement, _Uri, "table", _QName, _Attributes}, #state{gen_output=true, str=Str} = State) -> + State#state{str=["<table>"|Str]}; +gen_output({endElement, _Uri, "table", _QName}, #state{gen_output=true, str=Str} = State) -> + State#state{str=["</table>"|Str]}; + +gen_output({startElement, _Uri, "tbody", _QName, _Attributes}, #state{gen_output=true, str=Str} = State) -> + State#state{str=["<tbody>"|Str]}; +gen_output({endElement, _Uri, "tbody", _QName}, #state{gen_output=true, str=Str} = State) -> + State#state{str=["</tbody>"|Str]}; + +gen_output({startElement, _Uri, "thead", _QName, _Attributes}, #state{gen_output=true, str=Str} = State) -> + State#state{str=["<tbody>"|Str]}; +gen_output({endElement, _Uri, "thead", _QName}, #state{gen_output=true, str=Str} = State) -> + State#state{str=["</tbody>"|Str]}; +gen_output({startElement, _Uri, "row", _QName, _Attributes}, #state{gen_output=true, str=Str} = State) -> + State#state{str=["<tr>"|Str]}; +gen_output({endElement, _Uri, "row", _QName}, #state{gen_output=true, str=Str} = State) -> + State#state{str=["</tr>"|Str]}; +gen_output({startElement, _Uri, "entry", _QName, _Attributes}, #state{gen_output=true, str=Str} = State) -> + State#state{str=["<td>"|Str]}; +gen_output({endElement, _Uri, "entry", _QName}, #state{gen_output=true, str=Str} = State) -> + State#state{str=["</td>"|Str]}; + +gen_output({startElement, _Uri, "mi", _QName, _Attributes}, #state{gen_output=true} = State) -> + State#state{type=mi}; +gen_output({endElement, _Uri, "mi", _QName}, #state{gen_output=true} = State) -> + State#state{type=undefined}; +gen_output({startElement, _Uri, "mn", _QName, _Attributes}, #state{gen_output=true} = State) -> + State#state{type=mi}; +gen_output({endElement, _Uri, "mn", _QName}, #state{gen_output=true} = State) -> + State#state{type=undefined}; + + + +gen_output({startElement, _Uri, "varlistentry", _QName, _Attributes}, #state{gen_output=true, str=Str} = State) -> + State#state{str=[listentry|Str]}; + +gen_output({endElement, _Uri, "mfrac", _QName}, #state{gen_output=true, str=[A0,B|Str]} = State) -> + A = case A0 of + [$ |A1] -> A1; + A1 -> A1 + end, + State#state{str=[A,"/",B|Str]}; + +gen_output({startElement, _Uri, "para", _QName, _Attributes}, #state{gen_output=true, str=Str} = State) -> + case Str of + [para|_] -> State; + [": "|_] -> State; + [Const, listentry | Rest] -> + State#state{str=[": ",Const,para|Rest]}; + [Mod, Const, listentry | Rest] -> + State#state{str=[": ",Mod,Const,para|Rest]}; + _ -> + State#state{str=[para|Str]} + end; + +%% gen_output({startElement, _Uri, What, _QName, _Attributes}, State) -> +%% io:format("Skipped ~s~n",[What]), +%% State; + +gen_output(_E, State) -> + State. + +%%---------------------------------------------------------------------- +%% Function : parse_attributes(Attributes) -> Result +%% Parameters: +%% Result : +%% Description: +%%---------------------------------------------------------------------- +print_attributes([]) -> + ok; +print_attributes([{_Uri, _Prefix, LocalName, AttrValue} |Attributes]) -> + io:format(" ~s=\"~s\"",[LocalName, AttrValue]), + print_attributes(Attributes). + +get_fenc([{_Uri, _Prefix, "open", AttrValue} |Attributes], _Open, Close) + when AttrValue /= "" -> + get_fenc(Attributes, fenc(AttrValue), Close); +get_fenc([{_Uri, _Prefix, "close", AttrValue} |Attributes], Open, _Close) + when AttrValue /= "" -> + get_fenc(Attributes, Open, fenc(AttrValue)); +get_fenc([_|Attributes], Open, Close) -> + get_fenc(Attributes, Open, Close); +get_fenc([], Open, Close) -> + {fenced,Open,Close}. + +fenc("∥") -> "||"; +fenc("∣") -> "|"; +fenc("⌈") -> "|"; +fenc("⌉") -> "|"; +fenc("⌈") -> "|"; +fenc("⌉") -> "|"; +fenc("⌊") -> "|"; +fenc("⌋") -> "|"; +fenc("⌊") -> "|"; +fenc("⌋") -> "|"; +fenc("[") -> "["; +fenc("]") -> "]"; +fenc(Else = [_]) -> Else. + +strip_white_space([$ | Str = [$ |_]]) -> + strip_white_space(Str); +strip_white_space([$\n| Str]) -> + strip_white_space([$ |Str]); +strip_white_space([$\t| Str]) -> + strip_white_space([$ |Str]); +strip_white_space([$\\| Str]) -> + strip_white_space(Str); + +strip_white_space([Char|Str]) -> + [Char|strip_white_space(Str)]; +strip_white_space([]) -> []. + +fix_str([$<|Str]) -> + [$&,$l,$t,$;|fix_str(Str)]; +fix_str([$>|Str]) -> + [$&,$g,$t,$;|fix_str(Str)]; +fix_str("×"++Str) -> + [$*|fix_str(Str)]; +fix_str("″"++Str) -> + [$"|fix_str(Str)]; +fix_str("·"++Str) -> + [$.|fix_str(Str)]; +fix_str("⁡"++Str) -> + fix_str(Str); +fix_str("⁢"++Str) -> + [$ |fix_str(Str)]; +fix_str([$&|Str]) -> + [$&,$a,$m,$p,$; |fix_str(Str)]; +fix_str([C|Str]) when C > 255 -> + fix_str(Str); +fix_str([C|Str]) -> + [C|fix_str(Str)]; +fix_str([]) -> []. diff --git a/lib/wx/api_gen/glapi.conf b/lib/wx/api_gen/glapi.conf index 525ccf8b68..59fa8f7727 100644 --- a/lib/wx/api_gen/glapi.conf +++ b/lib/wx/api_gen/glapi.conf @@ -57,11 +57,13 @@ "glVertexAttribP3", %* "glVertexAttribP4", %* - "glGetActiveSubroutineUniformiv", %% Bad API don't know what to allocate needs to ask + %% Bad API don't know what to allocate needs to ask + "glGetActiveSubroutineUniformiv", + "glGetActiveAtomicCounterBufferiv", %% EXT %% By default skip these extensions - "SGIX","SGIS","NV","ATI","AMD","SUN","SUNX","GREMEDY", + "SGIX","SGIS","NV","ATI","AMD","SUN","SUNX","GREMEDY","OES","MESA", "HP","IBM","INTEL","APPLE","3DFX","PGI","EXT"]}. %% Exceptions to the above @@ -336,7 +338,6 @@ {"length", [skip, {single, true}]}, {"name", {string,"bufSize","length"}}]}. - {"glGenRenderbuffers", {"renderbuffers", {single,{list,"n","n"}}}}. {"glGenFramebuffers", {"framebuffers",{single,{list,"n","n"}}}}. {"glGetRenderbufferParameteriv", {"params", {single,true}}}. @@ -491,4 +492,5 @@ {"glScissorIndexedv", {"v", {single,{tuple,4}}}}. {"glDepthRangeArrayv", [{"count",{c_only,{length,"v"}}}, {"v", [{single,{tuple_list,2}}]}]}. +{"glGetInternalformativ", {"params", [out, {single, {list, "bufSize", "bufSize"}}]}}. diff --git a/lib/wx/api_gen/wx_extra/wxEvtHandler.erl b/lib/wx/api_gen/wx_extra/wxEvtHandler.erl index 080ebfa49f..23a34225ca 100644 --- a/lib/wx/api_gen/wx_extra/wxEvtHandler.erl +++ b/lib/wx/api_gen/wx_extra/wxEvtHandler.erl @@ -18,10 +18,7 @@ %% <a href="http://www.wxwidgets.org/manuals/stable/wx_wxevthandler.html"> %% The orginal documentation</a>. %% -%% @headerfile "../../include/wx.hrl" %% -%%@type wxEvtHandler(). An object reference - -module(wxEvtHandler). -include("wxe.hrl"). -include("../include/wx.hrl"). @@ -34,17 +31,16 @@ new_evt_listener/0, destroy_evt_listener/1, get_callback/1, replace_fun_with_id/2]). --record(evh, {et=null,id=?wxID_ANY,lastId=?wxID_ANY,skip=undefined,userdata=[],cb=0}). - +-export_type([wxEvtHandler/0, wx/0, event/0]). +-type wxEvtHandler() :: wx:wx_object(). +-record(evh, {et=null,id=?wxID_ANY,lastId=?wxID_ANY,skip=undefined,userdata=[],cb=0}). -%% @spec (This::wxEvtHandler(), EventType::wxEventType()) -> ok %% @doc Equivalent to {@link connect/3. connect(This, EventType, [])} - +-spec connect(This::wxEvtHandler(), EventType::wxEventType()) -> ok. connect(This, EventType) -> connect(This, EventType, []). -%% @spec (This::wxEvtHandler(), EventType::wxEventType(), [Options]) -> ok %% @doc This function subscribes the to events of EventType, %% in the range id, lastId. The events will be received as messages %% if no callback is supplied. @@ -63,6 +59,9 @@ connect(This, EventType) -> %% to process the event. Default not specfied i.e. a message will %% be delivered to the process calling this function. %% {userData, term()} An erlang term that will be sent with the event. Default: []. +-spec connect(This::wxEvtHandler(), EventType::wxEventType(), [Option]) -> ok when + Option :: {id, integer()} | {lastId, integer()} | {skip, boolean()} | + {callback, function()} | {userData, term()}. connect(This=#wx_ref{type=ThisT}, EventType, Options) -> EvH = parse_opts(Options, #evh{et=EventType}), ?CLASS(ThisT,wxEvtHandler), @@ -99,26 +98,27 @@ parse_opts([], Opts = #evh{id=Id,lastId=Lid,skip=Skip, cb=CB}) -> Opts end. -%% @spec (This::wxEvtHandler()) -> true | false + %% @doc Equivalent to {@link disconnect/3. disconnect(This, null, [])} %% Can also have an optional callback Fun() as an additional last argument. - +-spec disconnect(This::wxEvtHandler()) -> boolean(). disconnect(This=#wx_ref{type=ThisT,ref=_ThisRef}) -> ?CLASS(ThisT,wxEvtHandler), disconnect(This, null, []). -%% @spec (This::wxEvtHandler(), EventType::wxEventType()) -> true | false %% @doc Equivalent to {@link disconnect/3. disconnect(This, EventType, [])} +-spec disconnect(This::wxEvtHandler(), EventType::wxEventType()) -> boolean(). disconnect(This=#wx_ref{type=ThisT,ref=_ThisRef}, EventType) when is_atom(EventType) -> ?CLASS(ThisT,wxEvtHandler), disconnect(This, EventType, []). -%% @spec (This::wxEvtHandler(), EventType::wxEventType(), Opts) -> true | false %% @doc See <a href="http://www.wxwidgets.org/manuals/stable/wx_wxevthandler.html#wxevthandlerdisconnect">external documentation</a> %% This function unsubscribes the process or callback fun from the event handler. %% EventType may be the atom 'null' to match any eventtype. %% Notice that the options skip and userdata is not used to match the eventhandler. -disconnect(This=#wx_ref{type=ThisT,ref=_ThisRef}, EventType, Opts) -> +-spec disconnect(This::wxEvtHandler(), EventType::wxEventType(), [Option]) -> boolean() when + Option :: {id, integer()} | {lastId, integer()} | {callback, function()}. +disconnect(This=#wx_ref{type=ThisT,ref=_ThisRef}, EventType, Opts) -> ?CLASS(ThisT,wxEvtHandler), EvH = parse_opts(Opts, #evh{et=EventType}), case wxe_util:disconnect_cb(This, EvH) of diff --git a/lib/wx/api_gen/wx_gen.erl b/lib/wx/api_gen/wx_gen.erl index 209de48496..7f85151d03 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-2011. All Rights Reserved. +%% Copyright Ericsson AB 2008-2012. 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 @@ -665,7 +665,11 @@ extract_type_info2("&", Acc) -> [{by_ref,reference}|Acc]; extract_type_info2("WXDLLIMP" ++ _, Acc) -> Acc; extract_type_info2(Type, Acc) -> [Type|Acc]. -parse_type2(["void"], _Info, _Opts, _T) -> void; +parse_type2(["void"], _Info, _Opts, #type{by_val=ByVal}) -> + case ByVal of + true -> void; + false -> voidp + end; parse_type2(["virtual"|R], _Info, _Opts, _T) -> [] = R, %% Bug in old doxygen virtual destructors have type virtual @@ -1106,6 +1110,7 @@ type_foot_print(#type{base={enum,_}}) -> int; type_foot_print(#type{base={ref,_}}) -> ref; type_foot_print(#type{base={term,_}}) -> term; type_foot_print(#type{base=eventType}) -> atom; +type_foot_print(voidp) -> int; %% type_foot_print({Type,Str}) when is_list(Str) -> %% type_foot_print(Type); type_foot_print(#type{base={comp,_,R={record,_}}}) -> diff --git a/lib/wx/api_gen/wx_gen_cpp.erl b/lib/wx/api_gen/wx_gen_cpp.erl index 1b4c32db24..69e7510a95 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-2011. All Rights Reserved. +%% Copyright Ericsson AB 2008-2012. 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 @@ -64,11 +64,16 @@ gen_derived_dest(Defs) -> [gen_derived_dest_2(Class) || Class <- Defs], ok. -gen_derived_dest_2(C=#class{name=Class}) -> +gen_derived_dest_2(C=#class{name=Class, options=Opts}) -> ?WTC("gen_derived_dest_2"), Derived = is_derived(C), TaylorMade = taylormade_class(C), + if Derived andalso (TaylorMade =:= false) -> + case lists:keysearch(ifdef,1,Opts) of + {value, {ifdef, What}} -> w("#if ~p~n",[What]); + _ -> ok + end, w("class E~s : public ~s {~n",[Class,Class]), case Class of "wxGLCanvas" -> %% Special for cleaning up gl context @@ -78,7 +83,13 @@ gen_derived_dest_2(C=#class{name=Class}) -> w(" public: ~~E~s() {((WxeApp *)wxTheApp)->clearPtr(this);};~n", [Class]) end, gen_constructors(C), - w("};~n~n", []); + case lists:keysearch(ifdef,1,Opts) of + {value, {ifdef, Endif}} -> + w("};~n", []), + w("#endif // ~p~n~n",[Endif]); + _ -> + w("};~n~n", []) + end; TaylorMade /= false -> w("~s~n", [TaylorMade]); true -> @@ -324,6 +335,8 @@ declare_var(P = #param{name=Name,in=In,def=Def,type=Type}) -> declare_type(N,false,_,#type{name="wxArrayInt"}) -> w(" wxArrayInt ~s;~n", [N]); +declare_type(N,false,_,#type{name="wxArrayDouble"}) -> + w(" wxArrayDouble ~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}) @@ -335,6 +348,8 @@ declare_type(N,false,_,#type{name="wxArrayTreeItemIds",ref=reference}) -> w(" wxArrayTreeItemIds ~s;~n", [N]); declare_type(N,false,_,#type{name="wxDateTime"}) -> w(" wxDateTime ~s;~n", [N]); +declare_type(N,false,_,#type{name="wxColour"}) -> + w(" wxColour ~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}) @@ -363,6 +378,8 @@ declare_type(N,true,Def,#type{base=binary, name=char}) -> w(" char ~sD[] = {~s}, * ~s = ~sD;~n", [N,Def,N,N]); declare_type(_N,true,_Def,void) -> skip; +declare_type(_N,true,_Def,voidp) -> + skip; declare_type(N,true,Def,#type{name=Type, ref={pointer,2}}) -> %% xxxx w(" ~s ** ~s = ~s;~n", [Type,N,Def]); @@ -645,6 +662,16 @@ decode_arg(N,#type{name=Type,single=list,base={class,Class}},arg,A0) -> w(" ~s.Append(*(~s *) getPtr(bp,memenv)); bp += 4;}~n", [N,Class]), w(" bp += ((~p+ *~sLen)%2 )*4;~n", [A,N]), 0; +decode_arg(N,#type{single=array,base={comp,Class="wxPoint2DDouble",_}},arg,A0) -> + 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), + align(A0+1,64), + w(" for(int i=0; i < *~sLen; i++) {~n", [N]), + w(" double x = * (double *) bp; bp += 8;~n double y = * (double *) bp; bp += 8;~n", []), + w(" ~s[i] = wxPoint2DDouble(x,y);}~n", [N]), + 0; decode_arg(Name,T, Arg,_A) -> ?error({unhandled_type, {Name,T, Arg}}). @@ -792,6 +819,7 @@ call_arg(#param{name=N,type={merged,_,#type{base={class,_},single=true, when ByVal =:= true; Ref =:= reference -> "*" ++ N; call_arg(#param{def=Def, type=void}) when Def =/= none -> Def; +call_arg(#param{def=Def, type=voidp}) 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. @@ -917,6 +945,8 @@ build_ret(Name,_,#type{base=int,single=true,mod=M}) -> end; build_ret(Name,_,#type{name="wxArrayInt"}) -> w(" rt.add(~s);~n", [Name]); +build_ret(Name,_,#type{name="wxArrayDouble"}) -> + w(" rt.add(~s);~n", [Name]); 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]), @@ -1031,6 +1061,7 @@ gen_macros() -> w("#include <wx/toolbook.h>~n"), w("#include <wx/listbook.h>~n"), w("#include <wx/treebook.h>~n"), + w("#include <wx/taskbar.h>~n"), w("#include <wx/html/htmlwin.h>~n"), w("#include <wx/html/htmlcell.h>~n"), w("#include <wx/filename.h>~n"), diff --git a/lib/wx/api_gen/wx_gen_erl.erl b/lib/wx/api_gen/wx_gen_erl.erl index 5d73d93ead..aac57586bc 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-2011. All Rights Reserved. +%% Copyright Ericsson AB 2008-2012. 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 @@ -28,12 +28,16 @@ -include("wx_gen.hrl"). --compile(export_all). +%%-compile(export_all). +-export([gen/1]). +-export([parents/1, get_unique_names/0, get_unique_name/1, + event_type_name/1, event_rec_name/1, filter_attrs/1]). --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, + +-import(lists, [foldl/3,reverse/1, filter/2]). +-import(gen_util, [lowercase/1, lowercase_all/1, uppercase/1, open_write/1, close/0, erl_copyright/0, w/2, - args/3, args/4, strip_name/2]). + args/3, args/4]). gen(Defs) -> [put({class,N},C) || C=#class{name=N} <- Defs], @@ -128,8 +132,6 @@ gen_class1(C=#class{name=Name,parent=Parent,methods=Ms,options=Opts}) -> w("%% stored on disc or distributed for use on other nodes.~n~n", []), w("-module(~s).~n", [Name]), w("-include(\"wxe.hrl\").~n",[]), - %% w("-compile(export_all).~n~n", []), %% XXXX remove ??? - %% w("-compile(nowarn_unused_vars).~n~n", []), %% XXXX remove ??? 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)]), @@ -140,10 +142,10 @@ gen_class1(C=#class{name=Name,parent=Parent,methods=Ms,options=Opts}) -> w("-export([~s]).~n~n", [args(fun(EF) -> EF end, ",", lists:usort(["parent_class/1"|InExported]), 60)]), - + w("-export_type([~s/0]).~n", [Name]), w("%% @hidden~n", []), parents_check(Parents), - + w("-type ~s() :: wx:wx_object().~n", [Name]), Gen = fun(M) -> gen_method(Name,M) end, NewMs = lists:map(Gen,reverse(Ms)), gen_dest(C, Ms), @@ -317,8 +319,8 @@ gen_dest(#class{name=CName,abstract=Abs}, Ms) -> end. gen_dest2(Class, Id) -> - w("%% @spec (This::~s()) -> ok~n", [Class]), w("%% @doc Destroys this object, do not use object again~n", []), + w("-spec destroy(This::~s()) -> ok.~n", [Class]), w("destroy(Obj=#wx_ref{type=Type}) ->~n", []), w(" ?CLASS(Type,~s),~n",[Class]), case Id of @@ -601,9 +603,9 @@ guard_test(#param{name=N,type=#type{base=int64}}) -> guard_test(#param{name=N,type=#type{base=long}}) -> "is_integer(" ++ erl_arg_name(N) ++ ")"; guard_test(#param{name=N,type=#type{base=float}}) -> - "is_float(" ++ erl_arg_name(N) ++ ")"; + "is_number(" ++ erl_arg_name(N) ++ ")"; guard_test(#param{name=N,type=#type{base=double}}) -> - "is_float(" ++ erl_arg_name(N) ++ ")"; + "is_number(" ++ erl_arg_name(N) ++ ")"; guard_test(#param{name=N,type=#type{base=bool}}) -> "is_boolean(" ++ erl_arg_name(N) ++ ")"; guard_test(#param{name=N,type=#type{name="wxDateTime"}}) -> @@ -635,181 +637,141 @@ guard_test(#param{name=N,type={class,ignore}}) -> guard_test(T) -> ?error({unknown_type,T}). gen_doc(_Class, [#method{method_type=destructor}]) -> skip; -gen_doc(_Class,[#method{name=N,alias=A,params=Ps,type=T,where=erl_no_opt,method_type=MT}])-> - w("%% @spec (~s~s) -> ~s~n",[doc_arg_types(Ps),"",doc_return_types(T,Ps)]), +gen_doc(_Class,Ms=[#method{name=N,alias=A,params=Ps,where=erl_no_opt,method_type=MT}])-> w("%% @equiv ", []), - 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, - Def =:= none, In =/= false, Where =/= c], - OptsType = case Optional of - [] -> ""; - _ when NonDef =:= [] -> "[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), - case Class of - "utils" -> - w("%% @doc See <a href=\"http://www.wxwidgets.org/manuals/stable/wx_miscellany.html#~s\">" - "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", - [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}) -> - doc_return_types(T,Ps) - end, - 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) || - P=#param{in=In,def=none,where=W} <- Ps, - In =/= false, W =/= c] ++ Opt - end, - Args = zip(lists:map(GetArgs, Cs)), - Ret = lists:map(GetRet, Cs), - w("%% @spec (~s) -> ~s~n",[args(fun doc_arg/1,",",Args),doc_ret(Ret)]), - case Class of - "utils" -> - w("%% @doc See <a href=\"http://www.wxwidgets.org/manuals/stable/wx_miscellany.html#~s\">" - "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", - [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_function_clause(erl_func_name(N,A),MT,Ps,empty_list,[no_guards,name_only]), + w("~n-spec ",[]), + write_specs(Ms, "\n"); +gen_doc(Class,Ms=[#method{name=N, type=T}|Rest])-> + %%doc_optional(Optional, normal), + doc_link(Class, N), + gen_overload_doc(Rest), + Ps = lists:foldl(fun(#method{params=Ps}, Acc) -> Ps ++ Acc end,[],Ms), + doc_enum_desc(lists:usort(doc_enum(T,Ps))), + w("-spec ",[]), + write_specs(Ms, "\n"), ok. -gen_doc2(Name,#method{params=Ps,where=erl_no_opt,method_type=MT}) -> - w("%% <p><c>~n",[]), - w("%% ~s(~s) -> ", [Name,doc_arg_types(Ps)]), - gen_function_clause(Name,MT,Ps,empty_list,[no_guards,name_only]), - w(" </c></p>~n",[]); -gen_doc2(Name,#method{params=Ps,type=T}) -> +gen_overload_doc([]) -> ok; +%%gen_overload_doc(_) -> ok; +gen_overload_doc(Cs) -> + w("%% <br /> Also:<br />~n%% ",[]), + write_specs(Cs, "<br />\n%% "), + w("~n", []). + +write_specs(M=[#method{method_type=constructor}|_], Eol) -> + w("new", []), + write_specs1(M, Eol); +write_specs(M=[#method{name=N, alias=A}|_], Eol) -> + w("~s", [erl_func_name(N,A)]), + write_specs1(M, Eol). + +write_specs1([M], Eol) -> + write_spec(M, Eol), + w(".~s", [Eol]); +write_specs1([M|Next], Eol) -> + write_spec(M, Eol), + w(";~s ", [Eol]), + write_specs1(Next, Eol). + +write_spec(#method{params=Ps,type=T,where=erl_no_opt}, Eol) -> + {NonDef, _Optional} = split_optional(Ps), + Res = doc_return_types(T,Ps), + write_spec(NonDef, [], Res, Eol); +write_spec(#method{params=Ps,type=T}, Eol) -> {NonDef, Optional} = split_optional(Ps), - OptsType = case Optional of - [] -> ""; - _ when NonDef =:= [] -> "[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)]), - doc_optional(Optional, xhtml), - DocEnum = doc_enum(T,Ps, xhtml), - doc_enum_desc(DocEnum), - w("%% </p>~n",[]). - -doc_arg(ArgList) -> - case all_eq(ArgList) of - true -> hd(ArgList); - false -> - Get = fun(Str) -> - [_Name|Types] = string:tokens(Str, ":"), - case Types of - [Type] -> Type; - _ -> - "term()" - end - end, - Args0 = lists:map(Get, ArgList), - Args = unique(Args0, []), - "X::" ++ args(fun(A) -> A end, "|", Args) - end. - -doc_ret(ArgList) -> - case all_eq(ArgList) of - true -> hd(ArgList); - false -> - args(fun(A) -> A end, "|", ArgList) - end. - -unique([], U) -> reverse(U); -unique([H|R], U) -> - case lists:member(H,U) of - false -> unique(R,[H|U]); - true -> unique(R,U) - end. - -all_eq([H|R]) -> all_eq(R,H). - -all_eq([H|R],H) -> all_eq(R,H); -all_eq([],_) -> true; -all_eq(_,_) -> false. - -zip(List) -> - zip(List, [], [], []). - -zip([[F|L1]|List], Rest, AccL, Acc) -> - zip(List, [L1|Rest], [F|AccL], Acc); -zip(Empty, Rest, AccL, Acc) -> - true = empty(Empty), - case empty(Rest) andalso empty(AccL) of - true -> reverse(Acc); - false -> - zip(reverse(Rest), [], [], [reverse(AccL)|Acc]) - end. - -empty([[]|R]) -> empty(R); -empty([]) -> true; -empty(_) -> false. + Res = doc_return_types(T,Ps), + write_spec(NonDef, Optional, Res, Eol). + +write_spec([], [], {simple, Res}, _Eol) -> + w("() -> ~s", [Res]); +write_spec([], [], {complex, Res}, Eol) -> + w("() -> Resultwhen~s\tResult ::~s", [Eol,Res]); +write_spec(Args, [], {simple, Res}, Eol) -> + w("(~s) -> ~s when~s\t~s", + [erl_arg_names(Args), Res, Eol, doc_arg_types(Args)]); +write_spec(Args, [], {complex, Res}, Eol) -> + w("(~s) -> Result when~s\tResult ::~s,~s\t~s", + [erl_arg_names(Args), Eol, Res, Eol, doc_arg_types(Args)]); +write_spec([], Optional, {simple, Res}, Eol) -> + w("([Option]) -> ~s when~s\t~s", + [Res, Eol, optional_type(Optional, Eol)]); +write_spec([], Optional, {complex, Res}, Eol) -> + w("([Option]) -> Result when~s\tResult :: ~s,~s\t~s", + [Eol, Res, Eol, optional_type(Optional, Eol)]); +write_spec(Args, Optional, {simple, Res}, Eol) -> + w("(~s, [Option]) -> ~s when~s\t~s,~s\t~s", + [erl_arg_names(Args), Res, Eol, doc_arg_types(Args), Eol, optional_type(Optional, Eol)]); +write_spec(Args, Optional, {complex, Res}, Eol) -> + w("(~s, [Option]) -> Result when~s\tResult :: ~s,~s\t~s,~s\t~s", + [erl_arg_names(Args), Eol, Res, Eol, doc_arg_types(Args), Eol, optional_type(Optional, Eol)]). + +optional_type(Opts, Eol) -> + "Option :: " ++ args(fun optional_type2/1, Eol++"\t\t | ", Opts). +optional_type2(#param{name=Name, def=Def, type=T}) -> + "{" ++ erl_option_name(Name) ++ ", " ++ doc_arg_type2(T) ++ "}". %% %% Default: " ++ Def. + +doc_link("utils", Func) -> + w("%% @doc See <a href=\"http://www.wxwidgets.org/manuals/stable/wx_miscellany.html#~s\">" + "external documentation</a>.~n", + [lowercase_all(Func)]); +doc_link(Class, Func) -> + w("%% @doc See <a href=\"http://www.wxwidgets.org/manuals/stable/wx_~s.html#~s~s\">" + "external documentation</a>.~n", + [lowercase_all(Class),lowercase_all(Class),lowercase_all(Func)]). + +erl_arg_names(Ps0) -> + Ps = [Name || #param{name=Name, in=In, where=Where} <- Ps0,In =/= false, Where =/= c], + args(fun erl_arg_name/1, ", ", Ps). doc_arg_types(Ps0) -> Ps = [P || P=#param{in=In, where=Where} <- Ps0,In =/= false, Where =/= c], args(fun doc_arg_type/1, ", ", Ps). -doc_arg_type(#param{name=Name,def=none,type=T}) -> - erl_arg_name(Name) ++ "::" ++ doc_arg_type2(T); -doc_arg_type(#param{name=Name,in=false,type=T}) -> - erl_arg_name(Name) ++ "::" ++ doc_arg_type2(T); -doc_arg_type(_) -> skip. - -doc_arg_type2(T=#type{single=Single}) when Single =:= array; Single =:= list -> - "[" ++ doc_arg_type3(T) ++ "]"; + +doc_arg_type(T) -> + doc_arg_type(T, in). + +doc_arg_type(#param{name=Name,def=none,type=T}, Out) -> + erl_arg_name(Name) ++ "::" ++ doc_arg_type2(T, Out); +doc_arg_type(#param{name=Name,in=false,type=T}, Out) -> + erl_arg_name(Name) ++ "::" ++ doc_arg_type2(T, Out); +doc_arg_type(_, _) -> skip. + doc_arg_type2(T) -> - doc_arg_type3(T). - -doc_arg_type3(#type{base=string}) -> "string()"; -doc_arg_type3(#type{name="wxChar", single=S}) when S =/= true -> "string()"; -doc_arg_type3(#type{name="wxArrayString"}) -> "[string()]"; -doc_arg_type3(#type{name="wxDateTime"}) -> "wx:datetime()"; -doc_arg_type3(#type{name="wxArtClient"}) -> "string()"; -doc_arg_type3(#type{base=int}) -> "integer()"; -doc_arg_type3(#type{base=int64}) -> "integer()"; -doc_arg_type3(#type{base=long}) -> "integer()"; -doc_arg_type3(#type{name="wxTreeItemId"}) -> "wxTreeCtrl:treeItemId()"; -doc_arg_type3(#type{base=bool}) -> "bool()"; -doc_arg_type3(#type{base=float}) -> "float()"; -doc_arg_type3(#type{base=double}) -> "float()"; -doc_arg_type3(#type{base=binary}) -> "binary()"; -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}}) -> + doc_arg_type2(T, in). + +doc_arg_type2(T=#type{single=Single}, Out) when Single =:= array; Single =:= list -> + "[" ++ doc_arg_type3(T, Out) ++ "]"; +doc_arg_type2(T, Out) -> + doc_arg_type3(T, Out). + +doc_arg_type3(#type{base=string}, in) -> "unicode:chardata()"; +doc_arg_type3(#type{base=string}, out) -> "unicode:charlist()"; +doc_arg_type3(#type{name="wxChar", single=S},in) when S =/= true -> "unicode:chardata()"; +doc_arg_type3(#type{name="wxChar", single=S},out) when S =/= true -> "unicode:charlist()"; +doc_arg_type3(#type{name="wxArrayString"},in) -> "[unicode:chardata()]"; +doc_arg_type3(#type{name="wxArrayString"},out) -> "[unicode:charlist()]"; +doc_arg_type3(#type{name="wxDateTime"}, _) -> "wx:wx_datetime()"; +doc_arg_type3(#type{name="wxArtClient"}, _) -> "unicode:chardata()"; +doc_arg_type3(#type{base=int}, _) -> "integer()"; +doc_arg_type3(#type{base=int64}, _) -> "integer()"; +doc_arg_type3(#type{base=long}, _) -> "integer()"; +doc_arg_type3(#type{name="wxTreeItemId"}, _) -> "wxTreeCtrl:treeItemId()"; +doc_arg_type3(#type{base=bool}, _) -> "boolean()"; +doc_arg_type3(#type{base=float}, _) -> "number()"; +doc_arg_type3(#type{base=double}, _) -> "number()"; +doc_arg_type3(#type{base=binary}, _) -> "binary()"; +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), case get(current_class) of N -> N ++ "()"; _ -> N++":" ++ N++"()" end; -doc_arg_type3({merged,_,T1=#type{base={class,N1}},_,_,T2=#type{base={class,N2}},_}) -> +doc_arg_type3({merged,_,T1=#type{base={class,N1}},_,_,T2=#type{base={class,N2}},_}, _) -> check_class(T1), check_class(T2), Curr = get(current_class), @@ -820,60 +782,55 @@ doc_arg_type3({merged,_,T1=#type{base={class,N1}},_,_,T2=#type{base={class,N2}}, true -> N1++":" ++ N1++"() | "++ N2++":" ++ N2++"()" end; -doc_arg_type3(#type{base={enum,{_,N}}}) -> uppercase(N); -doc_arg_type3(#type{base={enum,N}}) -> uppercase(N); -doc_arg_type3(#type{base={comp,"wxColour",_Tup}}) -> - "wx:colour()"; -doc_arg_type3(#type{base={comp,_,{record,Name}}}) -> - "wx:" ++ atom_to_list(Name) ++ "()"; -doc_arg_type3(#type{base={comp,_,Tup}}) -> +%% doc_arg_type3(#type{base={enum,{_,N}}}, _) -> uppercase(N); +%% doc_arg_type3(#type{base={enum,N}}, _) -> uppercase(N); +doc_arg_type3(#type{base={enum,_N}}, _) -> "wx:wx_enum()"; +doc_arg_type3(#type{base={comp,"wxColour",_Tup}}, in) -> + "wx:wx_colour()"; +doc_arg_type3(#type{base={comp,"wxColour",_Tup}}, out) -> + "wx:wx_colour4()"; +doc_arg_type3(#type{base={comp,_,{record,Name}}}, _) -> + "wx:wx_" ++ atom_to_list(Name) ++ "()"; +doc_arg_type3(#type{base={comp,_,Tup}}, _) -> Doc = fun({int,V}) -> V ++ "::integer()"; ({double,V}) -> V ++ "::float()" end, "{" ++ args(Doc, ", ", Tup) ++ "}"; -doc_arg_type3(T) -> ?error({unknown_type,T}). +doc_arg_type3(T, _) -> ?error({unknown_type,T}). doc_return_types(T, Ps) -> doc_return_types2(T, [P || P=#param{in=In} <- Ps,In =/= true]). -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, []) -> {simple, "ok"}; +doc_return_types2(void, [#param{type=T}]) -> {simple, doc_arg_type2(T, out)}; +doc_return_types2(T, []) -> {simple, doc_arg_type2(T, out)}; +doc_return_types2(void, Ps) when length(Ps) < 4 -> + {simple, "{" ++ args(fun(Arg) -> doc_arg_type(Arg, out) end,", ",Ps) ++ "}"}; doc_return_types2(void, Ps) -> - "{" ++ args(fun doc_arg_type/1,", ",Ps) ++ "}"; + {complex, "{" ++ args(fun(Arg) -> doc_arg_type(Arg, out) end,", ",Ps) ++ "}"}; doc_return_types2(T, Ps) -> - "{" ++ doc_arg_type2(T) ++ ", " ++ args(fun doc_arg_type/1,", ",Ps) ++ "}". - -break(xhtml) -> "<br />"; -break(_) -> "". + {complex, "{Res ::" ++ doc_arg_type2(T, out) ++ ", " ++ + args(fun(Arg) -> doc_arg_type(Arg, out) end,", ",Ps) ++ "}"}. -doc_optional([],_) -> ok; -doc_optional(Opts,Type) -> - w("%%~s Option = ~s~n", [break(Type),args(fun doc_optional2/1, " | ", Opts)]). +doc_enum(#type{base={enum,Enum}},Ps) -> + [doc_enum_type(Enum, "res") | + [doc_enum_type(Type,Name) || #param{name=Name, type=#type{base={enum,Type}}} <- Ps]]; +doc_enum(_,Ps) -> + [doc_enum_type(Type,Name) || #param{name=Name, type=#type{base={enum,Type}}} <- Ps]. -doc_optional2(#param{name=Name, def=_Def, type=T}) -> - "{" ++ erl_option_name(Name) ++ ", " ++ doc_arg_type2(T) ++ "}". - -doc_enum(#type{base={enum,Enum}},Ps,Break) -> - [doc_enum_type(Enum,Break) | - [doc_enum_type(Type,Break) || #param{type=#type{base={enum,Type}}} <- Ps]]; -doc_enum(_,Ps,Break) -> - [doc_enum_type(Type,Break) || #param{type=#type{base={enum,Type}}} <- Ps]. - -doc_enum_type(Type,Break) -> +doc_enum_type(Type, Name) -> {Enum0, #enum{vals=Vals}} = wx_gen:get_enum(Type), - case Enum0 of {_, Enum} -> Enum; Enum -> Enum end, + Enum = case Enum0 of {_, E} -> E; E -> E end, Consts = get(consts), - Format = fun({Name,_What}) -> - #const{name=Name} = gb_trees:get(Name, Consts), - "?" ++ enum_name(Name) + Format = fun({N,_What}) -> + #const{name=N} = gb_trees:get(N, Consts), + "?" ++ enum_name(N) end, Vs = args(Format, " | ", Vals), - w("%%~s ~s = integer()~n", [break(Break),uppercase(Enum)]), - {uppercase(Enum),Vs}. + {uppercase(Enum),Name, Vs}. doc_enum_desc([]) -> ok; -doc_enum_desc([{Enum,Vs}|R]) -> - w("%%<br /> ~s is one of ~s~n", [Enum,Vs]), +doc_enum_desc([{_Enum,Name,Vs}|R]) -> + w("%%<br /> ~s = ~s~n", [erl_arg_name(Name),Vs]), doc_enum_desc(R). %% Misc functions prefixed with wx @@ -993,7 +950,7 @@ marshal_arg(#type{single=true,base={comp,_,Comp}}, Name, Align0) -> Str = args(fun(Str) -> Str end, ",", A), {Str,(Align0 + length(Comp)) rem 2}; {double,_} -> - A = [Name++Spec++":64/float" || {double,Spec} <- Comp], + A = [Name++Spec++":64/?F" || {double,Spec} <- Comp], Str = args(fun(Str) -> Str end, ",", A), align(64,Align0,Str) end; @@ -1019,9 +976,14 @@ marshal_arg(#type{base=Base, single=Single}, Name, Align0) Str0 = "(length("++Name++")):32/?UI,\n" " (<< <<X:32/?I,Y:32/?I>> || {X,Y} <- "++Name++">>)/binary", align(32,Align0, Str0); + {comp, "wxPoint2DDouble", _} -> + Str0 = "(length("++Name++")):32/?UI,\n", + Str1 = " (<< <<X:64/?F,Y:64/?F>> || {X,Y} <- "++Name++">>)/binary", + {Str,_Align} = align(64,Align0+1, Str1), + {Str0 ++ Str, 0}; double -> Str0 = "(length("++Name++")):32/?UI,\n", - Str1 = " (<< <<C:64/float>> || C <- "++Name++">>)/binary", + Str1 = " (<< <<C:64/?F>> || C <- "++Name++">>)/binary", {Str,_Align} = align(64,Align0+1, Str1), {Str0 ++ Str, 0}; _ -> @@ -1053,7 +1015,7 @@ gen_enums_ints() -> " controlDown, shiftDown, altDown, metaDown, cmdDown %% bool()~n" " }).~n", []), w("-record(wxHtmlLinkInfo, {~n" - " href, target %% string()~n" + " href, target %% unicode:chardata()~n" " }).~n", []), w("~n%% Hardcoded Defines~n", []), Enums = [E || {{enum,_},E = #enum{as_atom=false}} <- get()], @@ -1126,82 +1088,53 @@ gen_event_recs() -> "%% 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" - " obj, %% Object reference that was used in the connect call.~n" - " userData, %% User data specified in the connect call.~n" - " event}).%% The event record~n~n",[]), + w("-record(wx, {id :: integer(), %% Integer Identity of object.~n" + " obj :: wx:wx_object(), %% Object reference that was used in the connect call.~n" + " userData :: term(), %% User data specified in the connect call.~n" + " event :: event() %% The event record~n" + " }).~n~n", []), + w("-type wx() :: #wx{}. %% wx event record ~n",[]), 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", - [args(fun(Ev) -> Ev end, " | ", lists:sort(lists:append(Types)))]), + Events = [build_event_rec(C) || {_,C=#class{event=Evs}} <- get(), Evs =/= false], + EventSubTypes = [Type || {_Rec, Type} <- Events], + EventRecs = [Rec || {Rec, _Type} <- Events], + w("-type event() :: ~s.~n", + [args(fun(Ev) -> Ev++"()" end, " | ", lists:sort(EventRecs))]), + + w("-type wxEventType() :: ~s.~n", + [args(fun(Ev) -> Ev++"()" end, " | ", lists:sort(EventSubTypes))]), %% close(), closed in gen_enums_ints ok. -find_inherited_attr(Param = {PName,_}, Name) -> - #class{parent=Parent, attributes=Attrs} = get({class, Name}), - case lists:keysearch(atom_to_list(PName), #param.name, Attrs) of - {value, P=#param{}} -> - P; - _ -> - find_inherited_attr(Param, Parent) - end. - -filter_attrs(#class{name=Name, parent=Parent,attributes=Attrs}) -> - Attr1 = lists:foldl(fun(#param{acc=skip},Acc) -> Acc; - (P=#param{prot=public},Acc) -> [P|Acc]; - (#param{acc=undefined},Acc) -> Acc; - ({inherited, PName},Acc) -> - case find_inherited_attr(PName, Parent) of - undefined -> - io:format("~p:~p: Missing Event Attr ~p in ~p~n", - [?MODULE,?LINE, PName, Name]), - Acc; - 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), + Str = args(fun(Ev) -> Ev end, " | ", EvTypes), Attr = filter_attrs(Class), Rec = event_rec_name(Name), - GetName = fun(#param{name=N}) ->event_attr_name(N) end, + %%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, + EventType = Name ++ "Type", case Attr =:= [] of 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 -%% 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]); + %% w("%% <dl><dt>EventType:</dt> <dd>~s</dd></dl>~n",[Str]), + %% w("%% Callback event: {@link ~s}~n", [Name]), + w("-record(~s, {type :: ~s()}). %% Callback event: {@link ~s}~n", + [Rec, EventType, Name]), + w("-type ~s() :: ~s.~n", [EventType, Str]); false -> - 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 -%% 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, ~s}).~n~n", [Rec,args(GetName,",",Attr)]) + %% w("%% @type ~s() = #~s{type=wxEventType(),~s}.~n", + %% [Rec,Rec,args(GetType,",",Attr)]), + %% w("%% <dl><dt>EventType:</dt> <dd>~s</dd></dl>~n",[Str]), + %% w("%% Callback event: {@link ~s}~n", [Name]), + w("-record(~s,{type :: ~s(), %% Callback event: {@link ~s}~n\t~s}).~n", + [Rec,EventType, Name, args(GetType,",\n\t",Attr)]), + w("-type ~s() :: ~s.~n", [EventType, Str]) end, - EvTypes. - -is_command_event(Name) -> - case lists:member("wxCommandEvent", parents(Name)) of - true -> true; - false -> false - end. + w("-type ~s() :: #~s{}. %% Callback event: {@link ~s}~n~n", [Rec,Rec,Name]), + {Rec, EventType}. event_rec_name(Name0 = "wx" ++ _) -> "tnevE" ++ Name1 = reverse(Name0), @@ -1218,6 +1151,31 @@ event_attr_name("m_" ++ Attr) -> event_attr_name(Attr) -> lowercase(Attr). +find_inherited_attr(Param = {PName,_}, Name) -> + #class{parent=Parent, attributes=Attrs} = get({class, Name}), + case lists:keysearch(atom_to_list(PName), #param.name, Attrs) of + {value, P=#param{}} -> + P; + _ -> + find_inherited_attr(Param, Parent) + end. + +filter_attrs(#class{name=Name, parent=Parent,attributes=Attrs}) -> + Attr1 = lists:foldl(fun(#param{acc=skip},Acc) -> Acc; + (P=#param{prot=public},Acc) -> [P|Acc]; + (#param{acc=undefined},Acc) -> Acc; + ({inherited, PName},Acc) -> + case find_inherited_attr(PName, Parent) of + undefined -> + io:format("~p:~p: Missing Event Attr ~p in ~p~n", + [?MODULE,?LINE, PName, Name]), + Acc; + P -> + [P|Acc] + end; + (P, Acc) -> [P|Acc] + end, [], Attrs), + lists:reverse(Attr1). gen_funcnames() -> open_write("../src/gen/wxe_debug.hrl"), diff --git a/lib/wx/api_gen/wxapi.conf b/lib/wx/api_gen/wxapi.conf index ff618faf04..383addfe3f 100644 --- a/lib/wx/api_gen/wxapi.conf +++ b/lib/wx/api_gen/wxapi.conf @@ -2,7 +2,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2011. All Rights Reserved. +%% Copyright Ericsson AB 2008-2012. 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 @@ -330,9 +330,11 @@ {'DrawRotatedText',3}, 'DrawRoundedRectangle',%'DrawSpline', {'DrawText',2}, 'EndDoc','EndPage',{'FloodFill',3},'GetBackground','GetBackgroundMode', - 'GetBrush','GetCharHeight','GetCharWidth',{'GetClippingBox',1},'GetFont', - 'GetLayoutDirection','GetLogicalFunction','GetMapMode','GetMultiLineTextExtent', - 'GetPartialTextExtents','GetPen',{'GetPixel',2},'GetPPI','GetSize','GetSizeMM', + 'GetBrush','GetCharHeight','GetCharWidth',{'GetClippingBox',[{"rect", skip_member}]}, + 'GetFont','GetLayoutDirection','GetLogicalFunction','GetMapMode','GetMultiLineTextExtent', + {'GetPartialTextExtents', [{"widths", out}]}, + 'GetPen',{'GetPixel', [{"col", out}, {"x", skip_member}]}, + 'GetPPI','GetSize','GetSizeMM', 'GetTextBackground','GetTextExtent','GetTextForeground', 'GetUserScale','GradientFillConcentric','GradientFillLinear', 'LogicalToDeviceX','LogicalToDeviceXRel','LogicalToDeviceY','LogicalToDeviceYRel', @@ -355,20 +357,28 @@ %%{class,wxAutoBufferedPaintDC,wxBufferedPaintDC,[],['wxAutoBufferedPaintDC']}. {class, wxGraphicsObject, object, [{ifdef, wxUSE_GRAPHICS_CONTEXT}], - ['GetRenderer','IsNull']}. -{class, wxGraphicsContext, wxGraphicsObject, [{ifdef, wxUSE_GRAPHICS_CONTEXT}], - ['Create', %%CreateFromNative CreateFromNativeWindow + ['~wxGraphicsObject', 'GetRenderer','IsNull']}. +{class, wxGraphicsContext, wxGraphicsObject, + [{ifdef, wxUSE_GRAPHICS_CONTEXT}, {skip, [{'StrokeLines',4}]}], + ['~wxGraphicsContext', + 'Create', %%CreateFromNative CreateFromNativeWindow 'CreatePen','CreateBrush','CreateRadialGradientBrush', 'CreateLinearGradientBrush','CreateFont','CreateMatrix', 'CreatePath','Clip','ResetClip', - 'DrawBitmap','DrawEllipse','DrawIcon','DrawLines','DrawPath', + 'DrawBitmap','DrawEllipse','DrawIcon', + {'DrawLines', [{"n",{c_only,{length,"points"}}}, {"points", {single,array}}]}, + 'DrawPath', 'DrawRectangle','DrawRoundedRectangle','DrawText','FillPath', - 'StrokePath','GetNativeContext','GetPartialTextExtents', + 'StrokePath', %% 'GetNativeContext', + {'GetPartialTextExtents', [{"widths", out}]}, 'GetTextExtent','Rotate','Scale','Translate', 'GetTransform','SetTransform','ConcatTransform', - 'SetBrush','SetFont','SetPen','StrokeLine','StrokeLines']}. + 'SetBrush','SetFont','SetPen','StrokeLine', + {'StrokeLines', [{"n",{c_only,{length,"points"}}}, {"points", {single,array}}]} + ]}. {class, wxGraphicsMatrix, wxGraphicsObject, [{ifdef, wxUSE_GRAPHICS_CONTEXT}], - ['Concat','Get','GetNativeMatrix','Invert','IsEqual','IsIdentity', + ['Concat','Get',%%'GetNativeMatrix', + 'Invert','IsEqual','IsIdentity', 'Rotate','Scale','Translate','Set','TransformPoint','TransformDistance']}. {class, wxGraphicsPath, wxGraphicsObject, [{ifdef, wxUSE_GRAPHICS_CONTEXT}], ['MoveToPoint','AddArc','AddArcToPoint','AddCircle','AddCurveToPoint', @@ -400,17 +410,17 @@ {class, wxControl, wxWindow, [], [% 'Command','GetLabelText', 'GetLabel','SetLabel']}. -{class, wxControlWithItems, wxControl, - [{skip, [{'GetClientObject',1},{'SetClientObject',2}]}], +{class, wxControlWithItems, wxControl, + [{skip, [{'GetClientObject',1},{'SetClientObject',2}]}], [ - {'Append',[{"clientData",[{skip_member, void}]}, - {"strings", [{erl_func, "appendStrings"}]}]}, + {'Append',[{"clientData",[{skip_member, voidp}]}, + {"strings", [{erl_func, "appendStrings"}]}]}, 'Clear','Delete','FindString', %% 'GetClientData','SetClientData', {'GetClientObject', [{"n", [{erl_func, "getClientData"}]}]}, {'SetClientObject', [{"n", [{erl_func, "setClientData"}]}]}, 'GetCount','GetSelection','GetString','GetStringSelection', - {'Insert',[{"clientData",[{skip_member, void}]}]},%'Number', + {'Insert',[{"clientData",[{skip_member, voidp}]}]},%'Number', 'IsEmpty','Select','SetSelection','SetString','SetStringSelection' ]}. @@ -1592,9 +1602,9 @@ 'HomeWrapExtend', 'LineEndWrap', 'LineEndWrapExtend', 'VCHomeWrap', 'VCHomeWrapExtend', 'LineCopy', 'MoveCaretInsideView', 'LineLength', 'BraceHighlight', 'BraceBadLight', 'BraceMatch', 'GetViewEOL', 'SetViewEOL', %'GetDocPointer', 'SetDocPointer', Hmm void pointers - 'SetModEventMask', 'GetEdgeColumn', 'SetEdgeColumn', - 'GetEdgeMode', 'GetEdgeColour', 'SetEdgeColour', 'SearchAnchor', 'SearchNext', - 'SearchPrev', 'LinesOnScreen', + 'SetModEventMask', 'GetEdgeColumn', 'SetEdgeColumn', + 'SetEdgeMode', 'GetEdgeMode', 'GetEdgeColour', 'SetEdgeColour', 'SearchAnchor', 'SearchNext', + 'SearchPrev', 'LinesOnScreen', 'UsePopUp', 'SelectionIsRectangle', 'SetZoom', 'GetZoom', %%'CreateDocument', 'AddRefDocument', 'ReleaseDocument', Hmm void pointers 'GetModEventMask', 'SetSTCFocus', 'GetSTCFocus', 'SetStatus', 'GetStatus', @@ -1803,4 +1813,14 @@ {class, wxLogNull, root, [], [wxLogNull, '~wxLogNull']}. - + +{class, wxTaskBarIcon, wxEvtHandler, [], + [wxTaskBarIcon,'~wxTaskBarIcon', + %%'CreatePopupMenu', virtual overrided is a callback + %% 'IsIconInstalled', 'IsOk', not available on mac + 'PopupMenu','RemoveIcon','SetIcon']}. + +{class, wxTaskBarIconEvent, wxEvent, + [{event,[wxEVT_TASKBAR_MOVE,wxEVT_TASKBAR_LEFT_DOWN,wxEVT_TASKBAR_LEFT_UP, + wxEVT_TASKBAR_RIGHT_DOWN,wxEVT_TASKBAR_RIGHT_UP, + wxEVT_TASKBAR_LEFT_DCLICK,wxEVT_TASKBAR_RIGHT_DCLICK]}],[]}. |