Skip to content

Commit

Permalink
Merge branch 'FreeCAD:main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mosfet80 authored Feb 10, 2025
2 parents 1440705 + 6b59e4b commit d322dda
Show file tree
Hide file tree
Showing 84 changed files with 732 additions and 517 deletions.
4 changes: 2 additions & 2 deletions cMake/FreeCadMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ ENDMACRO(fc_target_copy_resource_flat)
# It would be a bit cleaner to generate these files in ${CMAKE_CURRENT_BINARY_DIR}

macro(generate_from_xml BASE_NAME)
set(TOOL_PATH "${CMAKE_SOURCE_DIR}/src/Tools/generate.py")
set(TOOL_PATH "${CMAKE_SOURCE_DIR}/src/Tools/bindings/generate.py")
file(TO_NATIVE_PATH "${TOOL_PATH}" TOOL_NATIVE_PATH)
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${BASE_NAME}.xml" SOURCE_NATIVE_PATH)

Expand All @@ -147,7 +147,7 @@ macro(generate_from_xml BASE_NAME)
COMMAND ${PYTHON_EXECUTABLE} "${TOOL_NATIVE_PATH}" --outputPath "${OUTPUT_NATIVE_PATH}" ${BASE_NAME}.xml
MAIN_DEPENDENCY "${BASE_NAME}.xml"
DEPENDS
"${CMAKE_SOURCE_DIR}/src/Tools/generateTemplates/templateClassPyExport.py"
"${CMAKE_SOURCE_DIR}/src/Tools/bindings/templates/templateClassPyExport.py"
"${TOOL_PATH}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Building ${BASE_NAME}.h/.cpp out of ${BASE_NAME}.xml"
Expand Down
6 changes: 3 additions & 3 deletions src/App/ApplicationPy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ PyObject* Application::sCheckLinkDepth(PyObject* /*self*/, PyObject* args)
PY_TRY
{
return Py::new_reference_to(
Py::Int(GetApplication().checkLinkDepth(depth, MessageOption::Throw)));
Py::Long(GetApplication().checkLinkDepth(depth, MessageOption::Throw)));
}
PY_CATCH;
}
Expand Down Expand Up @@ -1132,7 +1132,7 @@ PyObject* Application::sSetActiveTransaction(PyObject* /*self*/, PyObject* args)

