ICG exclude of class member variables now defines incorrect memory offsets in io_src #311

Added back the code that set the offset of variables with the offsetof function. This
code is running by default.  Any code that includes #ifndef TRICK_ICG in
classes/structures will want this on.

Added a flag to ICG that allows us to turn off writing of these lines.  If the flag
is present, ICG may write out io_src code for private/protected variables that it could
not reach if an offsetof function was required.  Code cannot have any #ifndef TRICK_ICG
present in classes/structures for this to work.
This commit is contained in:
Alex Lin
2016-09-16 08:39:37 -05:00
parent c4a32600cc
commit ae07b26243
8 changed files with 116 additions and 15 deletions

View File

@ -38,7 +38,8 @@ void ClassValues::addFieldDescription(FieldDescription * in_fdes) {
field_name_to_info_map[in_fdes->getName()] = in_fdes ;
}
void ClassValues::addInheritedFieldDescriptions(std::vector<FieldDescription *> in_fdes, unsigned int class_offset ) {
void ClassValues::addInheritedFieldDescriptions(std::vector<FieldDescription *> in_fdes,
unsigned int class_offset, bool virtual_inherited ) {
// Make a copy of all of the FieldDescription variables.
field_descripts.insert(field_descripts.end(), in_fdes.begin() , in_fdes.end()) ;
@ -46,7 +47,9 @@ void ClassValues::addInheritedFieldDescriptions(std::vector<FieldDescription *>
// Loop through the incoming inherited variable names
for ( fdit = in_fdes.begin() ; fdit != in_fdes.end() ; fdit++ ) {
(*fdit)->setBaseClassOffset( class_offset ) ;
(*fdit)->setInherited( true ) ;
(*fdit)->setVirtualInherited( virtual_inherited ) ;
// Adds the class offset to the field offset giving the total offset to the inherited variable
// The offset is stored in bits so multiply class_offset by 8.
(*fdit)->addOffset( class_offset * 8 ) ;