zserio
zserio copied to clipboard
Define types for the mapping of zserio types to c++ types
There are rules that define what zserio fundamental type is mapped to what c++/java/python type. For code maintainability, it is better that the mapped types are not used directly. Instead there should be a typedef for every mapped type in the proper namespace in the emitted code.
See https://github.com/ndsev/zserio/blob/master/doc/ZserioTypesMapping.md#base-types The idea would be to create a type definition in the emitted code for every mentioned Zserio type (first column of the table). And use these type definitions in the generated code (for example in the getXXX() and setXXX() methods for a field called XXX in a zserio struct).
For example:
Zserio should emit a typedef for 'varint':
namespace zserio
{
typedef int64_t varint;
}
And given the following struct definition:
struct Data
{
varint x;
};
We should get something like the following:
class Data
{
zserio::varsize getX();
};
instead of:
class Data
{
int64_t getX();
};
As a workaround, schema authors could probably use subtype
command.
Consider to use strong typedefs. Please also see #555.