PY_TRY
{
Py::Int ret(GetApplication().setActiveTransaction(name, Base::asBoolean(persist)));
Py::Long ret(GetApplication().setActiveTransaction(name, Base::asBoolean(persist)));
return Py::new_reference_to(ret);
}
PY_CATCH;
Expand All @@ -1153,7 +1153,7 @@ PyObject* Application::sGetActiveTransaction(PyObject* /*self*/, PyObject* args)
}
Py::Tuple ret(2);
ret.setItem(0, Py::String(name));
ret.setItem(1, Py::Int(id));
ret.setItem(1, Py::Long(id));
return Py::new_reference_to(ret);
}
PY_CATCH;
Expand Down
4 changes: 2 additions & 2 deletions src/App/ComplexGeoDataPy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<Documentation>
<UserDocu>Geometry Tag</UserDocu>
</Documentation>
<Parameter Name="Tag" Type="Int"/>
<Parameter Name="Tag" Type="Long"/>
</Attribute>
<Attribute Name="Hasher">
<Documentation>
Expand All @@ -129,7 +129,7 @@
<Documentation>
<UserDocu>Get the current element map size</UserDocu>
</Documentation>
<Parameter Name="ElementMapSize" Type="Int" />
<Parameter Name="ElementMapSize" Type="Long" />
</Attribute>
<Attribute Name="ElementMap">
<Documentation>
Expand Down
30 changes: 15 additions & 15 deletions src/App/ComplexGeoDataPyImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ PyObject* ComplexGeoDataPy::getFacesFromSubElement(PyObject* args)
Py::List facet;
for (const auto& it : facets) {
Py::Tuple f(3);
f.setItem(0, Py::Int(int(it.I1)));
f.setItem(1, Py::Int(int(it.I2)));
f.setItem(2, Py::Int(int(it.I3)));
f.setItem(0, Py::Long(int(it.I1)));

Check warning on line 113 in src/App/ComplexGeoDataPyImp.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

Using deprecated casting style. Use static_cast<int>(...) instead [readability/casting] [4]
f.setItem(1, Py::Long(int(it.I2)));

Check warning on line 114 in src/App/ComplexGeoDataPyImp.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

Using deprecated casting style. Use static_cast<int>(...) instead [readability/casting] [4]
f.setItem(2, Py::Long(int(it.I3)));
facet.append(f);
}
tuple.setItem(1, facet);
Expand Down Expand Up @@ -147,8 +147,8 @@ PyObject* ComplexGeoDataPy::getLinesFromSubElement(PyObject* args)
Py::List line;
for (const auto& it : lines) {
Py::Tuple l(2);
l.setItem(0, Py::Int((int)it.I1));
l.setItem(1, Py::Int((int)it.I2));
l.setItem(0, Py::Long((int)it.I1));
l.setItem(1, Py::Long((int)it.I2));
line.append(l);
}
tuple.setItem(1, line);
Expand Down Expand Up @@ -213,8 +213,8 @@ PyObject* ComplexGeoDataPy::getLines(PyObject* args)
Py::List line;
for (const auto& it : lines) {
Py::Tuple l(2);
l.setItem(0, Py::Int((int)it.I1));
l.setItem(1, Py::Int((int)it.I2));
l.setItem(0, Py::Long((int)it.I1));
l.setItem(1, Py::Long((int)it.I2));
line.append(l);
}
tuple.setItem(1, line);
Expand Down Expand Up @@ -247,9 +247,9 @@ PyObject* ComplexGeoDataPy::getFaces(PyObject* args)
Py::List facet;
for (const auto& it : facets) {
Py::Tuple f(3);
f.setItem(0, Py::Int((int)it.I1));
f.setItem(1, Py::Int((int)it.I2));
f.setItem(2, Py::Int((int)it.I3));
f.setItem(0, Py::Long((int)it.I1));
f.setItem(1, Py::Long((int)it.I2));
f.setItem(2, Py::Long((int)it.I3));
facet.append(f);
}
tuple.setItem(1, facet);
Expand Down Expand Up @@ -509,9 +509,9 @@ Py::Dict ComplexGeoDataPy::getElementReverseMap() const
return ret;
}

Py::Int ComplexGeoDataPy::getElementMapSize() const
Py::Long ComplexGeoDataPy::getElementMapSize() const
{
return Py::Int((long)getComplexGeoDataPtr()->getElementMapSize());
return Py::Long((long)getComplexGeoDataPtr()->getElementMapSize());
}

void ComplexGeoDataPy::setHasher(Py::Object obj)

Check warning on line 517 in src/App/ComplexGeoDataPyImp.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

Missing reference on non-trivial type (Py::Object) [-Wclazy-function-args-by-ref]
Expand Down Expand Up @@ -575,12 +575,12 @@ Py::String ComplexGeoDataPy::getElementMapVersion() const
}


Py::Int ComplexGeoDataPy::getTag() const
Py::Long ComplexGeoDataPy::getTag() const
{
return Py::Int(getComplexGeoDataPtr()->Tag);
return Py::Long(getComplexGeoDataPtr()->Tag);
}

void ComplexGeoDataPy::setTag(Py::Int tag)
void ComplexGeoDataPy::setTag(Py::Long tag)
{
getComplexGeoDataPtr()->Tag = tag;
}
Expand Down
2 changes: 1 addition & 1 deletion src/App/DocumentObjectPy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ or None if the GUI is not up</UserDocu>
<Documentation>
<UserDocu>The unique identifier (among its document) of this object</UserDocu>
</Documentation>
<Parameter Name="ID" Type="Int"/>
<Parameter Name="ID" Type="Long"/>
</Attribute>
<Attribute Name="Removing" ReadOnly="true">
<Documentation>
Expand Down
4 changes: 2 additions & 2 deletions src/App/DocumentObjectPyImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,9 +898,9 @@ int DocumentObjectPy::setCustomAttributes(const char*, PyObject*)
return 0;
}

