Skip to content

Commit 5c19040

Browse files
committed
[Matlab] Consistently use nix.Utils.fetchObj
Use of nix.Utils.fetchObj was added to - MultiTag.open_positions - MultiTag.open_extents - Section.parent - Section.openLink
1 parent 2e886ba commit 5c19040

File tree

3 files changed

+7
-24
lines changed

3 files changed

+7
-24
lines changed

+nix/MultiTag.m

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,7 @@
151151

152152
function r = open_positions(obj)
153153
fname = strcat(obj.alias, '::openPositions');
154-
h = nix_mx(fname, obj.nix_handle);
155-
r = {};
156-
if h ~= 0
157-
r = nix.DataArray(h);
158-
end
154+
r = nix.Utils.fetchObj(fname, obj.nix_handle, @nix.DataArray);
159155
end
160156

161157
function [] = add_positions(obj, add_this)
@@ -175,11 +171,7 @@
175171

176172
function r = open_extents(obj)
177173
fname = strcat(obj.alias, '::openExtents');
178-
h = nix_mx(fname, obj.nix_handle);
179-
r = {};
180-
if h ~= 0
181-
r = nix.DataArray(h);
182-
end
174+
r = nix.Utils.fetchObj(fname, obj.nix_handle, @nix.DataArray);
183175
end
184176

185177
function [] = set_extents(obj, add_this)

+nix/Section.m

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@
3030

3131
function r = parent(obj)
3232
fname = strcat(obj.alias, '::parent');
33-
h = nix_mx(fname, obj.nix_handle);
34-
r = {};
35-
if h ~= 0
36-
r = nix.Section(h);
37-
end
33+
r = nix.Utils.fetchObj(fname, obj.nix_handle, @nix.Section);
3834
end
3935

4036
% ----------------
@@ -59,11 +55,7 @@
5955

6056
function r = openLink(obj)
6157
fname = strcat(obj.alias, '::openLink');
62-
h = nix_mx(fname, obj.nix_handle);
63-
r = {};
64-
if h ~= 0
65-
r = nix.Section(h);
66-
end
58+
r = nix.Utils.fetchObj(fname, obj.nix_handle, @nix.Section);
6759
end
6860

6961
function r = inherited_properties(obj)

+nix/Utils.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@
3131
end
3232
end
3333

34-
function rcell = fetchObj(nixMxFunc, handle, objConstructor)
34+
function r = fetchObj(nixMxFunc, handle, objConstructor)
35+
r = {};
3536
h = nix_mx(nixMxFunc, handle);
3637
if (h ~= 0)
37-
rcell = objConstructor(h);
38-
else
39-
rcell = {};
38+
r = objConstructor(h);
4039
end
4140
end
4241

0 commit comments

Comments
 (0)