Avoiding call ambiguities when creating Edges, Region, EdgePairs and Texts from arrays of objects with properties.

This commit is contained in:
Matthias Koefferlein 2025-02-04 23:59:04 +01:00
parent 1f44a951f4
commit c09184989f
8 changed files with 48 additions and 38 deletions

View File

@ -230,7 +230,7 @@ static db::EdgePairs *new_a (const std::vector<db::EdgePair> &pairs)
return new db::EdgePairs (pairs.begin (), pairs.end ());
}
static db::EdgePairs *new_ap (const std::vector<db::EdgePairWithProperties> &pairs)
static db::EdgePairs *new_ap (const std::vector<db::EdgePairWithProperties> &pairs, bool)
{
return new db::EdgePairs (pairs.begin (), pairs.end ());
}
@ -592,12 +592,11 @@ Class<db::EdgePairs> decl_EdgePairs (decl_dbShapeCollection, "db", "EdgePairs",
"\n"
"This constructor has been introduced in version 0.26."
) +
constructor ("new", &new_ap, gsi::arg ("array"),
"@brief Constructor from an array of edge pairs with properties\n"
"\n"
"This constructor creates an edge pair collection from an array of \\EdgePairWithProperties objects.\n"
"\n"
"This constructor has been introduced in version 0.30."
// This is a dummy constructor that allows creating a EdgePairs collection from an array
// of EdgePairWithProperties objects too. GSI needs the dummy argument to
// differentiate between the cases when an empty array is passed.
constructor ("new", &new_ap, gsi::arg ("array"), gsi::arg ("dummy", true),
"@hide"
) +
constructor ("new", &new_ep, gsi::arg ("edge_pair"),
"@brief Constructor from a single edge pair object\n"

View File

@ -265,12 +265,12 @@ static db::Edges *new_ep (const db::EdgeWithProperties &e)
return ee;
}
static db::Edges *new_a1 (const std::vector <db::Polygon> &a)
static db::Edges *new_a1 (const std::vector <db::Polygon> &a, bool)
{
return new db::Edges (a.begin (), a.end ());
}
static db::Edges *new_a1p (const std::vector <db::PolygonWithProperties> &a)
static db::Edges *new_a1p (const std::vector <db::PolygonWithProperties> &a, bool)
{
return new db::Edges (a.begin (), a.end ());
}
@ -280,7 +280,7 @@ static db::Edges *new_a2 (const std::vector <db::Edge> &a)
return new db::Edges (a.begin (), a.end ());
}
static db::Edges *new_a2p (const std::vector <db::EdgeWithProperties> &a)
static db::Edges *new_a2p (const std::vector <db::EdgeWithProperties> &a, bool)
{
return new db::Edges (a.begin (), a.end ());
}
@ -768,31 +768,32 @@ Class<db::Edges> decl_Edges (decl_dbShapeCollection, "db", "Edges",
"\n"
"This variant has been introduced in version 0.30."
) +
constructor ("new", &new_a1, gsi::arg ("array"),
constructor ("new", &new_a1, gsi::arg ("array"), gsi::arg ("dummy", true),
"@brief Constructor from a polygon array\n"
"\n"
"This constructor creates an edge collection from an array of polygons.\n"
"The edges form the contours of the polygons.\n"
"\n"
"The dummy argument is needed internally to differentiate the constructors "
"taking arrays of polygons and edges in case of empty arrays. Do not specify "
"this argument."
) +
constructor ("new", &new_a1p, gsi::arg ("array"),
"@brief Constructor from a polygon array\n"
"\n"
"This constructor creates an edge collection from an array of polygons with properties.\n"
"The edges form the contours of the polygons.\n"
"\n"
"This variant has been introduced in version 0.30."
// This is a dummy constructor that allows creating an Edges collection from an array
// of PolygonWithProperties objects too. GSI needs the dummy argument to
// differentiate between the cases when an empty array is passed.
constructor ("new", &new_a1p, gsi::arg ("array"), gsi::arg ("dummy", true),
"@hide"
) +
constructor ("new", &new_a2, gsi::arg ("array"),
"@brief Constructor from an edge array\n"
"\n"
"This constructor creates an edge collection from an array of edges.\n"
) +
constructor ("new", &new_a2p, gsi::arg ("array"),
"@brief Constructor from an edge array\n"
"\n"
"This constructor creates an edge collection from an array of edges with properties.\n"
"\n"
"This variant has been introduced in version 0.30."
// This is a dummy constructor that allows creating an Edges collection from an array
// of EdgeWithProperties objects too. GSI needs the dummy argument to
// differentiate between the cases when an empty array is passed.
constructor ("new", &new_a2p, gsi::arg ("array"), gsi::arg ("dummy", true),
"@hide"
) +
constructor ("new", &new_b, gsi::arg ("box"),
"@brief Box constructor\n"

View File

@ -250,7 +250,7 @@ static db::Region *new_a (const std::vector <db::Polygon> &a)
return new db::Region (a.begin (), a.end ());
}
static db::Region *new_ap (const std::vector <db::PolygonWithProperties> &a)
static db::Region *new_ap (const std::vector <db::PolygonWithProperties> &a, bool)
{
return new db::Region (a.begin (), a.end ());
}
@ -1206,12 +1206,11 @@ Class<db::Region> decl_Region (decl_dbShapeCollection, "db", "Region",
"\n"
"This constructor creates a region from an array of polygons.\n"
) +
constructor ("new", &new_ap, gsi::arg ("array"),
"@brief Constructor from an array of polygons with properties\n"
"\n"
"This constructor creates a region from an array of polygons with properties.\n"
"\n"
"This variant has been introduced in version 0.30."
// This is a dummy constructor that allows creating a Region from an array
// of PolygonWithProperties objects too. GSI needs the dummy argument to
// differentiate between the cases when an empty array is passed.
constructor ("new", &new_ap, gsi::arg ("array"), gsi::arg ("dummy", true),
"@hide"
) +
constructor ("new", &new_b, gsi::arg ("box"),
"@brief Box constructor\n"

View File

@ -197,7 +197,7 @@ static db::Texts *new_a (const std::vector<db::Text> &t)
return new db::Texts (t.begin (), t.end ());
}
static db::Texts *new_ap (const std::vector<db::TextWithProperties> &t)
static db::Texts *new_ap (const std::vector<db::TextWithProperties> &t, bool)
{
return new db::Texts (t.begin (), t.end ());
}
@ -375,12 +375,11 @@ Class<db::Texts> decl_Texts (decl_dbShapeCollection, "db", "Texts",
"\n"
"This constructor creates an text collection from an array of \\Text objects.\n"
) +
constructor ("new", &new_ap, gsi::arg ("array"),
"@brief Constructor from an array with texts with properties\n"
"\n"
"This constructor creates an text collection from an array of \\TextWithProperties objects.\n"
"\n"
"This variant has been introduced in version 0.30."
// This is a dummy constructor that allows creating a Texts collection from an array
// of TextWithProperties objects too. GSI needs the dummy argument to
// differentiate between the cases when an empty array is passed.
constructor ("new", &new_ap, gsi::arg ("array"), gsi::arg ("dummy", true),
"@hide"
) +
constructor ("new", &new_text, gsi::arg ("text"),
"@brief Constructor from a single text object\n"

View File

@ -580,6 +580,9 @@ class DBEdgePairs_TestClass < TestBase
r = RBA::EdgePairs::new([ RBA::EdgePairWithProperties::new(RBA::EdgePair::new(RBA::Edge::new(0, 0, 100, 100), RBA::Edge::new(200, 300, 200, 500)), { 1 => "one" }) ])
assert_equal(r.to_s, "(0,0;100,100)/(200,300;200,500){1=>one}")
r = RBA::EdgePairs::new([])
assert_equal(r.to_s, "")
r = RBA::EdgePairs::new(RBA::EdgePairWithProperties::new(RBA::EdgePair::new(RBA::Edge::new(0, 0, 100, 100), RBA::Edge::new(200, 300, 200, 500)), { 1 => "one" }))
assert_equal(r.to_s, "(0,0;100,100)/(200,300;200,500){1=>one}")

View File

@ -961,6 +961,9 @@ class DBEdges_TestClass < TestBase
r = RBA::Edges::new([ RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 100, 100), { 1 => "one" }) ])
assert_equal(r.to_s, "(0,0;100,100){1=>one}")
r = RBA::Edges::new([])
assert_equal(r.to_s, "")
r = RBA::Edges::new
r.insert([ RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 100, 100), { 1 => "one" }) ])
assert_equal(r.to_s, "(0,0;100,100){1=>one}")

View File

@ -1534,6 +1534,9 @@ class DBRegion_TestClass < TestBase
r = RBA::Region::new([ RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }) ])
assert_equal(r.to_s, "(0,0;0,200;100,200;100,0){1=>one}")
r = RBA::Region::new([])
assert_equal(r.to_s, "")
r = RBA::Region::new
r.insert([ RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }) ])
assert_equal(r.to_s, "(0,0;0,200;100,200;100,0){1=>one}")

View File

@ -449,6 +449,9 @@ class DBTexts_TestClass < TestBase
r = RBA::Texts::new([ RBA::TextWithProperties::new(RBA::Text::new("abc", RBA::Trans::new), { 1 => "one" }) ])
assert_equal(r.to_s, "('abc',r0 0,0){1=>one}")
r = RBA::Texts::new([])
assert_equal(r.to_s, "")
r = RBA::Texts::new(RBA::TextWithProperties::new(RBA::Text::new("abc", RBA::Trans::new), { 1 => "one" }))
assert_equal(r.to_s, "('abc',r0 0,0){1=>one}")