Skip to content

Commit a10fbe7

Browse files
authored
Merge pull request #163 from mpsonntag/mIndexHandling
Refactor index handling on Matlab side
2 parents b9b7442 + 8e291fe commit a10fbe7

21 files changed

+238
-206
lines changed

+nix/Block.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
r = nix.Utils.open_entity(obj, 'getGroup', id_or_name, @nix.Group);
5050
end
5151

52-
function r = open_group_idx(obj, idx)
52+
function r = open_group_idx(obj, index)
53+
idx = nix.Utils.handle_index(index);
5354
r = nix.Utils.open_entity(obj, 'openGroupIdx', idx, @nix.Group);
5455
end
5556

@@ -73,7 +74,8 @@
7374
r = nix.Utils.open_entity(obj, 'openDataArray', id_or_name, @nix.DataArray);
7475
end
7576

76-
function r = open_data_array_idx(obj, idx)
77+
function r = open_data_array_idx(obj, index)
78+
idx = nix.Utils.handle_index(index);
7779
r = nix.Utils.open_entity(obj, 'openDataArrayIdx', idx, @nix.DataArray);
7880
end
7981

@@ -165,7 +167,8 @@
165167
r = nix.Utils.open_entity(obj, 'openSource', id_or_name, @nix.Source);
166168
end
167169

168-
function r = open_source_idx(obj, idx)
170+
function r = open_source_idx(obj, index)
171+
idx = nix.Utils.handle_index(index);
169172
r = nix.Utils.open_entity(obj, 'openSourceIdx', idx, @nix.Source);
170173
end
171174

@@ -199,7 +202,8 @@
199202
r = nix.Utils.open_entity(obj, 'openTag', id_or_name, @nix.Tag);
200203
end
201204

202-
function r = open_tag_idx(obj, idx)
205+
function r = open_tag_idx(obj, index)
206+
idx = nix.Utils.handle_index(index);
203207
r = nix.Utils.open_entity(obj, 'openTagIdx', idx, @nix.Tag);
204208
end
205209

@@ -233,7 +237,8 @@
233237
r = nix.Utils.open_entity(obj, 'openMultiTag', id_or_name, @nix.MultiTag);
234238
end
235239

236-
function r = open_multi_tag_idx(obj, idx)
240+
function r = open_multi_tag_idx(obj, index)
241+
idx = nix.Utils.handle_index(index);
237242
r = nix.Utils.open_entity(obj, 'openMultiTagIdx', idx, @nix.MultiTag);
238243
end
239244

+nix/DataArray.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
dimensions{i} = nix.Utils.createEntity(currList(i).dimension, ...
5353
@nix.RangeDimension);
5454
otherwise
55-
disp('some dimension type is unknown! skip')
55+
disp('some dimension type is unknown! skip');
5656
end
5757
end
5858
end

+nix/File.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
r = nix.Utils.open_entity(obj, 'openBlock', id_or_name, @nix.Block);
6666
end
6767

68-
function r = open_block_idx(obj, idx)
68+
function r = open_block_idx(obj, index)
69+
idx = nix.Utils.handle_index(index);
6970
r = nix.Utils.open_entity(obj, 'openBlockIdx', idx, @nix.Block);
7071
end
7172

@@ -99,7 +100,8 @@
99100
r = nix.Utils.open_entity(obj, 'openSection', id_or_name, @nix.Section);
100101
end
101102

102-
function r = open_section_idx(obj, idx)
103+
function r = open_section_idx(obj, index)
104+
idx = nix.Utils.handle_index(index);
103105
r = nix.Utils.open_entity(obj, 'openSectionIdx', idx, @nix.Section);
104106
end
105107

+nix/Group.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
r = nix.Utils.open_entity(obj, 'getDataArray', id_or_name, @nix.DataArray);
4343
end
4444

45-
function r = open_data_array_idx(obj, idx)
45+
function r = open_data_array_idx(obj, index)
46+
idx = nix.Utils.handle_index(index);
4647
r = nix.Utils.open_entity(obj, 'openDataArrayIdx', idx, @nix.DataArray);
4748
end
4849

