Android: Partly revert r29569 and only call the new getJavaEnvironment() when needed.
[maemo-rb.git] / lib / skin_parser / skin_parser.h
blob6f1af25a051aab8e5e3d5bcb0734561d3a478a17
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2010 Robert Bieber
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #ifndef GENERIC_PARSER_H
23 #define GENERIC_PARSER_H
25 #ifdef __cplusplus
26 extern "C"
28 #endif
29 #include <stdlib.h>
30 #include <stdbool.h>
32 /********************************************************************
33 ****** Data Structures *********************************************
34 *******************************************************************/
36 /* Possible types of element in a WPS file */
37 enum skin_element_type
39 UNKNOWN = -1,
40 VIEWPORT,
41 LINE_ALTERNATOR,
42 LINE,
43 CONDITIONAL,
44 TAG,
45 TEXT,
46 COMMENT,
49 enum skin_errorcode
51 MEMORY_LIMIT_EXCEEDED,
52 NEWLINE_EXPECTED,
53 ILLEGAL_TAG,
54 ARGLIST_EXPECTED,
55 TOO_MANY_ARGS,
56 DEFAULT_NOT_ALLOWED,
57 UNEXPECTED_NEWLINE,
58 INSUFFICIENT_ARGS,
59 INT_EXPECTED,
60 DECIMAL_EXPECTED,
61 SEPARATOR_EXPECTED,
62 CLOSE_EXPECTED,
63 MULTILINE_EXPECTED
66 /* Holds a tag parameter, either numeric or text */
67 struct skin_tag_parameter
69 enum
71 INTEGER,
72 DECIMAL, /* stored in data.number as (whole*10)+part */
73 STRING,
74 CODE,
75 DEFAULT
76 } type;
78 union
80 int number;
81 char* text;
82 struct skin_element* code;
83 } data;
85 char type_code;
89 /* Defines an element of a SKIN file */
90 struct skin_element
92 /* Defines what type of element it is */
93 enum skin_element_type type;
95 /* The line on which it's defined in the source file */
96 int line;
98 /* Placeholder for element data
99 * TEXT and COMMENT uses it for the text string
100 * TAG, VIEWPORT, LINE, etc may use it for post parse extra storage
102 void* data;
104 /* The tag or conditional name */
105 const struct tag_info *tag;
107 /* Pointer to and size of an array of parameters */
108 int params_count;
109 struct skin_tag_parameter* params;
111 /* Pointer to and size of an array of children */
112 int children_count;
113 struct skin_element** children;
115 /* Link to the next element */
116 struct skin_element* next;
119 enum skin_cb_returnvalue
121 CALLBACK_ERROR = -666,
122 FEATURE_NOT_AVAILABLE,
123 CALLBACK_OK = 0,
124 /* > 0 reserved for future use */
126 typedef int (*skin_callback)(struct skin_element* element, void* data);
128 /***********************************************************************
129 ***** Functions *******************************************************
130 **********************************************************************/
132 /* Parses a WPS document and returns a list of skin_element
133 structures. */
134 #ifdef ROCKBOX
135 struct skin_element* skin_parse(const char* document,
136 skin_callback callback, void* callback_data);
137 #else
138 struct skin_element* skin_parse(const char* document);
139 #endif
140 /* Memory management functions */
141 struct skin_element* skin_alloc_element(void);
142 struct skin_element** skin_alloc_children(int count);
143 struct skin_tag_parameter* skin_alloc_params(int count, bool use_shared_params);
144 char* skin_alloc_string(int length);
146 void skin_free_tree(struct skin_element* root);
149 #ifdef __cplusplus
151 #endif
153 #endif /* GENERIC_PARSER_H */