Closed amirgon closed 2 years ago
Summary so far:
__getitem__
, __setitem__
, __delitem__
s.field = 1
) or through the "subscript operator" (s[17].field = 1
).s == s[0]
, s[0] != s[1]
, s[10][20] == s[30]
, etc.char **
are converted to C_Pointer
Struct which provides str_val
and therefore provides a string array (with the subscript operator)int
types (8bit, 16bit, 32bit and 64bit). They are represented by a new C_Array
type which implements the "subscript operator" to access the integer values. Native arrays can be created from Python lists. Native arrays, as Structs, are convertible to Pointer (Blob
).len
operator is not implemented and the array don't provide iterator (since we don't know when to stop).del arr[17]
) simply memsets the array element at that position to 0.C_Array
constructor is not provided explicitly. The user would usually works with Python lists, which would be converted to C_Array
when needed. On the other direction, a C array usually cannot be converted to Python list because its size is not known, therefore either a Struct or a C_Array
are returned instead of a Python list when accessing a C pointer.
This allows creating and accessing arrays of structs, using Python subscript operator. Every struct actually becomes an array (with size 1 by default)
Related: https://github.com/lvgl/lvgl/pull/2565#issuecomment-922049390