diff options
Diffstat (limited to 'lib/wx/src/wx.erl')
-rw-r--r-- | lib/wx/src/wx.erl | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/lib/wx/src/wx.erl b/lib/wx/src/wx.erl index 2a4b18d101..34bf06cf46 100644 --- a/lib/wx/src/wx.erl +++ b/lib/wx/src/wx.erl @@ -1,18 +1,19 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2012. All Rights Reserved. +%% Copyright Ericsson AB 2008-2016. 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/. +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at %% -%% 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. +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. %% %% %CopyrightEnd% %%%------------------------------------------------------------------- @@ -65,7 +66,7 @@ get_env/0,set_env/1, debug/1, batch/1,foreach/2,map/2,foldl/3,foldr/3, getObjectType/1, typeCast/2, - null/0, is_null/1]). + null/0, is_null/1, equal/2]). -export([create_memory/1, get_memory_bin/1, retain_memory/1, release_memory/1]). @@ -105,8 +106,8 @@ new() -> %% Or {silent_start, Bool}, which causes error messages at startup to %% be suppressed. The latter can be used as a silent test of whether %% wx is properly installed or not. --spec new([Option]) -> wx_object() when Option :: {debug, list() | atom()} | - {silent_start, boolean()}. +-spec new([Option]) -> wx_object() + when Option :: {'debug', list() | atom()} | {'silent_start', boolean()}. new(Options) when is_list(Options) -> Debug = proplists:get_value(debug, Options, 0), SilentStart = proplists:get_value(silent_start, Options, false), @@ -117,7 +118,7 @@ new(Options) when is_list(Options) -> null(). %% @doc Stops a wx server. --spec destroy() -> ok. +-spec destroy() -> 'ok'. destroy() -> wxe_server:stop(), erase(?WXE_IDENTIFIER), @@ -135,7 +136,7 @@ get_env() -> %% @doc Sets the process wx environment, allows this process to use %% another process wx environment. --spec set_env(wx_env()) -> ok. +-spec set_env(wx_env()) -> 'ok'. set_env(#wx_env{sv=Pid, port=Port} = Env) -> put(?WXE_IDENTIFIER, Env), put(opengl_port, Port), @@ -152,6 +153,10 @@ null() -> -spec is_null(wx_object()) -> boolean(). is_null(#wx_ref{ref=NULL}) -> NULL =:= 0. +%% @doc Returns true if both arguments references the same object, false otherwise +-spec equal(wx_object(), wx_object()) -> boolean(). +equal(#wx_ref{ref=Ref1}, #wx_ref{ref=Ref2}) -> Ref1 =:= Ref2. + %% @doc Returns the object type -spec getObjectType(wx_object()) -> atom(). getObjectType(#wx_ref{type=Type}) -> @@ -186,7 +191,7 @@ batch(Fun) -> end. %% @doc Behaves like {@link //stdlib/lists:foreach/2} but batches wx commands. See {@link batch/1}. --spec foreach(function(), list()) -> ok. +-spec foreach(function(), list()) -> 'ok'. foreach(Fun, List) -> ok = wxe_util:cast(?BATCH_BEGIN, <<>>), try lists:foreach(Fun, List) @@ -262,7 +267,7 @@ get_memory_bin(#wx_mem{bin=Bin, size=Size}) -> %% @doc Saves the memory from deletion until release_memory/1 is called. %% If release_memory/1 is not called the memory will not be garbage collected. --spec retain_memory(wx_memory()) -> ok. +-spec retain_memory(wx_memory()) -> 'ok'. retain_memory(#wx_mem{bin=Bin}) -> wxe_util:send_bin(Bin), ok = wxe_util:cast(?WXE_BIN_INCR, <<>>); @@ -274,7 +279,7 @@ retain_memory(Bin) when is_binary(Bin) -> wxe_util:send_bin(Bin), ok = wxe_util:cast(?WXE_BIN_INCR, <<>>). --spec release_memory(wx_memory()) -> ok. +-spec release_memory(wx_memory()) -> 'ok'. release_memory(#wx_mem{bin=Bin}) -> wxe_util:send_bin(Bin), ok = wxe_util:cast(?WXE_BIN_DECR, <<>>); @@ -285,8 +290,8 @@ release_memory(Bin) when is_binary(Bin) -> %% @doc Sets debug level. If debug level is 'verbose' or 'trace' %% each call is printed on console. If Level is 'driver' each allocated %% object and deletion is printed on the console. --spec debug(Level | [Level]) -> ok - when Level :: none | verbose | trace | driver | integer(). +-spec debug(Level | [Level]) -> 'ok' + when Level :: 'none' | 'verbose' | 'trace' | 'driver' | integer(). debug(Debug) -> Level = calc_level(Debug), @@ -327,7 +332,7 @@ set_debug(Level) when is_integer(Level) -> end. %% @doc Starts a wxErlang demo if examples directory exists and is compiled --spec demo() -> ok | {error, atom()}. +-spec demo() -> 'ok' | {'error', atom()}. demo() -> Priv = code:priv_dir(wx), Demo = filename:join([filename:dirname(Priv),examples,demo]), |