Py::Int DocumentObjectPy::getID() const
Py::Long DocumentObjectPy::getID() const
{
return Py::Int(getDocumentObjectPtr()->getID());
return Py::Long(getDocumentObjectPtr()->getID());
}

Py::Boolean DocumentObjectPy::getRemoving() const
Expand Down
8 changes: 4 additions & 4 deletions src/App/DocumentPy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -313,25 +313,25 @@ sort: whether to topologically sort the return list
<Documentation>
<UserDocu>The Undo mode of the Document (0 = no Undo, 1 = Undo/Redo)</UserDocu>
</Documentation>
<Parameter Name="UndoMode" Type="Int" />
<Parameter Name="UndoMode" Type="Long" />
</Attribute>
<Attribute Name="UndoRedoMemSize" ReadOnly="true">
<Documentation>
<UserDocu>The size of the Undo stack in byte</UserDocu>
</Documentation>
<Parameter Name="UndoRedoMemSize" Type="Int" />
<Parameter Name="UndoRedoMemSize" Type="Long" />
</Attribute>
<Attribute Name="UndoCount" ReadOnly="true">
<Documentation>
<UserDocu>Number of possible Undos</UserDocu>
</Documentation>
<Parameter Name="UndoCount" Type="Int" />
<Parameter Name="UndoCount" Type="Long" />
</Attribute>
<Attribute Name="RedoCount" ReadOnly="true">
<Documentation>
<UserDocu>Number of possible Redos</UserDocu>
</Documentation>
<Parameter Name="RedoCount" Type="Int"/>
<Parameter Name="RedoCount" Type="Long"/>
</Attribute>
<Attribute Name="UndoNames" ReadOnly="true">
<Documentation>
Expand Down
22 changes: 11 additions & 11 deletions src/App/DocumentPyImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ PyObject* DocumentPy::addObject(PyObject* args, PyObject* kwd)
pyvp = Py::Object(view);
}
if (pyvp.isNone()) {
pyvp = Py::Int(1);
pyvp = Py::Long(1);
}
// 'pyvp' is the python class with the implementation for ViewProvider
if (pyvp.hasAttr("__vobject__")) {
Expand Down Expand Up @@ -695,7 +695,7 @@ PyObject* DocumentPy::recompute(PyObject* args)
return nullptr;
}

return Py::new_reference_to(Py::Int(objectCount));
return Py::new_reference_to(Py::Long(objectCount));
}
PY_CATCH;
}
Expand Down Expand Up @@ -890,30 +890,30 @@ Py::List DocumentPy::getRootObjectsIgnoreLinks() const
return res;
}

Py::Int DocumentPy::getUndoMode() const
Py::Long DocumentPy::getUndoMode() const
{
return Py::Int(getDocumentPtr()->getUndoMode());
return Py::Long(getDocumentPtr()->getUndoMode());
}

void DocumentPy::setUndoMode(Py::Int arg)
void DocumentPy::setUndoMode(Py::Long arg)
{
getDocumentPtr()->setUndoMode(arg);
}


Py::Int DocumentPy::getUndoRedoMemSize() const
Py::Long DocumentPy::getUndoRedoMemSize() const
{
return Py::Int((long)getDocumentPtr()->getUndoMemSize());
return Py::Long((long)getDocumentPtr()->getUndoMemSize());
}

Py::Int DocumentPy::getUndoCount() const
Py::Long DocumentPy::getUndoCount() const
{
return Py::Int((long)getDocumentPtr()->getAvailableUndos());
return Py::Long((long)getDocumentPtr()->getAvailableUndos());
}

