mirror of
https://github.com/nasa/trick.git
synced 2024-12-24 07:16:41 +00:00
Generate STL functions only when requested
Remove STL prototypes. They don't appear to be necessary anymore. Refs #427
This commit is contained in:
parent
d417b1bdf1
commit
353905c1ed
@ -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 ;
|
||||
}
|
||||
|
@ -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() ;
|
||||
|
@ -166,14 +166,18 @@ void PrintFileContents10::print_field_init_attr_stmts( std::ostream & ostream ,
|
||||
ostream << prefix << field << " = " << field << "_" << fullyQualifiedMangledClassNameUnderscores + "_" + fieldName + " ;\n";
|
||||
};
|
||||
|
||||
if ( fdes->isCheckpointable() ) {
|
||||
print("checkpoint_stl");
|
||||
print("post_checkpoint_stl");
|
||||
print("restore_stl");
|
||||
}
|
||||
|
||||
if ( fdes->isRestorable() ) {
|
||||
print("restore_stl");
|
||||
if ( fdes->hasSTLClear() ) {
|
||||
print("clear_stl");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( fdes->isRecord() or fdes->isEnum() ) {
|
||||
ostream << " trick_MM->add_attr_info(std::string(attr" << fullyQualifiedMangledClassNameUnderscores << "[" << index << "].type_name) , &attr" << fullyQualifiedMangledClassNameUnderscores << "[" << index << "], __FILE__ , __LINE__ ) ;\n" ;
|
||||
@ -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,20 +330,23 @@ void PrintFileContents10::print_stl_helper(std::ostream & ostream , ClassValues
|
||||
|
||||
for (auto& field : fieldDescriptions) {
|
||||
if ( field->isSTL() and determinePrintAttr(cv, field) ) {
|
||||
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) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print_close_extern_c(ostream) ;
|
||||
}
|
||||
|
||||
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) ;
|
||||
|
@ -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) ;
|
||||
|
||||
|
@ -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)) ;
|
||||
if ( !fdes->getTypeName().compare("void") or !fdes->getChkpntIO() or !fdes->getEnumString().compare("TRICK_VOID")) {
|
||||
return false;
|
||||
}
|
||||
} 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)) ;
|
||||
if ( fdes->getAccess() == clang::AS_public or (!fdes->isStatic() and !global_compat15 and !c->isCompat15())) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false ;
|
||||
return c->getHasInitAttrFriend() && ( !fdes->isInherited() || fdes->getAccess() == clang::AS_protected ) ;
|
||||
}
|
||||
|
||||
std::vector<FieldDescription*> PrintFileContentsBase::getPrintableFields(ClassValues& classValues) {
|
||||
|
Loading…
Reference in New Issue
Block a user