mirror of https://github.com/KLayout/klayout.git
Fixed #526 - Make scripe debugging more reliable
Problem: the debugger was printing an object's value as string. The effect is that for big objects "to_s" will deliver huge strings (e.g. polygons, netlists ...). "inspect" is better (already used for Python), but it's aliased to "to_s" in Python and Ruby. Huge strings will stall the debugger. The solution is to stop this aliasing (Ruby 2.x doesn't do it itself anymore) and use "inspect" consistently for Python and Ruby. Details can still be printed in the console.
This commit is contained in:
parent
b6ba51e563
commit
9afcec25bc
|
|
@ -2665,7 +2665,12 @@ PythonModule::make_classes (const char *mod_name)
|
|||
|
||||
// The str method is also routed via the tp_str implementation
|
||||
alt_names.push_back ("__str__");
|
||||
if (! has_inspect) {
|
||||
#if GSI_ALIAS_INSPECT
|
||||
bool alias_inspect = ! has_inspect;
|
||||
#else
|
||||
bool alias_inspect = false;
|
||||
#endif
|
||||
if (alias_inspect) {
|
||||
add_python_doc (**c, mt, int (mid), tl::to_string (tr ("This method is also available as 'str(object)' and 'repr(object)'")));
|
||||
alt_names.push_back ("__repr__");
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1632,7 +1632,7 @@ rba_init (RubyInterpreterPrivateData *d)
|
|||
}
|
||||
|
||||
if (mt->name (mid) == "to_s") {
|
||||
#if HAVE_RUBY_VERSION_CODE>=20000
|
||||
#if HAVE_RUBY_VERSION_CODE>=20000 && defined(GSI_ALIAS_INSPECT)
|
||||
// Ruby 2.x does no longer alias "inspect" to "to_s" automatically, so we have to do this:
|
||||
rb_define_alias (klass, "inspect", "to_s");
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ public:
|
|||
|
||||
std::string description () const
|
||||
{
|
||||
return ruby2c<std::string> (rba_safe_obj_as_string (m_obj));
|
||||
return ruby2c<std::string> (rba_safe_inspect (m_obj));
|
||||
}
|
||||
|
||||
VALUE rb_key (size_t index) const
|
||||
|
|
@ -357,7 +357,7 @@ public:
|
|||
|
||||
std::string description () const
|
||||
{
|
||||
return ruby2c<std::string> (rba_safe_obj_as_string (m_obj));
|
||||
return ruby2c<std::string> (rba_safe_inspect (m_obj));
|
||||
}
|
||||
|
||||
virtual std::string key (size_t index) const
|
||||
|
|
|
|||
|
|
@ -212,6 +212,15 @@ rba_safe_obj_as_string (VALUE obj)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief object to string with check
|
||||
*/
|
||||
VALUE
|
||||
rba_safe_inspect (VALUE obj)
|
||||
{
|
||||
return rba_safe_func (rb_inspect, obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief needed because NUM2INT may be a macro:
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -201,6 +201,7 @@ void rba_check_error ();
|
|||
VALUE rba_string_value_f (VALUE obj);
|
||||
VALUE rba_safe_string_value (VALUE obj);
|
||||
VALUE rba_safe_obj_as_string (VALUE obj);
|
||||
VALUE rba_safe_inspect (VALUE obj);
|
||||
int rba_num2int_f (VALUE obj);
|
||||
int rba_safe_num2int (VALUE obj);
|
||||
unsigned int rba_num2uint_f (VALUE obj);
|
||||
|
|
|
|||
Loading…
Reference in New Issue