From 0b950dd18e4a2ac7d051210a0fb40114a35792b2 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 1 Aug 2026 22:22:05 -0400 Subject: [PATCH 1/2] cmake: declare target link interfaces explicitly Use modern target_link_libraries scopes so libraries publish their transitive requirements and executables keep theirs private. This preserves schema test linkage with current CMake versions. --- cmake/SC_Targets.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmake/SC_Targets.cmake b/cmake/SC_Targets.cmake index 8218fad6e..4daa44179 100644 --- a/cmake/SC_Targets.cmake +++ b/cmake/SC_Targets.cmake @@ -22,6 +22,9 @@ macro(SC_ADDEXEC execname) message(SEND_ERROR "SC_ADDEXEC usage error - expected STATIC LINK_LIBRARIES targets (${_lib})") endif() endif() + # Executables consume their dependencies but do not publish an + # interface to downstream targets. + target_link_libraries(${execname} PRIVATE ${_lib}) endforeach() target_link_libraries(${execname} PRIVATE ${${_arg_prefix}_LINK_LIBRARIES}) endif() @@ -74,6 +77,11 @@ macro(SC_ADDLIB _addlib_target) message(SEND_ERROR "SC_ADDLIB usage error - expected (static) LINK_LIBRARIES targets (${_lib})") endif() endif() + # Schema libraries are consumed directly by generated test programs. + # Publish their link requirements explicitly; the legacy unscoped + # signature does not reliably provide a transitive interface with + # current CMake versions. + target_link_libraries(${_addlib_target} PUBLIC ${_lib}) endforeach() target_link_libraries(${_addlib_target} ${_lib}) endif() @@ -93,4 +101,3 @@ endmacro() # indent-tabs-mode: t # End: # ex: shiftwidth=2 tabstop=8 - From 780ed87cbb62845a1116e1a6680674f63c2c5357 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Sat, 1 Aug 2026 21:54:38 -0400 Subject: [PATCH 2/2] stepcore: serialize redefined attributes before derived markers A redefined attribute supplies the inherited physical-file slot even when that original attribute is derived. Prefer the redefinition consistently during formatting and STEP writing, remove debug output, and cover the behavior with unit tests. --- src/clstepcore/STEPattribute.cc | 39 ++++++++++--------- src/clstepcore/sdaiApplication_instance.cc | 3 -- .../test/test_operators_STEPattribute.cc | 30 ++++++++++++++ 3 files changed, 51 insertions(+), 21 deletions(-) diff --git a/src/clstepcore/STEPattribute.cc b/src/clstepcore/STEPattribute.cc index 487865687..9bb0c398f 100644 --- a/src/clstepcore/STEPattribute.cc +++ b/src/clstepcore/STEPattribute.cc @@ -392,18 +392,19 @@ const char * STEPattribute::asStr( std::string & str, const char * currSch ) con str.clear(); + // The attribute has been redefined by the attribute pointed + // to by _redefAttr so write the narrowed value in the inherited + // physical-file slot. STEPread and StrToVal use this same precedence. + if( _redefAttr ) { + return _redefAttr->asStr( str, currSch ); + } + // The attribute has been derived by a subtype's attribute if( IsDerived() ) { str = "*"; return const_cast( str.c_str() ); } - // The attribute has been redefined by the attribute pointed - // to by _redefAttr so write the redefined value. - if( _redefAttr ) { - return _redefAttr->asStr( str, currSch ); - } - if( is_null() ) { str = ""; return const_cast( str.c_str() ); @@ -485,18 +486,19 @@ std::string STEPattribute::asStr( const char * currSch ) const { ostringstream ss; std::string str; + // The attribute has been redefined by the attribute pointed + // to by _redefAttr so write the narrowed value in the inherited + // physical-file slot. STEPread and StrToVal use this same precedence. + if( _redefAttr ) { + return _redefAttr->asStr( currSch ); + } + // The attribute has been derived by a subtype's attribute if( IsDerived() ) { str = "*"; return str; } - // The attribute has been redefined by the attribute pointed - // to by _redefAttr so write the redefined value. - if( _redefAttr ) { - return _redefAttr->asStr( currSch ); - } - if( is_null() ) { return str; } @@ -587,17 +589,18 @@ void STEPattribute::STEPwriteError( ostream & out, unsigned int line, const char * */ void STEPattribute::STEPwrite( ostream & out, const char * currSch ) { + // The attribute has been redefined by the attribute pointed + // to by _redefAttr so write the narrowed value in the inherited + // physical-file slot. STEPread and StrToVal use this same precedence. + if( _redefAttr ) { + _redefAttr->STEPwrite( out, currSch ); + return; + } // The attribute has been derived by a subtype's attribute if( IsDerived() ) { out << "*"; return; } - // The attribute has been redefined by the attribute pointed - // to by _redefAttr so write the redefined value. - if( _redefAttr ) { - _redefAttr->STEPwrite( out ); - return; - } if( is_null() ) { out << "$"; diff --git a/src/clstepcore/sdaiApplication_instance.cc b/src/clstepcore/sdaiApplication_instance.cc index a7113d6dd..2da2d32a2 100644 --- a/src/clstepcore/sdaiApplication_instance.cc +++ b/src/clstepcore/sdaiApplication_instance.cc @@ -565,9 +565,6 @@ Severity SDAI_Application_instance::STEPread( int id, int idIncr, if( c == ')' ) { // assume you are at the end so read last char in >> c; } - cout << "Entity #" << STEPfile_id - << " skipping redefined attribute " - << attributes[i].aDesc->Name() << endl << endl << flush; } // increment counter to read following attr since these attrs // aren't written or read => there won't be a delimiter either diff --git a/src/clstepcore/test/test_operators_STEPattribute.cc b/src/clstepcore/test/test_operators_STEPattribute.cc index a64d274de..440370436 100644 --- a/src/clstepcore/test/test_operators_STEPattribute.cc +++ b/src/clstepcore/test/test_operators_STEPattribute.cc @@ -39,6 +39,35 @@ bool testEqu( const STEPattribute & a1, const STEPattribute & a2, bool invert, c return pass; } +bool testRedefinedDerivedWrite( const AttrDescriptor & ad ) { + SDAI_Integer inherited_value = 123L; + SDAI_Integer narrowed_value = 456L; + STEPattribute inherited( ad, & inherited_value ); + STEPattribute narrowed( ad, & narrowed_value ); + + // A redeclared explicit attribute occupies its inherited physical-file + // slot, which is also marked derived in the generated supertype class. + inherited.Derive(); + inherited.RedefiningAttr( & narrowed ); + + bool pass = true; + std::string value; + inherited.asStr( value ); + if( inherited.asStr() != "456" || value != "456" ) { + std::cerr << "redefined derived attribute asStr() failed" << std::endl; + pass = false; + } + + std::ostringstream output; + inherited.STEPwrite( output ); + if( output.str() != "456" ) { + std::cerr << "redefined derived attribute STEPwrite() failed" << std::endl; + pass = false; + } + + return pass; +} + int main( int /*argc*/, char ** /*argv*/ ) { bool pass = true; EntityDescriptor ed( "ename", 0, LFalse, LFalse ); @@ -64,6 +93,7 @@ int main( int /*argc*/, char ** /*argv*/ ) { STEPattribute aii( adi, & s2int ); pass &= testEqu( ai, aii, true, "ints !=" ); + pass &= testRedefinedDerivedWrite( adi ); if( pass ) { exit( EXIT_SUCCESS );