1) Read useful info on following websites:
RNA, Property, DataApi.
2) On this websites blender guys give description how they are creating their gui. Description is not very easy to understand, but following sentences gave me an idea, what is wrong, when I try to convert button from short to int.
More later about saving and loading, what we have to be careful about in the DNA files is alignment. For compatibility between different compilers and platforms, all members must be aligned correctly. The general rule is that if the size of some member variable is n, it must be defined starting at a location in the struct that is a multiple of n. For example ints must be defined at locations that are a multiple of 4. Structs must be created at locations that are a multiple of 8. If for some reason this does not work out, padding variables can be added in between (usually named pad, pad1, ..). Alignment errors in DNA structs will be printed during compilation.
This is exactly the error, which I was getting, when building the program with my changes.
Align 4 error (32 bit) in struct: Object col (add 2 padding bytes)
Then I have noticed that all over the code in the "DNA_object_types.h" developers were adding padding variables (void pad, char pad1, char pad2...) for the aligning of the memory.
3) So when you create additional property or variable in DNA, you should align it properly. More on alignment you can find in the file "dna_genfile.c".
- do not use #defines in structs for array lengths, this cannot be read by the dna functions
- do not use uint, but unsigned int instead, ushort and ulong are allowed
- only use a long in Blender if you want this to be the size of a pointer. so it is 32 bits or 64 bits, dependent at the cpu architecture
- chars are always unsigned
- alignment of variables has to be done in such a way, that any system does not create 'padding' (gaps) in structures. So make sure that:
- short: 2 aligned
- int: 4 aligned
- float: 4 aligned
- double: 8 aligned
- long: 8 aligned
- struct: 8 aligned
- the sdna functions have several error prints builtin, always check blender running from a console.
After I have added padding variable, "Pass index" was finally converted from short to int.