diff --git a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp index fa8d76a0..a4d613d8 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp @@ -443,6 +443,14 @@ void FieldDescription::setBitFieldWidth(unsigned int len) { bitfield_width = len ; } +void FieldDescription::setBitFieldStart(unsigned int sb) { + bitfield_start_bit = sb ; +} + +void FieldDescription::setBitFieldByteOffset(unsigned int wo) { + bitfield_word_offset = wo ; +} + unsigned int FieldDescription::getBitFieldWidth() { return bitfield_width ; } diff --git a/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh b/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh index 0f2a68ef..8c59f763 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh +++ b/trick_source/codegen/Interface_Code_Gen/FieldDescription.hh @@ -62,6 +62,8 @@ class FieldDescription : public ConstructValues { std::string getEnumString() ; void setBitField( bool yes_no ) ; void setBitFieldWidth( unsigned int len ) ; + void setBitFieldStart( unsigned int len ) ; + void setBitFieldByteOffset( unsigned int len ) ; unsigned int getBitFieldWidth() ; unsigned int getBitFieldStart() ; unsigned int getBitFieldByteOffset() ; diff --git a/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp b/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp index f6e29c75..aaf3002a 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp @@ -215,6 +215,9 @@ bool FieldVisitor::VisitFieldDecl( clang::FieldDecl *field ) { if ( field->isBitField()) { fdes->setBitField(true) ; fdes->setBitFieldWidth(field->getBitWidthValue(field->getASTContext())) ; + unsigned int field_offset_bits = field->getASTContext().getFieldOffset(field) + fdes->getBaseClassOffset() * 8 ; + fdes->setBitFieldStart( 32 - (field_offset_bits % 32) - fdes->getBitFieldWidth()) ; + fdes->setBitFieldByteOffset((field_offset_bits / 32) * 4 ) ; } if ( debug_level >= 3 ) {