summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-09-15 15:30:07 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-10-07 11:54:23 +0200
commit341ef8fc05b88ae8ee1c46de1baaf548cb5e4725 (patch)
tree5a41e3844503739049d25c3c4175197d017c14b1
parent17885ed3758096f677a5f2f2c73e07e5ba926388 (diff)
eolian gen2: initial type generation bits
-rw-r--r--src/Makefile_Eolian.am4
-rw-r--r--src/bin/eolian2/main.c23
-rw-r--r--src/bin/eolian2/main.h2
-rw-r--r--src/bin/eolian2/types.c15
-rw-r--r--src/bin/eolian2/types.h6
5 files changed, 49 insertions, 1 deletions
diff --git a/src/Makefile_Eolian.am b/src/Makefile_Eolian.am
index 06f4f924b1..654194a3a3 100644
--- a/src/Makefile_Eolian.am
+++ b/src/Makefile_Eolian.am
@@ -73,7 +73,9 @@ bin_PROGRAMS += \
73 73
74bin_eolian2_eolian_gen2_SOURCES = \ 74bin_eolian2_eolian_gen2_SOURCES = \
75 bin/eolian2/main.c \ 75 bin/eolian2/main.c \
76 bin/eolian2/main.h 76 bin/eolian2/main.h \
77 bin/eolian2/types.c \
78 bin/eolian2/types.h
77 79
78bin_eolian2_eolian_gen2_CPPFLAGS = -I$(top_builddir)/src/lib/efl @EOLIAN_CFLAGS@ 80bin_eolian2_eolian_gen2_CPPFLAGS = -I$(top_builddir)/src/lib/efl @EOLIAN_CFLAGS@
79bin_eolian2_eolian_gen2_LDADD = @USE_EOLIAN_LIBS@ 81bin_eolian2_eolian_gen2_LDADD = @USE_EOLIAN_LIBS@
diff --git a/src/bin/eolian2/main.c b/src/bin/eolian2/main.c
index d8d945cc85..0e6b019e60 100644
--- a/src/bin/eolian2/main.c
+++ b/src/bin/eolian2/main.c
@@ -6,6 +6,7 @@
6#include <libgen.h> 6#include <libgen.h>
7 7
8#include "main.h" 8#include "main.h"
9#include "types.h"
9 10
10int _eolian_gen_log_dom = -1; 11int _eolian_gen_log_dom = -1;
11 12
@@ -201,12 +202,34 @@ _read_file(const char *fname)
201 return eina_strbuf_manage_new_length(cont, fs); 202 return eina_strbuf_manage_new_length(cont, fs);
202} 203}
203 204
205char *eo_gen_class_full_name_get(const Eolian_Class *cl)
206{
207 Eina_Stringshare *cln = eolian_class_full_name_get(cl);
208 if (!cln)
209 return NULL;
210 char *buf = strdup(cln);
211 if (!buf)
212 return NULL;
213 for (char *p = strchr(buf, '.'); p; p = strchr(p, '.'))
214 *p = '_';
215 return buf;
216}
217
204static Eina_Bool 218static Eina_Bool
205_write_header(const char *ofname, const char *ifname, Eina_Bool legacy) 219_write_header(const char *ofname, const char *ifname, Eina_Bool legacy)
206{ 220{
207 INF("generating header: %s (legacy: %d)", ofname, legacy); 221 INF("generating header: %s (legacy: %d)", ofname, legacy);
208 Eina_Strbuf *buf = eina_strbuf_new(); 222 Eina_Strbuf *buf = eina_strbuf_new();
209 223
224 Eina_Strbuf *cltd = eo_gen_class_typedef_gen(ifname);
225 if (cltd)
226 {
227 cltd = _include_guard(ifname, "CLASS_TYPE", cltd);
228 eina_strbuf_append(buf, eina_strbuf_string_get(cltd));
229 eina_strbuf_append_char(buf, '\n');
230 eina_strbuf_free(cltd);
231 }
232
210 Eina_Bool ret = _write_file(ofname, buf, EINA_FALSE); 233 Eina_Bool ret = _write_file(ofname, buf, EINA_FALSE);
211 eina_strbuf_free(buf); 234 eina_strbuf_free(buf);
212 return ret; 235 return ret;
diff --git a/src/bin/eolian2/main.h b/src/bin/eolian2/main.h
index e80e5dc7bb..985e806ef0 100644
--- a/src/bin/eolian2/main.h
+++ b/src/bin/eolian2/main.h
@@ -31,4 +31,6 @@ extern int _eolian_gen_log_dom;
31#endif 31#endif
32#define CRIT(...) EINA_LOG_DOM_CRIT(_eolian_gen_log_dom, __VA_ARGS__) 32#define CRIT(...) EINA_LOG_DOM_CRIT(_eolian_gen_log_dom, __VA_ARGS__)
33 33
34char *eo_gen_class_full_name_get(const Eolian_Class *cl);
35
34#endif 36#endif
diff --git a/src/bin/eolian2/types.c b/src/bin/eolian2/types.c
new file mode 100644
index 0000000000..4669e281c1
--- /dev/null
+++ b/src/bin/eolian2/types.c
@@ -0,0 +1,15 @@
1#include "main.h"
2
3Eina_Strbuf *eo_gen_class_typedef_gen(const char *eof)
4{
5 const Eolian_Class *cl = eolian_class_get_by_file(eof);
6 if (!cl)
7 return NULL;
8 char *clfn = eo_gen_class_full_name_get(cl);
9 if (!clfn)
10 return NULL;
11 Eina_Strbuf *ret = eina_strbuf_new();
12 eina_strbuf_append_printf(ret, "typedef Eo %s;\n", clfn);
13 free(clfn);
14 return ret;
15}
diff --git a/src/bin/eolian2/types.h b/src/bin/eolian2/types.h
new file mode 100644
index 0000000000..2f4434ecaa
--- /dev/null
+++ b/src/bin/eolian2/types.h
@@ -0,0 +1,6 @@
1#ifndef EOLIAN_GEN_TYPES_H
2#define EOLIAN_GEN_TYPES_H
3
4Eina_Strbuf *eo_gen_class_typedef_gen(const char *eof);
5
6#endif