diff --git a/src/pymod/lay/lay.pro b/src/pymod/lay/lay.pro index 8efe24ceb..8fe613bfa 100644 --- a/src/pymod/lay/lay.pro +++ b/src/pymod/lay/lay.pro @@ -8,7 +8,7 @@ SOURCES = \ HEADERS += \ -LIBS += -lklayout_lay +LIBS += -lklayout_lay -lklayout_ext # Use this opportunity to provide the __init__.py file diff --git a/src/pymod/pymod.pro b/src/pymod/pymod.pro index ef24ef8d8..86a6dd135 100644 --- a/src/pymod/pymod.pro +++ b/src/pymod/pymod.pro @@ -3,6 +3,7 @@ TEMPLATE = subdirs SUBDIRS = \ db \ tl \ + rdb \ lay \ equals(HAVE_QTBINDINGS, "1") { diff --git a/src/pymod/rdb/rdb.pro b/src/pymod/rdb/rdb.pro new file mode 100644 index 000000000..5a54aa383 --- /dev/null +++ b/src/pymod/rdb/rdb.pro @@ -0,0 +1,11 @@ + +TARGET = rdb + +include($$PWD/../pymod.pri) + +SOURCES = \ + rdbMain.cc \ + +HEADERS += \ + +LIBS += -lklayout_rdb diff --git a/src/pymod/rdb/rdbMain.cc b/src/pymod/rdb/rdbMain.cc new file mode 100644 index 000000000..cd7cf391a --- /dev/null +++ b/src/pymod/rdb/rdbMain.cc @@ -0,0 +1,25 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2018 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 "../pymodHelper.h" + +DEFINE_PYMOD(rdb, "rdb", "KLayout core module 'rdb'") diff --git a/src/pymod/unit_tests/pymod_tests.cc b/src/pymod/unit_tests/pymod_tests.cc index 55a66f98c..ef1a866aa 100644 --- a/src/pymod/unit_tests/pymod_tests.cc +++ b/src/pymod/unit_tests/pymod_tests.cc @@ -29,6 +29,7 @@ #include + int run_pymodtest (tl::TestBase * /*_this*/, const std::string &fn) { QProcess process; @@ -57,7 +58,12 @@ PYMODTEST (bridge, "bridge.py") PYMODTEST (import_tl, "import_tl.py") PYMODTEST (import_db, "import_db.py") +PYMODTEST (import_rdb, "import_rdb.py") + +#if defined(HAVE_QTBINDINGS) + PYMODTEST (import_lay, "import_lay.py") + PYMODTEST (import_QtCore, "import_QtCore.py") PYMODTEST (import_QtGui, "import_QtGui.py") PYMODTEST (import_QtXml, "import_QtXml.py") @@ -74,3 +80,9 @@ PYMODTEST (import_QtSvg, "import_QtSvg.py") PYMODTEST (import_QtXmlPatterns, "import_QtXmlPatterns.py") #endif + +#else + +PYMODTEST (import_lay, "import_lay_noqt.py") + +#endif diff --git a/src/rdb/rdb/gsiDeclRdb.cc b/src/rdb/rdb/gsiDeclRdb.cc index f420a3b58..7b5070471 100644 --- a/src/rdb/rdb/gsiDeclRdb.cc +++ b/src/rdb/rdb/gsiDeclRdb.cc @@ -96,7 +96,7 @@ static rdb::Reference *new_ref_tp (const db::DCplxTrans &trans, rdb::id_type par return new rdb::Reference (trans, parent_cell_id); } -Class decl_RdbReference ("lay", "RdbReference", +Class decl_RdbReference ("rdb", "RdbReference", gsi::constructor ("new", &new_ref_tp, "@brief Creates a reference with a given transformation and parent cell ID\n" "@args trans, parent_cell_id\n" @@ -166,7 +166,7 @@ ItemRefUnwrappingIterator cell_items_end (const rdb::Cell *cell) return cell->database ()->items_by_cell (cell->id ()).second; } -Class decl_RdbCell ("lay", "RdbCell", +Class decl_RdbCell ("rdb", "RdbCell", gsi::method ("rdb_id", &rdb::Cell::id, "@brief Gets the cell ID\n" "The cell ID is an integer that uniquely identifies the cell. It is used for referring to a " @@ -272,7 +272,7 @@ static void scan_shapes (rdb::Category *cat, const db::RecursiveShapeIterator &i rdb::scan_layer (cat, iter); } -Class decl_RdbCategory ("lay", "RdbCategory", +Class decl_RdbCategory ("rdb", "RdbCategory", gsi::method ("rdb_id", &rdb::Category::id, "@brief Gets the category ID\n" "The category ID is an integer that uniquely identifies the category. It is used for referring to a " @@ -559,7 +559,7 @@ void value_set_tag_id (rdb::ValueWrapper *v, rdb::id_type id) v->set_tag_id (id); } -Class decl_RdbItemValue ("lay", "RdbItemValue", +Class decl_RdbItemValue ("rdb", "RdbItemValue", gsi::method ("from_s", &value_from_string, "@brief Creates a value object from a string\n" "@args s\n" @@ -739,7 +739,7 @@ static void clear_values (rdb::Item *item) item->set_values (rdb::Values ()); } -Class decl_RdbItem ("lay", "RdbItem", +Class decl_RdbItem ("rdb", "RdbItem", gsi::method ("database", (const rdb::Database *(rdb::Item::*)() const) &rdb::Item::database, "@brief Gets the database object that item is associated with\n" "\n" @@ -1078,7 +1078,7 @@ static rdb::Item *create_item_from_objects (rdb::Database *db, rdb::Cell *cell, } } -Class decl_ReportDatabase ("lay", "ReportDatabase", +Class decl_ReportDatabase ("rdb", "ReportDatabase", gsi::constructor ("new", &create_rdb, "@brief Creates a report database\n" "@args name\n" diff --git a/testdata/pymod/import_lay_noqt.py b/testdata/pymod/import_lay_noqt.py new file mode 100644 index 000000000..5e231e3cf --- /dev/null +++ b/testdata/pymod/import_lay_noqt.py @@ -0,0 +1,47 @@ +# KLayout Layout Viewer +# Copyright (C) 2006-2018 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 + + +import pykl.db as db +import pykl.lay as lay +import unittest +import sys + +# Tests the basic abilities of the module + +class BasicTest(unittest.TestCase): + + def test_1(self): + self.assertEqual("Annotation" in lay.__all__, True) + + def test_2(self): + # Some smoke test + ant = lay.Annotation() + ant.style = lay.Annotation.StyleRuler + self.assertEqual(str(ant.style), str(lay.Annotation.StyleRuler)) + ant.fmt_x = "abc" + self.assertEqual(ant.fmt_x, "abc") + +# run unit tests +if __name__ == '__main__': + suite = unittest.TestSuite() + suite = unittest.TestLoader().loadTestsFromTestCase(BasicTest) + + if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): + sys.exit(1) + + diff --git a/testdata/pymod/import_rdb.py b/testdata/pymod/import_rdb.py new file mode 100644 index 000000000..cc0b8155f --- /dev/null +++ b/testdata/pymod/import_rdb.py @@ -0,0 +1,45 @@ +# KLayout Layout Viewer +# Copyright (C) 2006-2018 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 + + +import pykl.rdb as rdb +import unittest +import sys + +# Tests the basic abilities of the module + +class BasicTest(unittest.TestCase): + + def test_1(self): + self.assertEqual("RdbItemValue" in rdb.__all__, True) + + def test_2(self): + # Some smoke test + v = rdb.RdbItemValue() + self.assertEqual(str(v), "") + v = rdb.RdbItemValue(2.5) + self.assertEqual(str(v), "float: 2.5") + +# run unit tests +if __name__ == '__main__': + suite = unittest.TestSuite() + suite = unittest.TestLoader().loadTestsFromTestCase(BasicTest) + + if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): + sys.exit(1) + +