summaryrefslogtreecommitdiff
path: root/lib/skin_parser/skin_parser.h
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2011-11-15 14:11:08 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2011-11-15 14:11:08 +0000
commit9e07ef2b0adb8fca7e5a9e516397e533653f8836 (patch)
tree0a283550421917e52ee04068b84a464976f0c4f2 /lib/skin_parser/skin_parser.h
parent101693fd3047fb64e766580e80635a424fa25c4d (diff)
downloadrockbox-9e07ef2b0adb8fca7e5a9e516397e533653f8836.tar.gz
rockbox-9e07ef2b0adb8fca7e5a9e516397e533653f8836.zip
Use buflib for all skin engine allocations.
Massive thanks to Michael Chicoine and other testers for finding the early bugs. This removes all skin memory limitations git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30991 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'lib/skin_parser/skin_parser.h')
-rw-r--r--lib/skin_parser/skin_parser.h35
1 files changed, 27 insertions, 8 deletions
diff --git a/lib/skin_parser/skin_parser.h b/lib/skin_parser/skin_parser.h
index 3e0634976c..120112d995 100644
--- a/lib/skin_parser/skin_parser.h
+++ b/lib/skin_parser/skin_parser.h
@@ -29,6 +29,25 @@ extern "C"
29#include <stdlib.h> 29#include <stdlib.h>
30#include <stdbool.h> 30#include <stdbool.h>
31 31
32#if defined(ROCKBOX) && !defined(__PCTOOL__)
33/* Use this type and macro to convert a pointer from the
34 * skin buffer to a useable pointer */
35typedef long skinoffset_t;
36#define SKINOFFSETTOPTR(base, offset) ((offset) < 0 ? NULL : ((void*)&base[offset]))
37#define PTRTOSKINOFFSET(base, pointer) ((pointer) ? ((void*)pointer-(void*)base) : -1)
38/* Use this macro when declaring a variable to self-document the code.
39 * type is the actual type being pointed to (i.e OFFSETTYPE(char*) foo )
40 *
41 * WARNING: Don't use the PTRTOSKINOFFSET() around a function call as it wont
42 * do what you expect.
43 */
44#define OFFSETTYPE(type) skinoffset_t
45#else
46#define SKINOFFSETTOPTR(base, offset) offset
47#define PTRTOSKINOFFSET(base, pointer) pointer
48#define OFFSETTYPE(type) type
49#endif
50
32/******************************************************************** 51/********************************************************************
33 ****** Data Structures ********************************************* 52 ****** Data Structures *********************************************
34 *******************************************************************/ 53 *******************************************************************/
@@ -78,8 +97,8 @@ struct skin_tag_parameter
78 union 97 union
79 { 98 {
80 int number; 99 int number;
81 char* text; 100 OFFSETTYPE(char*) text;
82 struct skin_element* code; 101 OFFSETTYPE(struct skin_element*) code;
83 } data; 102 } data;
84 103
85 char type_code; 104 char type_code;
@@ -92,20 +111,20 @@ struct skin_tag_parameter
92struct skin_element 111struct skin_element
93{ 112{
94 /* Link to the next element */ 113 /* Link to the next element */
95 struct skin_element* next; 114 OFFSETTYPE(struct skin_element*) next;
96 /* Pointer to an array of children */ 115 /* Pointer to an array of children */
97 struct skin_element** children; 116 OFFSETTYPE(struct skin_element**) children;
98 /* Placeholder for element data 117 /* Placeholder for element data
99 * TEXT and COMMENT uses it for the text string 118 * TEXT and COMMENT uses it for the text string
100 * TAG, VIEWPORT, LINE, etc may use it for post parse extra storage 119 * TAG, VIEWPORT, LINE, etc may use it for post parse extra storage
101 */ 120 */
102 void* data; 121 OFFSETTYPE(void*) data;
103 122
104 /* The tag or conditional name */ 123 /* The tag or conditional name */
105 const struct tag_info *tag; 124 const struct tag_info *tag;
106 125
107 /* Pointer to an array of parameters */ 126 /* Pointer to an array of parameters */
108 struct skin_tag_parameter* params; 127 OFFSETTYPE(struct skin_tag_parameter*) params;
109 128
110 /* Number of elements in the children array */ 129 /* Number of elements in the children array */
111 short children_count; 130 short children_count;
@@ -140,8 +159,8 @@ struct skin_element* skin_parse(const char* document);
140#endif 159#endif
141/* Memory management functions */ 160/* Memory management functions */
142struct skin_element* skin_alloc_element(void); 161struct skin_element* skin_alloc_element(void);
143struct skin_element** skin_alloc_children(int count); 162OFFSETTYPE(struct skin_element*)* skin_alloc_children(int count);
144struct skin_tag_parameter* skin_alloc_params(int count, bool use_shared_params); 163struct skin_tag_parameter* skin_alloc_params(int count);
145char* skin_alloc_string(int length); 164char* skin_alloc_string(int length);
146 165
147void skin_free_tree(struct skin_element* root); 166void skin_free_tree(struct skin_element* root);