Member function Expression::toString() and Component::toString().

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
andrecaldas
Posts: 300
Joined: Fri Jan 27, 2023 8:45 pm
Contact:

Member function Expression::toString() and Component::toString().

Post by andrecaldas »

The class Expression deals with ObjectIdentifier::Component.

They both have a toString() method that takes a stream as first argument and a boolean as second. However, in Expression, the boolean means "persistent or not" (bool persistent). While in ObjectIdentifier::Component, the boolean means "quote for python or do not quote for python" (bool toPython).

So, as far as I see, there is not much relation between those two booleans. However, when one calls Expression::toString, s/he might end up calling Component::toString. This happens here. There, the used toPython is !persistent.

This means that if persistent is set to false, toPython will be set to true. And when persistent is set to true, toPython will be set to false.

Now, this does not make much sense to me. Can someone explain why this behaviour? :-)
User avatar
andrecaldas
Posts: 300
Joined: Fri Jan 27, 2023 8:45 pm
Contact:

Re: Member function Expression::toString() and Component::toString().

Post by andrecaldas »

Ping... @eivindkvedalen.
wmayer
Founder
Posts: 20241
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Member function Expression::toString() and Component::toString().

Post by wmayer »

He hasn't been active any more for more than 3 years. Better to ask realthunder: git commit a1417c5ffa52ea and git commit 93e60caa35
Post Reply