diff --git a/src/db/db/dbD25TechnologyComponent.cc b/src/db/db/dbD25TechnologyComponent.cc
index 7e3742a5e..f710d829a 100644
--- a/src/db/db/dbD25TechnologyComponent.cc
+++ b/src/db/db/dbD25TechnologyComponent.cc
@@ -134,10 +134,11 @@ D25TechnologyComponent::D25TechnologyComponent ()
"# 'zstart' and 'zstop'.\n"
"#\n"
"# Examples:\n"
- "# 1: 0.5 1.5 # extrude layer 1/0 from 0.5 to 1.5 vertically\n"
- "# 1: zstop=1.5, zstart=0.5 # same as above\n"
- "# 1: height=1.0, zstop=1.5 # same as above\n"
- "# 1: 1.0 zstop=1.5 # same as above\n"
+ "# 1: 0.5 1.5 # extrude layer 1/0 from 0.5 to 1.5 vertically\n"
+ "# 1/0: 0.5 1.5 # same with explicit datatype\n"
+ "# 1: zstop=1.5, zstart=0.5 # same with named parameters\n"
+ "# 1: height=1.0, zstop=1.5 # same with z stop minus height\n"
+ "# 1: 1.0 zstop=1.5 # same with height as unnamed parameter\n"
;
}
@@ -186,6 +187,10 @@ D25TechnologyComponent::compile_from_source (const std::string &src)
while (! ex.at_end ()) {
+ if (ex.test ("#")) {
+ break;
+ }
+
double pv = 0.0;
std::string pn;
@@ -227,6 +232,9 @@ D25TechnologyComponent::compile_from_source (const std::string &src)
if (! h.is_nil ()) {
info.set_zstop (info.zstart () + h.to_double ());
}
+ } else {
+ info.set_zstart (z0.to_double ());
+ info.set_zstop (z1.to_double ());
}
} else if (args.size () == 1) {
info.set_zstop ((! z0.is_nil () ? z0.to_double () : info.zstart ()) + args[0]);
@@ -250,6 +258,21 @@ D25TechnologyComponent::compile_from_source (const std::string &src)
m_src = src;
}
+std::string
+D25TechnologyComponent::to_string () const
+{
+ std::string res;
+
+ for (const_iterator i = begin (); i != end (); ++i) {
+ if (! res.empty ()) {
+ res += "\n";
+ }
+ res += i->layer ().to_string () + ": zstart=" + tl::to_string (i->zstart ()) + ", zstop=" + tl::to_string (i->zstop ());
+ }
+
+ return res;
+}
+
// -----------------------------------------------------------------------------------
// D25TechnologyComponent technology component registration
diff --git a/src/db/db/dbD25TechnologyComponent.h b/src/db/db/dbD25TechnologyComponent.h
index 8d16796e0..4c31363c1 100644
--- a/src/db/db/dbD25TechnologyComponent.h
+++ b/src/db/db/dbD25TechnologyComponent.h
@@ -137,6 +137,8 @@ public:
m_src = s;
}
+ std::string to_string () const;
+
db::TechnologyComponent *clone () const
{
return new D25TechnologyComponent (*this);
diff --git a/src/db/unit_tests/dbD25TechnologyComponentTests.cc b/src/db/unit_tests/dbD25TechnologyComponentTests.cc
new file mode 100644
index 000000000..3dc872953
--- /dev/null
+++ b/src/db/unit_tests/dbD25TechnologyComponentTests.cc
@@ -0,0 +1,70 @@
+
+/*
+
+ KLayout Layout Viewer
+ Copyright (C) 2006-2020 Matthias Koefferlein
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+
+
+#include "dbD25TechnologyComponent.h"
+#include "tlUnitTest.h"
+
+
+TEST(1)
+{
+ db::D25TechnologyComponent comp;
+
+ comp.compile_from_source ("1/0: 1.0 1.5 # a comment");
+ EXPECT_EQ (comp.to_string (), "1/0: zstart=1, zstop=1.5");
+
+ comp.compile_from_source ("1/0: zstart=1.0 zstop=1.5");
+ EXPECT_EQ (comp.to_string (), "1/0: zstart=1, zstop=1.5");
+
+ comp.compile_from_source ("1/0: zstart=1.0 height=0.5");
+ EXPECT_EQ (comp.to_string (), "1/0: zstart=1, zstop=1.5");
+
+ comp.compile_from_source ("1/0: zstop=1.5 height=0.5");
+ EXPECT_EQ (comp.to_string (), "1/0: zstart=1, zstop=1.5");
+
+ comp.compile_from_source ("1/0: zstart=1.0 zstop=1.5\nname: height=3");
+ EXPECT_EQ (comp.to_string (), "1/0: zstart=1, zstop=1.5\nname: zstart=1.5, zstop=4.5");
+
+ comp.compile_from_source ("1/0: zstart=1.0 zstop=1.5\nname: zstart=4.0 height=3\n\n# a comment line");
+ EXPECT_EQ (comp.to_string (), "1/0: zstart=1, zstop=1.5\nname: zstart=4, zstop=7");
+
+ try {
+ comp.compile_from_source ("blabla");
+ EXPECT_EQ (false, true);
+ } catch (...) { }
+
+ try {
+ comp.compile_from_source ("1/0: 1 2 3");
+ EXPECT_EQ (false, true);
+ } catch (...) { }
+
+ try {
+ comp.compile_from_source ("1/0: foo=1 bar=2");
+ EXPECT_EQ (false, true);
+ } catch (...) { }
+
+ try {
+ comp.compile_from_source ("1/0: 1;2");
+ EXPECT_EQ (false, true);
+ } catch (...) { }
+}
diff --git a/src/db/unit_tests/unit_tests.pro b/src/db/unit_tests/unit_tests.pro
index 5aa37d85e..f69577d0a 100644
--- a/src/db/unit_tests/unit_tests.pro
+++ b/src/db/unit_tests/unit_tests.pro
@@ -73,7 +73,8 @@ SOURCES = \
dbLayoutQueryTests.cc \
dbPolygonToolsTests.cc \
dbTechnologyTests.cc \
- dbStreamLayerTests.cc
+ dbStreamLayerTests.cc \
+ dbD25TechnologyComponentTests.cc
INCLUDEPATH += $$TL_INC $$DB_INC $$GSI_INC
DEPENDPATH += $$TL_INC $$DB_INC $$GSI_INC
diff --git a/src/laybasic/laybasic/syntax/d25_text.xml b/src/laybasic/laybasic/syntax/d25_text.xml
index c845bf7b1..654dd7c93 100644
--- a/src/laybasic/laybasic/syntax/d25_text.xml
+++ b/src/laybasic/laybasic/syntax/d25_text.xml
@@ -15,7 +15,7 @@
-
+
@@ -46,13 +46,13 @@
-
+
-
+