Skip to content

Commit

Permalink
fixed bugs in subsref methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ulfgri committed Nov 15, 2016
1 parent e09979e commit 8cd6e5e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 32 deletions.
31 changes: 15 additions & 16 deletions Basic/@gds_library/subsref.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@

% Ulf Griesmann, NIST, June 2011

% convert cs-lists --> cell arrays
itype = {ins.type};
isubs = {ins.subs};
gstrs = [];

% first indexing operator
switch itype{1}
idx = ins(1).subs;

switch ins(1).type

case '()'

idx = isubs{1};

if iscell(idx)
idx = idx{1};
idx = idx{:};
end

if ischar(idx) && idx == ':'
Expand All @@ -35,27 +34,27 @@
case '.' % look up structure name

for k = 1:length(glib.st)
if strcmp(ins.subs, get(glib.st{k}, 'sname'))
if strcmp(idx, sname(glib.st{k}))
gstrs = glib.st{k};
return
break;
end
end

error(sprintf('gds_library.subsref : structure >> %s << not found', ins.subs));

if isempty(gstrs)
error(sprintf('gds_library.subsref : structure >> %s << not found', ins.subs));
end

otherwise
error('gds_library.subsref : invalid indexing type.');

end

% pass additional structure indexing to structure subsref method
if length(itype) > 1
sins.type = itype{2};
sins.subs = isubs{2};
if length(ins) > 1
if iscell(gstrs)
gstrs = cellfun(@(x)subsref(x, sins), gstrs, 'Un',0);
gstrs = cellfun(@(x)subsref(x, ins(2:end)), gstrs, 'Un',0);
else
gstrs = subsref(gstrs, sins);
gstrs = subsref(gstrs, ins(2:end));
end
end

Expand Down
23 changes: 9 additions & 14 deletions Basic/@gds_structure/subsref.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@

% Ulf Griesmann, NIST, June 2011

% convert cs-lists --> cell arrays
itype = {ins.type};
isubs = {ins.subs};

% first indexing operator
switch itype{1}
idx = ins(1).subs;

switch ins(1).type

case '()'

idx = isubs{1};
if iscell(idx)
idx = idx{1};
idx = idx{:};
end

if ischar(idx) && idx == ':'
gelp = gstruct.el;
elseif length(idx) == 1
Expand All @@ -37,7 +34,7 @@
case '.'

try
gelp = gstruct.(ins.subs);
gelp = gstruct.(ins(1).subs);
catch
error('gds_structure.subsref : invalid structure property.');
end
Expand All @@ -48,13 +45,11 @@
end

% pass additional element indexing to element subsref method
if length(itype) > 1
eins.type = itype{2};
eins.subs = isubs{2};
if length(ins) > 1
if iscell(gelp)
gelp = cellfun(@(x)subsref(x, eins), gelp, 'Un',0);
gelp = cellfun(@(x)subsref(x, ins(2:end)), gelp, 'Un',0);
else
gelp = subsref(gelp, eins);
gelp = subsref(gelp, ins(2:end));
end
end

Expand Down
4 changes: 2 additions & 2 deletions Basic/gdsii_version.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
%

% toolbox version and version date
tb_version = '139';
tb_date = '2016-November-07';
tb_version = '140';
tb_date = '2016-November-14';
ltb_ver = [tb_version, ' (', tb_date, ')'];
if exist('OCTAVE_VERSION')
interpreter = 'Octave';
Expand Down
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2016-November-14
- version 140
- fixed the remaining bugs in the 'subsref' methods for gds_library and gds_structure
objects.

2016-November-07
- version 139
- much improved (faster) 'subsref' methods for gds_library and gds_structure
Expand Down

0 comments on commit 8cd6e5e

Please sign in to comment.