GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
A JSON parser for widget layout. More...
Go to the source code of this file.
Data Structures | |
struct | gp_widget_json_addr |
A structure to pass widget callbacks. More... | |
struct | gp_widget_json_callbacks |
Structure to pass callbacks to the JSON loader. More... | |
struct | gp_widget_json_ctx |
A context to propagate values top down and bottom up. More... | |
Typedefs | |
typedef struct gp_widget_json_addr | gp_widget_json_addr |
A structure to pass widget callbacks. | |
Functions | |
gp_widget * | gp_widget_from_json (gp_json_reader *json, gp_json_val *val, gp_widget_json_ctx *ctx) |
Loads a widget layout given a JSON object. | |
gp_widget * | gp_widget_from_json_str (const char *str, const gp_widget_json_callbacks *const callbacks, gp_htable **uids) |
Loads a widget layout given a string with JSON layout. | |
gp_widget * | gp_widget_layout_json (const char *fname, const gp_widget_json_callbacks *const callbacks, gp_htable **uids) |
Loads a widget layout given a path to a JSON layout description. | |
void * | gp_widget_callback_addr (const char *fn_name, const gp_widget_json_ctx *ctx) |
Attempts to get a pointer to a function given it's name. | |
void * | gp_widget_struct_addr (const char *struct_name, const gp_widget_json_ctx *ctx) |
Attempts to get a pointer to a structure given it's name. | |
A JSON parser for widget layout.
Widget layout can be loaded from a JSON description. The application can resolve widgets by unique id and event handlers are resolved from the application binary at runtime.
Definition in file gp_widget_json.h.
typedef struct gp_widget_json_addr gp_widget_json_addr |
A structure to pass widget callbacks.
The pointers to application callbacks can either be resolved by the dynamic linker at runtime, or can be explicitly passed in this table. The table has to be sorted by id
and NULL id
terminted.
Example use:
void * gp_widget_callback_addr | ( | const char * | fn_name, |
const gp_widget_json_ctx * | ctx | ||
) |
Attempts to get a pointer to a function given it's name.
This function is used to resolve callbacks from a JSON layout.
fn_name | A fucntion name. |
ctx | A widget JSON loader context, usually passed from our caller. |
gp_widget * gp_widget_from_json | ( | gp_json_reader * | json, |
gp_json_val * | val, | ||
gp_widget_json_ctx * | ctx | ||
) |
Loads a widget layout given a JSON object.
json | A json object. |
val | A json value. |
ctx | A widget JSON loader context, usually passed from our caller. |
gp_widget * gp_widget_from_json_str | ( | const char * | str, |
const gp_widget_json_callbacks *const | callbacks, | ||
gp_htable ** | uids | ||
) |
Loads a widget layout given a string with JSON layout.
str | A string with a JSON layout. |
callbacks | An optional NULL terminated array of application callbacks. |
uids | A pointer to a hash table to store widget pointers by UIDs. |
gp_widget * gp_widget_layout_json | ( | const char * | fname, |
const gp_widget_json_callbacks *const | callbacks, | ||
gp_htable ** | uids | ||
) |
Loads a widget layout given a path to a JSON layout description.
fname | A path to a JSON layout file. |
callbacks | An optional NULL terminated array of application callbacks. |
uids | A pointer to a hash table to store widget pointers by UIDs. |
void * gp_widget_struct_addr | ( | const char * | struct_name, |
const gp_widget_json_ctx * | ctx | ||
) |
Attempts to get a pointer to a structure given it's name.
This function is used to resolve structures from a JSON layout.
struct_name | A structure name. |
ctx | A widget JSON loader context, usually passed from our caller. |