Merge pull request #19479 from tritao/base-cleanup-xml-generation

Base: Minor cleanups to base XML bindings generation
This commit is contained in:
Chris Hennes
2025-02-10 09:34:50 -06:00
committed by GitHub
73 changed files with 405 additions and 396 deletions

View File

@@ -64,7 +64,7 @@ max : Base.Vector, tuple
Invalidate the bounding box.</UserDocu>
</Documentation>
</Methode>
<Methode Name="isValid">
<Methode Name="isValid" Const="true">
<Documentation>
<UserDocu>isValid() -> bool
@@ -90,9 +90,9 @@ z : float
Value to enlarge at z-direction.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getPoint">
<Methode Name="getPoint" Const="true">
<Documentation>
<UserDocu>getPoint(index) ->Base.Vector
<UserDocu>getPoint(index) -> Base.Vector
Get the point of the given index.
The index must be in the range of [0, 7].
@@ -100,7 +100,7 @@ The index must be in the range of [0, 7].
index : int</UserDocu>
</Documentation>
</Methode>
<Methode Name="getEdge">
<Methode Name="getEdge" Const="true">
<Documentation>
<UserDocu>getEdge(index) -> tuple of Base.Vector
@@ -110,7 +110,7 @@ The index must be in the range of [0, 11].
index : int</UserDocu>
</Documentation>
</Methode>
<Methode Name="closestPoint">
<Methode Name="closestPoint" Const="true">
<Documentation>
<UserDocu>closestPoint(point) -> Base.Vector
closestPoint(x, y, z) -> Base.Vector

View File

@@ -99,7 +99,8 @@ tol : float</UserDocu>
</Methode>
<Methode Name="decompose" Const="true">
<Documentation>
<UserDocu>decompose() -> Base.Matrix, Base.Matrix, Base.Matrix, Base.Matrix\n
<UserDocu>decompose() -> Base.Matrix, Base.Matrix, Base.Matrix, Base.Matrix
Return a tuple of matrices representing shear, scale, rotation and move.
So that matrix = move * rotation * scale * shear.</UserDocu>
</Documentation>

View File

@@ -212,7 +212,7 @@ PyObject* MatrixPy::number_power_handler(PyObject* self, PyObject* other, PyObje
Base::Matrix4D a = static_cast<MatrixPy*>(self)->value();
long b = Py::Int(other);
long b = Py::Long(other);
if (b == 0) {
return new MatrixPy(Matrix4D());
}
@@ -363,7 +363,7 @@ PyObject* MatrixPy::hasScale(PyObject* args)
ScaleType type = getMatrixPtr()->hasScale(tol);
Py::Module mod("FreeCAD");
return Py::new_reference_to(
mod.callMemberFunction("ScaleType", Py::TupleN(Py::Int(static_cast<int>(type)))));
mod.callMemberFunction("ScaleType", Py::TupleN(Py::Long(static_cast<int>(type)))));
}
PyObject* MatrixPy::decompose(PyObject* args)

View File

@@ -26,7 +26,7 @@ Class to dump and restore the content of an object.</UserDocu>
<Documentation>
<UserDocu>Memory size of the object in bytes.</UserDocu>
</Documentation>
<Parameter Name="MemSize" Type="Int"/>
<Parameter Name="MemSize" Type="Long"/>
</Attribute>
<Methode Name="dumpContent" Keyword="true" Const="true">
<Documentation>

View File

@@ -52,9 +52,9 @@ Py::String PersistencePy::getContent() const
return {writer.getString()};
}
Py::Int PersistencePy::getMemSize() const
Py::Long PersistencePy::getMemSize() const
{
return Py::Int((long)getPersistencePtr()->getMemSize());
return Py::Long((long)getPersistencePtr()->getMemSize());
}
PyObject* PersistencePy::dumpContent(PyObject* args, PyObject* kwds)

View File

