a more complete test theme
[manmower/obtheme.git] / obtheme.h
1 #ifndef __THEME_PARSE_H__
2 #define __THEME_PARSE_H__
3
4 #include <glib.h>
5 #include "frame.h"
6 #include "misc.h"
7
8 #undef YY_DECL
9 #define YY_DECL int obthemelex(YYSTYPE *yylval, struct parser_control *pc)
10
11 #define YYDEBUG 1
12 #define YYLEX_PARAM pc
13
14 #define MAX_INCLUDE_DEPTH 32
15 #define LINE pc->currline[pc->include_stack_ptr]
16
17 extern int themedebug;
18
19 typedef enum {
20         OB_THEME_ADD,
21         OB_THEME_SUB,
22         OB_THEME_MUL,
23         OB_THEME_DIV,
24         OB_THEME_EQL
25 } ObThemeOp;
26
27 struct variable {
28         char *base;
29         char *member;
30         double number;
31 };
32
33 struct expression {
34         ObThemeOp op;
35         struct expression *a;
36         struct expression *b;
37         struct variable v;
38 };
39
40 struct material {
41         float opacity;
42 };
43
44 struct style {
45         char *name;
46         GSList *tree;
47 };
48
49 struct obthemedata {
50         GHashTable *themes;
51         GHashTable *materials;
52 };
53
54 struct theme {
55         char *name;
56         GHashTable *styles;
57 };
58
59 struct vector {
60         struct expression x;
61         struct expression y;
62         struct expression z;
63 };
64
65 struct space {
66         struct vector anchor;
67         struct vector up;
68 };
69
70 struct texture {
71         gboolean present;
72         gboolean internal;
73         char *name;
74 };
75
76 struct box {
77         struct vector start;
78         struct vector end;
79 };
80
81 struct geometry {
82         struct box box;
83 };
84
85 struct decor {
86         char *name;
87         GSList *children;
88         struct space space;
89         ObDirection cursor;
90         ObFrameContext context;
91         struct texture texture;
92         struct material *material;
93         struct geometry geometry;
94 };
95
96 struct parser_control {
97         struct yy_buffer_state *include_stack[MAX_INCLUDE_DEPTH];
98         int currline[MAX_INCLUDE_DEPTH];
99         char currfile[MAX_INCLUDE_DEPTH][501];
100         int include_stack_ptr;
101         char error_buf[4096];
102         struct obthemedata *target;
103 };
104
105 void obthemeerror(struct parser_control *pc, char *s);
106 int obtheme_parse(struct obthemedata *td, const char *filename);
107 struct parser_control *parser_init(struct obthemedata *td);
108 int obthemeparse(struct parser_control *);
109 void parser_finish(struct parser_control *);
110
111 #endif /* __THEME_PARSE_H__ */