summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-10-06 14:56:49 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-10-07 11:54:23 +0200
commit1ad1eb300bff7bab2300d94ca9d8529eed870f1f (patch)
tree9242a9ec578c1c7e1be39b6cffeaaa04654137a3
parent08e270391766e210e346dfcee2ed224a982b0223 (diff)
eolian gen2: fix file read to actually trigger impl gen
-rw-r--r--src/bin/eolian2/main.c22
-rw-r--r--src/bin/eolian2/sources.c6
2 files changed, 16 insertions, 12 deletions
diff --git a/src/bin/eolian2/main.c b/src/bin/eolian2/main.c
index 68b7896077..a7d9aed2b5 100644
--- a/src/bin/eolian2/main.c
+++ b/src/bin/eolian2/main.c
@@ -183,12 +183,15 @@ end:
183 return fret; 183 return fret;
184} 184}
185 185
186static Eina_Strbuf * 186static Eina_Bool
187_read_file(const char *fname) 187_read_file(const char *fname, Eina_Strbuf **buf)
188{ 188{
189 FILE *f = fopen(fname, "rb"); 189 FILE *f = fopen(fname, "rb");
190 if (!f) 190 if (!f)
191 return NULL; 191 {
192 *buf = eina_strbuf_new();
193 return EINA_TRUE;
194 }
192 195
193 fseek(f, 0, SEEK_END); 196 fseek(f, 0, SEEK_END);
194 long fs = ftell(f); 197 long fs = ftell(f);
@@ -196,7 +199,7 @@ _read_file(const char *fname)
196 { 199 {
197 fprintf(stderr, "eolian: could not get length of '%s'\n", fname); 200 fprintf(stderr, "eolian: could not get length of '%s'\n", fname);
198 fclose(f); 201 fclose(f);
199 return NULL; 202 return EINA_FALSE;
200 } 203 }
201 fseek(f, 0, SEEK_SET); 204 fseek(f, 0, SEEK_SET);
202 205
@@ -205,7 +208,7 @@ _read_file(const char *fname)
205 { 208 {
206 fprintf(stderr, "eolian: could not allocate memory for '%s'\n", fname); 209 fprintf(stderr, "eolian: could not allocate memory for '%s'\n", fname);
207 fclose(f); 210 fclose(f);
208 return NULL; 211 return EINA_FALSE;
209 } 212 }
210 213
211 long as = fread(cont, 1, fs, f); 214 long as = fread(cont, 1, fs, f);
@@ -215,12 +218,13 @@ _read_file(const char *fname)
215 fs, fname, as); 218 fs, fname, as);
216 free(cont); 219 free(cont);
217 fclose(f); 220 fclose(f);
218 return NULL; 221 return EINA_FALSE;
219 } 222 }
220 223
221 cont[fs] = '\0'; 224 cont[fs] = '\0';
222 fclose(f); 225 fclose(f);
223 return eina_strbuf_manage_new_length(cont, fs); 226 *buf = eina_strbuf_manage_new_length(cont, fs);
227 return EINA_TRUE;
224} 228}
225 229
226char *eo_gen_c_full_name_get(const char *nm) 230char *eo_gen_c_full_name_get(const char *nm)
@@ -361,8 +365,8 @@ _write_impl(const char *ofname, const char *ifname)
361 if (!cl) 365 if (!cl)
362 return EINA_FALSE; 366 return EINA_FALSE;
363 367
364 Eina_Strbuf *buf = _read_file(ofname); 368 Eina_Strbuf *buf;
365 if (!buf) 369 if (!_read_file(ofname, &buf))
366 return EINA_FALSE; 370 return EINA_FALSE;
367 371
368 eo_gen_impl_gen(cl, buf); 372 eo_gen_impl_gen(cl, buf);
diff --git a/src/bin/eolian2/sources.c b/src/bin/eolian2/sources.c
index dfcf224371..afeb5d7b83 100644
--- a/src/bin/eolian2/sources.c
+++ b/src/bin/eolian2/sources.c
@@ -859,7 +859,7 @@ eo_gen_impl_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
859 if (adt[0] && !_type_exists(adt, buf)) 859 if (adt[0] && !_type_exists(adt, buf))
860 { 860 {
861 printf("generating data type structure %s...\n", adt); 861 printf("generating data type structure %s...\n", adt);
862 eina_strbuf_append_printf(beg, "typedef struct\n{\n} %s;\n\n", adt); 862 eina_strbuf_append_printf(beg, "typedef struct\n{\n\n} %s;\n\n", adt);
863 } 863 }
864 864
865 if (eina_strbuf_length_get(beg)) 865 if (eina_strbuf_length_get(beg))
@@ -902,7 +902,7 @@ eo_gen_impl_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
902 eina_strbuf_append_printf(buf, 902 eina_strbuf_append_printf(buf,
903 "EOLIAN static void\n" 903 "EOLIAN static void\n"
904 "_%s_class_constructor(Efl_Class *klass)\n" 904 "_%s_class_constructor(Efl_Class *klass)\n"
905 "{\n" 905 "{\n\n"
906 "}\n\n", cnamel); 906 "}\n\n", cnamel);
907 } 907 }
908 } 908 }
@@ -917,7 +917,7 @@ eo_gen_impl_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
917 eina_strbuf_append_printf(buf, 917 eina_strbuf_append_printf(buf,
918 "EOLIAN static void\n" 918 "EOLIAN static void\n"
919 "_%s_class_destructor(Efl_Class *klass)\n" 919 "_%s_class_destructor(Efl_Class *klass)\n"
920 "{\n" 920 "{\n\n"
921 "}\n\n", cnamel); 921 "}\n\n", cnamel);
922 } 922 }
923 } 923 }