@@ -163,18 +163,18 @@ namespace Base
{
/** The PyObjectBase class, exports the class as a python type
/** The PyObjectBase class, exports the class as a Python type
* PyObjectBase is the base class for all C++ classes which
* need to get exported into the python namespace. This class is
* need to get exported into the Python namespace. This class is
* very important because nearly all important classes in FreeCAD
* are visible in python for macro recording and automation purpose.
* The class App::Document is a good expample for an exported class.
* are visible in Python for macro recording and automation purpose.
* The class App::Document is a good example for an exported class.
* There are some convenience macros to make it easier to inherit
* from this class and defining new methods exported to python.
* from this class and defining new methods exported to Python.
* PYFUNCDEF_D defines a new exported method.
* PYFUNCIMP_D defines the implementation of the new exported method.
* In the implementation you can use Py_Return, Py_Error, Py_Try and Py_Assert.
* PYMETHODEDEF makes the entry in the python method table.
* PYMETHODEDEF makes the entry in the Python method table.
* @see Document
* @see PYFUNCDEF_D
* @see PYFUNCIMP_D

View File

@@ -29,38 +29,36 @@ Quantity(string) -- arbitrary mixture of numbers and chars defining a Quantity
</Documentation>
<Methode Name="toStr" Const="true">
<Documentation>
<UserDocu>
toStr([decimals])
returns a string representation rounded to number of decimals. If no decimals are specified then
the internal precision is used
<UserDocu>toStr([decimals])
Returns a string representation rounded to number of decimals. If no decimals are specified then
the internal precision is used
</UserDocu>
</Documentation>
</Methode>
<Methode Name="getUserPreferred" Const="true">
<Documentation>
<UserDocu>
returns a quantity with the translation factor and a string with the prevered unit
Returns a quantity with the translation factor and a string with the prevered unit
</UserDocu>
</Documentation>
</Methode>
<Methode Name="getValueAs" Const="true">
<Documentation>
<UserDocu>
returns a floating point value as the provided unit
<UserDocu>Returns a floating point value as the provided unit
Following parameters are allowed:
getValueAs('m/s') # unit string to parse
getValueAs(2.45,1) # translation value and unit signature
getValueAs(FreeCAD.Units.Pascal) # predefined standard units
getValueAs(Qantity('N/m^2')) # a quantity
getValueAs(Unit(0,1,0,0,0,0,0,0)) # a unit
Following parameters are allowed:
getValueAs('m/s') # unit string to parse
getValueAs(2.45,1) # translation value and unit signature
getValueAs(FreeCAD.Units.Pascal) # predefined standard units
getValueAs(Qantity('N/m^2')) # a quantity
getValueAs(Unit(0,1,0,0,0,0,0,0)) # a unit
</UserDocu>
</Documentation>
</Methode>
<Methode Name="__round__" Const="true">
<Documentation>
<UserDocu>
Return the Integral closest to x, rounding half toward even.
<UserDocu>Returns the Integral closest to x, rounding half toward even.
When an argument is passed, work like built-in round(x, ndigits).
</UserDocu>
</Documentation>

View File

@@ -641,9 +641,9 @@ Py::Dict QuantityPy::getFormat() const
QuantityFormat fmt = getQuantityPtr()->getFormat();
Py::Dict dict;
dict.setItem("Precision", Py::Int(fmt.precision));
dict.setItem("Precision", Py::Long(fmt.precision));
dict.setItem("NumberFormat", Py::Char(fmt.toFormat()));
dict.setItem("Denominator", Py::Int(fmt.denominator));
dict.setItem("Denominator", Py::Long(fmt.denominator));
return dict;
}
@@ -652,14 +652,14 @@ void QuantityPy::setFormat(Py::Dict arg)
QuantityFormat fmt = getQuantityPtr()->getFormat();
if (arg.hasKey("Precision")) {
Py::Int prec(arg.getItem("Precision"));
Py::Long prec(arg.getItem("Precision"));
fmt.precision = static_cast<int>(prec);
}
if (arg.hasKey("NumberFormat")) {
Py::Object item = arg.getItem("NumberFormat");
if (item.isNumeric()) {
int format = static_cast<int>(Py::Int(item));
int format = static_cast<int>(Py::Long(item));
if (format < 0 || format > QuantityFormat::Scientific) {
throw Py::ValueError("Invalid format value");
}
@@ -681,7 +681,7 @@ void QuantityPy::setFormat(Py::Dict arg)
}
if (arg.hasKey("Denominator")) {
Py::Int denom(arg.getItem("Denominator"));
Py::Long denom(arg.getItem("Denominator"));
int fracInch = static_cast<int>(denom);
// check that the value is positive and a power of 2
if (fracInch <= 0) {

View File

@@ -88,7 +88,7 @@ coef : sequence of float</UserDocu>
Sets the rotation to its inverse.</UserDocu>
</Documentation>
</Methode>
<Methode Name="inverted">
<Methode Name="inverted" Const="true">
<Documentation>
<UserDocu>inverted() -> Base.Rotation
@@ -232,12 +232,11 @@ tol : float
</Documentation>
<Parameter Name="Angle" Type="Float" />
</Attribute>
<ClassDeclarations>
public:
RotationPy(const Rotation &amp; mat, PyTypeObject *T = &amp;Type)
:PyObjectBase(new Rotation(mat),T){}
Rotation value() const
{ return *(getRotationPtr()); }
<ClassDeclarations>public:
RotationPy(const Rotation &amp; mat, PyTypeObject *T = &amp;Type)
:PyObjectBase(new Rotation(mat),T){}
Rotation value() const
{ return *(getRotationPtr()); }
</ClassDeclarations>
</PythonExport>
</GenerateModel>

View File

@@ -19,7 +19,7 @@ namespace Base {
<DeveloperDocu>This is the Type class</DeveloperDocu>
<UserDocu>BaseTypePy class.
This class provides functionality related to type management in the Base module. It's not intended for direct instantiation but for accessing type information and creating instances of various types. Instantiation is possible for classes that inherit from the Base::BaseClass class and are not abstract.</UserDocu>
This class provides functionality related to type management in the Base module. It's not intended for direct instantiation but for accessing type information and creating instances of various types. Instantiation is possible for classes that inherit from the Base::BaseClass class and are not abstract.</UserDocu>
</Documentation>
<Methode Name="fromName" Static="true">
<Documentation>

View File

@@ -15,16 +15,15 @@
FatherNamespace="Base">
<Documentation>
<Author Licence="LGPL" Name="Juergen Riegel" EMail="FreeCAD@juergen-riegel.net" />
<UserDocu>
Unit
defines a unit type, calculate and compare.
<UserDocu>Unit
defines a unit type, calculate and compare.
The following constructors are supported:
Unit() -- empty constructor
Unit(i1,i2,i3,i4,i5,i6,i7,i8) -- unit signature
Unit(Quantity) -- copy unit from Quantity
Unit(Unit) -- copy constructor
Unit(string) -- parse the string for units
The following constructors are supported:
Unit() -- empty constructor
Unit(i1,i2,i3,i4,i5,i6,i7,i8) -- unit signature
Unit(Quantity) -- copy unit from Quantity
Unit(Unit) -- copy constructor
Unit(string) -- parse the string for units
</UserDocu>
<DeveloperDocu>Unit</DeveloperDocu>
</Documentation>