summaryrefslogtreecommitdiff
path: root/build-aux/qmi-codegen/VariableFactory.py
AgeCommit message (Collapse)AuthorFilesLines
2012-09-26qmi-codegen: don't issue the array element clear function on 'Input' arraysAleksander Morgado1-4/+4
When an array is required to be passed in an input TLV, the user who created it is responsible for freeing it. Therefore, we should not dump the static array element clear function in these cases, or these unused methods will end up breaking the compilation.
2012-07-03qmi-codegen: new `sequence' variable typeAleksander Morgado1-0/+3
The `sequence' variable types are defined in the same way as `struct' types, but the generated implementation is completely different: * Struct TLVs will generate public struct types, and the getter/setter methods will pass a single variable of that new struct type. * Sequence TLVs will not generate any new public nor private type. The getter and setter methods will pass N items, one for each member of the sequence. It should be safe to do so and maintain API/ABI compatibility afterwards, as existing TLVs are not expected to change.
2012-07-03qmi-codegen: refactor, don't use internal packed structs to match TLVsAleksander Morgado1-0/+42
This is a huge refactor to avoid using internal packed structs to match TLVs from a raw byte buffer. There are cases where packed structs do not help, for example when two variable-length fields (like strings) are found in the same TLV. Instead of packed structs, we'll read basic types one by one directly from the raw byte buffer. With this new logic, struct and array variables are no more than containers of other basic types. Each basic type, implemented as objects inheriting from a base Variable type, knows how to read/write from/to the raw buffer. Therefore, reading a struct is just about reading one by one each of the fields in the struct; and reading an array is just about providing a loop to read all the array elements one by one. This greatly simplifies reading basic types like integers, as the implementation is kept in a single place, regardless of having the integer as the only field in the TLV or as a field of a struct TLV or as an element of an array TLV. Strings are treated a bit differently. In string TLVs, the string is to be considered to be as long as the TLV value itself. In struct TLVs with string fields, the string is assumed to have a 1-byte length prefix which specifies the length of the string field within the TLV.