diff options
author | Xiang Xiao <xiaoxiang@xiaomi.com> | 2021-03-31 12:31:56 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-31 19:31:56 +0200 |
commit | 07a9b3232d3853cdca523bdd4ad0018d48812039 (patch) | |
tree | bb01890e08bb1eeb5b662e112d00413bb8397501 /scripts/style_api_gen.py | |
parent | ed7aee668d8fe0402ab9d70fe9051ceffcf13ce2 (diff) | |
download | lvgl-07a9b3232d3853cdca523bdd4ad0018d48812039.tar.gz lvgl-07a9b3232d3853cdca523bdd4ad0018d48812039.zip |
fix(style_api_gen.py) extract style_get_cast and style_set_cast (#2174)
Diffstat (limited to 'scripts/style_api_gen.py')
-rwxr-xr-x | scripts/style_api_gen.py | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/scripts/style_api_gen.py b/scripts/style_api_gen.py index a460f54f4..79b9edd52 100755 --- a/scripts/style_api_gen.py +++ b/scripts/style_api_gen.py @@ -87,9 +87,14 @@ props = [ {'name': 'ARC_IMG_SRC', 'style_type': 'ptr', 'var_type': 'const void *' }, ] +def style_get_cast(style_type, var_type): + cast = "" + if style_type != 'color': + cast = "(" + var_type + ")" + return cast + def obj_style_get(p): - is_struct = p['style_type'] == 'color' - cast = "(" + p['var_type'] + ")" if not is_struct else "" + cast = style_get_cast(p['style_type'], p['var_type']) print("static inline " + p['var_type'] + " lv_obj_get_style_" + p['name'].lower() +"(const struct _lv_obj_t * obj, uint32_t part)") print("{") print(" lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_" + p['name'] + ");") @@ -97,29 +102,29 @@ def obj_style_get(p): print("}") print("") -def get_func_cast(style): - func_cast = "" - if style == 'num': - func_cast = "(int32_t)" - return func_cast +def style_set_cast(style_type): + cast = "" + if style_type == 'num': + cast = "(int32_t)" + return cast def style_set(p): - func_cast = get_func_cast(p['style_type']) + cast = style_set_cast(p['style_type']) print("static inline void lv_style_set_" + p['name'].lower() +"(lv_style_t * style, "+ p['var_type'] +" value)") print("{") print(" lv_style_value_t v = {") - print(" ." + p['style_type'] +" = " + func_cast + "value") + print(" ." + p['style_type'] +" = " + cast + "value") print(" };") print(" lv_style_set_prop(style, LV_STYLE_" + p['name'] +", v);") print("}") print("") def local_style_set(p): - func_cast = get_func_cast(p['style_type']) + cast = style_set_cast(p['style_type']) print("static inline void lv_obj_set_style_" + p['name'].lower() + "(struct _lv_obj_t * obj, uint32_t part, uint32_t state, " + p['var_type'] +" value)") print("{") print(" lv_style_value_t v = {") - print(" ." + p['style_type'] +" = " + func_cast + "value") + print(" ." + p['style_type'] +" = " + cast + "value") print(" };") print(" lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_" + p['name'] +", v);") print("}") |