2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
2016-04-14 14:22:23 +00:00
|
|
|
#include <sstream>
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
#include "PrintFileContents10.hh"
|
|
|
|
#include "FieldDescription.hh"
|
|
|
|
#include "ClassValues.hh"
|
|
|
|
#include "EnumValues.hh"
|
2015-06-01 15:28:29 +00:00
|
|
|
#include "Utilities.hh"
|
2015-02-26 15:02:31 +00:00
|
|
|
|
2016-09-16 13:39:37 +00:00
|
|
|
extern llvm::cl::opt< bool > no_offset_of ;
|
|
|
|
|
2015-02-26 15:02:31 +00:00
|
|
|
PrintFileContents10::PrintFileContents10() {}
|
|
|
|
|
|
|
|
/** Prints the io_src header information */
|
|
|
|
void PrintFileContents10::printIOHeader(std::ofstream & outfile , std::string header_file_name) {
|
|
|
|
|
|
|
|
if ( ! header_file_name.compare("S_source.hh") ) {
|
|
|
|
header_file_name = "../S_source.hh" ;
|
2015-06-01 15:28:29 +00:00
|
|
|
} else {
|
|
|
|
header_file_name = almostRealPath(header_file_name.c_str()) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
}
|
|
|
|
outfile << "\n"
|
|
|
|
"/*\n"
|
|
|
|
" * This file was automatically generated by the ICG based on the file:\n"
|
|
|
|
" * " << header_file_name << "\n"
|
|
|
|
" * This file contains database parameter declarations specific to the\n"
|
|
|
|
" * data structures and enumerated types declared in the above file.\n"
|
|
|
|
" * These database parameters are used by the Trick input and\n"
|
|
|
|
" * data recording processors to gain access to important simulation\n"
|
|
|
|
" * variable information.\n"
|
|
|
|
" *\n"
|
|
|
|
" * Auto Code Generator Programmer:\n"
|
|
|
|
" * Rob Bailey Sweet Systems Inc 12/97\n"
|
|
|
|
" * Alex Lin NASA 03/01\n"
|
|
|
|
" * Alex Lin NASA 05/09\n"
|
|
|
|
" */\n"
|
|
|
|
"#define TRICK_IN_IOSRC\n"
|
|
|
|
"#include <stdlib.h>\n"
|
|
|
|
"\n"
|
2015-06-01 15:28:29 +00:00
|
|
|
"#include \"trick/MemoryManager.hh\"\n"
|
|
|
|
"#include \"trick/attributes.h\"\n"
|
|
|
|
"#include \"trick/parameter_types.h\"\n"
|
|
|
|
"#include \"trick/UnitsMap.hh\"\n\n"
|
2016-03-29 14:26:49 +00:00
|
|
|
"#include \"trick/checkpoint_stl.hh\"\n\n"
|
2015-02-26 15:02:31 +00:00
|
|
|
"#include \""
|
|
|
|
<< header_file_name <<
|
|
|
|
"\"\n\n" ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Prints enumeration attributes */
|
|
|
|
void PrintFileContents10::print_enum_attr(std::ofstream & outfile , EnumValues * e ) {
|
|
|
|
EnumValues::NameValueIterator nvit ;
|
|
|
|
|
|
|
|
print_open_extern_c(outfile) ;
|
|
|
|
outfile << "ENUM_ATTR enum" ;
|
|
|
|
printNamespaces( outfile, e , "__" ) ;
|
|
|
|
printContainerClasses( outfile, e , "__" ) ;
|
|
|
|
outfile << e->getName() << "[] = {\n" ;
|
|
|
|
for ( nvit = e->begin() ; nvit != e->end() ; nvit++ ) {
|
|
|
|
outfile << "{\"";
|
|
|
|
printNamespaces( outfile, e , "::" ) ;
|
|
|
|
printContainerClasses( outfile, e , "::" ) ;
|
|
|
|
outfile << (*nvit).first << "\" , " << (*nvit).second << " , 0x0 } ,\n" ;
|
|
|
|
}
|
|
|
|
outfile << "{\"\" , 0 , 0x0 }\n} ;\n\n" ;
|
|
|
|
print_close_extern_c(outfile) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Prints attributes for a field */
|
|
|
|
void PrintFileContents10::print_field_attr(std::ofstream & outfile , FieldDescription * fdes ) {
|
|
|
|
int array_dim ;
|
|
|
|
|
|
|
|
outfile << "{ \"" << fdes->getName() << "\"" ; // name
|
|
|
|
outfile << ", \"" ; // start type_name
|
|
|
|
printNamespaces( outfile, fdes , "__" ) ;
|
|
|
|
printContainerClasses( outfile, fdes , "__" ) ;
|
|
|
|
outfile << fdes->getMangledTypeName() << "\""; // end type_name
|
|
|
|
outfile << ", \"" << fdes->getUnits() << "\"" ; // units
|
|
|
|
outfile << ", \"\", \"\"," << std::endl ; // alias , user_defined
|
2016-04-06 13:23:23 +00:00
|
|
|
outfile << " \"" << fdes->getDescription() << "\"," << std::endl ; // description
|
2015-02-26 15:02:31 +00:00
|
|
|
outfile << " " << fdes->getIO() ; // io
|
|
|
|
outfile << "," << fdes->getEnumString() ; // type
|
2016-04-14 14:22:23 +00:00
|
|
|
// There are several cases when printing the size of a variable.
|
2016-04-12 20:53:39 +00:00
|
|
|
if ( fdes->isBitField() ) {
|
2016-04-14 14:22:23 +00:00
|
|
|
// bitfields are handled in 4 byte (32 bit) chunks
|
|
|
|
outfile << ",4" ;
|
|
|
|
} else if ( fdes->isRecord() or fdes->isEnum() or fdes->getTypeName().empty() ) {
|
|
|
|
// records enums use io_src_get_size. The sentinel has no typename
|
|
|
|
outfile << ",0" ;
|
2016-04-12 20:53:39 +00:00
|
|
|
} else {
|
2016-04-14 14:22:23 +00:00
|
|
|
// print size of the underlying type
|
|
|
|
outfile << ",sizeof(" << fdes->getTypeName() << ")" ;
|
2016-04-12 20:53:39 +00:00
|
|
|
}
|
|
|
|
outfile << ",0,0,Language_CPP" ; // range_min, range_max, language
|
2016-06-21 21:12:28 +00:00
|
|
|
outfile << "," << (fdes->isStatic() << 1) + (fdes->isDashDashUnits() << 2) << "," << std::endl ; // mods
|
2016-04-12 20:53:39 +00:00
|
|
|
if ( fdes->isBitField() ) {
|
|
|
|
// For bitfields we need the offset to start on 4 byte boundaries because that is what our
|
|
|
|
// insert and extract bitfield routines work with.
|
|
|
|
outfile << " " << (fdes->getFieldOffset() - (fdes->getFieldOffset() % 32)) / 8 ; // offset
|
|
|
|
} else {
|
|
|
|
outfile << " " << (fdes->getFieldOffset() / 8) ; // offset
|
|
|
|
}
|
|
|
|
outfile << ",NULL" ; // attr
|
2015-02-26 15:02:31 +00:00
|
|
|
outfile << "," << fdes->getNumDims() ; // num_index
|
|
|
|
|
|
|
|
outfile << ",{" ;
|
|
|
|
if ( fdes->isBitField() ) {
|
2016-04-12 20:53:39 +00:00
|
|
|
outfile << "{" << fdes->getBitFieldWidth() ; // size of bitfield
|
|
|
|
outfile << "," << 32 - (fdes->getFieldOffset() % 32) - fdes->getBitFieldWidth() << "}" ; // start bit
|
2015-02-26 15:02:31 +00:00
|
|
|
} else {
|
|
|
|
array_dim = fdes->getArrayDim(0) ;
|
|
|
|
if ( array_dim < 0 ) array_dim = 0 ;
|
|
|
|
outfile << "{" << array_dim << ",0}" ; // index 0
|
|
|
|
}
|
|
|
|
unsigned int ii ;
|
|
|
|
for ( ii = 1 ; ii < 8 ; ii++ ) {
|
|
|
|
array_dim = fdes->getArrayDim(ii) ;
|
|
|
|
if ( array_dim < 0 ) array_dim = 0 ;
|
|
|
|
outfile << ",{" << array_dim << ",0}" ; // indexes 1 through 7
|
|
|
|
}
|
2016-03-29 14:26:49 +00:00
|
|
|
outfile << "}," << std::endl ;
|
|
|
|
outfile << " NULL, NULL, NULL, NULL" ;
|
|
|
|
outfile << "}" ;
|
2015-02-26 15:02:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Prints class attributes */
|
|
|
|
void PrintFileContents10::print_class_attr(std::ofstream & outfile , ClassValues * c ) {
|
|
|
|
|
|
|
|
unsigned int ii ;
|
|
|
|
ClassValues::FieldIterator fit ;
|
|
|
|
|
|
|
|
print_open_extern_c(outfile) ;
|
|
|
|
outfile << "\nATTRIBUTES attr" ;
|
|
|
|
printNamespaces( outfile, c , "__" ) ;
|
|
|
|
printContainerClasses( outfile, c , "__" ) ;
|
|
|
|
outfile << c->getMangledTypeName() ;
|
|
|
|
outfile << "[] = {" << std::endl ;
|
|
|
|
|
|
|
|
for ( fit = c->field_begin() ; fit != c->field_end() ; fit++ ) {
|
|
|
|
if ( determinePrintAttr(c , *fit) ) {
|
|
|
|
print_field_attr(outfile, *fit) ;
|
|
|
|
outfile << "," << std::endl ;
|
|
|
|
}
|
|
|
|
}
|
2016-04-06 13:23:23 +00:00
|
|
|
// Print an empty sentinel attribute at the end of the class.
|
2016-04-11 13:01:54 +00:00
|
|
|
FieldDescription * new_fdes = new FieldDescription(std::string("")) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
print_field_attr(outfile, new_fdes) ;
|
|
|
|
outfile << " };" << std::endl ;
|
|
|
|
delete new_fdes ;
|
|
|
|
|
|
|
|
print_close_extern_c(outfile) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Prints init_attr function for each class */
|
2016-04-12 20:53:39 +00:00
|
|
|
void PrintFileContents10::print_field_init_attr_stmts( std::ofstream & outfile , FieldDescription * fdes ,
|
|
|
|
ClassValues * cv , unsigned int index ) {
|
2015-02-26 15:02:31 +00:00
|
|
|
|
2016-04-12 20:53:39 +00:00
|
|
|
// For static variables replace the offset field with the address of the static variable
|
2016-09-16 13:39:37 +00:00
|
|
|
if ( no_offset_of ) {
|
|
|
|
if ( fdes->isStatic() ) {
|
|
|
|
outfile << " attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "[" << index << "].offset = (long)(void *)&" ;
|
|
|
|
printNamespaces( outfile, cv , "::" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "::" ) ;
|
|
|
|
outfile << cv->getName() << "::" << fdes->getName() << " ;\n" ;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ( fdes->isStatic() ) {
|
|
|
|
// print a special offsetof statement if this is a static
|
|
|
|
outfile << " attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "[" << index << "].offset = (long)(void *)&" ;
|
|
|
|
printNamespaces( outfile, cv , "::" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "::" ) ;
|
|
|
|
outfile << cv->getName() << "::" << fdes->getName() << " ;\n" ;
|
|
|
|
} else if ( fdes->isBitField() ) {
|
|
|
|
// else if this is a bitfield
|
|
|
|
outfile << " attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "[" << index << "].offset = " ;
|
|
|
|
outfile << fdes->getBitFieldByteOffset() << " ;\n" ;
|
|
|
|
// All bitfield offsets are in terms of unsigned ints.
|
|
|
|
outfile << " attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "[" << index << "].size = sizeof(unsigned int) ;\n" ;
|
|
|
|
} else if ( fdes->isVirtualInherited() ) {
|
|
|
|
// else if we have a virtually inherited class.
|
|
|
|
outfile << " attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "[" << index << "].offset = " << fdes->getBaseClassOffset() ;
|
|
|
|
outfile << " + offsetof(" ;
|
|
|
|
outfile << fdes->getContainerClass() << "," << fdes->getName() << ") ;\n" ;
|
|
|
|
} else if ( cv->getMangledTypeName() != cv->getName() ) {
|
|
|
|
// else if we have a template type where mangled_type_name is different then name.
|
|
|
|
outfile << " attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "[" << index << "].offset = offsetof(" ;
|
|
|
|
outfile << cv->getMangledTypeName() << "," << fdes->getName() << ") ;\n" ;
|
|
|
|
} else {
|
|
|
|
// else print an offsetof statement if this is not a special case
|
|
|
|
outfile << " attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "[" << index << "].offset = offsetof(" ;
|
|
|
|
printNamespaces( outfile, cv , "::" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "::" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "," << fdes->getName() << ") ;\n" ;
|
|
|
|
}
|
2016-04-06 13:23:23 +00:00
|
|
|
}
|
|
|
|
|
2016-03-29 14:26:49 +00:00
|
|
|
if ( fdes->isSTL()) {
|
|
|
|
outfile << " attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-04-12 20:53:39 +00:00
|
|
|
outfile << cv->getMangledTypeName() << "[" << index << "].checkpoint_stl = checkpoint_stl_" ;
|
2016-04-13 21:01:59 +00:00
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-03-29 14:26:49 +00:00
|
|
|
outfile << cv->getMangledTypeName() ;
|
|
|
|
outfile << "_" ;
|
|
|
|
outfile << fdes->getName() ;
|
|
|
|
outfile << " ;\n" ;
|
|
|
|
|
|
|
|
outfile << " attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-04-12 20:53:39 +00:00
|
|
|
outfile << cv->getMangledTypeName() << "[" << index << "].post_checkpoint_stl = post_checkpoint_stl_" ;
|
2016-04-13 21:01:59 +00:00
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-03-29 14:26:49 +00:00
|
|
|
outfile << cv->getMangledTypeName() ;
|
|
|
|
outfile << "_" ;
|
|
|
|
outfile << fdes->getName() ;
|
|
|
|
outfile << " ;\n" ;
|
|
|
|
|
|
|
|
outfile << " attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-04-12 20:53:39 +00:00
|
|
|
outfile << cv->getMangledTypeName() << "[" << index << "].restore_stl = restore_stl_" ;
|
2016-04-13 21:01:59 +00:00
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-03-29 14:26:49 +00:00
|
|
|
outfile << cv->getMangledTypeName() ;
|
|
|
|
outfile << "_" ;
|
|
|
|
outfile << fdes->getName() ;
|
|
|
|
outfile << " ;\n" ;
|
|
|
|
|
|
|
|
if (fdes->hasSTLClear()) {
|
|
|
|
outfile << " attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-04-12 20:53:39 +00:00
|
|
|
outfile << cv->getMangledTypeName() << "[" << index << "].clear_stl = clear_stl_" ;
|
2016-04-13 21:01:59 +00:00
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-03-29 14:26:49 +00:00
|
|
|
outfile << cv->getMangledTypeName() ;
|
|
|
|
outfile << "_" ;
|
|
|
|
outfile << fdes->getName() ;
|
|
|
|
outfile << " ;\n" ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-26 15:02:31 +00:00
|
|
|
if ( fdes->isRecord() or fdes->isEnum()) {
|
|
|
|
outfile << " next_attr = std::string(attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-04-12 20:53:39 +00:00
|
|
|
outfile << cv->getMangledTypeName() << "[" << index << "].type_name) ;\n" ;
|
2015-02-26 15:02:31 +00:00
|
|
|
|
2016-10-20 16:45:51 +00:00
|
|
|
outfile << " trick_MM->add_attr_info(next_attr , &attr" ;
|
2015-02-26 15:02:31 +00:00
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-04-12 20:53:39 +00:00
|
|
|
outfile << cv->getMangledTypeName() << "[" << index << "], __FILE__ , __LINE__ ) ;\n" ;
|
2015-02-26 15:02:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Prints add_attr_info statements for each inherited class */
|
|
|
|
void PrintFileContents10::print_inherited_add_attr_info( std::ofstream & outfile , ClassValues * cv ) {
|
|
|
|
ClassValues::InheritedClassesIterator cit ;
|
|
|
|
if ( cv->getNumInheritedClasses() > 0 ) {
|
|
|
|
outfile << "\n ATTRIBUTES temp_attr ;\n\n" ;
|
|
|
|
}
|
|
|
|
for ( cit = cv->inherit_classes_begin() ; cit != cv->inherit_classes_end() ; cit++ ) {
|
2016-04-11 13:01:54 +00:00
|
|
|
outfile << " next_attr = \"" << *cit << "\" ;\n" ;
|
2016-10-20 16:45:51 +00:00
|
|
|
outfile << " trick_MM->add_attr_info( next_attr , &temp_attr , __FILE__ , __LINE__ ) ;\n" ;
|
2015-02-26 15:02:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Prints init_attr function for each class */
|
|
|
|
void PrintFileContents10::print_init_attr_func( std::ofstream & outfile , ClassValues * cv ) {
|
|
|
|
|
|
|
|
ClassValues::FieldIterator fit ;
|
|
|
|
|
|
|
|
printOpenNamespaceBlocks(outfile, cv) ;
|
|
|
|
outfile << "\nvoid init_attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() ;
|
|
|
|
outfile << "() {\n\n"
|
|
|
|
" static int initialized_1337 ;\n"
|
|
|
|
" if ( initialized_1337 ) {\n"
|
|
|
|
" return ;\n"
|
|
|
|
" }\n"
|
|
|
|
" initialized_1337 = 1 ;\n\n"
|
2016-10-20 16:45:51 +00:00
|
|
|
" std::string next_attr ;\n" ;
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
if ( cv->getMangledTypeName() != cv->getName() ) {
|
|
|
|
outfile << " typedef " << cv->getName() << " " << cv->getMangledTypeName() << " ;\n\n" ;
|
|
|
|
}
|
|
|
|
|
2016-04-12 20:53:39 +00:00
|
|
|
unsigned int ii = 0 ;
|
2015-02-26 15:02:31 +00:00
|
|
|
for ( fit = cv->field_begin() ; fit != cv->field_end() ; fit++ ) {
|
|
|
|
if ( determinePrintAttr(cv , *fit) ) {
|
2016-04-12 20:53:39 +00:00
|
|
|
print_field_init_attr_stmts(outfile, *fit, cv, ii) ;
|
|
|
|
ii++ ;
|
2015-02-26 15:02:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
print_inherited_add_attr_info(outfile, cv ) ;
|
|
|
|
outfile << "}\n\n" ;
|
|
|
|
printCloseNamespaceBlocks(outfile, cv) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Prints the io_src_sizeof function for enumerations */
|
|
|
|
void PrintFileContents10::print_enum_io_src_sizeof( std::ofstream & outfile , EnumValues * ev ) {
|
|
|
|
print_open_extern_c(outfile) ;
|
|
|
|
outfile << "size_t io_src_sizeof_" ;
|
|
|
|
printNamespaces( outfile, ev , "__" ) ;
|
|
|
|
printContainerClasses( outfile, ev , "__" ) ;
|
|
|
|
outfile << ev->getName() << "( void ) {\n" ;
|
|
|
|
if ( ev->getHasDefinition() ) {
|
|
|
|
outfile << " return( sizeof(" ;
|
|
|
|
printNamespaces( outfile, ev , "::" ) ;
|
|
|
|
printContainerClasses( outfile, ev , "::" ) ;
|
|
|
|
outfile << ev->getName() << "));\n}\n\n" ;
|
|
|
|
} else {
|
|
|
|
outfile << " return(sizeof(int)) ;\n}\n\n" ;
|
|
|
|
}
|
|
|
|
print_close_extern_c(outfile) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Prints the C linkage init_attr function */
|
|
|
|
void PrintFileContents10::print_init_attr_c_intf( std::ofstream & outfile , ClassValues * cv ) {
|
|
|
|
outfile << "void init_attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "_c_intf() {\n " ;
|
|
|
|
printNamespaces( outfile, cv , "::" ) ;
|
|
|
|
outfile << "init_attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "() ;\n"
|
|
|
|
"}\n\n" ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Prints the io_src_sizeof function */
|
|
|
|
void PrintFileContents10::print_io_src_sizeof( std::ofstream & outfile , ClassValues * cv ) {
|
|
|
|
outfile << "size_t io_src_sizeof_" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "( void ) {\n" ;
|
|
|
|
outfile << " return( sizeof(" ;
|
|
|
|
// Template types
|
|
|
|
if ( cv->getMangledTypeName() == cv->getName() ) {
|
|
|
|
printNamespaces( outfile, cv , "::" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "::" ) ;
|
|
|
|
}
|
|
|
|
outfile << cv->getName() << "));\n"
|
|
|
|
"}\n\n" ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Prints the io_src_allocate function */
|
|
|
|
void PrintFileContents10::print_io_src_allocate( std::ofstream & outfile , ClassValues * cv ) {
|
|
|
|
if ( cv->isPOD() or (! cv->isAbstract() and cv->getHasDefaultConstructor()) ) {
|
|
|
|
outfile << "void * io_src_allocate_" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "( int num) {\n" ;
|
|
|
|
|
|
|
|
outfile << " " ;
|
|
|
|
if ( cv->getMangledTypeName() == cv->getName() ) {
|
|
|
|
printNamespaces( outfile, cv , "::" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "::" ) ;
|
|
|
|
}
|
|
|
|
outfile << cv->getName() << " * temp = (" ;
|
|
|
|
if ( cv->getMangledTypeName() == cv->getName() ) {
|
|
|
|
printNamespaces( outfile, cv , "::" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "::" ) ;
|
|
|
|
}
|
|
|
|
outfile << cv->getName() << " * )calloc( num, sizeof(" ;
|
|
|
|
if ( cv->getMangledTypeName() == cv->getName() ) {
|
|
|
|
printNamespaces( outfile, cv , "::" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "::" ) ;
|
|
|
|
}
|
|
|
|
outfile << cv->getName() << "));\n" ;
|
|
|
|
if ( ! cv->isPOD() ) {
|
|
|
|
outfile << " for (int ii=0 ; ii<num ; ii++) {\n" ;
|
|
|
|
outfile << " new( &temp[ii]) " ;
|
|
|
|
if ( cv->getMangledTypeName() == cv->getName() ) {
|
|
|
|
printNamespaces( outfile, cv , "::" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "::" ) ;
|
|
|
|
}
|
|
|
|
outfile << cv->getName() << "();\n" << " }\n" ;
|
|
|
|
}
|
|
|
|
outfile << " return ((void *)temp);\n" << "}\n\n" ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Prints the io_src_allocate function */
|
|
|
|
void PrintFileContents10::print_io_src_destruct( std::ofstream & outfile , ClassValues * cv ) {
|
|
|
|
if ( cv->getHasPublicDestructor()) {
|
|
|
|
outfile << "void io_src_destruct_" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "( void * addr __attribute__((unused)), int num __attribute__((unused)) ) {\n" ;
|
|
|
|
if ( ! cv->isPOD() ) {
|
|
|
|
// Add a using statement so we can call the destructor without fully qualifying it.
|
|
|
|
ClassValues::NamespaceIterator nsi = cv->namespace_begin() ;
|
|
|
|
if ( nsi != cv->namespace_end() ) {
|
|
|
|
outfile << " using namespace " ;
|
|
|
|
while ( nsi != cv->namespace_end() ) {
|
|
|
|
outfile << *nsi ;
|
|
|
|
nsi++ ;
|
|
|
|
if ( nsi != cv->namespace_end()) {
|
|
|
|
outfile << "::" ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
outfile << " ;\n" ;
|
|
|
|
}
|
|
|
|
outfile << " " ;
|
|
|
|
if ( cv->getMangledTypeName() == cv->getName() ) {
|
|
|
|
printNamespaces( outfile, cv , "::" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "::" ) ;
|
|
|
|
}
|
|
|
|
outfile << cv->getName() << " * temp = (" ;
|
|
|
|
if ( cv->getMangledTypeName() == cv->getName() ) {
|
|
|
|
printNamespaces( outfile, cv , "::" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "::" ) ;
|
|
|
|
}
|
|
|
|
outfile << cv->getName() << " * )addr ;\n" ;
|
|
|
|
outfile << " for (int ii=0 ; ii<num ; ii++) {\n" ;
|
|
|
|
if ( cv->getMangledTypeName() == cv->getName() ) {
|
|
|
|
outfile << " temp[ii].~" ;
|
|
|
|
outfile << cv->getName() << "();\n" ;
|
|
|
|
}
|
|
|
|
outfile << " }\n" ;
|
|
|
|
}
|
|
|
|
outfile << "}\n\n" ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintFileContents10::print_io_src_delete( std::ofstream & outfile , ClassValues * cv ) {
|
|
|
|
if ( cv->getHasPublicDestructor()) {
|
|
|
|
outfile << "void io_src_delete_" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "( void * addr __attribute__((unused)) ) {\n" ;
|
|
|
|
if ( ! cv->isPOD() ) {
|
|
|
|
// Add a using statement so we can call the destructor without fully qualifying it.
|
|
|
|
ClassValues::NamespaceIterator nsi = cv->namespace_begin() ;
|
|
|
|
if ( nsi != cv->namespace_end() ) {
|
|
|
|
outfile << " using namespace " ;
|
|
|
|
while ( nsi != cv->namespace_end() ) {
|
|
|
|
outfile << *nsi ;
|
|
|
|
nsi++ ;
|
|
|
|
if ( nsi != cv->namespace_end()) {
|
|
|
|
outfile << "::" ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
outfile << " ;\n" ;
|
|
|
|
}
|
|
|
|
outfile << " " ;
|
|
|
|
if ( cv->getMangledTypeName() == cv->getName() ) {
|
|
|
|
printNamespaces( outfile, cv , "::" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "::" ) ;
|
|
|
|
}
|
|
|
|
outfile << cv->getName() << " * temp = (" ;
|
|
|
|
if ( cv->getMangledTypeName() == cv->getName() ) {
|
|
|
|
printNamespaces( outfile, cv , "::" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "::" ) ;
|
|
|
|
}
|
|
|
|
outfile << cv->getName() << " * )addr ;\n" ;
|
|
|
|
outfile << " delete temp ;\n" ;
|
|
|
|
}
|
|
|
|
outfile << "}\n\n" ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-29 14:26:49 +00:00
|
|
|
void PrintFileContents10::print_stl_helper_proto(std::ofstream & outfile , ClassValues * cv ) {
|
|
|
|
|
|
|
|
unsigned int ii ;
|
|
|
|
ClassValues::FieldIterator fit ;
|
|
|
|
|
|
|
|
print_open_extern_c(outfile) ;
|
|
|
|
|
|
|
|
for ( fit = cv->field_begin() ; fit != cv->field_end() ; fit++ ) {
|
|
|
|
if ( (*fit)->isSTL() and determinePrintAttr(cv , *fit) ) {
|
|
|
|
outfile << "void checkpoint_stl_" ;
|
2016-04-13 21:01:59 +00:00
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-03-29 14:26:49 +00:00
|
|
|
outfile << cv->getMangledTypeName() ;
|
|
|
|
outfile << "_" ;
|
|
|
|
outfile << (*fit)->getName() ;
|
|
|
|
outfile << "(void * start_address, const char * obj_name , const char * var_name) ;" << std::endl ;
|
|
|
|
|
|
|
|
outfile << "void post_checkpoint_stl_" ;
|
2016-04-13 21:01:59 +00:00
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-03-29 14:26:49 +00:00
|
|
|
outfile << cv->getMangledTypeName() ;
|
|
|
|
outfile << "_" ;
|
|
|
|
outfile << (*fit)->getName() ;
|
|
|
|
outfile << "(void * start_address, const char * obj_name , const char * var_name) ;" << std::endl ;
|
|
|
|
|
|
|
|
outfile << "void restore_stl_" ;
|
2016-04-13 21:01:59 +00:00
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-03-29 14:26:49 +00:00
|
|
|
outfile << cv->getMangledTypeName() ;
|
|
|
|
outfile << "_" ;
|
|
|
|
outfile << (*fit)->getName() ;
|
|
|
|
outfile << "(void * start_address, const char * obj_name , const char * var_name) ;" << std::endl ;
|
|
|
|
|
|
|
|
if ((*fit)->hasSTLClear()) {
|
|
|
|
outfile << "void clear_stl_" ;
|
2016-04-13 21:01:59 +00:00
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-03-29 14:26:49 +00:00
|
|
|
outfile << cv->getMangledTypeName() ;
|
|
|
|
outfile << "_" ;
|
|
|
|
outfile << (*fit)->getName() ;
|
|
|
|
outfile << "(void * start_address) ;" << std::endl ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print_close_extern_c(outfile) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintFileContents10::print_checkpoint_stl(std::ofstream & outfile , FieldDescription * fdes , ClassValues * cv ) {
|
|
|
|
outfile << "void checkpoint_stl_" ;
|
2016-04-13 21:01:59 +00:00
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-03-29 14:26:49 +00:00
|
|
|
outfile << cv->getMangledTypeName() ;
|
|
|
|
outfile << "_" ;
|
|
|
|
outfile << fdes->getName() ;
|
|
|
|
outfile << "(void * start_address, const char * obj_name , const char * var_name) {" << std::endl ;
|
|
|
|
|
|
|
|
outfile << " " << fdes->getTypeName() << " * stl = reinterpret_cast<" << fdes->getTypeName() << " * >(start_address) ;" << std::endl ;
|
|
|
|
outfile << " " << "checkpoint_stl(*stl , obj_name , var_name) ;" << std::endl ;
|
|
|
|
|
|
|
|
outfile << "}" << std::endl ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintFileContents10::print_post_checkpoint_stl(std::ofstream & outfile , FieldDescription * fdes , ClassValues * cv ) {
|
|
|
|
outfile << "void post_checkpoint_stl_" ;
|
2016-04-13 21:01:59 +00:00
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-03-29 14:26:49 +00:00
|
|
|
outfile << cv->getMangledTypeName() ;
|
|
|
|
outfile << "_" ;
|
|
|
|
outfile << fdes->getName() ;
|
|
|
|
outfile << "(void * start_address, const char * obj_name , const char * var_name) {" << std::endl ;
|
|
|
|
|
|
|
|
outfile << " " << fdes->getTypeName() << " * stl = reinterpret_cast<" << fdes->getTypeName() << " * >(start_address) ;" << std::endl ;
|
|
|
|
outfile << " " << "delete_stl(*stl , obj_name , var_name) ;" << std::endl ;
|
|
|
|
|
|
|
|
outfile << "}" << std::endl ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintFileContents10::print_restore_stl(std::ofstream & outfile , FieldDescription * fdes , ClassValues * cv ) {
|
|
|
|
outfile << "void restore_stl_" ;
|
2016-04-13 21:01:59 +00:00
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-03-29 14:26:49 +00:00
|
|
|
outfile << cv->getMangledTypeName() ;
|
|
|
|
outfile << "_" ;
|
|
|
|
outfile << fdes->getName() ;
|
|
|
|
outfile << "(void * start_address, const char * obj_name , const char * var_name) {" << std::endl ;
|
|
|
|
|
|
|
|
outfile << " " << fdes->getTypeName() << " * stl = reinterpret_cast<" << fdes->getTypeName() << " * >(start_address) ;" << std::endl ;
|
|
|
|
outfile << " " << "restore_stl(*stl , obj_name , var_name) ;" << std::endl ;
|
|
|
|
|
|
|
|
outfile << "}" << std::endl ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintFileContents10::print_clear_stl(std::ofstream & outfile , FieldDescription * fdes , ClassValues * cv ) {
|
|
|
|
outfile << "void clear_stl_" ;
|
2016-04-13 21:01:59 +00:00
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
2016-03-29 14:26:49 +00:00
|
|
|
outfile << cv->getMangledTypeName() ;
|
|
|
|
outfile << "_" ;
|
|
|
|
outfile << fdes->getName() ;
|
|
|
|
outfile << "(void * start_address) {" << std::endl ;
|
|
|
|
|
|
|
|
outfile << " " << fdes->getTypeName() << " * stl = reinterpret_cast<" << fdes->getTypeName() << " * >(start_address) ;" << std::endl ;
|
|
|
|
outfile << " " << "stl->clear() ;" << std::endl ;
|
|
|
|
|
|
|
|
outfile << "}" << std::endl ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintFileContents10::print_stl_helper(std::ofstream & outfile , ClassValues * cv ) {
|
|
|
|
|
|
|
|
unsigned int ii ;
|
|
|
|
ClassValues::FieldIterator fit ;
|
|
|
|
|
|
|
|
print_open_extern_c(outfile) ;
|
|
|
|
|
|
|
|
for ( fit = cv->field_begin() ; fit != cv->field_end() ; fit++ ) {
|
|
|
|
if ( (*fit)->isSTL() and determinePrintAttr(cv , *fit) ) {
|
|
|
|
print_checkpoint_stl(outfile , *fit, cv) ;
|
|
|
|
print_post_checkpoint_stl(outfile , *fit, cv) ;
|
|
|
|
print_restore_stl(outfile , *fit, cv) ;
|
|
|
|
if ((*fit)->hasSTLClear()) {
|
|
|
|
print_clear_stl(outfile , *fit, cv) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print_close_extern_c(outfile) ;
|
|
|
|
}
|
|
|
|
|
2015-02-26 15:02:31 +00:00
|
|
|
void PrintFileContents10::printClass( std::ofstream & outfile , ClassValues * cv ) {
|
2016-03-29 14:26:49 +00:00
|
|
|
print_stl_helper_proto(outfile, cv) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
print_class_attr(outfile, cv) ;
|
2016-03-29 14:26:49 +00:00
|
|
|
print_stl_helper(outfile, cv) ;
|
2015-02-26 15:02:31 +00:00
|
|
|
print_init_attr_func(outfile, cv) ;
|
|
|
|
print_open_extern_c(outfile) ;
|
|
|
|
print_init_attr_c_intf(outfile, cv) ;
|
|
|
|
print_io_src_sizeof(outfile, cv) ;
|
|
|
|
print_io_src_allocate(outfile, cv) ;
|
|
|
|
print_io_src_destruct(outfile, cv) ;
|
|
|
|
print_io_src_delete(outfile, cv) ;
|
|
|
|
print_close_extern_c(outfile) ;
|
|
|
|
print_units_map(outfile, cv) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintFileContents10::printEnum( std::ofstream & outfile , EnumValues * ev ) {
|
|
|
|
print_enum_attr(outfile, ev) ;
|
|
|
|
print_enum_io_src_sizeof(outfile, ev) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintFileContents10::printClassMapHeader( std::ofstream & outfile , std::string function_name ) {
|
|
|
|
outfile <<
|
|
|
|
"/*\n"
|
|
|
|
" * This file was automatically generated by the ICG\n"
|
|
|
|
" * This file contains the map from class/struct names to attributes\n"
|
|
|
|
" */\n\n"
|
|
|
|
"#include <map>\n"
|
|
|
|
"#include <string>\n\n"
|
2015-06-01 15:28:29 +00:00
|
|
|
"#include \"trick/AttributesMap.hh\"\n"
|
2015-07-16 20:36:36 +00:00
|
|
|
"#include \"trick/EnumAttributesMap.hh\"\n"
|
2015-06-01 15:28:29 +00:00
|
|
|
"#include \"trick/attributes.h\"\n\n"
|
2015-02-26 15:02:31 +00:00
|
|
|
"void " << function_name << "() {\n\n"
|
|
|
|
" Trick::AttributesMap * class_attribute_map = Trick::AttributesMap::attributes_map();\n\n" ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintFileContents10::printClassMap( std::ofstream & outfile , ClassValues * cv ) {
|
|
|
|
outfile << " // " << cv->getFileName() << std::endl ;
|
|
|
|
outfile << " extern ATTRIBUTES attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "[] ;" << std::endl ;
|
|
|
|
|
|
|
|
outfile << " class_attribute_map->add_attr(\"" ;
|
|
|
|
printNamespaces( outfile, cv , "::" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "::" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << "\" , attr" ;
|
|
|
|
printNamespaces( outfile, cv , "__" ) ;
|
|
|
|
printContainerClasses( outfile, cv , "__" ) ;
|
|
|
|
outfile << cv->getMangledTypeName() << ") ;" << std::endl ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintFileContents10::printClassMapFooter( std::ofstream & outfile ) {
|
2015-07-16 20:36:36 +00:00
|
|
|
outfile << "}" << std::endl << std::endl ;
|
2015-02-26 15:02:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrintFileContents10::printEnumMapHeader( std::ofstream & outfile , std::string function_name ) {
|
|
|
|
outfile <<
|
|
|
|
"void " << function_name << "() {\n"
|
|
|
|
" Trick::EnumAttributesMap * enum_attribute_map __attribute__((unused)) = Trick::EnumAttributesMap::attributes_map();\n\n" ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintFileContents10::printEnumMap( std::ofstream & outfile , EnumValues * ev ) {
|
|
|
|
outfile << " extern ENUM_ATTR enum" ;
|
|
|
|
printNamespaces( outfile, ev , "__" ) ;
|
|
|
|
printContainerClasses( outfile, ev , "__" ) ;
|
|
|
|
outfile << ev->getName() << "[] ;" << std::endl ;
|
|
|
|
|
|
|
|
outfile << " enum_attribute_map->add_attr(\"" ;
|
|
|
|
printNamespaces( outfile, ev , "::" ) ;
|
|
|
|
printContainerClasses( outfile, ev , "::" ) ;
|
|
|
|
outfile << ev->getName() << "\" , enum" ;
|
|
|
|
printNamespaces( outfile, ev , "__" ) ;
|
|
|
|
printContainerClasses( outfile, ev , "__" ) ;
|
|
|
|
outfile << ev->getName() << ") ;" << std::endl ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintFileContents10::printEnumMapFooter( std::ofstream & outfile ) {
|
2015-07-16 20:36:36 +00:00
|
|
|
outfile << "}" << std::endl << std::endl ;
|
2015-02-26 15:02:31 +00:00
|
|
|
}
|