summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2014-02-16 16:09:06 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-03-03 14:09:54 +0200
commit9add4c695c9047c9c095d8958fae7094a5e266e9 (patch)
tree2084d14f6536f326066a92f2923e3536f6df5962 /src/bin
parent17abdbdd43c709e24edf50534bfb27b01394863f (diff)
Eolian: remove --class option.
Now, the .eo file needs to be supplied instead of the class.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian/main.c70
1 files changed, 43 insertions, 27 deletions
diff --git a/src/bin/eolian/main.c b/src/bin/eolian/main.c
index ab74a3b246..fc73594bc4 100644
--- a/src/bin/eolian/main.c
+++ b/src/bin/eolian/main.c
@@ -13,7 +13,7 @@ static int eo_version = 0;
13static Eina_Bool legacy_support = EINA_FALSE; 13static Eina_Bool legacy_support = EINA_FALSE;
14 14
15static Eina_Bool 15static Eina_Bool
16_generate_h_file(char *filename, char *classname, Eina_Bool append) 16_generate_h_file(char *filename, const char *classname, Eina_Bool append)
17{ 17{
18 Eina_Bool ret = EINA_FALSE; 18 Eina_Bool ret = EINA_FALSE;
19 Eina_Strbuf *hfile = eina_strbuf_new(); 19 Eina_Strbuf *hfile = eina_strbuf_new();
@@ -54,7 +54,7 @@ end:
54} 54}
55 55
56static Eina_Bool 56static Eina_Bool
57_generate_c_file(char *filename, char *classname, Eina_Bool append) 57_generate_c_file(char *filename, const char *classname, Eina_Bool append)
58{ 58{
59 Eina_Bool ret = EINA_FALSE; 59 Eina_Bool ret = EINA_FALSE;
60 60
@@ -79,7 +79,7 @@ end:
79 79
80// TODO join with header gen. 80// TODO join with header gen.
81static Eina_Bool 81static Eina_Bool
82_generate_legacy_header_file(char *filename, char *classname, Eina_Bool append) 82_generate_legacy_header_file(char *filename, const char *classname, Eina_Bool append)
83{ 83{
84 Eina_Bool ret = EINA_FALSE; 84 Eina_Bool ret = EINA_FALSE;
85 85
@@ -120,7 +120,7 @@ end:
120} 120}
121 121
122static Eina_Bool 122static Eina_Bool
123_generate_eo_and_legacy_h_file(char *filename, char *classname) 123_generate_eo_and_legacy_h_file(char *filename, const char *classname)
124{ 124{
125 Eina_Bool ret = EINA_FALSE; 125 Eina_Bool ret = EINA_FALSE;
126 126
@@ -151,11 +151,11 @@ int main(int argc, char **argv)
151 eina_init(); 151 eina_init();
152 int ret = 0; 152 int ret = 0;
153 Eina_Bool help = EINA_FALSE, show = EINA_FALSE; 153 Eina_Bool help = EINA_FALSE, show = EINA_FALSE;
154 Eina_List *files = NULL, *itr; 154 Eina_List *included_files = NULL, *itr;
155 Eina_List *classes = NULL; 155 Eina_List *files4gen = NULL;
156 const char *classname;
156 char *h_filename = NULL, *c_filename = NULL, 157 char *h_filename = NULL, *c_filename = NULL,
157 *classname = NULL, *leg_filename = NULL, 158 *leg_filename = NULL, *eoleg_filename = NULL;
158 *eoleg_filename = NULL;
159 159
160 Eina_Bool happend = EINA_FALSE; 160 Eina_Bool happend = EINA_FALSE;
161 Eina_Bool lappend = EINA_FALSE; 161 Eina_Bool lappend = EINA_FALSE;
@@ -174,11 +174,10 @@ int main(int argc, char **argv)
174 {"gle", required_argument, 0, 5}, 174 {"gle", required_argument, 0, 5},
175 {"legacy", no_argument, 0, 6}, 175 {"legacy", no_argument, 0, 6},
176 {"include", required_argument, 0, 'I'}, 176 {"include", required_argument, 0, 'I'},
177 {"class", required_argument, 0, 'c'},
178 {0, 0, 0, 0} 177 {0, 0, 0, 0}
179 }; 178 };
180 int long_index =0, opt; 179 int long_index =0, opt;
181 while ((opt = getopt_long(argc, argv,"Vho:I:c:", long_options, &long_index )) != -1) 180 while ((opt = getopt_long(argc, argv,"Vho:I:", long_options, &long_index )) != -1)
182 { 181 {
183 switch (opt) { 182 switch (opt) {
184 case 0: break; 183 case 0: break;
@@ -208,8 +207,8 @@ int main(int argc, char **argv)
208 sprintf(filepath, "%s/%s", dir, file); 207 sprintf(filepath, "%s/%s", dir, file);
209 if ((!ecore_file_is_dir(filepath)) && eina_str_has_suffix(filepath, EO_SUFFIX)) 208 if ((!ecore_file_is_dir(filepath)) && eina_str_has_suffix(filepath, EO_SUFFIX))
210 { 209 {
211 /* Allocated string will be freed during deletion of "files" list. */ 210 /* Allocated string will be freed during deletion of "included_files" list. */
212 files = eina_list_append(files, strdup(filepath)); 211 included_files = eina_list_append(included_files, strdup(filepath));
213 } 212 }
214 free(filepath); 213 free(filepath);
215 free(file); 214 free(file);
@@ -219,19 +218,24 @@ int main(int argc, char **argv)
219 free(dir); 218 free(dir);
220 break; 219 break;
221 } 220 }
222 case 'c': classes = eina_list_append(classes, optarg); break;
223 default: help = EINA_TRUE; 221 default: help = EINA_TRUE;
224 } 222 }
225 } 223 }
224 while (optind < argc)
225 {
226 char *short_name = argv[optind++];
227 char *included_file;
228 EINA_LIST_FOREACH(included_files, itr, included_file)
229 if (strstr(included_file, short_name))
230 files4gen = eina_list_append(files4gen, included_file);
231 }
226 232
227 if (eina_list_count(classes)) classname = eina_list_data_get(classes); 233 if (!included_files || help || !files4gen)
228
229 if (!files || help || !classname)
230 { 234 {
231 printf("Usage: %s [-h/--help] [-V/--verbose] [-I/--include input_dir] [--legacy] [--gh|--gc|--ah] filename [-c/--class] classname \n", argv[0]); 235 printf("Usage: %s [-h/--help] [-V/--verbose] [-I/--include input_dir] [--legacy] [--gh|--gc|--ah filename] eo_file... \n", argv[0]);
232 printf(" --eo1/--eo2 Set generator to eo1/eo2 mode. Must be specified\n"); 236 printf(" --eo1/--eo2 Set generator to eo1/eo2 mode. Must be specified\n");
233 printf(" --gh Generate c header file [.h] for eo class specified by classname\n"); 237 printf(" --gh Generate c header file [.h]\n");
234 printf(" --gc Generate c source file [.c] for eo class specified by classname\n"); 238 printf(" --gc Generate c source file [.c]\n");
235 printf(" --ah Append eo class definitions to an existing c header file [.h]\n"); 239 printf(" --ah Append eo class definitions to an existing c header file [.h]\n");
236 printf(" --al Append legacy function definitions to an existing c header file [.h]\n"); 240 printf(" --al Append legacy function definitions to an existing c header file [.h]\n");
237 printf(" --gle Generate eo and legacy file [.h]\n"); 241 printf(" --gle Generate eo and legacy file [.h]\n");
@@ -241,7 +245,7 @@ int main(int argc, char **argv)
241 245
242 eolian_init(); 246 eolian_init();
243 const char *filename; 247 const char *filename;
244 EINA_LIST_FOREACH(files, itr, filename) 248 EINA_LIST_FOREACH(included_files, itr, filename)
245 { 249 {
246 if (!eolian_eo_file_parse(filename)) 250 if (!eolian_eo_file_parse(filename))
247 { 251 {
@@ -250,7 +254,15 @@ int main(int argc, char **argv)
250 } 254 }
251 } 255 }
252 256
253 if (show) eolian_show(classname); 257 char *fname;
258 if (show)
259 {
260 EINA_LIST_FOREACH(files4gen, itr, fname)
261 {
262 const char *cname = eolian_class_find_by_file(fname);
263 eolian_show(cname);
264 }
265 }
254 266
255 if (!eo_version) 267 if (!eo_version)
256 { 268 {
@@ -259,6 +271,8 @@ int main(int argc, char **argv)
259 goto end; 271 goto end;
260 } 272 }
261 273
274 classname = eolian_class_find_by_file(eina_list_data_get(files4gen));
275
262 if (h_filename) 276 if (h_filename)
263 { 277 {
264 printf("%s header file %s\n", (happend) ? "Appending" : "Generating", h_filename); 278 printf("%s header file %s\n", (happend) ? "Appending" : "Generating", h_filename);
@@ -268,10 +282,12 @@ int main(int argc, char **argv)
268 if (c_filename) 282 if (c_filename)
269 { 283 {
270 printf("Generating source file %s\n", c_filename); 284 printf("Generating source file %s\n", c_filename);
271 Eina_List *l = NULL; 285 const char *cname;
272 char *cname = NULL; 286 EINA_LIST_FOREACH(files4gen, itr, fname)
273 EINA_LIST_FOREACH(classes,l,cname) 287 {
274 _generate_c_file(c_filename, cname, (classes != l)); 288 cname = eolian_class_find_by_file(fname);
289 _generate_c_file(c_filename, cname, (files4gen != itr));
290 }
275 } 291 }
276 292
277 if (leg_filename) 293 if (leg_filename)
@@ -287,9 +303,9 @@ int main(int argc, char **argv)
287 } 303 }
288 304
289end: 305end:
290 EINA_LIST_FREE(files, filename) 306 EINA_LIST_FREE(included_files, filename)
291 free((char *)filename); 307 free((char *)filename);
292 eina_list_free(classes); 308 eina_list_free(files4gen);
293 eolian_shutdown(); 309 eolian_shutdown();
294 eina_shutdown(); 310 eina_shutdown();
295 return ret; 311 return ret;