Eolian/Generator: support --eo.

--eo1 is still supported but it will be removed soon.
This commit is contained in:
Daniel Zaoui 2014-04-23 08:55:15 +03:00
parent 9122f603f9
commit 5ea1ffac5b
6 changed files with 20 additions and 24 deletions

View File

@ -13,10 +13,10 @@ am__v_EOL_0 = @echo " EOLIAN " $@;
SUFFIXES = .eo .eo.c .eo.h .eo.legacy.h SUFFIXES = .eo .eo.c .eo.h .eo.legacy.h
%.eo.c: %.eo ${_EOLIAN_GEN_DEP} %.eo.c: %.eo ${_EOLIAN_GEN_DEP}
$(AM_V_EOL)$(EOLIAN_GEN) --eo1 --legacy $(EOLIAN_FLAGS) --gc -o $@ $< $(AM_V_EOL)$(EOLIAN_GEN) --eo --legacy $(EOLIAN_FLAGS) --gc -o $@ $<
%.eo.h: %.eo ${_EOLIAN_GEN_DEP} %.eo.h: %.eo ${_EOLIAN_GEN_DEP}
$(AM_V_EOL)$(EOLIAN_GEN) --eo1 $(EOLIAN_FLAGS) --gh -o $@ $< $(AM_V_EOL)$(EOLIAN_GEN) --eo $(EOLIAN_FLAGS) --gh -o $@ $<
%.eo.legacy.h: %.eo ${_EOLIAN_GEN_DEP} %.eo.legacy.h: %.eo ${_EOLIAN_GEN_DEP}
$(AM_V_EOL)$(EOLIAN_GEN) --legacy $(EOLIAN_FLAGS) --gh -o $@ $< $(AM_V_EOL)$(EOLIAN_GEN) --legacy $(EOLIAN_FLAGS) --gh -o $@ $<

View File

