Skip to content

[v6.0] Callback conventions #1036

@amirgon

Description

@amirgon

As discussed on #557, #785, #316 and #935, callbacks must have a well defined structure that would allow an automatic script (for [micro]python bindings) find the related user_data of each callback.
A user_data is needed when more than one callback instance can be present for a function callback, and we need to correlate the right callback object of a higher level language with the C callback functions that was just fired.

A convention that we agreed upon was:

  • The callback will receive as the first parameter the pointer to the structure that contains the user_data
  • The user_data will be named according to the callback name (<callback>_user_data)

I checked and this convention solves some cases, but not all cases.

Here is a list of callbacks which currently do not follow this convention:

void lv_indev_feedback_t(struct _lv_indev_t *, uint8_t)
int32_t lv_anim_path_t(const struct _lv_anim_t *)
void lv_anim_fp_t(void *, int32_t)
void lv_anim_cb_t(void *)
void lv_group_style_mod_func_t(struct _lv_group_t *, lv_style_t *)
void lv_group_focus_cb_t(struct _lv_group_t *)
lv_res_t lv_img_decoder_info_f_t(const void *src, lv_img_header_t *header)
const uint8_t *lv_img_decoder_open_f_t(const void *src, const lv_style_t *style)
lv_res_t lv_img_decoder_read_line_f_t(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t *buf)
void lv_img_decoder_close_f_t(void)
lv_res_t lv_tileview_action_t(lv_obj_t *, lv_coord_t, lv_coord_t)
void lv_spinbox_value_changed_cb_t(lv_obj_t *spinbox, int32_t new_value)
void mem_blend_cb(lv_color_t *dest, const lv_color_t *src, uint32_t length, lv_opa_t opa)
void mem_fill_cb(lv_color_t *dest_buf, const lv_area_t *dest_area, const lv_area_t *fill_area, lv_color_t color)
void task(void *)
const uint8_t *get_bitmap(const struct _lv_font_struct *, uint32_t)
int16_t get_width(const struct _lv_font_struct *, uint32_t)
void cb(lv_obj_t *) // used on lv_obj_animate
void f(lv_log_level_t, const char *, uint32_t, const char *)

I would like to ask your opinion:

  • Which functions do you think are important for [micro]python bindings? My opinion is that we should support as much as possible, including images, animations etc.
  • Do we need user_data for each of these functions? In some cases (like logging) a single global callback is enough so we don't need a user_data per callback (or we can manage it globally, internally in the binding code)
  • Where do you think we can add the missing user_data on each of these callbacks? Can we use the existing convention (and pass a struct as first parameter) or do we need some new convention (like passing the user_data itself to the callback)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy