// CPPTypeBitfield.cpp: Implementation for Bitfield type modifier.
#include "CPPType.h"
#include "CPPTypeBitfield.h"
#include "stdio.h"
/////////////////////////////////////////////////////////////////////////
// ctor/dtor
/////////////////////////////////////////////////////////////////////////
CPPTypeBitfield::CPPTypeBitfield(
CPPTypeRefI baseType_,
int fieldlen_,
bool addToBase
) :
CPPTypeModifier(Bitfield, baseType_),
fieldlen(fieldlen_)
{
assert(baseType_.get() != 0);
if (addToBase)
{
AddToBase();
}
}
//virtual
CPPTypeBitfield::~CPPTypeBitfield()
{
assertValid();
RemoveFromBase();
}
/////////////////////////////////////////////////////////////////
// FormatName: Format the name of the type, using the names of the
// modified types where needed to construct the full type name.
//
// Inputs:
// const JLStr& declName If non-empty, then this is used
// to format the declarator name
// in the proper position.
// const JLStr& suffixStr Any accumulated suffix string
// bool forSpecialization
// If true, then the name is formatted
// to be suitable in constructing a
// specialization scope.
// Return:
// JLStr The formatted type name
/////////////////////////////////////////////////////////////////
// virtual
JLStr
CPPTypeBitfield::FormatName(
const JLStr& declName,
const JLStr& suffixStr,
StrListRefI,
bool forSpecialization
) const
{
assertValid();
char buf[20];
sprintf(buf, ": %d", fieldlen);
return GetBaseType()->FormatName(
declName,
buf + suffixStr,
StrListRefI(),
forSpecialization
);
}