1 #ifndef _WIDGET_BASE_H 2 #define _WIDGET_BASE_H 3 #include <stdio.h> 4 #include <stdlib.h> 5 #include <stdbool.h> 6 #include <string.h> 7 //#include <memory.h> 8 #include "amp_defines.h" 9 //#include "amp_system.h" 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 #if 0 15 typedef unsigned char uint8_t; 16 typedef signed char int8_t; 17 typedef unsigned short uint16_t; 18 typedef signed short int16_t; 19 typedef unsigned int uint32_t; 20 typedef signed int int32_t; 21 // typedef unsigned long long uint64_t; 22 // typedef long long int64_t; 23 #endif 24 25 typedef union { 26 uint32_t value; 27 struct { 28 uint8_t b; 29 uint8_t g; 30 uint8_t r; 31 uint8_t a; 32 }; 33 struct { 34 uint8_t blue; 35 uint8_t green; 36 uint8_t red; 37 uint8_t alpha; 38 }; 39 } widget_color; 40 41 typedef struct _widget_default_type_map_t { 42 int type; 43 char *name; 44 } widget_default_type_map_t; 45 46 typedef struct _list_node_t { 47 struct _list_node_t *prev; 48 struct _list_node_t *next; 49 void *data; 50 }list_node_t; 51 52 typedef struct _list { 53 list_node_t head; 54 list_node_t tail; 55 uint32_t len; 56 }list; 57 58 char *widget_str_duplicate(char *src); 59 60 int widget_style_type_get(char *str); 61 62 bool widget_str_equal(char *str1, char *str2); 63 64 int widget_str2type(char *name, widget_default_type_map_t* map, int max); 65 66 int widget_str2uint(char *str, uint32_t *data); 67 68 int widget_str2int(char *str, int32_t *data); 69 70 int widget_color_parse(char *str, widget_color *color); 71 72 void amp_list_init(list* list); 73 74 void amp_node_insert(list_node_t *list_node, list_node_t *node); 75 76 void amp_node_delete(list_node_t *node); 77 78 void amp_list_node_insert(list* list, int index, list_node_t *node); 79 80 void amp_list_node_append(list* list, list_node_t *node); 81 82 int amp_list_node_delete(list *list, list_node_t *node); 83 84 int amp_strtok_num_get(char *str, const char *delim); 85 86 #if 0 87 void *amp_debug_malloc(uint32_t size, char* func, int line); 88 89 90 void *amp_debug_calloc(uint32_t nitems, uint32_t size, char* func, int line); 91 92 93 void *amp_debug_realloc(void* addr, uint32_t size, char* func, int line); 94 95 void amp_debug_free(void* addr, char* func, int line); 96 97 98 99 #define render_alloc(size) amp_debug_malloc(size, __func__, __LINE__) 100 #define render_calloc(nitems, size) amp_debug_calloc(nitems, size, __func__, __LINE__) 101 #define render_realloc(addr, size) amp_debug_realloc(addr, size, __func__, __LINE__) 102 #define render_free(addr) amp_debug_free(addr, __func__, __LINE__) 103 #else 104 #define render_alloc aos_malloc 105 #define render_calloc aos_calloc 106 #define render_realloc aos_realloc 107 #define render_free aos_free 108 #endif 109 110 #ifdef __cplusplus 111 } /* extern "C" */ 112 #endif 113 114 #endif /*_WIDGET_BASE_H*/ 115 116