@@ -82,7 +83,8 @@
8283
r = nix.Utils.open_entity(obj, 'getTag', id_or_name, @nix.Tag);
8384
end
8485

85-
function r = open_tag_idx(obj, idx)
86+
function r = open_tag_idx(obj, index)
87+
idx = nix.Utils.handle_index(index);
8688
r = nix.Utils.open_entity(obj, 'openTagIdx', idx, @nix.Tag);
8789
end
8890

@@ -118,7 +120,8 @@
118120
r = nix.Utils.open_entity(obj, 'getMultiTag', id_or_name, @nix.MultiTag);
119121
end
120122

121-
function r = open_multi_tag_idx(obj, idx)
123+
function r = open_multi_tag_idx(obj, index)
124+
idx = nix.Utils.handle_index(index);
122125
r = nix.Utils.open_entity(obj, 'openMultiTagIdx', idx, @nix.MultiTag);
123126
end
124127

+nix/MultiTag.m

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,21 @@
5252
r = nix.Utils.open_entity(obj, 'openReferences', id_or_name, @nix.DataArray);
5353
end
5454

55-
function r = open_reference_idx(obj, idx)
55+
function r = open_reference_idx(obj, index)
56+
idx = nix.Utils.handle_index(index);
5657
r = nix.Utils.open_entity(obj, 'openReferenceIdx', idx, @nix.DataArray);
5758
end
5859

59-
function r = retrieve_data(obj, pos_idx, id_or_name)
60+
function r = retrieve_data(obj, position_idx, id_or_name)
61+
pos_idx = nix.Utils.handle_index(position_idx);
6062
fname = strcat(obj.alias, '::retrieveData');
6163
data = nix_mx(fname, obj.nix_handle, pos_idx, id_or_name);
6264
r = nix.Utils.transpose_array(data);
6365
end
6466

65-
function r = retrieve_data_idx(obj, pos_idx, ref_idx)
67+
function r = retrieve_data_idx(obj, position_idx, reference_idx)
68+
pos_idx = nix.Utils.handle_index(position_idx);
69+
ref_idx = nix.Utils.handle_index(reference_idx);
6670
fname = strcat(obj.alias, '::retrieveDataIdx');
6771
data = nix_mx(fname, obj.nix_handle, pos_idx, ref_idx);
6872
r = nix.Utils.transpose_array(data);
@@ -99,17 +103,21 @@
99103
r = nix.Utils.open_entity(obj, 'openFeature', id_or_name, @nix.Feature);
100104
end
101105

102-
function r = open_feature_idx(obj, idx)
106+
function r = open_feature_idx(obj, index)
107+
idx = nix.Utils.handle_index(index);
103108
r = nix.Utils.open_entity(obj, 'openFeatureIdx', idx, @nix.Feature);
104109
end
105110

106-
function r = retrieve_feature_data(obj, pos_idx, id_or_name)
111+
function r = retrieve_feature_data(obj, position_idx, id_or_name)
112+
pos_idx = nix.Utils.handle_index(position_idx);
107113
fname = strcat(obj.alias, '::featureRetrieveData');
108114
data = nix_mx(fname, obj.nix_handle, pos_idx, id_or_name);
109115
r = nix.Utils.transpose_array(data);
110116
end
111117

112-
function r = retrieve_feature_data_idx(obj, pos_idx, feat_idx)
118+
function r = retrieve_feature_data_idx(obj, position_idx, feature_idx)
119+
pos_idx = nix.Utils.handle_index(position_idx);
120+
feat_idx = nix.Utils.handle_index(feature_idx);
113121
fname = strcat(obj.alias, '::featureRetrieveDataIdx');
114122
data = nix_mx(fname, obj.nix_handle, pos_idx, feat_idx);
115123
r = nix.Utils.transpose_array(data);

+nix/RangeDimension.m

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
end
2828

