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 ;
|
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() {
|
std::string FieldDescription::getDescription() {
|
||||||
return description ;
|
return description ;
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,11 @@ class FieldDescription : public ConstructValues {
|
|||||||
bool isDashDashUnits() ;
|
bool isDashDashUnits() ;
|
||||||
void setIO(unsigned int) ;
|
void setIO(unsigned int) ;
|
||||||
unsigned int getIO() ;
|
unsigned int getIO() ;
|
||||||
|
unsigned int getChkpntIO() ;
|
||||||
|
bool isReadable() ;
|
||||||
|
bool isWriteable();
|
||||||
|
bool isCheckpointable();
|
||||||
|
bool isRestorable();
|
||||||
std::string getDescription() ;
|
std::string getDescription() ;
|
||||||
void setEnumString(std::string) ;
|
void setEnumString(std::string) ;
|
||||||
std::string getEnumString() ;
|
std::string getEnumString() ;
|
||||||
|
@ -166,12 +166,16 @@ void PrintFileContents10::print_field_init_attr_stmts( std::ostream & ostream ,
|
|||||||
ostream << prefix << field << " = " << field << "_" << fullyQualifiedMangledClassNameUnderscores + "_" + fieldName + " ;\n";
|
ostream << prefix << field << " = " << field << "_" << fullyQualifiedMangledClassNameUnderscores + "_" + fieldName + " ;\n";
|
||||||
};
|
};
|
||||||
|
|
||||||
print("checkpoint_stl");
|
if ( fdes->isCheckpointable() ) {
|
||||||
print("post_checkpoint_stl");
|
print("checkpoint_stl");
|
||||||
print("restore_stl");
|
print("post_checkpoint_stl");
|
||||||
|
}
|
||||||
|
|
||||||
if ( fdes->hasSTLClear() ) {
|
if ( fdes->isRestorable() ) {
|
||||||
print("clear_stl");
|
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 ) {
|
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);
|
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) {
|
for (auto& field : fieldDescriptions) {
|
||||||
if ( field->isSTL() and determinePrintAttr(cv, field) ) {
|
if ( field->isSTL() and determinePrintAttr(cv, field) ) {
|
||||||
print_checkpoint_stl(ostream, field, cv) ;
|
if (field->isCheckpointable()) {
|
||||||
print_post_checkpoint_stl(ostream, field, cv) ;
|
print_checkpoint_stl(ostream, field, cv) ;
|
||||||
print_restore_stl(ostream, field, cv) ;
|
print_post_checkpoint_stl(ostream, field, cv) ;
|
||||||
if (field->hasSTLClear()) {
|
}
|
||||||
print_clear_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 ) {
|
void PrintFileContents10::printClass( std::ostream & ostream , ClassValues * cv ) {
|
||||||
print_stl_helper_proto(ostream, cv) ;
|
|
||||||
print_class_attr(ostream, cv) ;
|
print_class_attr(ostream, cv) ;
|
||||||
print_stl_helper(ostream, cv) ;
|
print_stl_helper(ostream, cv) ;
|
||||||
print_init_attr_func(ostream, cv) ;
|
print_init_attr_func(ostream, cv) ;
|
||||||
|
@ -86,9 +86,6 @@ class PrintFileContents10 : public PrintFileContentsBase {
|
|||||||
/** Prints the io_src_delete function */
|
/** Prints the io_src_delete function */
|
||||||
void print_io_src_delete(std::ostream & outfile , ClassValues * cv ) ;
|
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 */
|
/** Prints stl helper function */
|
||||||
void print_stl_helper(std::ostream & outfile , ClassValues * in_class) ;
|
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.
|
on access to the field and the presense of init_attr friends.
|
||||||
*/
|
*/
|
||||||
bool PrintFileContentsBase::determinePrintAttr( ClassValues * c , FieldDescription * fdes ) {
|
bool PrintFileContentsBase::determinePrintAttr( ClassValues * c , FieldDescription * fdes ) {
|
||||||
if ( fdes->getTypeName().compare("void") and fdes->getIO() != 0 and fdes->getEnumString().compare("TRICK_VOID")) {
|
if ( !fdes->getTypeName().compare("void") or !fdes->getChkpntIO() or !fdes->getEnumString().compare("TRICK_VOID")) {
|
||||||
if ( global_compat15 or c->isCompat15()) {
|
return false;
|
||||||
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 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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<FieldDescription*> PrintFileContentsBase::getPrintableFields(ClassValues& classValues) {
|
std::vector<FieldDescription*> PrintFileContentsBase::getPrintableFields(ClassValues& classValues) {
|
||||||
|
Loading…
Reference in New Issue
Block a user