At this moment makesdna
doesn’t support enum
fields. As a result, the DNA structs have a lot of int
, short
, and char
fields that actually take predefined values from some enumeration. The problem is that it’s often not that clear, at least not at first sight, which values are supposed to go into which field.
Just to name one concrete example, the Object
struct in DNA_object_types.h
has a field int mode
. There is no comment that explains what should go in there, and it’s left as an exercise for the reader to discover there is DNA_object_enums.h
with an eObjectMode
enum. Ok, the enum itself has a comment /** #Object.mode */
above it, so there is a pointer from the enum to the property that uses it, but not the opposite way. The compiler or an IDE of course has no idea that these two (the int mode
field and the enum eObjectMode
) are related at all.
I think that using enums more widely in Blender’s code base will make it easier to understand for humans, and also will allow compilers to help us developers more.
Since for C an enum
field is just treated as an int
, I would suggest to add enum support to makesdna
. I don’t know much about makesdna
, but as it parses text, I don’t think it should be too hard to just have it interpret enum eSomeEnumType
as an alias for int
.
@ideasman42, @mont29, what do you think?