summaryrefslogtreecommitdiff
path: root/lib/wx/src
diff options
context:
space:
mode:
authorDan Gudmundsson <dgud@erlang.org>2016-03-30 09:48:30 +0200
committerDan Gudmundsson <dgud@erlang.org>2016-04-22 09:17:40 +0200
commita3a5bcab69695b7bfe8a77f4c1b245a1b58fb5fb (patch)
tree803fc2446613b3f32dbcd81ce4b65b42564fb685 /lib/wx/src
parente0a67398ad3d034e1afe59585a5f82af6981c1eb (diff)
downloaderlang-a3a5bcab69695b7bfe8a77f4c1b245a1b58fb5fb.tar.gz
wx: add object set/check funcions
Needed functionality, to avoid abusing opauqe objects.
Diffstat (limited to 'lib/wx/src')
-rw-r--r--lib/wx/src/wx.erl6
-rw-r--r--lib/wx/src/wx_object.erl8
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/wx/src/wx.erl b/lib/wx/src/wx.erl
index a1a9344316..6498b58cda 100644
--- a/lib/wx/src/wx.erl
+++ b/lib/wx/src/wx.erl
@@ -66,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]).
@@ -153,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}) ->
diff --git a/lib/wx/src/wx_object.erl b/lib/wx/src/wx_object.erl
index a2acbb0a63..c22a083eb9 100644
--- a/lib/wx/src/wx_object.erl
+++ b/lib/wx/src/wx_object.erl
@@ -107,7 +107,8 @@
call/2, call/3,
cast/2,
reply/2,
- get_pid/1
+ get_pid/1,
+ set_pid/2
]).
%% -export([behaviour_info/1]).
@@ -306,6 +307,11 @@ cast(Name, Request) when is_atom(Name) orelse is_pid(Name) ->
get_pid(#wx_ref{state=Pid}) when is_pid(Pid) ->
Pid.
+%% @spec (Ref::wxObject(), pid()) -> wxObject()
+%% @doc Sets the controlling process of the object handle.
+set_pid(#wx_ref{}=R, Pid) when is_pid(Pid) ->
+ R#wx_ref{state=Pid}.
+
%% -----------------------------------------------------------------
%% Send a reply to the client.
%% -----------------------------------------------------------------