Py::Int DocumentPy::getRedoCount() const
Py::Long DocumentPy::getRedoCount() const
{
return Py::Int((long)getDocumentPtr()->getAvailableRedos());
return Py::Long((long)getDocumentPtr()->getAvailableRedos());
}

Py::List DocumentPy::getUndoNames() const
Expand Down
14 changes: 7 additions & 7 deletions src/App/FeaturePython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,14 @@ bool FeaturePythonImp::getSubObject(DocumentObject*& ret,
subname = "";
}
args.setItem(1, Py::String(subname));
args.setItem(2, Py::Int(pyObj ? 2 : 1));
args.setItem(2, Py::Long(pyObj ? 2 : 1));
Base::MatrixPy* pyMat = new Base::MatrixPy(new Base::Matrix4D);
if (_mat) {
*pyMat->getMatrixPtr() = *_mat;
}
args.setItem(3, Py::asObject(pyMat));
args.setItem(4, Py::Boolean(transform));
args.setItem(5, Py::Int(depth));
args.setItem(5, Py::Long(depth));

Py::Object res(Base::pyCall(py_getSubObject.ptr(), args.ptr()));
if (res.isNone()) {
Expand Down Expand Up @@ -343,7 +343,7 @@ bool FeaturePythonImp::getSubObjects(std::vector<std::string>& ret, int reason)
try {
Py::Tuple args(2);
args.setItem(0, Py::Object(object->getPyObject(), true));
args.setItem(1, Py::Int(reason));
args.setItem(1, Py::Long(reason));
Py::Object res(Base::pyCall(py_getSubObjects.ptr(), args.ptr()));
if (!res.isTrue()) {
return true;
Expand Down Expand Up @@ -390,7 +390,7 @@ bool FeaturePythonImp::getLinkedObject(DocumentObject*& ret,
}
args.setItem(2, Py::asObject(pyMat));
args.setItem(3, Py::Boolean(transform));
args.setItem(4, Py::Int(depth));
args.setItem(4, Py::Long(depth));

Py::Object res(Base::pyCall(py_getLinkedObject.ptr(), args.ptr()));
if (!res.isTrue()) {
Expand Down Expand Up @@ -466,7 +466,7 @@ int FeaturePythonImp::isElementVisible(const char* element) const
Py::Tuple args(2);
args.setItem(0, Py::Object(object->getPyObject(), true));
args.setItem(1, Py::String(element ? element : ""));
return Py::Int(Base::pyCall(py_isElementVisible.ptr(), args.ptr()));
return Py::Long(Base::pyCall(py_isElementVisible.ptr(), args.ptr()));
}
catch (Py::Exception&) {
if (PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
Expand All @@ -488,7 +488,7 @@ int FeaturePythonImp::setElementVisible(const char* element, bool visible)
args.setItem(0, Py::Object(object->getPyObject(), true));
args.setItem(1, Py::String(element ? element : ""));
args.setItem(2, Py::Boolean(visible));
return Py::Int(Base::pyCall(py_setElementVisible.ptr(), args.ptr()));
return Py::Long(Base::pyCall(py_setElementVisible.ptr(), args.ptr()));
}
catch (Py::Exception&) {
if (PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
Expand Down Expand Up @@ -568,7 +568,7 @@ int FeaturePythonImp::canLoadPartial() const
try {
Py::Tuple args(1);
args.setItem(0, Py::Object(object->getPyObject(), true));
Py::Int ret(Base::pyCall(py_canLoadPartial.ptr(), args.ptr()));
Py::Long ret(Base::pyCall(py_canLoadPartial.ptr(), args.ptr()));
return ret;
}
catch (Py::Exception&) {
Expand Down
2 changes: 1 addition & 1 deletion src/App/Link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ App::DocumentObjectExecReturn* LinkBaseExtension::extensionExecute()
else {
const auto& elements = _getElementListValue();
for (int i = 0; i < _getElementCountValue(); ++i) {
args.setItem(2, Py::Int(i));
args.setItem(2, Py::Long(i));
if (i < (int)elements.size()) {
args.setItem(3, Py::asObject(elements[i]->getPyObject()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/App/LinkBaseExtensionPyImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ PyObject* LinkBaseExtensionPy::setLink(PyObject* _args)
PyObject *key, *value;
Py_ssize_t pos = 0;
while (PyDict_Next(pcObj, &pos, &key, &value)) {
parseLink(ext, Py::Int(key), value);
parseLink(ext, Py::Long(key), value);
}
}
else if (PySequence_Check(pcObj)) {
Expand Down
24 changes: 12 additions & 12 deletions src/App/ObjectIdentifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ Py::Object ObjectIdentifier::Component::get(const Py::Object& pyobj) const
}
else if (isArray()) {
if (pyobj.isMapping()) {
res = Py::Mapping(pyobj).getItem(Py::Int(begin));
res = Py::Mapping(pyobj).getItem(Py::Long(begin));
}
else {
res = Py::Sequence(pyobj).getItem(begin);
Expand All @@ -703,9 +703,9 @@ Py::Object ObjectIdentifier::Component::get(const Py::Object& pyobj) const
}
else {
assert(isRange());
Py::Object slice(PySlice_New(Py::Int(begin).ptr(),
end != INT_MAX ? Py::Int(end).ptr() : nullptr,
step != 1 ? Py::Int(step).ptr() : nullptr),
Py::Object slice(PySlice_New(Py::Long(begin).ptr(),
end != INT_MAX ? Py::Long(end).ptr() : nullptr,
step != 1 ? Py::Long(step).ptr() : nullptr),
true);
PyObject* r = PyObject_GetItem(pyobj.ptr(), slice.ptr());
if (!r) {
Expand All @@ -731,7 +731,7 @@ void ObjectIdentifier::Component::set(Py::Object& pyobj, const Py::Object& value
}
else if (isArray()) {
if (pyobj.isMapping()) {
Py::Mapping(pyobj).setItem(Py::Int(begin), value);
Py::Mapping(pyobj).setItem(Py::Long(begin), value);
}
else {
Py::Sequence(pyobj).setItem(begin, value);
Expand All @@ -742,9 +742,9 @@ void ObjectIdentifier::Component::set(Py::Object& pyobj, const Py::Object& value
}
else {
assert(isRange());
Py::Object slice(PySlice_New(Py::Int(begin).ptr(),
end != INT_MAX ? Py::Int(end).ptr() : nullptr,
step != 1 ? Py::Int(step).ptr() : nullptr),
Py::Object slice(PySlice_New(Py::Long(begin).ptr(),
end != INT_MAX ? Py::Long(end).ptr() : nullptr,
step != 1 ? Py::Long(step).ptr() : nullptr),
true);
if (PyObject_SetItem(pyobj.ptr(), slice.ptr(), value.ptr()) < 0) {
Base::PyException::ThrowException();
Expand All @@ -759,7 +759,7 @@ void ObjectIdentifier::Component::del(Py::Object& pyobj) const
}
else if (isArray()) {
if (pyobj.isMapping()) {
Py::Mapping(pyobj).delItem(Py::Int(begin));
Py::Mapping(pyobj).delItem(Py::Long(begin));
}
else {
PySequence_DelItem(pyobj.ptr(), begin);
Expand All @@ -770,9 +770,9 @@ void ObjectIdentifier::Component::del(Py::Object& pyobj) const
}
else {
assert(isRange());
Py::Object slice(PySlice_New(Py::Int(begin).ptr(),
end != INT_MAX ? Py::Int(end).ptr() : nullptr,
step != 1 ? Py::Int(step).ptr() : nullptr),
Py::Object slice(PySlice_New(Py::Long(begin).ptr(),
end != INT_MAX ? Py::Long(end).ptr() : nullptr,
step != 1 ? Py::Long(step).ptr() : nullptr),
true);
if (PyObject_DelItem(pyobj.ptr(), slice.ptr()) < 0) {
Base::PyException::ThrowException();
Expand Down
Loading

0 comments on commit d322dda

Please sign in to comment.