tests update
[mala.git] / engine / action.h
blob8ebfdf082f52f22feb613b20c053638b541e1d4d
1 /*
2 action.h - MaLa action handler
4 Copyright (C) 2004, Christian Thaeter <chth@gmx.net>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, contact me.
20 #ifndef MALA_ACTION_H
21 #define MALA_ACTION_H
23 #include "llist.h"
24 #include "mala_types.h"
25 #include "action.h"
27 struct
28 mala_actioninit_struct
30 const char * name;
31 MalaParserFunc parser;
32 mala_action_datatype type;
33 void *data;
34 const char * parent;
37 #define MALA_ACTIONS_END {NULL,NULL,MALA_DATA_UNUSED,NULL,NULL}
39 struct mala_action_struct
41 MalaString name;
42 MalaParserFunc parser;
43 MalaAction parent;
44 llist childs;
45 llist cldnode;
46 llist stknode;
47 union
49 MalaStringList list;
50 MalaString string;
51 void * data;
53 acogc_alloc_type data_alloc_type;
57 typedef enum {
58 MALA_NIL_TYPE,
59 MALA_DATAPTR_TYPE,
60 MALA_STRINGLIST_TYPE,
61 MALA_STRING_TYPE
62 } mala_data_type;
65 static inline void
66 mala_action_attach_child (MalaAction parent, MalaAction child)
68 if (parent)
69 llist_insert_tail (&parent->childs, &child->cldnode);
72 MalaAction
73 mala_action_new_actioninit (MalaActionInit init, MalaEngine engine);
75 MalaAction
76 mala_action_new (MalaString name,
77 MalaParserFunc parser,
78 void * data,
79 acogc_alloc_type data_alloc,
80 MalaEngine engine);
82 void
83 mala_action_acogc_initize (void*);
85 void
86 mala_action_acogc_finalize (void*);
88 acogc_mark_result
89 mala_action_acogc_mark (void*);
91 void
92 mala_action_attach (MalaAction self, MalaString name);
94 static inline AcogcFactory
95 mala_action_data_type (MalaAction self)
97 if (self->data_alloc_type >= ACOGC_STATIC)
99 return acogc_object_type (self->data);
101 else
102 return NULL;
105 static inline MalaStringList
106 mala_action_stringlist (MalaAction self)
108 return self->list;
111 static inline MalaString
112 mala_action_string (MalaAction self)
114 return self->string;
117 static inline void *
118 mala_action_dataptr (MalaAction self)
120 return self->data;
125 #endif /*MALA_ACTION_H*/
127 // Local Variables:
128 // mode: C
129 // c-file-style: "gnu"
130 // End:
131 // arch-tag: d8b425b7-18c1-4dc8-a19b-cdd095873e70
132 // end_of_file