Commit Graph

6 Commits

Author SHA1 Message Date
Pasukhin Dmitry 56e162c480 Coding - Fix critical CodeQL static analysis warnings (#1074)
Interface_ParamSet:
- Eliminate use-after-free in Append() by deleting old buffer through
  a temp variable after reassigning the member pointer (CodeQL #5132/#2684)

delabella.cpp:
- Fix upcast array pointer arithmetic by parenthesizing cast to ensure
  pointer arithmetic uses derived class (Vert) size rather than base
  class (DelaBella_Vertex) size (CodeQL #5131)

NCollection_SparseArrayBase:
- Rework to replace virtual dispatch (createItem/destroyItem/copyItem)
  with function pointers passed as arguments to protected methods
- Store only DestroyItemFunc in base class to enable safe cleanup
  in destructor without virtual dispatch
- Pass CreateItemFunc and CopyItemFunc as arguments with zero
  per-instance storage overhead
- Move Clear() and UnsetValue() from base public API to protected
  clearItems()/unsetValue() with function pointer parameters;
  template class provides public wrappers
- Remove vtable entirely (no virtual methods remain)
- This eliminates the pure virtual call during base class destruction
  (CodeQL #5012)

AdvApp2Var_MathBase:
- Rewrite comparison to avoid potential signed integer overflow:
  *ncfnew + 1 > ncut becomes *ncfnew >= ncut (CodeQL #2692)
2026-02-13 08:48:17 +00:00
Pasukhin Dmitry bfa0311ef0 Foundation Classes - Tree & collection performance optimizations, move semantics, unified map API (#1065)
NCollection_UBTree/EBTree:
- Add move constructor and move assignment operators
- Replace recursive Select() and delNode() with iterative stack-based
  traversal to avoid stack overflow on deeply unbalanced trees
- Optimize EBTree::Add() and Remove() to use single-lookup TryEmplaced()
  instead of double-lookup UnBind()+Bind() / Contains()+operator()
- Remove unused DEFINE_HUBTREE / DEFINE_HEBTREE / IMPLEMENT_HUBTREE /
  IMPLEMENT_HEBTREE macros
- Remove unused includes from EBTree (Standard_Type, Standard_Transient,
  NCollection_List, Standard_Integer, NCollection_Sequence)
- Fix doxygen @param tags and comment style

NCollection_LocalArray:
- Add move constructor and move assignment operators with optimized
  three-way branching (stack-stack copy, heap-heap swap, stack-heap steal)
- Add Reallocate() method supporting grow-with-copy for use as a
  dynamically growable stack
- Add static_assert enforcing trivially copyable element type

NCollection_CellFilter:
- Replace const_cast destructive-copy hack in Cell with proper move
  semantics; delete copy constructor and copy assignment
- Add Cell constructor from CellIndex for lightweight lookup keys
- Refactor add()/iterateAdd() to accept CellIndex instead of Cell,
  use TryEmplaced() for single-lookup cell insertion
- Refactor remove()/inspect() to use Contained() API with const_cast
  instead of C-style cast on Seek()
- Change ListNode default constructor from runtime throw to = delete
- Use size_t for dimension loops and add dimension size guard in IsEqual
- Remove SUN WorkShop 5.3 workaround
- Fix typo "usially" -> "usually" in class documentation

NCollection map API unification (Contained, TryEmplace, TryBind):
- Add Contained() to all map types returning std::optional with
  std::reference_wrapper; key-only maps return const key ref,
  data maps return std::pair of const key ref + value ref
- Add TryEmplace()/TryEmplaced() to NCollection_FlatMap and
  NCollection_IndexedMap for parity with NCollection_Map
- Add TryBind() to NCollection_IndexedDataMap for parity with
  NCollection_DataMap and NCollection_FlatDataMap
- Remove Seek()/ChangeSeek() from NCollection_Map (replaced by
  Contained())

Dead compiler workaround removal:
- NCollection_DefineAlloc: remove Borland/SUN #if branch, keep only
  the version with placement delete
- NCollection_SparseArrayBase: remove SUN WorkShop 5.3 workaround

GTests:
- Add move constructor/assignment tests for LocalArray, UBTree, EBTree
- Add Contained tests for NCollection_Map
- Add CellFilter tests and UBTree deep-unbalanced-tree stress test
2026-02-12 20:28:20 +00:00
Pasukhin Dmitry 14d4e91171 Coding - Global Refactoring OCCT as a part of 8.0.0 (#955)
- Added automated migration scripts for handle syntax, standard types, and macros
- Deprecated legacy `Standard_*` types and macros in favor of native C++ equivalents
- Introduced modern `occ` namespace with template-based type checking helpers
- Enhanced NCollection macros to support variadic arguments for complex template types- Added automated migration scripts for handle syntax, standard types, and macros
- Deprecated legacy `Standard_*` types and macros in favor of native C++ equivalents
- Introduced modern `occ` namespace with template-based type checking helpers
- Enhanced NCollection macros to support variadic arguments for complex template types
2025-12-28 14:38:06 +00:00
Pasukhin Dmitry f923370c82 Foundation Classes - Modernize NCollection_SparseArrayBase memory handling and style (#804)
- Replace malloc/calloc/free with Standard::AllocateOptimal/Standard::Free for OCCT-consistent memory management
- Modernize constructor declarations and use nullptr instead of 0 for null pointers
- Replace custom swap implementation with std::swap and add noexcept specifications
2025-11-04 10:55:54 +00:00
Pasukhin Dmitry a575926c2d Foundation Classes, NCollection - Modernize code, add noexcept/constexpr (#793)
- Mark many methods and operators noexcept (iterators, containers, allocators, maps, lists, buffers, UTF/string utilities, etc.)
- Add constexpr to suitable functions and factory methods (matrices, vectors, static sizes) to enable compile-time usage
- Replace non-constexpr memcpy usages in NCollection_Mat3/NCollection_Mat4 with constexpr-friendly initialization and promote static arrays to constexpr
- Make several small API improvements: stronger const-correctness, noexcept on allocation/deallocation operators, delete forbidden copy ctors/assign where appropriate
- Remove obsolete NCollection_TypeDef.hxx and update FILES.cmake
- Miscellaneous small refactors to support modern C++ patterns and better compile-time guarantees
2025-11-01 21:38:48 +00:00
Pasukhin Dmitry 5647b46a34 Configuration - Reorganize repository structure #450
Reorganizing structure to have Module/TK/Package/FILES structure.
New structure reflect the structure inside IDE.
Migrate FILES, PACKAGES, EXTRLIB to CMake version to handle changes on updates.
No changes were done to installation layout, all installation result keep as before.
The migration was done using python script, see PR, which refactor automatically the structure.
Updated doc generation to have valid path to modules, toolkits and packages.
In case of PR into new version, IR-790 can be used as a target for the previous version.
2025-03-20 00:39:26 +00:00