summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2014-07-25 15:04:41 +0100
committerTom Hacohen <tom@stosb.com>2014-07-25 15:04:41 +0100
commitce9648777e8831fedeb1ac9d65de32c4ea02ec35 (patch)
treefb63e8f8f4cca901fba13a955ae028c8cc161625
parent5ac3d96f7e4691fd6ee063b118ccbb6b24baea69 (diff)
Add prop_func_dump, a property and function dumper
This tool dumps all the newly declared properties and functions to standard output.
-rw-r--r--prop_func_dump.c125
1 files changed, 125 insertions, 0 deletions
diff --git a/prop_func_dump.c b/prop_func_dump.c
new file mode 100644
index 0000000..2a50b67
--- /dev/null
+++ b/prop_func_dump.c
@@ -0,0 +1,125 @@
1// gcc `pkg-config --cflags --libs eolian eina` -DEFL_BETA_API_SUPPORT ${=CFLAGS} prop_func_dump.c -o prop_func_dump
2
3#include <getopt.h>
4#include <libgen.h>
5
6#include <Eina.h>
7
8#include <Eolian.h>
9
10#ifdef ERR
11# undef ERR
12#endif
13#define ERR(...) EINA_LOG_DOM_ERR(_eolian_gen_log_dom, __VA_ARGS__)
14
15int _eolian_gen_log_dom;
16
17int main(int argc, char **argv)
18{
19 int ret = 1;
20 Eina_Bool help = EINA_FALSE;
21 const char *eo_filename = NULL;
22 char *output_filename = NULL; /* if NULL, have to generate, otherwise use the name stored there */
23 char *eo_filename_copy = NULL, *eo_file_basename;
24
25 eina_init();
26 eolian_init();
27
28 const char *log_dom = "eolian_gen";
29 _eolian_gen_log_dom = eina_log_domain_register(log_dom, EINA_COLOR_GREEN);
30 if (_eolian_gen_log_dom < 0)
31 {
32 EINA_LOG_ERR("Could not register log domain: %s", log_dom);
33 goto end;
34 }
35
36 eina_log_timing(_eolian_gen_log_dom,
37 EINA_LOG_STATE_STOP,
38 EINA_LOG_STATE_INIT);
39
40 static struct option long_options[] =
41 {
42 /* These options set a flag. */
43 {"verbose", no_argument, 0, 'v'},
44 {"help", no_argument, 0, 'h'},
45 {"include", required_argument, 0, 'I'},
46 {0, 0, 0, 0}
47 };
48 int long_index =0, opt;
49 while ((opt = getopt_long(argc, argv,"hI:", long_options, &long_index )) != -1)
50 {
51 switch (opt) {
52 case 0: break;
53 case 'h': help = EINA_TRUE; break;
54 case 'I':
55 {
56 const char *dir = optarg;
57 if (!eolian_directory_scan(dir))
58 {
59 ERR("Failed to scan %s", dir);
60 goto end;
61 }
62 break;
63 }
64 default: help = EINA_TRUE;
65 }
66 }
67 eo_filename = argv[optind++];
68
69 if (help)
70 {
71 printf("Usage: %s [-h/--help] [-I/--include input_dir] file.eo ... \n", argv[0]);
72 printf(" --help/-h Print that help\n");
73 printf(" --include/-I Include 'input_dir' as directory to search .eo files into\n");
74 ret = 0;
75 goto end;
76 }
77
78 if (!eo_filename)
79 {
80 ERR("No input file specified.\nTerminating.\n");
81 goto end;
82 }
83
84 eolian_all_eot_files_parse();
85
86 if (!eolian_eo_file_parse(eo_filename))
87 {
88 ERR("Error during parsing file %s\n", eo_filename);
89 goto end;
90 }
91
92 eo_filename_copy = strdup(eo_filename);
93 eo_file_basename = basename(eo_filename_copy);
94
95 {
96 const Eolian_Function_Type ftype_order[] = {EOLIAN_CTOR, EOLIAN_PROPERTY, EOLIAN_METHOD};
97
98 const Eolian_Class *class = eolian_class_get_by_file(eo_file_basename);
99 int i;
100 for (i = 0; i < 3; i++)
101 {
102 Eolian_Function *fid;
103 Eina_Iterator *itr = eolian_class_functions_get(class, ftype_order[i]);
104 EINA_ITERATOR_FOREACH(itr, fid)
105 {
106 printf("%s\n", eolian_function_name_get(fid));
107 }
108 eina_iterator_free(itr);
109 }
110 }
111
112end:
113 free(eo_filename_copy);
114 free(output_filename);
115
116 eina_log_timing(_eolian_gen_log_dom,
117 EINA_LOG_STATE_START,
118 EINA_LOG_STATE_SHUTDOWN);
119 eina_log_domain_unregister(_eolian_gen_log_dom);
120 _eolian_gen_log_dom = -1;
121
122 eolian_shutdown();
123 eina_shutdown();
124 return ret;
125}