7 double variable_lookup(struct variable *in)
12 double expression_eval(struct expression *in)
16 return expression_eval(in->a) * expression_eval(in->b);
19 return expression_eval(in->a) / expression_eval(in->b);
22 return expression_eval(in->a) + expression_eval(in->b);
25 return expression_eval(in->a) - expression_eval(in->b);
28 if (in->v.base == NULL) {
30 } else return variable_lookup(&in->v);
33 assert(!!!"OH NOES!!!");
38 static void decor_print(gpointer data, gpointer user_data)
41 struct decor *decor = data;
42 printf(" decor id %s\n", decor->name);
43 printf(" anchor.x = %f\n", expression_eval(&decor->space.anchor.x));
44 // printf(" anchor (%d %d %d)\n", decor->space.anchor.x, decor->space.anchor.y, decor->space.anchor.z);
45 // printf(" up (%d %d %d)\n", decor->space.up.x, decor->space.up.y, decor->space.up.z);
47 g_slist_foreach(decor->children, decor_print, NULL);
50 static void style_print(gpointer key, gpointer value, gpointer user_data)
52 char *stylename = key;
53 struct style *style = value;
55 printf(" style %s\n", stylename);
56 g_slist_foreach(style->tree, decor_print, NULL);
59 static void theme_print(gpointer key, gpointer value, gpointer user_data)
62 struct theme *thm = value;
63 printf("name = %s\n", name);
64 g_hash_table_foreach(thm->styles, style_print, NULL);
67 static void material_print(gpointer key, gpointer value, gpointer user_data)
70 struct material *mat = value;
71 printf("name = %s\n", name);
72 printf(" opacity = %f\n", mat->opacity);
75 int main(int argc, char **argv)
78 struct obthemedata themedata;
80 themedata.themes = g_hash_table_new(g_str_hash, g_str_equal);
81 themedata.materials = g_hash_table_new(g_str_hash, g_str_equal);
82 err = obtheme_parse(&themedata, argv[1]);
83 printf("err = %d\n", err);
85 g_hash_table_foreach(themedata.materials, material_print, NULL);
87 g_hash_table_foreach(themedata.themes, theme_print, NULL);