From 8cd6e5e0959f9ceb20d10a3f6073f8d1da43b568 Mon Sep 17 00:00:00 2001 From: Ulf GRIESMANN Date: Mon, 14 Nov 2016 19:34:41 -0500 Subject: [PATCH] fixed bugs in subsref methods --- Basic/@gds_library/subsref.m | 31 +++++++++++++++---------------- Basic/@gds_structure/subsref.m | 23 +++++++++-------------- Basic/gdsii_version.m | 4 ++-- ChangeLog | 5 +++++ 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/Basic/@gds_library/subsref.m b/Basic/@gds_library/subsref.m index ab69aaa..9fe1414 100644 --- a/Basic/@gds_library/subsref.m +++ b/Basic/@gds_library/subsref.m @@ -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 == ':' @@ -35,13 +34,15 @@ 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.'); @@ -49,13 +50,11 @@ 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 diff --git a/Basic/@gds_structure/subsref.m b/Basic/@gds_structure/subsref.m index c3bdd35..c4f1544 100644 --- a/Basic/@gds_structure/subsref.m +++ b/Basic/@gds_structure/subsref.m @@ -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 @@ -37,7 +34,7 @@ case '.' try - gelp = gstruct.(ins.subs); + gelp = gstruct.(ins(1).subs); catch error('gds_structure.subsref : invalid structure property.'); end @@ -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 diff --git a/Basic/gdsii_version.m b/Basic/gdsii_version.m index 92741c5..b8aefab 100644 --- a/Basic/gdsii_version.m +++ b/Basic/gdsii_version.m @@ -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'; diff --git a/ChangeLog b/ChangeLog index 0a33e59..0bb4098 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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