Mercurial > audlegacy
annotate src/audacious/tuple_compiler.h @ 4547:024be3d7ef4c
Make MPRIS work again.
author | Jonathan Schleifer <js-audacious@webkeks.org> |
---|---|
date | Thu, 15 May 2008 19:25:29 +0200 |
parents | 5a0f5ef1de61 |
children | 2eee464379dc |
rev | line source |
---|---|
3409
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * Audacious - Tuplez compiler |
3837 | 3 * Copyright (c) 2007 Matti 'ccr' Hämäläinen |
3409
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 * |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 * the Free Software Foundation; under version 3 of the License. |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 * |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 * GNU General Public License for more details. |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 * |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 * You should have received a copy of the GNU General Public License |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 * along with this program. If not, see <http://www.gnu.org/licenses>. |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 * |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 * The Audacious team does not consider modular code linking to |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 * Audacious or using our public API to be a derived work. |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 */ |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 #ifndef __AUDACIOUS_TUPLE_COMPILER_H__ |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 #define __AUDACIOUS_TUPLE_COMPILER_H__ |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 #include <glib.h> |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 #include <mowgli.h> |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 #include "tuple.h" |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 |
4383
5794aa593490
Renamed TUP_MAX_VAR to TUPLEZ_MAX_VARS.
Matti Hamalainen <ccr@tnsp.org>
parents:
4381
diff
changeset
|
28 #define TUPLEZ_MAX_VARS (4) |
3409
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 enum { |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 OP_RAW = 0, /* plain text */ |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 OP_FIELD, /* a field/variable */ |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 OP_EXISTS, |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 OP_DEF_STRING, |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 OP_DEF_INT, |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 OP_EQUALS, |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 OP_NOT_EQUALS, |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 OP_GT, |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 OP_GTEQ, |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 OP_LT, |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 OP_LTEQ, |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
43 OP_IS_EMPTY, |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 OP_FUNCTION, /* function */ |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 OP_EXPRESSION /* additional registered expressions */ |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 }; |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 enum { |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 VAR_FIELD = 0, |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 VAR_CONST, |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 VAR_DEF |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 }; |
3489
9580bb3e58fa
Tuple handling API changed to include support for "hardcoded" fields.
Matti Hamalainen <ccr@tnsp.org>
parents:
3409
diff
changeset
|
55 |
3409
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 /* Caching structure for deterministic functions |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 */ |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 typedef struct { |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 gchar *name; |
3489
9580bb3e58fa
Tuple handling API changed to include support for "hardcoded" fields.
Matti Hamalainen <ccr@tnsp.org>
parents:
3409
diff
changeset
|
61 gboolean istemp; /* Scope of variable - TRUE = temporary */ |
9580bb3e58fa
Tuple handling API changed to include support for "hardcoded" fields.
Matti Hamalainen <ccr@tnsp.org>
parents:
3409
diff
changeset
|
62 gint type; /* Type of variable, see VAR_* */ |
3954
7afbcd87cd65
The compiler should now correctly recognize integer constants, thanks to
Matti Hamalainen <ccr@tnsp.org>
parents:
3952
diff
changeset
|
63 gchar *defvals; /* Defined value ${=foo,bar} */ |
7afbcd87cd65
The compiler should now correctly recognize integer constants, thanks to
Matti Hamalainen <ccr@tnsp.org>
parents:
3952
diff
changeset
|
64 gint defvali; |
7afbcd87cd65
The compiler should now correctly recognize integer constants, thanks to
Matti Hamalainen <ccr@tnsp.org>
parents:
3952
diff
changeset
|
65 TupleValueType ctype; /* Type of constant/def value */ |
3489
9580bb3e58fa
Tuple handling API changed to include support for "hardcoded" fields.
Matti Hamalainen <ccr@tnsp.org>
parents:
3409
diff
changeset
|
66 |
9580bb3e58fa
Tuple handling API changed to include support for "hardcoded" fields.
Matti Hamalainen <ccr@tnsp.org>
parents:
3409
diff
changeset
|
67 gint fieldidx; /* if >= 0: Index # of "pre-defined" Tuple fields */ |
9580bb3e58fa
Tuple handling API changed to include support for "hardcoded" fields.
Matti Hamalainen <ccr@tnsp.org>
parents:
3409
diff
changeset
|
68 TupleValue *fieldref; /* Cached tuple field ref */ |
3409
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 } TupleEvalVar; |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 |
3951 | 72 typedef struct { |
73 gchar *name; | |
74 gboolean isdeterministic; | |
75 gchar *(*func)(Tuple *tuple, TupleEvalVar **argument); | |
76 } TupleEvalFunc; | |
77 | |
78 | |
3409
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 typedef struct _TupleEvalNode { |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
80 gint opcode; /* operator, see OP_ enums */ |
4383
5794aa593490
Renamed TUP_MAX_VAR to TUPLEZ_MAX_VARS.
Matti Hamalainen <ccr@tnsp.org>
parents:
4381
diff
changeset
|
81 gint var[TUPLEZ_MAX_VARS]; /* tuple / global variable references */ |
5794aa593490
Renamed TUP_MAX_VAR to TUPLEZ_MAX_VARS.
Matti Hamalainen <ccr@tnsp.org>
parents:
4381
diff
changeset
|
82 gboolean global[TUPLEZ_MAX_VARS]; |
3409
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 gchar *text; /* raw text, if any (OP_RAW) */ |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 gint function, expression; /* for OP_FUNCTION and OP_EXPRESSION */ |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 struct _TupleEvalNode *children, *next, *prev; /* children of this struct, and pointer to next node. */ |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 } TupleEvalNode; |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
88 |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 typedef struct { |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
90 gint nvariables, nfunctions, nexpressions; |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 TupleEvalVar **variables; |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 TupleEvalFunc **functions; |
3810
e307e455aca0
Improved error handling. Now the error status and message are saved into evaluation context.
Matti Hamalainen <ccr@tnsp.org>
parents:
3809
diff
changeset
|
93 |
e307e455aca0
Improved error handling. Now the error status and message are saved into evaluation context.
Matti Hamalainen <ccr@tnsp.org>
parents:
3809
diff
changeset
|
94 /* Error context */ |
e307e455aca0
Improved error handling. Now the error status and message are saved into evaluation context.
Matti Hamalainen <ccr@tnsp.org>
parents:
3809
diff
changeset
|
95 gboolean iserror; |
e307e455aca0
Improved error handling. Now the error status and message are saved into evaluation context.
Matti Hamalainen <ccr@tnsp.org>
parents:
3809
diff
changeset
|
96 gchar *errmsg; |
3409
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 } TupleEvalContext; |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
100 TupleEvalContext * tuple_evalctx_new(void); |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 void tuple_evalctx_reset(TupleEvalContext *ctx); |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
102 void tuple_evalctx_free(TupleEvalContext *ctx); |
3954
7afbcd87cd65
The compiler should now correctly recognize integer constants, thanks to
Matti Hamalainen <ccr@tnsp.org>
parents:
3952
diff
changeset
|
103 gint tuple_evalctx_add_var(TupleEvalContext *ctx, const gchar *name, const gboolean istemp, const gint type, const TupleValueType ctype); |
3409
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 void tuple_evalnode_free(TupleEvalNode *expr); |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
106 |
4381
ce3f2d2455cf
Moved debugging functions to tuple_compiler.c
Matti Hamalainen <ccr@tnsp.org>
parents:
3954
diff
changeset
|
107 gint tuple_formatter_print(FILE *f, gint *level, TupleEvalContext *ctx, TupleEvalNode *expr); |
3409
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
108 TupleEvalNode *tuple_formatter_compile(TupleEvalContext *ctx, gchar *expr); |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 gchar *tuple_formatter_eval(TupleEvalContext *ctx, TupleEvalNode *expr, Tuple *tuple); |
86dafe2300f7
Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 |
4407
5a0f5ef1de61
Some stupid header cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
4383
diff
changeset
|
111 #endif /* __AUDACIOUS_TUPLE_COMPILER_H__ */ |