summaryrefslogtreecommitdiff
path: root/matlab/lib/+IceInternal/WrapperObject.m
diff options
context:
space:
mode:
Diffstat (limited to 'matlab/lib/+IceInternal/WrapperObject.m')
-rw-r--r--matlab/lib/+IceInternal/WrapperObject.m57
1 files changed, 52 insertions, 5 deletions
diff --git a/matlab/lib/+IceInternal/WrapperObject.m b/matlab/lib/+IceInternal/WrapperObject.m
index 35fcf0cb0c8..125c879958d 100644
--- a/matlab/lib/+IceInternal/WrapperObject.m
+++ b/matlab/lib/+IceInternal/WrapperObject.m
@@ -11,16 +11,63 @@ ICE_LICENSE file included in this distribution.
classdef (Abstract) WrapperObject < handle
methods
- function obj = WrapperObject(impl)
- obj.impl = impl;
+ function obj = WrapperObject(impl, type)
+ %
+ % If no type was supplied, we convert the class name into the prefix that we'll use for invoking
+ % external C functions.
+ %
+ if nargin == 1
+ type = strrep(class(obj), '.', '_'); % E.g., Ice.Communicator -> Ice_Communicator
+ end
+ obj.impl_ = impl;
+ obj.type_ = type;
end
+ end
+ methods(Hidden)
function delete(obj)
- if ~isempty(obj.impl)
- Ice.Util.callMethod(obj, '_release');
+ if ~isempty(obj.impl_)
+ obj.call_('_release');
+ end
+ end
+ function call_(obj, fn, varargin)
+ name = strcat(obj.type_, '_', fn);
+ ex = calllib('icematlab', name, obj.impl_, varargin{:});
+ if ~isempty(ex)
+ ex.throwAsCaller();
+ end
+ end
+ function r = callWithResult_(obj, fn, varargin)
+ name = strcat(obj.type_, '_', fn);
+ result = calllib('icematlab', name, obj.impl_, varargin{:});
+ if isempty(result)
+ r = result;
+ elseif ~isempty(result.exception)
+ result.exception.throwAsCaller();
+ else
+ r = result.result;
+ end
+ end
+ function callOnType_(obj, type, fn, varargin)
+ name = strcat(type, '_', fn);
+ ex = calllib('icematlab', name, obj.impl_, varargin{:});
+ if ~isempty(ex)
+ ex.throwAsCaller();
+ end
+ end
+ function r = callOnTypeWithResult_(obj, type, fn, varargin)
+ name = strcat(type, '_', fn);
+ result = calllib('icematlab', name, obj.impl_, varargin{:});
+ if isempty(result)
+ r = result;
+ elseif ~isempty(result.exception)
+ result.exception.throwAsCaller();
+ else
+ r = result.result;
end
end
end
properties(Hidden,SetAccess=protected)
- impl
+ impl_
+ type_
end
end