2929
function r = tick_at(obj, index)
30-
if (index > 0)
31-
index = index - 1;
32-
end
30+
index = nix.Utils.handle_index(index);
3331
fname = strcat(obj.alias, '::tickAt');
3432
r = nix_mx(fname, obj.nix_handle, index);
3533
end
@@ -41,12 +39,10 @@
4139

4240
function r = axis(obj, count, startIndex)
4341
if (nargin < 3)
44-
startIndex = 0;
42+
startIndex = 1;
4543
end
4644

47-
if (startIndex > 0)
48-
startIndex = startIndex - 1;
49-
end
45+
startIndex = nix.Utils.handle_index(startIndex);
5046

5147
fname = strcat(obj.alias, '::axis');
5248
r = nix_mx(fname, obj.nix_handle, count, startIndex);

+nix/SampledDimension.m

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,17 @@
3232
end
3333

3434
function r = position_at(obj, index)
35-
if (index > 0)
36-
index = index - 1;
37-
end
38-
35+
index = nix.Utils.handle_index(index);
3936
fname = strcat(obj.alias, '::positionAt');
4037
r = nix_mx(fname, obj.nix_handle, index);
4138
end
4239

4340
function r = axis(obj, count, startIndex)
4441
if (nargin < 3)
45-
startIndex = 0;
46-
end
47-
48-
if (startIndex > 0)
49-
startIndex = startIndex - 1;
42+
startIndex = 1;
5043
end
5144

45+
startIndex = nix.Utils.handle_index(startIndex);
5246
fname = strcat(obj.alias, '::axis');
5347
r = nix_mx(fname, obj.nix_handle, count, startIndex);
5448
end

+nix/Section.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
r = nix.Utils.open_entity(obj, 'openSection', id_or_name, @nix.Section);
7171
end
7272

73-
function r = open_section_idx(obj, idx)
73+
function r = open_section_idx(obj, index)
74+
idx = nix.Utils.handle_index(index);
7475
r = nix.Utils.open_entity(obj, 'openSectionIdx', idx, @nix.Section);
7576
end
7677

@@ -94,12 +95,12 @@
9495
r = nix.Utils.filter(obj, 'findRelated', filter, val, @nix.Section);
9596
end
9697

97-
% maxdepth is an index
98+
% maxdepth is handled like an index
9899
function r = find_sections(obj, max_depth)
99100
r = obj.find_filtered_sections(max_depth, nix.Filter.accept_all, '');
100101
end
101102

102-
% maxdepth is an index
103+
% maxdepth is handled like an index
103104
function r = find_filtered_sections(obj, max_depth, filter, val)
104105
r = nix.Utils.find(obj, 'findSections', max_depth, filter, val, @nix.Section);
105106
end
@@ -144,7 +145,8 @@
144145
r = nix.Utils.open_entity(obj, 'openProperty', id_or_name, @nix.Property);
145146
end
146147

147-
function r = open_property_idx(obj, idx)
148+
function r = open_property_idx(obj, index)
149+
idx = nix.Utils.handle_index(index);
148150
r = nix.Utils.open_entity(obj, 'openPropertyIdx', idx, @nix.Property);
149151
end
150152

+nix/Source.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
r = nix.Utils.open_entity(obj, 'openSource', id_or_name, @nix.Source);
5050
end
5151

52-
function r = open_source_idx(obj, idx)
52+
function r = open_source_idx(obj, index)
53+
idx = nix.Utils.handle_index(index);
5354
r = nix.Utils.open_entity(obj, 'openSourceIdx', idx, @nix.Source);
5455
end
5556

+nix/SourcesMixIn.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
r = nix.Utils.open_entity(obj, 'openSource', id_or_name, @nix.Source);
4646
end
4747

48-
function r = open_source_idx(obj, idx)
48+
function r = open_source_idx(obj, index)
49+
idx = nix.Utils.handle_index(index);
4950
r = nix.Utils.open_entity(obj, 'openSourceIdx', idx, @nix.Source);
5051
end
5152

0 commit comments

Comments
 (0)