summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-02-25 17:27:38 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-03-03 14:09:57 +0200
commit1287177ac2183952dacfdf58ec6aa3b3401d7274 (patch)
tree54cef9aa29857a63db05028b659474fd591a818c /src/bin
parentb3beeb42448ad068eb77c13c9e3aa962332f7ab4 (diff)
Eolian: New features/bugs fixes
1) Include files now have include guards 2) --gh option generates legacy header with --legacy flag and eo header without --legacy flag 3) EOLIAN keyword is introduced to mark functions used by generated file. 4) * for comments when comment text is empty
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian/eo1_generator.c6
-rw-r--r--src/bin/eolian/legacy_generator.c4
-rw-r--r--src/bin/eolian/main.c47
3 files changed, 50 insertions, 7 deletions
diff --git a/src/bin/eolian/eo1_generator.c b/src/bin/eolian/eo1_generator.c
index 8e1f2407f6..1542f08ab5 100644
--- a/src/bin/eolian/eo1_generator.c
+++ b/src/bin/eolian/eo1_generator.c
@@ -152,7 +152,11 @@ eo1_fundef_generate(const char *classname, Eolian_Function func, Eolian_Function
152 if (eina_strbuf_length_get(linedesc)) 152 if (eina_strbuf_length_get(linedesc))
153 { 153 {
154 eina_strbuf_replace_all(linedesc, "\n", "\n * "); 154 eina_strbuf_replace_all(linedesc, "\n", "\n * ");
155 eina_strbuf_prepend(linedesc," * "); 155 eina_strbuf_prepend(linedesc, " * ");
156 }
157 else
158 {
159 eina_strbuf_append(linedesc, " *");
156 } 160 }
157 161
158 eina_strbuf_replace_all(str_func, "@#desc", eina_strbuf_string_get(linedesc)); 162 eina_strbuf_replace_all(str_func, "@#desc", eina_strbuf_string_get(linedesc));
diff --git a/src/bin/eolian/legacy_generator.c b/src/bin/eolian/legacy_generator.c
index d16e198610..2ee6694fb2 100644
--- a/src/bin/eolian/legacy_generator.c
+++ b/src/bin/eolian/legacy_generator.c
@@ -89,6 +89,10 @@ _eapi_decl_func_generate(const char *classname, Eolian_Function funcid, Eolian_F
89 eina_strbuf_replace_all(linedesc, "\n", "\n * "); 89 eina_strbuf_replace_all(linedesc, "\n", "\n * ");
90 eina_strbuf_prepend(linedesc," * "); 90 eina_strbuf_prepend(linedesc," * ");
91 } 91 }
92 else
93 {
94 eina_strbuf_append(linedesc," *");
95 }
92 96
93 eina_strbuf_replace_all(fbody, "@#desc", eina_strbuf_string_get(linedesc)); 97 eina_strbuf_replace_all(fbody, "@#desc", eina_strbuf_string_get(linedesc));
94 eina_strbuf_free(linedesc); 98 eina_strbuf_free(linedesc);
diff --git a/src/bin/eolian/main.c b/src/bin/eolian/main.c
index 754f6e8bb8..6fe3e9d705 100644
--- a/src/bin/eolian/main.c
+++ b/src/bin/eolian/main.c
@@ -13,6 +13,24 @@
13static int eo_version = 0; 13static int eo_version = 0;
14static Eina_Bool legacy_support = EINA_FALSE; 14static Eina_Bool legacy_support = EINA_FALSE;
15 15
16static char*
17_include_guard_enclose(const char *fname, const char *fbody)
18{
19 char incname[0xFF];
20 strcpy (incname, fname);
21 char *p = incname;
22 eina_str_toupper(&p);
23
24 Eina_Strbuf *incguard = eina_strbuf_new();
25 eina_strbuf_append_printf(incguard,
26 "#ifndef _%s_\n#define _%s_\n\n_code_\n#endif",
27 incname,
28 incname);
29 eina_strbuf_replace_all(incguard, ".", "_");
30 eina_strbuf_replace_all(incguard, "_code_", fbody);
31 return eina_strbuf_string_steal(incguard);
32}
33
16static Eina_Bool 34static Eina_Bool
17_generate_h_file(char *filename, const char *classname, Eina_Bool append) 35_generate_h_file(char *filename, const char *classname, Eina_Bool append)
18{ 36{
@@ -44,6 +62,7 @@ _generate_h_file(char *filename, const char *classname, Eina_Bool append)
44 goto end; 62 goto end;
45 } 63 }
46 } 64 }
65
47 const char *htext = eina_strbuf_string_get(hfile); 66 const char *htext = eina_strbuf_string_get(hfile);
48 67
49 FILE* fd = fopen(filename, "w"); 68 FILE* fd = fopen(filename, "w");
@@ -52,7 +71,14 @@ _generate_h_file(char *filename, const char *classname, Eina_Bool append)
52 ERR ("Couldn't open file %s for writing", filename); 71 ERR ("Couldn't open file %s for writing", filename);
53 goto end; 72 goto end;
54 } 73 }
55 if (htext) fputs(htext, fd); 74
75 if (htext)
76 {
77 char *fcontent = _include_guard_enclose(ecore_file_file_get(filename), htext);
78 fputs(fcontent, fd);
79 free(fcontent);
80 }
81
56 fclose(fd); 82 fclose(fd);
57 83
58 ret = EINA_TRUE; 84 ret = EINA_TRUE;
@@ -117,7 +143,7 @@ _generate_legacy_header_file(char *filename, const char *classname, Eina_Bool ap
117 } 143 }
118 else 144 else
119 { 145 {
120 if (!eo1_header_generate(classname, lfile)) 146 if (!legacy_header_generate(classname, eo_version, lfile))
121 { 147 {
122 ERR("Failed to generate header for %s", classname); 148 ERR("Failed to generate header for %s", classname);
123 goto end; 149 goto end;
@@ -130,8 +156,16 @@ _generate_legacy_header_file(char *filename, const char *classname, Eina_Bool ap
130 ERR ("Couldnt open file %s for writing", filename); 156 ERR ("Couldnt open file %s for writing", filename);
131 goto end; 157 goto end;
132 } 158 }
159
133 const char *ltext = eina_strbuf_string_get(lfile); 160 const char *ltext = eina_strbuf_string_get(lfile);
134 if (ltext) fputs(ltext, fd); 161
162 if (ltext)
163 {
164 char *fcontent = _include_guard_enclose(ecore_file_file_get(filename), ltext);
165 fputs(fcontent, fd);
166 free(fcontent);
167 }
168
135 fclose(fd); 169 fclose(fd);
136 170
137 ret = EINA_TRUE; 171 ret = EINA_TRUE;
@@ -222,7 +256,6 @@ int main(int argc, char **argv)
222 {"gc", no_argument, &gen_opt, C_GEN}, 256 {"gc", no_argument, &gen_opt, C_GEN},
223 {"ah", no_argument, &gen_opt, H_EO_APP}, 257 {"ah", no_argument, &gen_opt, H_EO_APP},
224 {"al", no_argument, &gen_opt, H_LEG_APP}, 258 {"al", no_argument, &gen_opt, H_LEG_APP},
225 {"gle", no_argument, &gen_opt, H_LEG_EO_GEN},
226 {"output", required_argument, 0, 'o'}, 259 {"output", required_argument, 0, 'o'},
227 {"legacy", no_argument, (int *)&legacy_support, EINA_TRUE}, 260 {"legacy", no_argument, (int *)&legacy_support, EINA_TRUE},
228 {"include", required_argument, 0, 'I'}, 261 {"include", required_argument, 0, 'I'},
@@ -281,7 +314,6 @@ int main(int argc, char **argv)
281 printf(" --gc Generate c source file [.c]\n"); 314 printf(" --gc Generate c source file [.c]\n");
282 printf(" --ah Append eo class definitions to an existing c header file [.h]\n"); 315 printf(" --ah Append eo class definitions to an existing c header file [.h]\n");
283 printf(" --al Append legacy function definitions to an existing c header file [.h]\n"); 316 printf(" --al Append legacy function definitions to an existing c header file [.h]\n");
284 printf(" --gle Generate eo and legacy file [.h]\n");
285 printf(" --legacy Generate legacy\n"); 317 printf(" --legacy Generate legacy\n");
286 ret = 0; 318 ret = 0;
287 goto end; 319 goto end;
@@ -343,7 +375,10 @@ int main(int argc, char **argv)
343 case H_GEN: case H_EO_APP: 375 case H_GEN: case H_EO_APP:
344 { 376 {
345 INF("%s header file %s\n", (gen_opt == H_EO_APP) ? "Appending" : "Generating", output_filename); 377 INF("%s header file %s\n", (gen_opt == H_EO_APP) ? "Appending" : "Generating", output_filename);
346 ret = (_generate_h_file(output_filename, classname, gen_opt == H_EO_APP)?0:1); 378 if (legacy_support)
379 ret = ( _generate_legacy_header_file(output_filename, classname, EINA_FALSE) ? 0 : 1 );
380 else
381 ret = ( _generate_h_file(output_filename, classname, EINA_FALSE) ? 0 : 1 );
347 break; 382 break;
348 } 383 }
349 case H_LEG_APP: 384 case H_LEG_APP: