2017-05-17 14:37:22 +00:00
# include <algorithm>
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-10-21 14:30:55 +00:00
extern llvm : : cl : : opt < bool > global_compat15 ;
2016-09-16 13:39:37 +00:00
2015-02-26 15:02:31 +00:00
PrintFileContents10 : : PrintFileContents10 ( ) { }
/** Prints the io_src header information */
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : printIOHeader ( std : : ostream & ostream , std : : string header_file_name ) {
2015-02-26 15:02:31 +00:00
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
}
2016-10-28 19:37:12 +00:00
ostream < < " /** \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 "
< < " \n "
< < " #define TRICK_IN_IOSRC \n "
< < " #include <stdlib.h> \n "
< < " #include \" trick/MemoryManager.hh \" \n "
< < " #include \" trick/attributes.h \" \n "
< < " #include \" trick/parameter_types.h \" \n "
< < " #include \" trick/ClassSizeCheck.hh \" \n "
< < " #include \" trick/UnitsMap.hh \" \n "
< < " #include \" trick/checkpoint_stl.hh \" \n "
< < " #include \" " < < header_file_name < < " \" \n "
< < " \n " ;
2015-02-26 15:02:31 +00:00
}
/** Prints enumeration attributes */
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_enum_attr ( std : : ostream & ostream , EnumValues * e ) {
print_open_extern_c ( ostream ) ;
2016-10-28 19:37:12 +00:00
ostream < < " ENUM_ATTR enum " < < e - > getFullyQualifiedTypeName ( " __ " ) < < " [] = { \n " ;
std : : string name = e - > getNamespacesAndContainerClasses ( ) ;
for ( auto & pair : e - > getPairs ( ) ) {
ostream < < " { \" " < < name < < pair . first < < " \" , " < < pair . second < < " , 0x0}, \n " ;
2015-02-26 15:02:31 +00:00
}
2016-10-28 19:37:12 +00:00
ostream < < " { \" \" , 0, 0x0} \n }; \n " ;
2016-10-20 19:53:21 +00:00
print_close_extern_c ( ostream ) ;
2015-02-26 15:02:31 +00:00
}
/** Prints attributes for a field */
2017-05-17 14:37:22 +00:00
void PrintFileContents10 : : print_field_attr ( std : : ostream & ostream , FieldDescription & fdes ) {
2015-02-26 15:02:31 +00:00
int array_dim ;
2017-05-17 14:37:22 +00:00
ostream < < " { \" " < < fdes . getName ( ) < < " \" " // name
< < " , \" " < < fdes . getFullyQualifiedMangledTypeName ( " __ " ) < < " \" " // type_name
< < " , \" " < < fdes . getUnits ( ) < < " \" " // units
2016-10-28 19:37:12 +00:00
< < " , \" \" , \" \" , " < < std : : endl // alias, user_defined
2017-05-17 14:37:22 +00:00
< < " \" " < < fdes . getDescription ( ) < < " \" , " < < std : : endl // description
< < " " < < fdes . getIO ( ) // io
< < " , " < < fdes . getEnumString ( ) ; // type
2016-04-14 14:22:23 +00:00
// There are several cases when printing the size of a variable.
2017-05-17 14:37:22 +00:00
if ( fdes . isBitField ( ) ) {
2016-04-14 14:22:23 +00:00
// bitfields are handled in 4 byte (32 bit) chunks
2016-10-28 19:37:12 +00:00
ostream < < " , 4 " ;
2017-05-17 14:37:22 +00:00
} else if ( fdes . isRecord ( ) or fdes . isEnum ( ) or fdes . getTypeName ( ) . empty ( ) ) {
2016-04-14 14:22:23 +00:00
// records enums use io_src_get_size. The sentinel has no typename
2016-10-28 19:37:12 +00:00
ostream < < " , 0 " ;
2016-04-12 20:53:39 +00:00
} else {
2016-04-14 14:22:23 +00:00
// print size of the underlying type
2017-05-17 14:37:22 +00:00
ostream < < " , sizeof( " < < fdes . getTypeName ( ) < < " ) " ;
2016-04-12 20:53:39 +00:00
}
2016-10-28 19:37:12 +00:00
ostream < < " , 0, 0, Language_CPP " ; // range_min, range_max, language
2017-05-17 14:37:22 +00:00
ostream < < " , " < < ( fdes . isStatic ( ) < < 1 ) + ( fdes . isDashDashUnits ( ) < < 2 ) < < " , " < < std : : endl ; // mods
if ( fdes . isBitField ( ) ) {
2016-04-12 20:53:39 +00:00
// For bitfields we need the offset to start on 4 byte boundaries because that is what our
// insert and extract bitfield routines work with.
2017-05-17 14:37:22 +00:00
ostream < < " " < < ( fdes . getFieldOffset ( ) - ( fdes . getFieldOffset ( ) % 32 ) ) / 8 ; // offset
2016-04-12 20:53:39 +00:00
} else {
2017-05-17 14:37:22 +00:00
ostream < < " " < < ( fdes . getFieldOffset ( ) / 8 ) ; // offset
2016-04-12 20:53:39 +00:00
}
2016-10-28 19:37:12 +00:00
ostream < < " , NULL " ; // attr
2017-05-17 14:37:22 +00:00
ostream < < " , " < < fdes . getNumDims ( ) ; // num_index
2015-02-26 15:02:31 +00:00
2016-10-28 19:37:12 +00:00
ostream < < " , { " ;
2017-05-17 14:37:22 +00:00
if ( fdes . isBitField ( ) ) {
ostream < < " { " < < fdes . getBitFieldWidth ( ) ; // size of bitfield
ostream < < " , " < < 32 - ( fdes . getFieldOffset ( ) % 32 ) - fdes . getBitFieldWidth ( ) < < " } " ; // start bit
2015-02-26 15:02:31 +00:00
} else {
2017-05-17 14:37:22 +00:00
array_dim = fdes . getArrayDim ( 0 ) ;
2015-02-26 15:02:31 +00:00
if ( array_dim < 0 ) array_dim = 0 ;
2016-10-28 19:37:12 +00:00
ostream < < " { " < < array_dim < < " , 0} " ; // index 0
2015-02-26 15:02:31 +00:00
}
unsigned int ii ;
for ( ii = 1 ; ii < 8 ; ii + + ) {
2017-05-17 14:37:22 +00:00
array_dim = fdes . getArrayDim ( ii ) ;
2015-02-26 15:02:31 +00:00
if ( array_dim < 0 ) array_dim = 0 ;
2016-10-28 19:37:12 +00:00
ostream < < " , { " < < array_dim < < " , 0} " ; // indexes 1 through 7
2015-02-26 15:02:31 +00:00
}
2016-10-20 19:53:21 +00:00
ostream < < " }, " < < std : : endl ;
ostream < < " NULL, NULL, NULL, NULL " ;
ostream < < " } " ;
2015-02-26 15:02:31 +00:00
}
/** Prints class attributes */
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_class_attr ( std : : ostream & ostream , ClassValues * c ) {
2015-02-26 15:02:31 +00:00
2016-10-20 19:53:21 +00:00
print_open_extern_c ( ostream ) ;
2016-10-28 19:37:12 +00:00
ostream < < " ATTRIBUTES attr " < < c - > getFullyQualifiedMangledTypeName ( " __ " ) < < " [] = { " < < std : : endl ;
2017-05-17 14:37:22 +00:00
for ( FieldDescription * fieldDescription : getPrintableFields ( * c ) ) {
print_field_attr ( ostream , * fieldDescription ) ;
2016-10-20 19:53:21 +00:00
ostream < < " , " < < std : : endl ;
2015-02-26 15:02:31 +00:00
}
2016-04-06 13:23:23 +00:00
// Print an empty sentinel attribute at the end of the class.
2017-05-17 14:37:22 +00:00
FieldDescription new_fdes ( std : : string ( " " ) ) ;
2016-10-20 19:53:21 +00:00
print_field_attr ( ostream , new_fdes ) ;
ostream < < " }; " < < std : : endl ;
2015-02-26 15:02:31 +00:00
2016-10-20 19:53:21 +00:00
print_close_extern_c ( ostream ) ;
2015-02-26 15:02:31 +00:00
}
/** Prints init_attr function for each class */
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_field_init_attr_stmts ( std : : ostream & ostream , FieldDescription * fdes ,
2016-04-12 20:53:39 +00:00
ClassValues * cv , unsigned int index ) {
2015-02-26 15:02:31 +00:00
2016-10-28 19:37:12 +00:00
const std : : string className = cv - > getName ( ) ;
const std : : string mangledClassName = cv - > getMangledTypeName ( ) ;
const std : : string fieldName = fdes - > getName ( ) ;
const std : : string fullyQualifiedClassNameColons = cv - > getFullyQualifiedTypeName ( ) ;
const std : : string fullyQualifiedMangledClassNameColons = cv - > getFullyQualifiedMangledTypeName ( ) ;
const std : : string fullyQualifiedMangledClassNameUnderscores = cv - > getFullyQualifiedMangledTypeName ( " __ " ) ;
std : : ostringstream oss ;
oss < < " attr " < < fullyQualifiedMangledClassNameUnderscores < < " [ " < < index < < " ]. " ;
const std : : string prefix = oss . str ( ) ;
if ( fdes - > isStatic ( ) ) {
ostream < < prefix < < " offset = (long)(void *)& " < < fullyQualifiedClassNameColons < < " :: " < < fieldName < < " ; \n " ;
}
else if ( global_compat15 or cv - > isCompat15 ( ) ) {
if ( fdes - > isBitField ( ) ) {
ostream < < prefix < < " offset = " < < fdes - > getBitFieldByteOffset ( ) < < " ; \n " ;
ostream < < prefix < < " size = sizeof(unsigned int) ; \n " ;
2016-09-16 13:39:37 +00:00
}
2016-10-28 19:37:12 +00:00
else if ( fdes - > isVirtualInherited ( ) ) {
ostream < < prefix < < " offset = " < < fdes - > getBaseClassOffset ( ) < < " + offsetof( " < < fdes - > getContainerClass ( ) < < " , " < < fieldName < < " ) ; \n " ;
}
else if ( mangledClassName ! = className ) {
ostream < < prefix < < " offset = " < < " offsetof( " < < mangledClassName < < " , " < < fieldName < < " ) ; \n " ;
}
else {
ostream < < prefix < < " offset = " < < " offsetof( " < < fullyQualifiedMangledClassNameColons < < " , " < < fieldName < < " ) ; \n " ;
2016-10-21 14:30:55 +00:00
}
2016-04-06 13:23:23 +00:00
}
2016-10-28 19:37:12 +00:00
if ( fdes - > isSTL ( ) ) {
auto print = [ & ] ( const std : : string & field ) {
2017-05-18 13:42:40 +00:00
ostream < < prefix < < field < < " = " < < field < < " _ " < < fullyQualifiedMangledClassNameUnderscores + " _ " + sanitize ( fieldName ) + " ; \n " ;
2016-10-28 19:37:12 +00:00
} ;
2017-05-16 20:29:02 +00:00
if ( fdes - > isCheckpointable ( ) ) {
print ( " checkpoint_stl " ) ;
print ( " post_checkpoint_stl " ) ;
}
2016-10-28 19:37:12 +00:00
2017-05-16 20:29:02 +00:00
if ( fdes - > isRestorable ( ) ) {
print ( " restore_stl " ) ;
if ( fdes - > hasSTLClear ( ) ) {
print ( " clear_stl " ) ;
}
2016-03-29 14:26:49 +00:00
}
}
2016-10-28 19:37:12 +00:00
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 " ;
2015-02-26 15:02:31 +00:00
}
}
/** Prints add_attr_info statements for each inherited class */
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_inherited_add_attr_info ( std : : ostream & ostream , ClassValues * cv ) {
2016-10-28 19:37:12 +00:00
auto inheritedClasses = cv - > getInheritedClasses ( ) ;
if ( inheritedClasses . size ( ) > 0 ) {
2016-10-20 19:53:21 +00:00
ostream < < " \n ATTRIBUTES temp_attr ; \n \n " ;
2015-02-26 15:02:31 +00:00
}
2016-10-28 19:37:12 +00:00
for ( auto & inheritedClass : inheritedClasses ) {
ostream < < " trick_MM->add_attr_info( std::string( \" " < < inheritedClass < < " \" ), &temp_attr , __FILE__ , __LINE__ ) ; \n " ;
2015-02-26 15:02:31 +00:00
}
}
/** Prints init_attr function for each class */
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_init_attr_func ( std : : ostream & ostream , ClassValues * cv ) {
2016-10-28 19:37:12 +00:00
cv - > printOpenNamespaceBlocks ( ostream ) ;
ostream < < " \n void init_attr " < < cv - > getFullyQualifiedMangledTypeName ( " __ " ) < < " () { \n \n "
< < " static int initialized ; \n "
< < " if (initialized) { \n "
< < " return; \n "
< < " } \n "
< < " initialized = 1; \n \n " ;
2015-02-26 15:02:31 +00:00
2016-10-28 19:37:12 +00:00
unsigned int ii = 0 ;
2017-05-17 14:37:22 +00:00
for ( FieldDescription * field : getPrintableFields ( * cv ) ) {
print_field_init_attr_stmts ( ostream , field , cv , ii + + ) ;
2015-02-26 15:02:31 +00:00
}
2016-10-20 19:53:21 +00:00
print_inherited_add_attr_info ( ostream , cv ) ;
2016-10-21 20:05:26 +00:00
ostream < < " } \n " ;
2016-10-28 19:37:12 +00:00
cv - > printCloseNamespaceBlocks ( ostream ) ;
2015-02-26 15:02:31 +00:00
}
/** Prints the io_src_sizeof function for enumerations */
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_enum_io_src_sizeof ( std : : ostream & ostream , EnumValues * ev ) {
print_open_extern_c ( ostream ) ;
2016-10-28 19:37:12 +00:00
ostream < < " size_t io_src_sizeof_ " < < ev - > getFullyQualifiedName ( " __ " ) < < " ( void ) { \n " ;
2015-02-26 15:02:31 +00:00
if ( ev - > getHasDefinition ( ) ) {
2016-10-28 19:37:12 +00:00
ostream < < " return sizeof( " < < ev - > getFullyQualifiedName ( ) < < " ) " ;
2015-02-26 15:02:31 +00:00
} else {
2016-10-28 19:37:12 +00:00
ostream < < " return sizeof(int) " ;
2015-02-26 15:02:31 +00:00
}
2016-10-28 19:37:12 +00:00
ostream < < " ; \n } \n " ;
2016-10-20 19:53:21 +00:00
print_close_extern_c ( ostream ) ;
2015-02-26 15:02:31 +00:00
}
/** Prints the C linkage init_attr function */
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_init_attr_c_intf ( std : : ostream & ostream , ClassValues * cv ) {
2016-10-28 19:37:12 +00:00
ostream < < " void init_attr " < < cv - > getFullyQualifiedMangledTypeName ( " __ " ) < < " _c_intf() { \n " ;
cv - > printNamespaces ( ostream , " :: " ) ;
ostream < < " init_attr " < < cv - > getFullyQualifiedMangledTypeName ( " __ " ) < < " () ; \n "
< < " } \n \n " ;
2015-02-26 15:02:31 +00:00
}
/** Prints the io_src_sizeof function */
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_io_src_sizeof ( std : : ostream & ostream , ClassValues * cv ) {
2016-10-28 19:37:12 +00:00
ostream < < " size_t io_src_sizeof_ " < < cv - > getFullyQualifiedMangledTypeName ( " __ " ) < < " () { \n " ;
ostream < < " return sizeof( " < < cv - > getFullyQualifiedNameIfEqual ( ) < < " ) ; \n } \n \n " ;
2015-02-26 15:02:31 +00:00
}
/** Prints the io_src_allocate function */
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_io_src_allocate ( std : : ostream & ostream , ClassValues * cv ) {
2016-10-28 19:37:12 +00:00
if ( cv - > isPOD ( ) or ( ! cv - > isAbstract ( ) and cv - > getHasDefaultConstructor ( ) ) ) {
const std : : string name = cv - > getFullyQualifiedNameIfEqual ( ) ;
ostream < < " void* io_src_allocate_ " < < cv - > getFullyQualifiedMangledTypeName ( " __ " ) < < " (int num) { \n " ;
ostream < < " " < < name < < " * temp = ( " < < name < < " *)calloc(num, sizeof( " < < name < < " )); \n " ;
2015-02-26 15:02:31 +00:00
if ( ! cv - > isPOD ( ) ) {
2016-10-28 19:37:12 +00:00
ostream < < " for (int ii = 0; ii < num; ++ii) { \n " ;
ostream < < " new(&temp[ii]) " < < name < < " (); \n } \n " ;
2015-02-26 15:02:31 +00:00
}
2016-10-28 19:37:12 +00:00
ostream < < " return (void*)temp; \n " < < " } \n \n " ;
2015-02-26 15:02:31 +00:00
}
}
/** Prints the io_src_allocate function */
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_io_src_destruct ( std : : ostream & ostream , ClassValues * cv ) {
2016-10-28 19:37:12 +00:00
if ( cv - > getHasPublicDestructor ( ) ) {
ostream < < " void io_src_destruct_ " < < cv - > getFullyQualifiedMangledTypeName ( " __ " ) < < " (void* address __attribute__((unused)), int num __attribute__((unused))) { \n " ;
2015-02-26 15:02:31 +00:00
if ( ! cv - > isPOD ( ) ) {
// Add a using statement so we can call the destructor without fully qualifying it.
2016-10-28 19:37:12 +00:00
auto namespaces = cv - > getNamespaces ( ) ;
if ( namespaces . size ( ) ) {
2016-10-20 19:53:21 +00:00
ostream < < " using namespace " ;
2016-10-28 19:37:12 +00:00
auto last = namespaces [ namespaces . size ( ) - 1 ] ;
for ( auto & name : namespaces ) {
ostream < < name ;
if ( name ! = last ) {
ostream < < " :: " ;
2015-02-26 15:02:31 +00:00
}
}
2016-10-28 19:37:12 +00:00
ostream < < " ; \n " ;
2015-02-26 15:02:31 +00:00
}
2016-10-28 19:37:12 +00:00
const std : : string name = cv - > getName ( ) ;
const std : : string qualifiedName = cv - > getFullyQualifiedNameIfEqual ( ) ;
ostream < < qualifiedName < < " * temp = ( " < < qualifiedName < < " *)address; \n " ;
if ( cv - > getMangledTypeName ( ) = = name ) {
ostream < < " for (int ii = 0; ii < num; ++ii) { \n "
< < " temp[ii].~ " < < name < < " (); \n "
< < " } \n " ;
2015-02-26 15:02:31 +00:00
}
}
2016-10-20 19:53:21 +00:00
ostream < < " } \n \n " ;
2015-02-26 15:02:31 +00:00
}
}
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_io_src_delete ( std : : ostream & ostream , ClassValues * cv ) {
2016-10-28 19:37:12 +00:00
if ( cv - > getHasPublicDestructor ( ) ) {
ostream < < " void io_src_delete_ " < < cv - > getFullyQualifiedMangledTypeName ( " __ " ) < < " (void* address " ;
2015-02-26 15:02:31 +00:00
if ( ! cv - > isPOD ( ) ) {
2016-10-28 19:37:12 +00:00
ostream < < " ) { \n delete ( " < < cv - > getFullyQualifiedNameIfEqual ( ) < < " *)address; \n " ;
2016-10-20 19:53:21 +00:00
}
else {
2016-10-28 19:37:12 +00:00
ostream < < " __attribute__((unused))) { " ;
2015-02-26 15:02:31 +00:00
}
2016-10-20 19:53:21 +00:00
ostream < < " } \n " ;
2015-02-26 15:02:31 +00:00
}
}
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_checkpoint_stl ( std : : ostream & ostream , FieldDescription * fdes , ClassValues * cv ) {
2016-10-28 19:37:12 +00:00
printStlFunction ( " checkpoint " , " void* start_address, const char* obj_name , const char* var_name " , " checkpoint_stl(*stl, obj_name, var_name) " , ostream , * fdes , * cv ) ;
2016-03-29 14:26:49 +00:00
}
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_post_checkpoint_stl ( std : : ostream & ostream , FieldDescription * fdes , ClassValues * cv ) {
2016-10-28 19:37:12 +00:00
printStlFunction ( " post_checkpoint " , " void* start_address, const char* obj_name , const char* var_name " , " delete_stl(*stl, obj_name, var_name) " , ostream , * fdes , * cv ) ;
2016-03-29 14:26:49 +00:00
}
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_restore_stl ( std : : ostream & ostream , FieldDescription * fdes , ClassValues * cv ) {
2016-10-28 19:37:12 +00:00
printStlFunction ( " restore " , " void* start_address, const char* obj_name , const char* var_name " , " restore_stl(*stl, obj_name, var_name) " , ostream , * fdes , * cv ) ;
2016-03-29 14:26:49 +00:00
}
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_clear_stl ( std : : ostream & ostream , FieldDescription * fdes , ClassValues * cv ) {
2016-10-28 19:37:12 +00:00
printStlFunction ( " clear " , " void* start_address " , " stl->clear() " , ostream , * fdes , * cv ) ;
2016-03-29 14:26:49 +00:00
}
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : print_stl_helper ( std : : ostream & ostream , ClassValues * cv ) {
2017-05-17 14:37:22 +00:00
std : : vector < FieldDescription * > fieldDescriptions = getPrintableFields ( * cv , 0x3 < < 2 ) ;
fieldDescriptions . erase ( std : : remove_if ( fieldDescriptions . begin ( ) , fieldDescriptions . end ( ) , [ ] ( FieldDescription * field ) { return ! field - > isSTL ( ) ; } ) , fieldDescriptions . end ( ) ) ;
2016-10-28 19:37:12 +00:00
if ( ! fieldDescriptions . size ( ) ) {
return ;
}
print_open_extern_c ( ostream ) ;
2016-03-29 14:26:49 +00:00
2017-05-17 14:37:22 +00:00
for ( FieldDescription * field : fieldDescriptions ) {
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 ) ;
2016-03-29 14:26:49 +00:00
}
}
}
2016-10-20 19:53:21 +00:00
2016-10-28 19:37:12 +00:00
print_close_extern_c ( ostream ) ;
2016-03-29 14:26:49 +00:00
}
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : printClass ( std : : ostream & ostream , ClassValues * cv ) {
print_class_attr ( ostream , cv ) ;
print_stl_helper ( ostream , cv ) ;
print_init_attr_func ( ostream , cv ) ;
ostream < < std : : endl ;
print_open_extern_c ( ostream ) ;
print_init_attr_c_intf ( ostream , cv ) ;
print_io_src_sizeof ( ostream , cv ) ;
print_io_src_allocate ( ostream , cv ) ;
print_io_src_destruct ( ostream , cv ) ;
print_io_src_delete ( ostream , cv ) ;
print_close_extern_c ( ostream ) ;
print_units_map ( ostream , cv ) ;
2015-02-26 15:02:31 +00:00
}
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : printEnum ( std : : ostream & ostream , EnumValues * ev ) {
print_enum_attr ( ostream , ev ) ;
print_enum_io_src_sizeof ( ostream , ev ) ;
2015-02-26 15:02:31 +00:00
}
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : printClassMapHeader ( std : : ostream & ostream , std : : string function_name ) {
ostream < <
2015-02-26 15:02:31 +00:00
" /* \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 " ;
}
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : printClassMap ( std : : ostream & ostream , ClassValues * cv ) {
2016-10-28 19:37:12 +00:00
std : : string name = cv - > getFullyQualifiedMangledTypeName ( " __ " ) ;
ostream < < " // " < < cv - > getFileName ( ) < < std : : endl
< < " extern ATTRIBUTES attr " < < name < < " [] ; " < < std : : endl
< < " class_attribute_map->add_attr( \" " < < cv - > getFullyQualifiedMangledTypeName ( ) < < " \" , attr " < < name < < " ) ; " < < std : : endl ;
2015-02-26 15:02:31 +00:00
}
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : printClassMapFooter ( std : : ostream & ostream ) {
ostream < < " } " < < std : : endl < < std : : endl ;
2015-02-26 15:02:31 +00:00
}
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : printEnumMapHeader ( std : : ostream & ostream , std : : string function_name ) {
2016-10-28 19:37:12 +00:00
ostream < < " void " < < function_name < < " () { \n "
< < " Trick::EnumAttributesMap* enum_attribute_map __attribute__((unused)) = Trick::EnumAttributesMap::attributes_map(); \n \n " ;
2015-02-26 15:02:31 +00:00
}
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : printEnumMap ( std : : ostream & ostream , EnumValues * ev ) {
2016-10-28 19:37:12 +00:00
std : : string name = ev - > getFullyQualifiedTypeName ( " __ " ) ;
ostream < < " extern ENUM_ATTR enum " < < name < < " []; " < < std : : endl
< < " enum_attribute_map->add_attr( \" " < < ev - > getFullyQualifiedTypeName ( ) < < " \" , enum " < < name < < " ); " < < std : : endl ;
2015-02-26 15:02:31 +00:00
}
2016-10-20 19:53:21 +00:00
void PrintFileContents10 : : printEnumMapFooter ( std : : ostream & ostream ) {
ostream < < " } " < < std : : endl < < std : : endl ;
2015-02-26 15:02:31 +00:00
}
2016-10-28 19:37:12 +00:00
void PrintFileContents10 : : printStlFunction ( const std : : string & name , const std : : string & parameters , const std : : string & call , std : : ostream & ostream , FieldDescription & fieldDescription , ClassValues & classValues ) {
const std : : string typeName = fieldDescription . getTypeName ( ) ;
const std : : string functionName = name + " _stl " ;
2017-05-18 13:42:40 +00:00
ostream < < " void " < < functionName < < " _ " < < classValues . getFullyQualifiedMangledTypeName ( " __ " ) < < " _ " < < sanitize ( fieldDescription . getName ( ) )
2016-10-28 19:37:12 +00:00
< < " ( " < < parameters < < " ) { " < < std : : endl
< < " " < < typeName < < " * stl = reinterpret_cast< " < < typeName < < " *>(start_address); " < < std : : endl
< < " " < < call < < " ; " < < std : : endl
< < " } " < < std : : endl ;
}