Replace empty arrays with NULL

Relates to cherrypicker/unl0kr#18
This commit is contained in:
Johannes Marbach 2021-09-22 20:39:55 +02:00
parent 5faaf14831
commit 01c343b96c
4 changed files with 24 additions and 54 deletions

View file

@ -33,9 +33,7 @@ static const lv_btnmatrix_ctrl_t attributes_lower_de[] = { \
static const int num_modifiers_lower_de = 0;
static const int modifier_idxs_lower_de[] = { \
\
};
static const int * const modifier_idxs_lower_de = NULL;
static const int num_switchers_lower_de = 3;
@ -67,9 +65,7 @@ static const lv_btnmatrix_ctrl_t attributes_upper_de[] = { \
static const int num_modifiers_upper_de = 0;
static const int modifier_idxs_upper_de[] = { \
\
};
static const int * const modifier_idxs_upper_de = NULL;
static const int num_switchers_upper_de = 3;
@ -101,9 +97,7 @@ static const lv_btnmatrix_ctrl_t attributes_numbers_de[] = { \
static const int num_modifiers_numbers_de = 0;
static const int modifier_idxs_numbers_de[] = { \
\
};
static const int * const modifier_idxs_numbers_de = NULL;
static const int num_switchers_numbers_de = 2;
@ -135,9 +129,7 @@ static const lv_btnmatrix_ctrl_t attributes_special_de[] = { \
static const int num_modifiers_special_de = 0;
static const int modifier_idxs_special_de[] = { \
\
};
static const int * const modifier_idxs_special_de = NULL;
static const int num_switchers_special_de = 3;

View file

@ -33,9 +33,7 @@ static const lv_btnmatrix_ctrl_t attributes_lower_es[] = { \
static const int num_modifiers_lower_es = 0;
static const int modifier_idxs_lower_es[] = { \
\
};
static const int * const modifier_idxs_lower_es = NULL;
static const int num_switchers_lower_es = 3;
@ -67,9 +65,7 @@ static const lv_btnmatrix_ctrl_t attributes_upper_es[] = { \
static const int num_modifiers_upper_es = 0;
static const int modifier_idxs_upper_es[] = { \
\
};
static const int * const modifier_idxs_upper_es = NULL;
static const int num_switchers_upper_es = 3;
@ -101,9 +97,7 @@ static const lv_btnmatrix_ctrl_t attributes_numbers_es[] = { \
static const int num_modifiers_numbers_es = 0;
static const int modifier_idxs_numbers_es[] = { \
\
};
static const int * const modifier_idxs_numbers_es = NULL;
static const int num_switchers_numbers_es = 2;
@ -135,9 +129,7 @@ static const lv_btnmatrix_ctrl_t attributes_special_es[] = { \
static const int num_modifiers_special_es = 0;
static const int modifier_idxs_special_es[] = { \
\
};
static const int * const modifier_idxs_special_es = NULL;
static const int num_switchers_special_es = 3;
@ -223,9 +215,7 @@ static const lv_btnmatrix_ctrl_t attributes_lower_fr[] = { \
static const int num_modifiers_lower_fr = 0;
static const int modifier_idxs_lower_fr[] = { \
\
};
static const int * const modifier_idxs_lower_fr = NULL;
static const int num_switchers_lower_fr = 3;
@ -257,9 +247,7 @@ static const lv_btnmatrix_ctrl_t attributes_upper_fr[] = { \
static const int num_modifiers_upper_fr = 0;
static const int modifier_idxs_upper_fr[] = { \
\
};
static const int * const modifier_idxs_upper_fr = NULL;
static const int num_switchers_upper_fr = 3;
@ -291,9 +279,7 @@ static const lv_btnmatrix_ctrl_t attributes_numbers_fr[] = { \
static const int num_modifiers_numbers_fr = 0;
static const int modifier_idxs_numbers_fr[] = { \
\
};
static const int * const modifier_idxs_numbers_fr = NULL;
static const int num_switchers_numbers_fr = 2;
@ -325,9 +311,7 @@ static const lv_btnmatrix_ctrl_t attributes_special_fr[] = { \
static const int num_modifiers_special_fr = 0;
static const int modifier_idxs_special_fr[] = { \
\
};
static const int * const modifier_idxs_special_fr = NULL;
static const int num_switchers_special_fr = 3;
@ -413,9 +397,7 @@ static const lv_btnmatrix_ctrl_t attributes_lower_us[] = { \
static const int num_modifiers_lower_us = 0;
static const int modifier_idxs_lower_us[] = { \
\
};
static const int * const modifier_idxs_lower_us = NULL;
static const int num_switchers_lower_us = 2;
@ -447,9 +429,7 @@ static const lv_btnmatrix_ctrl_t attributes_upper_us[] = { \
static const int num_modifiers_upper_us = 0;
static const int modifier_idxs_upper_us[] = { \
\
};
static const int * const modifier_idxs_upper_us = NULL;
static const int num_switchers_upper_us = 2;
@ -481,9 +461,7 @@ static const lv_btnmatrix_ctrl_t attributes_numbers_us[] = { \
static const int num_modifiers_numbers_us = 0;
static const int modifier_idxs_numbers_us[] = { \
\
};
static const int * const modifier_idxs_numbers_us = NULL;
static const int num_switchers_numbers_us = 1;

View file

@ -33,9 +33,7 @@ static const lv_btnmatrix_ctrl_t attributes_lower_us[] = { \
static const int num_modifiers_lower_us = 0;
static const int modifier_idxs_lower_us[] = { \
\
};
static const int * const modifier_idxs_lower_us = NULL;
static const int num_switchers_lower_us = 2;
@ -67,9 +65,7 @@ static const lv_btnmatrix_ctrl_t attributes_upper_us[] = { \
static const int num_modifiers_upper_us = 0;
static const int modifier_idxs_upper_us[] = { \
\
};
static const int * const modifier_idxs_upper_us = NULL;
static const int num_switchers_upper_us = 2;
@ -101,9 +97,7 @@ static const lv_btnmatrix_ctrl_t attributes_numbers_us[] = { \
static const int num_modifiers_numbers_us = 0;
static const int modifier_idxs_numbers_us[] = { \
\
};
static const int * const modifier_idxs_numbers_us = NULL;
static const int num_switchers_numbers_us = 1;

View file

@ -224,6 +224,11 @@ class SourceFileBuilder(object):
array_terminator -- element to append to the last row
"""
prefix = 'static ' if static else ''
if not values or not values[0]:
self.add_line(f'{prefix}{type} * const {identifier} = NULL;')
return self
self.add_line(f'{prefix}{type} {identifier}[] = ' + '{ \\')
for i, values_in_row in enumerate(values):
elements = values_in_row
@ -234,6 +239,7 @@ class SourceFileBuilder(object):
joined = ', '.join([f'{e}' for e in elements])
self.add_line(f' {joined}{comma_if_needed(values, i)} \\')
self.add_line('};')
return self
def add_flat_array(self, static, type, identifier, values, array_terminator):