PROBLEM
- We want to use the types that provide the best fit for the valid range of our components property.
- Say we have a property that represents a quantity that is always > 0, we want it to be declared as an unsigned integer
- We declare a member
m_prop of type say uint32_t
- This property must then declared in the XPCF configuration file as
uint.
Our problem is that after some code reviews, we noticed that sometimes signed integer types have been used.
We want to be able to change the type to unsigned integer in the code, but we want to ensure that all occurence of these property declarations in XPCF configuration files also set the type to uint, otherwise unexpected behavior can happen if a confiuration file set the value to a negative integer value.
This is tedious work, and we could expect XPCF to striclty enforce type compatiblity automatically for us.
But from what I tested:
- No error is raised if a property is declared as
uint32_t in code and as int in configuration file
- No error is raised if a property is declared as
uint in the configuration file and a negative value is set to it.
SUGGESTED SOLUTION
Would it be technically feasible to:
- Ensure
declareProperty binds equivalent types (signed with signed, unsigned with unsigned) and raises an error if types do not match?
- Raise an error if a negative value is set to a property declared as
uint in a configuration file?
Thanks.
PROBLEM
m_propof type sayuint32_tuint.Our problem is that after some code reviews, we noticed that sometimes signed integer types have been used.
We want to be able to change the type to unsigned integer in the code, but we want to ensure that all occurence of these property declarations in XPCF configuration files also set the type to
uint, otherwise unexpected behavior can happen if a confiuration file set the value to a negative integer value.This is tedious work, and we could expect XPCF to striclty enforce type compatiblity automatically for us.
But from what I tested:
uint32_tin code and asintin configuration fileuintin the configuration file and a negative value is set to it.SUGGESTED SOLUTION
Would it be technically feasible to:
declarePropertybinds equivalent types (signed with signed, unsigned with unsigned) and raises an error if types do not match?uintin a configuration file?Thanks.