mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -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;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
| instance_identifier ':' INTEGER
|
| instance_identifier ':' const_expr
|
||||||
{
|
{
|
||||||
// Bitfield definition.
|
// Bitfield definition.
|
||||||
$1->_bit_width = $3;
|
$1->_bit_width = $3;
|
||||||
|
@ -74,7 +74,17 @@ CPPInstance(CPPType *type, CPPInstanceIdentifier *ii, int storage_class,
|
|||||||
ii->_ident = nullptr;
|
ii->_ident = nullptr;
|
||||||
_storage_class = storage_class;
|
_storage_class = storage_class;
|
||||||
_initializer = nullptr;
|
_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();
|
CPPParameterList *params = ii->get_initializer();
|
||||||
if (params != nullptr) {
|
if (params != nullptr) {
|
||||||
|
@ -82,7 +82,7 @@ initializer_type(CPPParameterList *params) {
|
|||||||
CPPInstanceIdentifier::
|
CPPInstanceIdentifier::
|
||||||
CPPInstanceIdentifier(CPPIdentifier *ident) :
|
CPPInstanceIdentifier(CPPIdentifier *ident) :
|
||||||
_ident(ident),
|
_ident(ident),
|
||||||
_bit_width(-1),
|
_bit_width(nullptr),
|
||||||
_packed(false) {
|
_packed(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,8 +86,8 @@ public:
|
|||||||
typedef std::vector<Modifier> Modifiers;
|
typedef std::vector<Modifier> Modifiers;
|
||||||
Modifiers _modifiers;
|
Modifiers _modifiers;
|
||||||
|
|
||||||
// If not -1, indicates a bitfield
|
// If not null, indicates a bitfield
|
||||||
int _bit_width;
|
CPPExpression *_bit_width;
|
||||||
|
|
||||||
// Indicates a parameter pack
|
// Indicates a parameter pack
|
||||||
bool _packed;
|
bool _packed;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user