mirror of https://github.com/KLayout/klayout.git
Merge pull request #1973 from KLayout/feature/issue-1971
Feature/issue 1971
This commit is contained in:
commit
253270aaa3
|
|
@ -105,11 +105,14 @@ Class<Logger> decl_Logger ("tl", "Logger",
|
||||||
"Level 0 is silent, levels 10, 20, 30 etc. denote levels with increasing verbosity. "
|
"Level 0 is silent, levels 10, 20, 30 etc. denote levels with increasing verbosity. "
|
||||||
"11, 21, 31 .. are sublevels which also enable timing logs in addition to messages."
|
"11, 21, 31 .. are sublevels which also enable timing logs in addition to messages."
|
||||||
) +
|
) +
|
||||||
gsi::method ("verbosity=", &Logger::set_verbosity, gsi::arg ("v"),
|
gsi::method ("verbosity=|set_verbosity", &Logger::set_verbosity, gsi::arg ("v"),
|
||||||
"@brief Sets the verbosity level for the application\n"
|
"@brief Sets the verbosity level for the application\n"
|
||||||
"\n"
|
"\n"
|
||||||
"See \\verbosity for a definition of the verbosity levels. Please note that this method "
|
"See \\verbosity for a definition of the verbosity levels. Please note that this method "
|
||||||
"changes the verbosity level for the whole application.\n"
|
"changes the verbosity level for the whole application.\n"
|
||||||
|
"\n"
|
||||||
|
"The 'set_verbosity' alias has been introduced in version 0.29.11 as class attributes "
|
||||||
|
"are not always available in Python."
|
||||||
),
|
),
|
||||||
"@brief A logger\n"
|
"@brief A logger\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|
|
||||||
|
|
@ -375,6 +375,18 @@ A *A::a20_get ()
|
||||||
return a_inst.get ();
|
return a_inst.get ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int s_sp = 0;
|
||||||
|
|
||||||
|
int A::sp_i_get ()
|
||||||
|
{
|
||||||
|
return s_sp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void A::sp_i_set (int v)
|
||||||
|
{
|
||||||
|
s_sp = v + 1;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
// Implementation of B
|
// Implementation of B
|
||||||
|
|
||||||
|
|
@ -1253,6 +1265,8 @@ static gsi::Class<A> decl_a ("", "A",
|
||||||
gsi::method ("a9b", &A::a9b) +
|
gsi::method ("a9b", &A::a9b) +
|
||||||
gsi::method ("a20", &A::a20) +
|
gsi::method ("a20", &A::a20) +
|
||||||
gsi::method ("a20_get", &A::a20_get) +
|
gsi::method ("a20_get", &A::a20_get) +
|
||||||
|
gsi::method ("sp_i", &A::sp_i_get) +
|
||||||
|
gsi::method ("sp_i=", &A::sp_i_set) +
|
||||||
gsi::method ("to_s", &A::to_s) +
|
gsi::method ("to_s", &A::to_s) +
|
||||||
gsi::iterator ("a6", &A::a6b, &A::a6e) +
|
gsi::iterator ("a6", &A::a6b, &A::a6e) +
|
||||||
gsi::iterator ("a7", &A::a7b, &A::a7e) +
|
gsi::iterator ("a7", &A::a7b, &A::a7e) +
|
||||||
|
|
|
||||||
|
|
@ -415,6 +415,10 @@ struct A
|
||||||
|
|
||||||
std::string to_s () const;
|
std::string to_s () const;
|
||||||
|
|
||||||
|
// static (class) properties
|
||||||
|
static int sp_i_get ();
|
||||||
|
static void sp_i_set (int v);
|
||||||
|
|
||||||
// members
|
// members
|
||||||
std::vector<double> m_d;
|
std::vector<double> m_d;
|
||||||
int n;
|
int n;
|
||||||
|
|
|
||||||
|
|
@ -1285,7 +1285,14 @@ property_setter_impl (int mid, PyObject *self, PyObject *value)
|
||||||
|
|
||||||
meth->call (obj, arglist, retlist);
|
meth->call (obj, arglist, retlist);
|
||||||
|
|
||||||
return get_return_value (p, retlist, meth, heap);
|
PyObject *ret = get_return_value (p, retlist, meth, heap);
|
||||||
|
|
||||||
|
if (ret == NULL) {
|
||||||
|
Py_INCREF (Py_None);
|
||||||
|
ret = Py_None;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -426,7 +426,11 @@ public:
|
||||||
doc += "\n\n";
|
doc += "\n\n";
|
||||||
}
|
}
|
||||||
doc += (*m)->doc ();
|
doc += (*m)->doc ();
|
||||||
|
if (! is_static) {
|
||||||
mp_module->add_python_doc (*m, tl::sprintf (tl::to_string (tr ("The object exposes a readable attribute '%s'. This is the getter")), name));
|
mp_module->add_python_doc (*m, tl::sprintf (tl::to_string (tr ("The object exposes a readable attribute '%s'. This is the getter")), name));
|
||||||
|
} else {
|
||||||
|
mp_module->add_python_doc (*m, tl::sprintf (tl::to_string (tr ("The class exposes a readable attribute '%s'. This is the getter")), name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MethodTableEntry::method_iterator m = begin_setters; m != end_setters; ++m) {
|
for (MethodTableEntry::method_iterator m = begin_setters; m != end_setters; ++m) {
|
||||||
|
|
@ -434,7 +438,11 @@ public:
|
||||||
doc += "\n\n";
|
doc += "\n\n";
|
||||||
}
|
}
|
||||||
doc += (*m)->doc ();
|
doc += (*m)->doc ();
|
||||||
|
if (! is_static) {
|
||||||
mp_module->add_python_doc (*m, tl::sprintf (tl::to_string (tr ("The object exposes a writable attribute '%s'. This is the setter")), name));
|
mp_module->add_python_doc (*m, tl::sprintf (tl::to_string (tr ("The object exposes a writable attribute '%s'. This is the setter")), name));
|
||||||
|
} else {
|
||||||
|
mp_module->add_python_doc (*m, tl::sprintf (tl::to_string (tr ("The class exposes a writable attribute '%s'. This setter may not be available in Python")), name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PythonRef attr;
|
PythonRef attr;
|
||||||
|
|
|
||||||
|
|
@ -392,28 +392,35 @@ WarningChannel::~WarningChannel ()
|
||||||
void
|
void
|
||||||
WarningChannel::puts (const char *s)
|
WarningChannel::puts (const char *s)
|
||||||
{
|
{
|
||||||
|
if (verbosity () >= 0) {
|
||||||
fputs (s, stdout);
|
fputs (s, stdout);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WarningChannel::endl ()
|
WarningChannel::endl ()
|
||||||
{
|
{
|
||||||
|
if (verbosity () >= 0) {
|
||||||
fputs ("\n", stdout);
|
fputs ("\n", stdout);
|
||||||
m_new_line = true;
|
m_new_line = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WarningChannel::end ()
|
WarningChannel::end ()
|
||||||
{
|
{
|
||||||
|
if (verbosity () >= 0) {
|
||||||
if (m_colorized) {
|
if (m_colorized) {
|
||||||
fputs (ANSI_RESET, stdout);
|
fputs (ANSI_RESET, stdout);
|
||||||
}
|
}
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WarningChannel::begin ()
|
WarningChannel::begin ()
|
||||||
{
|
{
|
||||||
|
if (verbosity () >= 0) {
|
||||||
if (m_colorized) {
|
if (m_colorized) {
|
||||||
fputs (ANSI_BLUE, stdout);
|
fputs (ANSI_BLUE, stdout);
|
||||||
}
|
}
|
||||||
|
|
@ -422,6 +429,7 @@ WarningChannel::begin ()
|
||||||
m_new_line = false;
|
m_new_line = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------
|
// ------------------------------------------------
|
||||||
|
|
@ -463,28 +471,35 @@ ErrorChannel::~ErrorChannel ()
|
||||||
void
|
void
|
||||||
ErrorChannel::puts (const char *s)
|
ErrorChannel::puts (const char *s)
|
||||||
{
|
{
|
||||||
|
if (verbosity () >= -10) {
|
||||||
fputs (s, stderr);
|
fputs (s, stderr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ErrorChannel::endl ()
|
ErrorChannel::endl ()
|
||||||
{
|
{
|
||||||
|
if (verbosity () >= -10) {
|
||||||
fputs ("\n", stderr);
|
fputs ("\n", stderr);
|
||||||
m_new_line = true;
|
m_new_line = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ErrorChannel::end ()
|
ErrorChannel::end ()
|
||||||
{
|
{
|
||||||
|
if (verbosity () >= -10) {
|
||||||
if (m_colorized) {
|
if (m_colorized) {
|
||||||
fputs (ANSI_RESET, stderr);
|
fputs (ANSI_RESET, stderr);
|
||||||
}
|
}
|
||||||
fflush (stderr);
|
fflush (stderr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ErrorChannel::begin ()
|
ErrorChannel::begin ()
|
||||||
{
|
{
|
||||||
|
if (verbosity () >= -10) {
|
||||||
if (m_colorized) {
|
if (m_colorized) {
|
||||||
fputs (ANSI_RED, stderr);
|
fputs (ANSI_RED, stderr);
|
||||||
}
|
}
|
||||||
|
|
@ -493,6 +508,7 @@ ErrorChannel::begin ()
|
||||||
m_new_line = false;
|
m_new_line = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------
|
// ------------------------------------------------
|
||||||
// The instances of the log channels
|
// The instances of the log channels
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,15 @@ class BasicTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_00(self):
|
def test_00(self):
|
||||||
|
|
||||||
|
# does not work with all Python versions
|
||||||
|
# (debugging shows that Python calls the setter on the metaclass,
|
||||||
|
# not on the class itself at least on 3.12)
|
||||||
|
# # static (class) properties
|
||||||
|
# pya.A.sp_i = 17
|
||||||
|
# self.assertEqual(pya.A.sp_i, 18)
|
||||||
|
# pya.A.sp_i = -1
|
||||||
|
# self.assertEqual(pya.A.sp_i, 0)
|
||||||
|
|
||||||
# all references of PA are released now:
|
# all references of PA are released now:
|
||||||
ic0 = pya.A.instance_count()
|
ic0 = pya.A.instance_count()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,12 @@ class Basic_TestClass < TestBase
|
||||||
# for testing the ut logger:
|
# for testing the ut logger:
|
||||||
puts "Special chars: <&>"
|
puts "Special chars: <&>"
|
||||||
|
|
||||||
|
# static (class) properties
|
||||||
|
RBA::A.sp_i = 17
|
||||||
|
assert_equal( RBA::A.sp_i, 18 )
|
||||||
|
RBA::A.sp_i = -1
|
||||||
|
assert_equal( RBA::A.sp_i, 0 )
|
||||||
|
|
||||||
GC.start
|
GC.start
|
||||||
|
|
||||||
# all references of A are released now:
|
# all references of A are released now:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue