mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
cppparser: support arbitrary constant expression in bitfields
This commit is contained in:
parent
2880525c1e
commit
97e6a314b1
@ -1891,7 +1891,7 @@ instance_identifier_and_maybe_trailing_return_type:
|
||||
}
|
||||
$$ = $1;
|
||||
}
|
||||
| instance_identifier ':' INTEGER
|
||||
| instance_identifier ':' const_expr
|
||||
{
|
||||
// Bitfield definition.
|
||||
$1->_bit_width = $3;
|
||||
|
@ -74,7 +74,17 @@ CPPInstance(CPPType *type, CPPInstanceIdentifier *ii, int storage_class,
|
||||
ii->_ident = nullptr;
|
||||
_storage_class = storage_class;
|
||||
_initializer = nullptr;
|
||||
_bit_width = ii->_bit_width;
|
||||
|
||||
if (ii->_bit_width != nullptr) {
|
||||
CPPExpression::Result result = ii->_bit_width->evaluate();
|
||||
if (result._type != CPPExpression::RT_error) {
|
||||
_bit_width = ii->_bit_width->evaluate().as_integer();
|
||||
} else {
|
||||
_bit_width = -1;
|
||||
}
|
||||
} else {
|
||||
_bit_width = -1;
|
||||
}
|
||||
|
||||
CPPParameterList *params = ii->get_initializer();
|
||||
if (params != nullptr) {
|
||||
|
@ -82,7 +82,7 @@ initializer_type(CPPParameterList *params) {
|
||||
CPPInstanceIdentifier::
|
||||
CPPInstanceIdentifier(CPPIdentifier *ident) :
|
||||
_ident(ident),
|
||||
_bit_width(-1),
|
||||
_bit_width(nullptr),
|
||||
_packed(false) {
|
||||
}
|
||||
|
||||
|
@ -86,8 +86,8 @@ public:
|
||||
typedef std::vector<Modifier> Modifiers;
|
||||
Modifiers _modifiers;
|
||||
|
||||
// If not -1, indicates a bitfield
|
||||
int _bit_width;
|
||||
// If not null, indicates a bitfield
|
||||
CPPExpression *_bit_width;
|
||||
|
||||
// Indicates a parameter pack
|
||||
bool _packed;
|
||||
|
Loading…
x
Reference in New Issue
Block a user