mirror of https://github.com/KLayout/klayout.git
Cleanup and fixed some compile issues
This commit is contained in:
parent
b1cc8ccbdf
commit
fcceca378c
|
|
@ -702,59 +702,30 @@ Class<PCellDeclarationImpl> decl_PCellDeclaration (decl_PCellDeclaration_Native,
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// db::PCellParameterDeclaration binding
|
// db::PCellParameterDeclaration binding
|
||||||
|
|
||||||
unsigned int get_type (const db::PCellParameterDeclaration *pd)
|
static unsigned int get_type (const db::PCellParameterDeclaration *pd)
|
||||||
{
|
{
|
||||||
return (unsigned int) pd->get_type ();
|
return (unsigned int) pd->get_type ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_type (db::PCellParameterDeclaration *pd, unsigned int t)
|
static void set_type (db::PCellParameterDeclaration *pd, unsigned int t)
|
||||||
{
|
{
|
||||||
pd->set_type (db::PCellParameterDeclaration::type (t));
|
pd->set_type (db::PCellParameterDeclaration::type (t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_choices (db::PCellParameterDeclaration *pd)
|
static void clear_choices (db::PCellParameterDeclaration *pd)
|
||||||
{
|
{
|
||||||
pd->set_choices (std::vector<tl::Variant> ());
|
pd->set_choices (std::vector<tl::Variant> ());
|
||||||
pd->set_choice_descriptions (std::vector<std::string> ());
|
pd->set_choice_descriptions (std::vector<std::string> ());
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_choice (db::PCellParameterDeclaration *pd, const std::string &d, const tl::Variant &v)
|
static void add_choice (db::PCellParameterDeclaration *pd, const std::string &d, const tl::Variant &v)
|
||||||
{
|
{
|
||||||
if (!pd->get_range().has_value())
|
std::vector<tl::Variant> vv = pd->get_choices ();
|
||||||
{
|
std::vector<std::string> dd = pd->get_choice_descriptions ();
|
||||||
std::vector<tl::Variant> vv = pd->get_choices ();
|
vv.push_back (v);
|
||||||
std::vector<std::string> dd = pd->get_choice_descriptions ();
|
dd.push_back (d);
|
||||||
vv.push_back (v);
|
pd->set_choice_descriptions (dd);
|
||||||
dd.push_back (d);
|
pd->set_choices (vv);
|
||||||
pd->set_choice_descriptions (dd);
|
|
||||||
pd->set_choices (vv);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tl::warn
|
|
||||||
<< "PCell parameter '" << pd->get_name() << "' has a range constraint, could not add choice '"
|
|
||||||
<< v.to_string() << "'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_range (db::PCellParameterDeclaration *pd, const tl::Variant& low, const tl::Variant& high, const tl::Variant& resolution, unsigned int action)
|
|
||||||
{
|
|
||||||
if (pd->get_choices().empty() && pd->get_choice_descriptions().empty())
|
|
||||||
{
|
|
||||||
if ((pd->get_type() == db::PCellParameterDeclaration::t_int
|
|
||||||
|| pd->get_type() == db::PCellParameterDeclaration::t_double) &&
|
|
||||||
!low.is_nil() && low.can_convert_to_double() &&
|
|
||||||
!high.is_nil() && high.can_convert_to_double())
|
|
||||||
{
|
|
||||||
pd->set_range(low, high, resolution, db::PCellParameterDeclaration::Action(action));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tl::warn
|
|
||||||
<< "PCell parameter '" << pd->get_name() << "' has a choice constraint, could not add range '["
|
|
||||||
<< low.to_string() << ", " << high.to_string() << "]'";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int pd_type_int ()
|
static unsigned int pd_type_int ()
|
||||||
|
|
@ -802,21 +773,6 @@ static unsigned int pd_type_none ()
|
||||||
return (unsigned int) db::PCellParameterDeclaration::t_none;
|
return (unsigned int) db::PCellParameterDeclaration::t_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int pd_action_reject ()
|
|
||||||
{
|
|
||||||
return (unsigned int) db::PCellParameterDeclaration::t_Reject;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int pd_action_accept ()
|
|
||||||
{
|
|
||||||
return (unsigned int) db::PCellParameterDeclaration::t_Accept;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int pd_action_use_default ()
|
|
||||||
{
|
|
||||||
return (unsigned int) db::PCellParameterDeclaration::t_Use_Default;
|
|
||||||
}
|
|
||||||
|
|
||||||
db::PCellParameterDeclaration *ctor_pcell_parameter (const std::string &name, unsigned int type, const std::string &description)
|
db::PCellParameterDeclaration *ctor_pcell_parameter (const std::string &name, unsigned int type, const std::string &description)
|
||||||
{
|
{
|
||||||
db::PCellParameterDeclaration *pd = new db::PCellParameterDeclaration ();
|
db::PCellParameterDeclaration *pd = new db::PCellParameterDeclaration ();
|
||||||
|
|
@ -981,10 +937,7 @@ Class<db::PCellParameterDeclaration> decl_PCellParameterDeclaration ("db", "PCel
|
||||||
gsi::method ("TypeLayer", &pd_type_layer, "@brief Type code: a layer (a \\LayerInfo object)") +
|
gsi::method ("TypeLayer", &pd_type_layer, "@brief Type code: a layer (a \\LayerInfo object)") +
|
||||||
gsi::method ("TypeShape", &pd_type_shape, "@brief Type code: a guiding shape (Box, Edge, Point, Polygon or Path)") +
|
gsi::method ("TypeShape", &pd_type_shape, "@brief Type code: a guiding shape (Box, Edge, Point, Polygon or Path)") +
|
||||||
gsi::method ("TypeCallback", &pd_type_callback, "@brief Type code: a button triggering a callback\n\nThis code has been introduced in version 0.28.") +
|
gsi::method ("TypeCallback", &pd_type_callback, "@brief Type code: a button triggering a callback\n\nThis code has been introduced in version 0.28.") +
|
||||||
gsi::method ("TypeNone", &pd_type_none, "@brief Type code: unspecific type") +
|
gsi::method ("TypeNone", &pd_type_none, "@brief Type code: unspecific type")
|
||||||
gsi::method ("REJECT", &pd_action_reject, "@brief Action type: reject violating parameter") +
|
|
||||||
gsi::method ("ACCEPT", &pd_action_accept, "@brief Action type: accept violating parameter") +
|
|
||||||
gsi::method ("USE_DEFAULT", &pd_action_use_default, "@brief Action type: use default instead violating parameter (currently not supported)")
|
|
||||||
,
|
,
|
||||||
"@brief A PCell parameter declaration\n"
|
"@brief A PCell parameter declaration\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|
|
||||||
|
|
@ -773,10 +773,7 @@ PCellParametersPage::get_parameters_internal (db::ParameterStates &states, bool
|
||||||
ps.set_value (tl::Variant (v));
|
ps.set_value (tl::Variant (v));
|
||||||
lay::indicate_error (le, (tl::Exception *) 0);
|
lay::indicate_error (le, (tl::Exception *) 0);
|
||||||
|
|
||||||
if (p->get_range().has_value())
|
check_range(tl::Variant (v), *p);
|
||||||
{
|
|
||||||
check_range(tl::Variant(v), p->get_range().value());
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (tl::Exception &ex) {
|
} catch (tl::Exception &ex) {
|
||||||
|
|
||||||
|
|
@ -802,10 +799,7 @@ PCellParametersPage::get_parameters_internal (db::ParameterStates &states, bool
|
||||||
ps.set_value (tl::Variant (v));
|
ps.set_value (tl::Variant (v));
|
||||||
lay::indicate_error (le, (tl::Exception *) 0);
|
lay::indicate_error (le, (tl::Exception *) 0);
|
||||||
|
|
||||||
if (p->get_range().has_value())
|
check_range(tl::Variant (v), *p);
|
||||||
{
|
|
||||||
check_range(tl::Variant(v), p->get_range().value());
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (tl::Exception &ex) {
|
} catch (tl::Exception &ex) {
|
||||||
|
|
||||||
|
|
@ -1110,11 +1104,11 @@ void
|
||||||
PCellParametersPage::check_range (const tl::Variant &value, const db::PCellParameterDeclaration &decl)
|
PCellParametersPage::check_range (const tl::Variant &value, const db::PCellParameterDeclaration &decl)
|
||||||
{
|
{
|
||||||
if (! decl.min_value ().is_nil () && value < decl.min_value ()) {
|
if (! decl.min_value ().is_nil () && value < decl.min_value ()) {
|
||||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("The value is below the minimum allowed value: given value is %s, minimum value is %s")), value.to_string (), decl.min_value ().to_string ()));
|
throw tl::Exception (tl::sprintf (tl::to_string (tr ("The value is lower than the minimum allowed value: given value is %s, minimum value is %s")), value.to_string (), decl.min_value ().to_string ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! decl.max_value ().is_nil () && value > decl.max_value ()) {
|
if (! decl.max_value ().is_nil () && ! (value < decl.max_value () || value == decl.max_value ())) {
|
||||||
throw tl::Exception (tl::sprintf (tl::to_string (tr ("The value is above the maximum allowed value: given value is %s, maximum value is %s")), value.to_string (), decl.max_value ().to_string ()));
|
throw tl::Exception (tl::sprintf (tl::to_string (tr ("The value is higher than the maximum allowed value: given value is %s, maximum value is %s")), value.to_string (), decl.max_value ().to_string ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue