Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cmake/SC_Targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -93,4 +101,3 @@ endmacro()
# indent-tabs-mode: t
# End:
# ex: shiftwidth=2 tabstop=8

39 changes: 21 additions & 18 deletions src/clstepcore/STEPattribute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<char *>( 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<char *>( str.c_str() );
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 << "$";
Expand Down
3 changes: 0 additions & 3 deletions src/clstepcore/sdaiApplication_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions src/clstepcore/test/test_operators_STEPattribute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 );
Expand Down
Loading