diff --git a/src/db/db/gsiDeclDbMetaInfo.cc b/src/db/db/gsiDeclDbMetaInfo.cc index 9835d86c4..ef760d438 100644 --- a/src/db/db/gsiDeclDbMetaInfo.cc +++ b/src/db/db/gsiDeclDbMetaInfo.cc @@ -86,26 +86,26 @@ Class decl_LayoutMetaInfo ("db", "LayoutMetaInfo", gsi::method_ext ("name", &layout_meta_get_name, "@brief Gets the name of the layout meta info object\n" ) + - gsi::method_ext ("name=", &layout_meta_set_name, + gsi::method_ext ("name=", &layout_meta_set_name, gsi::arg ("name"), "@brief Sets the name of the layout meta info object\n" ) + gsi::method_ext ("value", &layout_meta_get_value, "@brief Gets the value of the layout meta info object\n" ) + - gsi::method_ext ("value=", &layout_meta_set_value, + gsi::method_ext ("value=", &layout_meta_set_value, gsi::arg ("value"), "@brief Sets the value of the layout meta info object\n" ) + gsi::method_ext ("description", &layout_meta_get_description, "@brief Gets the description of the layout meta info object\n" ) + - gsi::method_ext ("description=", &layout_meta_set_description, + gsi::method_ext ("description=", &layout_meta_set_description, gsi::arg ("description"), "@brief Sets the description of the layout meta info object\n" ) + gsi::method_ext ("is_persisted?", &layout_meta_get_persisted, "@brief Gets a value indicating whether the meta information will be persisted\n" "This predicate was introduced in version 0.28.8.\n" ) + - gsi::method_ext ("persisted=", &layout_meta_set_persisted, + gsi::method_ext ("persisted=", &layout_meta_set_persisted, gsi::arg ("flag"), "@brief Sets a value indicating whether the meta information will be persisted\n" "This predicate was introduced in version 0.28.8.\n" ), @@ -131,12 +131,37 @@ Class decl_LayoutMetaInfo ("db", "LayoutMetaInfo", " keys for user properties. @/li\n" "@/ul\n" "\n" - "Note that only meta information marked with \\is_persisted? == true are stored in GDS or OASIS files. " + "Elementary (serializable) objects are: \\Box, \\DBox, \\Edge, \\DEdge, \\EdgePair, \\DEdgePair, " + "\\EdgePairs, \\Edges, \\LayerProperties, \\Matrix2d, \\Matrix3d, \\Path, \\DPath, \\Point, \\DPoint, " + "\\Polygon, \\DPolygon, \\SimplePolygon, \\DSimplePolygon, \\Region, \\Text, \\DText, \\Texts, " + "\\Trans, \\DTrans, \\CplxTrans, \\ICplxTrans, \\DCplxTrans, \\VCplxTrans, \\Vector, \\DVector " + "(list may not be complete).\n" + "\n" + "KLayout itself also generates meta information with specific keys. " + "For disambiguation, namespaces can be established by prefixing " + "the key strings with some unique identifier in XML fashion, like a domain name - " + "e.g. 'example.com:key'.\n" + "\n" + "@b Note: @/b only meta information marked with \\is_persisted? == true is stored in GDS or OASIS files. " "This is not the default setting, so you need to explicitly set that flag.\n" "\n" "See also \\Layout#each_meta_info, \\Layout#meta_info_value, \\Layout#meta_info and \\Layout#remove_meta_info as " "well as the corresponding \\Cell methods.\n" "\n" + "An example of how to attach persisted meta information to a cell is here:\n" + "\n" + "@code\n" + "ly = RBA::Layout::new\n" + "c1 = ly.create_cell(\"C1\")\n" + "\n" + "mi = RBA::LayoutMetaInfo::new(\"the-answer\", 42.0)\n" + "mi.persisted = true\n" + "c1.add_meta_info(mi)\n" + "\n" + "# will now hold this piece of meta information attached to cell 'C1':\n" + "ly.write(\"to.gds\")\n" + "@/code\n" + "\n" "This class has been introduced in version 0.25 and was extended in version 0.28.8." ); diff --git a/src/plugins/streamers/gds2/unit_tests/dbGDS2Writer.cc b/src/plugins/streamers/gds2/unit_tests/dbGDS2Writer.cc index 648a5105f..20499fc60 100644 --- a/src/plugins/streamers/gds2/unit_tests/dbGDS2Writer.cc +++ b/src/plugins/streamers/gds2/unit_tests/dbGDS2Writer.cc @@ -1194,7 +1194,7 @@ TEST(121) } // Meta info -TEST(130) +TEST(130a) { db::Layout layout_org; @@ -1207,7 +1207,19 @@ TEST(130) layout_org.add_meta_info (ci, "a", db::MetaInfo ("dd", true, true)); layout_org.add_meta_info (ci, "c", db::MetaInfo ("d", -1, true)); - std::string tmp_file = tl::TestBase::tmp_file ("tmp_GDS2Writer_130.gds"); + // complex type + tl::Variant v2; + v2.set_array (); + v2.insert ("x", "value_for_x"); + v2.insert ("y", db::DBox (1.5, 2.5, 3.5, 4.5)); + tl::Variant v1; + v1.set_list (0); + v1.push (-1.5); + v1.push (v2); + layout_org.add_meta_info (ci, "complex", db::MetaInfo ("", v1, true)); + layout_org.add_meta_info ("complex", db::MetaInfo ("", v1, true)); + + std::string tmp_file = tl::TestBase::tmp_file ("tmp_GDS2Writer_130a.gds"); { tl::OutputStream out (tmp_file); @@ -1224,11 +1236,19 @@ TEST(130) reader.read (layout_read); } + EXPECT_EQ (layout_read.has_meta_info ("x"), false); + EXPECT_EQ (layout_read.has_meta_info ("a"), true); EXPECT_EQ (layout_read.meta_info ("x").value.to_string (), "nil"); EXPECT_EQ (layout_read.meta_info ("a").value.to_string (), "17.5"); EXPECT_EQ (layout_read.meta_info ("a").description, "description"); + EXPECT_EQ (layout_read.has_meta_info ("b"), true); EXPECT_EQ (layout_read.meta_info ("b").value.to_string (), "value"); EXPECT_EQ (layout_read.meta_info ("b").description, ""); + EXPECT_EQ (layout_read.has_meta_info ("complex"), true); + EXPECT_EQ (layout_read.meta_info ("complex").value.is_list (), true); + EXPECT_EQ (layout_read.meta_info ("complex").value.size (), size_t (2)); + EXPECT_EQ (layout_read.meta_info ("complex").value.begin () [1].is_array (), true); + EXPECT_EQ (layout_read.meta_info ("complex").value.to_string (), "-1.5,x=>value_for_x,y=>(1.5,2.5;3.5,4.5)"); db::cell_index_type ci2 = layout_read.cell_by_name ("X").second; @@ -1237,6 +1257,10 @@ TEST(130) EXPECT_EQ (layout_read.meta_info (ci2, "a").description, "dd"); EXPECT_EQ (layout_read.meta_info (ci2, "c").value.to_string (), "-1"); EXPECT_EQ (layout_read.meta_info (ci2, "c").description, "d"); + EXPECT_EQ (layout_read.meta_info (ci2, "complex").value.is_list (), true); + EXPECT_EQ (layout_read.meta_info (ci2, "complex").value.size (), size_t (2)); + EXPECT_EQ (layout_read.meta_info (ci2, "complex").value.begin () [1].is_array (), true); + EXPECT_EQ (layout_read.meta_info (ci2, "complex").value.to_string (), "-1.5,x=>value_for_x,y=>(1.5,2.5;3.5,4.5)"); tmp_file = tl::TestBase::tmp_file ("tmp_GDS2Writer_130b.gds");