diff --git a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp index 359b9463..f1cd4784 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp @@ -398,6 +398,26 @@ unsigned int FieldDescription::getIO() { return io ; } +unsigned int FieldDescription::getChkpntIO() { + return io >> 2 & 3 ; +} + +bool FieldDescription::isWriteable() { + return io & 1; +} + +bool FieldDescription::isReadable() { + return io & 2; +} + +bool FieldDescription::isCheckpointable() { + return io & 4; +} + +bool FieldDescription::isRestorable() { + return io & 8; +} + std::string FieldDescription::getDescription() { return description ; } diff --git a/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh b/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh index 811398ea..dff5fe86 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh +++ b/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh @@ -58,6 +58,11 @@ class FieldDescription : public ConstructValues { bool isDashDashUnits() ; void setIO(unsigned int) ; unsigned int getIO() ; + unsigned int getChkpntIO() ; + bool isReadable() ; + bool isWriteable(); + bool isCheckpointable(); + bool isRestorable(); std::string getDescription() ; void setEnumString(std::string) ; std::string getEnumString() ; diff --git a/trick_source/codegen/Interface_Code_Gen/PrintFileContents10.cpp b/trick_source/codegen/Interface_Code_Gen/PrintFileContents10.cpp index 211a78ae..4cb79352 100644 --- a/trick_source/codegen/Interface_Code_Gen/PrintFileContents10.cpp +++ b/trick_source/codegen/Interface_Code_Gen/PrintFileContents10.cpp @@ -166,12 +166,16 @@ void PrintFileContents10::print_field_init_attr_stmts( std::ostream & ostream , ostream << prefix << field << " = " << field << "_" << fullyQualifiedMangledClassNameUnderscores + "_" + fieldName + " ;\n"; }; - print("checkpoint_stl"); - print("post_checkpoint_stl"); - print("restore_stl"); + if ( fdes->isCheckpointable() ) { + print("checkpoint_stl"); + print("post_checkpoint_stl"); + } - if ( fdes->hasSTLClear() ) { - print("clear_stl"); + if ( fdes->isRestorable() ) { + print("restore_stl"); + if ( fdes->hasSTLClear() ) { + print("clear_stl"); + } } } @@ -299,37 +303,6 @@ void PrintFileContents10::print_io_src_delete( std::ostream & ostream , ClassVal } } -void PrintFileContents10::print_stl_helper_proto(std::ostream & ostream , ClassValues * cv ) { - auto& fieldDescriptions = cv->getFieldDescriptions(); - - if (!fieldDescriptions.size()) { - return; - } - - print_open_extern_c(ostream) ; - - for (auto& field : cv->getFieldDescriptions()) { - if ( field->isSTL() and determinePrintAttr(cv, field) ) { - const std::string classAndFieldName = cv->getFullyQualifiedMangledTypeName("__") + "_" + field->getName(); - - auto print = [&](const std::string& name) { - ostream << "void " << name << "_" << classAndFieldName - << "(void* start_address, const char* obj_name , const char* var_name);" << std::endl ; - }; - - print("checkpoint_stl"); - print("post_checkpoint_stl"); - print("restore_checkpoint_stl"); - - if ( field->hasSTLClear() ) { - ostream << "void clear_stl_" << classAndFieldName << "(void* start_address);" << std::endl ; - } - } - } - - print_close_extern_c(ostream) ; -} - void PrintFileContents10::print_checkpoint_stl(std::ostream & ostream , FieldDescription * fdes , ClassValues * cv ) { printStlFunction("checkpoint", "void* start_address, const char* obj_name , const char* var_name", "checkpoint_stl(*stl, obj_name, var_name)", ostream, *fdes, *cv); } @@ -357,11 +330,15 @@ void PrintFileContents10::print_stl_helper(std::ostream & ostream , ClassValues for (auto& field : fieldDescriptions) { if ( field->isSTL() and determinePrintAttr(cv, field) ) { - print_checkpoint_stl(ostream, field, cv) ; - print_post_checkpoint_stl(ostream, field, cv) ; - print_restore_stl(ostream, field, cv) ; - if (field->hasSTLClear()) { - print_clear_stl(ostream, field, cv) ; + if (field->isCheckpointable()) { + print_checkpoint_stl(ostream, field, cv) ; + print_post_checkpoint_stl(ostream, field, cv) ; + } + if (field->isRestorable()) { + print_restore_stl(ostream, field, cv) ; + if (field->hasSTLClear()) { + print_clear_stl(ostream, field, cv) ; + } } } } @@ -370,7 +347,6 @@ void PrintFileContents10::print_stl_helper(std::ostream & ostream , ClassValues } void PrintFileContents10::printClass( std::ostream & ostream , ClassValues * cv ) { - print_stl_helper_proto(ostream, cv) ; print_class_attr(ostream, cv) ; print_stl_helper(ostream, cv) ; print_init_attr_func(ostream, cv) ; diff --git a/trick_source/codegen/Interface_Code_Gen/PrintFileContents10.hh b/trick_source/codegen/Interface_Code_Gen/PrintFileContents10.hh index 96df008c..c1a4f428 100644 --- a/trick_source/codegen/Interface_Code_Gen/PrintFileContents10.hh +++ b/trick_source/codegen/Interface_Code_Gen/PrintFileContents10.hh @@ -86,9 +86,6 @@ class PrintFileContents10 : public PrintFileContentsBase { /** Prints the io_src_delete function */ void print_io_src_delete(std::ostream & outfile , ClassValues * cv ) ; - /** Prints stl helper function prototypes */ - void print_stl_helper_proto(std::ostream & outfile , ClassValues * in_class) ; - /** Prints stl helper function */ void print_stl_helper(std::ostream & outfile , ClassValues * in_class) ; diff --git a/trick_source/codegen/Interface_Code_Gen/PrintFileContentsBase.cpp b/trick_source/codegen/Interface_Code_Gen/PrintFileContentsBase.cpp index 0404b66e..d647cd47 100644 --- a/trick_source/codegen/Interface_Code_Gen/PrintFileContentsBase.cpp +++ b/trick_source/codegen/Interface_Code_Gen/PrintFileContentsBase.cpp @@ -57,31 +57,13 @@ void PrintFileContentsBase::print_close_extern_c(std::ostream & ostream) { on access to the field and the presense of init_attr friends. */ bool PrintFileContentsBase::determinePrintAttr( ClassValues * c , FieldDescription * fdes ) { - if ( fdes->getTypeName().compare("void") and fdes->getIO() != 0 and fdes->getEnumString().compare("TRICK_VOID")) { - if ( global_compat15 or c->isCompat15()) { - if ( fdes->isInherited() ) { - return ((c->getHasInitAttrFriend() && fdes->getAccess() == clang::AS_protected) - || (fdes->getAccess() == clang::AS_public)) ; - } else { - return (c->getHasInitAttrFriend() - || (fdes->getAccess() == clang::AS_public)) ; - } - } else { - if ( fdes->isStatic() ) { - if ( fdes->isInherited() ) { - return ((c->getHasInitAttrFriend() && fdes->getAccess() == clang::AS_protected) - || (fdes->getAccess() == clang::AS_public)) ; - } else { - return (c->getHasInitAttrFriend() - || (fdes->getAccess() == clang::AS_public)) ; - } - } else { - return true ; - } - - } + if ( !fdes->getTypeName().compare("void") or !fdes->getChkpntIO() or !fdes->getEnumString().compare("TRICK_VOID")) { + return false; } - return false ; + if ( fdes->getAccess() == clang::AS_public or (!fdes->isStatic() and !global_compat15 and !c->isCompat15())) { + return true; + } + return c->getHasInitAttrFriend() && ( !fdes->isInherited() || fdes->getAccess() == clang::AS_protected ) ; } std::vector PrintFileContentsBase::getPrintableFields(ClassValues& classValues) {