annotate src/audacious/tuple_compiler.h @ 3688:8ab4cd5c6462

multifile plugins :(
author William Pitcock <nenolod@atheme.org>
date Tue, 02 Oct 2007 21:47:17 -0500
parents 6f67258c43fd
children f31e93cd8f2f 5a267ba155cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * Copyright (c) 2007 Matti 'ccr' Hämäläinen
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
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 #define MAX_VAR (4)
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 #define MAX_STR (256)
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 #define MIN_ALLOC_NODES (8)
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 #define MIN_ALLOC_BUF (64)
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 enum {
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 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
36 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
37 OP_EXISTS,
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 OP_DEF_STRING,
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 OP_DEF_INT,
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 OP_EQUALS,
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 OP_NOT_EQUALS,
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 OP_GT,
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 OP_GTEQ,
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 OP_LT,
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 OP_LTEQ,
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 OP_IS_EMPTY,
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 OP_FUNCTION, /* function */
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 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
50 };
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 enum {
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 VAR_FIELD = 0,
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 VAR_CONST,
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 VAR_DEF
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 };
3489
9580bb3e58fa Tuple handling API changed to include support for "hardcoded" fields.
Matti Hamalainen <ccr@tnsp.org>
parents: 3409
diff changeset
58
3409
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 /* 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
61 */
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 typedef struct {
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 gchar *name;
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 gboolean isdeterministic;
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 gchar *(*func)(Tuple *tuple, gchar **argument);
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 } TupleEvalFunc;
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 typedef struct {
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 gchar *name;
3489
9580bb3e58fa Tuple handling API changed to include support for "hardcoded" fields.
Matti Hamalainen <ccr@tnsp.org>
parents: 3409
diff changeset
71 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
72 gint type; /* Type of variable, see VAR_* */
9580bb3e58fa Tuple handling API changed to include support for "hardcoded" fields.
Matti Hamalainen <ccr@tnsp.org>
parents: 3409
diff changeset
73 gchar *defval; /* Defined value ${=foo,bar} */
9580bb3e58fa Tuple handling API changed to include support for "hardcoded" fields.
Matti Hamalainen <ccr@tnsp.org>
parents: 3409
diff changeset
74
9580bb3e58fa Tuple handling API changed to include support for "hardcoded" fields.
Matti Hamalainen <ccr@tnsp.org>
parents: 3409
diff changeset
75 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
76 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
77 } TupleEvalVar;
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 typedef struct _TupleEvalNode {
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 gint opcode; /* operator, see OP_ enums */
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 gint var[MAX_VAR]; /* tuple / global variable references (perhaps hashes, or just indexes to a list?) */
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 gboolean global[MAX_VAR];
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 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
85 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
86 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
87 } TupleEvalNode;
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
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 typedef struct {
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 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
92 TupleEvalVar **variables;
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 TupleEvalFunc **functions;
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 } TupleEvalContext;
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 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
98 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
99 void tuple_evalctx_free(TupleEvalContext *ctx);
3489
9580bb3e58fa Tuple handling API changed to include support for "hardcoded" fields.
Matti Hamalainen <ccr@tnsp.org>
parents: 3409
diff changeset
100 gint tuple_evalctx_add_var(TupleEvalContext *ctx, const gchar *name, const gboolean istemp, const gint type);
3409
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 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
103
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 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
105 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
106
86dafe2300f7 Added Tuplez compiler (not used yet, though) and some related changes in
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 #endif