Missing "Const" attribute in xml

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!
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Missing "Const" attribute in xml

Post by dpoen »

Hello,

I might be misunderstanding the meaning of the "Const" in xml for the Python generation (for instance MatrixPy.xml).
I do understand it indicate that to object will not be changed. Correct ?
If so, should be more method received this attribute? For instance the inverse() method should be " Const="true", isn't it ?

I could do the fix, but I do need to know if I'm right,

Code: Select all

OS: Debian GNU/Linux 11 (bullseye) (XFCE/xfce)
Word size of FreeCAD: 64-bit
Version: 0.21.Unknown
Build type: Unknown
Python 3.9.2, Qt 5.15.2, Coin 4.0.0, Vtk 7.1.1, OCC 7.5.1
Locale: English/United States (en_US)
User avatar
onekk
Veteran
Posts: 6205
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Missing "Const" attribute in xml

Post by onekk »

dpoen wrote: Mon Jun 20, 2022 10:12 am Hello,

I might be misunderstanding the meaning of the "Const" in xml for the Python generation (for instance MatrixPy.xml).
I do understand it indicate that to object will not be changed. Correct ?
If so, should be more method received this attribute? For instance the inverse() method should be " Const="true", isn't it ?
Internals of such things are known by few developers, @wmayer er is the most authoritative person" let's see if poking will make something happens.

wmayer wrote:
Hi and sorry for poking but I think this answer is know by very few people here.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
wmayer
Founder
Posts: 20306
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Missing "Const" attribute in xml

Post by wmayer »

I do understand it indicate that to object will not be changed. Correct ?
Yes, that's correct.
If so, should be more method received this attribute? For instance the inverse() method should be " Const="true", isn't it ?
There still might be functions where we forgot to add this attribute. And yes the inverse() method requires it, too.

I will add it. git commit 7de8a14b37
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Re: Missing "Const" attribute in xml

Post by dpoen »

the methods multiply(), determinant(), isOrthogonal(), submatrix(), analyze() might also get the const attribute, is that correct ?
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Missing "Const" attribute in xml

Post by openBrain »

dpoen wrote: Wed Jun 22, 2022 12:05 pm the methods multiply(), determinant(), isOrthogonal(), submatrix(), analyze() might also get the const attribute, is that correct ?
I guess you can prepare a PR on GH. ;) @wmayer will likely check it there directly.
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Re: Missing "Const" attribute in xml

Post by dpoen »

Yes, that work too xD
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Re: Missing "Const" attribute in xml

Post by dpoen »

@wmayer, I have a question, which tool actually use those xml ? I expect that to be some sort of code generation stuff, but I can't find it ...
marioalexis
Posts: 124
Joined: Wed Jun 19, 2019 7:44 pm

Re: Missing "Const" attribute in xml

Post by marioalexis »

You will see the changes in the MatrixPy.xml file reflected in the MatrixPy.cpp and MatrixPy.h files in the build directory once you compile the program.
To see more details about the impact of the xml file tags, you can read src/Tools/generateTemplates/templateClassPyExport.py
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Re: Missing "Const" attribute in xml

Post by dpoen »

Got it, that is what I was looking for, thank :)
User avatar
adrianinsaval
Veteran
Posts: 5551
Joined: Thu Apr 05, 2018 5:15 pm

Re: Missing "Const" attribute in xml

Post by adrianinsaval »

@wmayer no clue if this is really related: https://forum.freecadweb.org/viewtopic. ... 10#p565791
but could it be that the function for obj.Shape.scaled is also missing this const attribute?
Post Reply