@ -876,7 +876,7 @@ end:
} }
Eina_Bool Eina_Bool
eo_source_generate(const char *classname, int eo_version EINA_UNUSED, Eina_Strbuf *buf) eo_source_generate(const char *classname, Eina_Strbuf *buf)
{ {
Eina_Bool ret = EINA_FALSE; Eina_Bool ret = EINA_FALSE;
const Eina_List *itr; const Eina_List *itr;

View File

@ -9,14 +9,13 @@
* This function generates all the source code for Eo. * This function generates all the source code for Eo.
* *
* @param[in] classname class name * @param[in] classname class name
* @param[in] eo_version Eo version to generate
* @param[inout] buf buffer to fill * @param[inout] buf buffer to fill
* *
* @return EINA_TRUE on success, EINA_FALSE on error. * @return EINA_TRUE on success, EINA_FALSE on error.
* *
*/ */
Eina_Bool Eina_Bool
eo_source_generate(const char *classname, int eo_version, Eina_Strbuf *buf); eo_source_generate(const char *classname, Eina_Strbuf *buf);
/* /*
* @brief Generate the header code for a specific Eo class. * @brief Generate the header code for a specific Eo class.

View File

@ -344,7 +344,7 @@ end:
} }
Eina_Bool Eina_Bool
legacy_header_generate(const char *classname, int eo_version EINA_UNUSED, Eina_Strbuf *buf) legacy_header_generate(const char *classname, Eina_Strbuf *buf)
{ {
const Eolian_Function_Type ftype_order[] = {EOLIAN_PROPERTY, EOLIAN_METHOD}; const Eolian_Function_Type ftype_order[] = {EOLIAN_PROPERTY, EOLIAN_METHOD};
const Eina_List *l; const Eina_List *l;
@ -381,7 +381,7 @@ legacy_header_generate(const char *classname, int eo_version EINA_UNUSED, Eina_S
} }
Eina_Bool Eina_Bool
legacy_source_generate(const char *classname, int eo_version EINA_UNUSED, Eina_Strbuf *buf) legacy_source_generate(const char *classname, Eina_Strbuf *buf)
{ {
Eina_Bool ret = EINA_FALSE; Eina_Bool ret = EINA_FALSE;
const Eina_List *itr; const Eina_List *itr;

View File

@ -11,13 +11,12 @@
* There will not be respect of the order of the Eo Op Ids. * There will not be respect of the order of the Eo Op Ids.
* *
* @param[in] classname class name * @param[in] classname class name
* @param[in] eo_version Eo version to generate
* @param[inout] buf buffer to fill * @param[inout] buf buffer to fill
* *
* @return EINA_TRUE on success, EINA_FALSE on error. * @return EINA_TRUE on success, EINA_FALSE on error.
* *
*/ */
Eina_Bool legacy_header_generate(const char *classname, int eo_version, Eina_Strbuf *buf); Eina_Bool legacy_header_generate(const char *classname, Eina_Strbuf *buf);
/* /*
* @brief Generate C source code for Eo class * @brief Generate C source code for Eo class
@ -26,13 +25,12 @@ Eina_Bool legacy_header_generate(const char *classname, int eo_version, Eina_Str
* code from scratch. * code from scratch.
* *
* @param[in] classname class name * @param[in] classname class name
* @param[in] eo_version Eo version to generate
* @param[inout] buf buffer to fill * @param[inout] buf buffer to fill
* *
* @return EINA_TRUE on success, EINA_FALSE on error. * @return EINA_TRUE on success, EINA_FALSE on error.
* *
*/ */
Eina_Bool legacy_source_generate(const char *classname, int eo_version, Eina_Strbuf *buf); Eina_Bool legacy_source_generate(const char *classname, Eina_Strbuf *buf);
#endif #endif

View File

@ -9,9 +9,6 @@
#define EO_SUFFIX ".eo" #define EO_SUFFIX ".eo"
static int eo_version = 0;
static Eina_Bool legacy_support = EINA_FALSE;
static char* static char*
_include_guard_enclose(const char *fname, const char *fbody) _include_guard_enclose(const char *fname, const char *fbody)
{ {
@ -82,21 +79,21 @@ end:
} }
static Eina_Bool static Eina_Bool
_generate_c_file(char *filename, const char *classname) _generate_c_file(char *filename, const char *classname, Eina_Bool legacy_support)
{ {
Eina_Bool ret = EINA_FALSE; Eina_Bool ret = EINA_FALSE;
Eina_Strbuf *eo_buf = eina_strbuf_new(); Eina_Strbuf *eo_buf = eina_strbuf_new();
Eina_Strbuf *legacy_buf = eina_strbuf_new(); Eina_Strbuf *legacy_buf = eina_strbuf_new();
if (!eo_source_generate(classname, eo_version, eo_buf)) if (!eo_source_generate(classname, eo_buf))
{ {
ERR("Failed to generate source for %s", classname); ERR("Failed to generate source for %s", classname);
goto end; goto end;
} }
if (legacy_support) if (legacy_support)
if (!legacy_source_generate(classname, eo_version, legacy_buf)) if (!legacy_source_generate(classname, legacy_buf))
{ {
ERR("Failed to generate source for %s", classname); ERR("Failed to generate source for %s", classname);
goto end; goto end;
@ -131,7 +128,7 @@ _generate_legacy_header_file(char *filename, const char *classname)
Eina_Strbuf *lfile = eina_strbuf_new(); Eina_Strbuf *lfile = eina_strbuf_new();
if (!legacy_header_generate(classname, eo_version, lfile)) if (!legacy_header_generate(classname, lfile))
{ {
ERR("Failed to generate header for %s", classname); ERR("Failed to generate header for %s", classname);
goto end; goto end;
@ -167,7 +164,9 @@ enum
H_GEN, H_GEN,
C_GEN C_GEN
}; };
int gen_opt = NO_WAY_GEN; static int gen_opt = NO_WAY_GEN;
static int eo_needed = 0;
static Eina_Bool legacy_support = EINA_FALSE;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
@ -196,8 +195,8 @@ int main(int argc, char **argv)
static struct option long_options[] = static struct option long_options[] =
{ {
/* These options set a flag. */ /* These options set a flag. */
{"eo1", no_argument, &eo_version, 1}, {"eo1", no_argument, &eo_needed, 1},
{"eo", no_argument, &eo_version, 2}, {"eo", no_argument, &eo_needed, 1},
{"verbose", no_argument, 0, 'v'}, {"verbose", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{"gh", no_argument, &gen_opt, H_GEN}, {"gh", no_argument, &gen_opt, H_GEN},
@ -293,9 +292,9 @@ int main(int argc, char **argv)
} }
} }
if (!eo_version && !(gen_opt==H_GEN && legacy_support)) if (!eo_needed && !(gen_opt == H_GEN && legacy_support))
{ {
ERR("No eo version specified (use --eo). Aborting eo generation.\n"); ERR("Eo flag is not specified (use --eo). Aborting eo generation.\n");
goto end; goto end;
} }
@ -324,7 +323,7 @@ int main(int argc, char **argv)
case C_GEN: case C_GEN:
{ {
INF("Generating source file %s\n", output_filename); INF("Generating source file %s\n", output_filename);
ret = _generate_c_file(output_filename, classname)?0:1; ret = _generate_c_file(output_filename, classname, legacy_support)?0:1;
break; break;
} }
default: default: