forked from enlightenment/efl
Eolian/Generator: support legacy as option.
For the moment, the option works for C files. Have to add support for H files.
This commit is contained in:
parent
327202ef37
commit
ab8d877150
|
@ -397,7 +397,7 @@ legacy_header_append(const char *classname, int eo_version, Eina_Strbuf *header)
|
||||||
}
|
}
|
||||||
|
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
legacy_source_generate(const char *classname, int eo_version, Eina_Strbuf *buf)
|
legacy_source_generate(const char *classname, Eina_Bool legacy, int eo_version, Eina_Strbuf *buf)
|
||||||
{
|
{
|
||||||
const Eina_List *itr;
|
const Eina_List *itr;
|
||||||
|
|
||||||
|
@ -424,12 +424,12 @@ legacy_source_generate(const char *classname, int eo_version, Eina_Strbuf *buf)
|
||||||
if (prop_read)
|
if (prop_read)
|
||||||
{
|
{
|
||||||
eo1_bind_func_generate(classname, fn, GET, str_bodyf);
|
eo1_bind_func_generate(classname, fn, GET, str_bodyf);
|
||||||
_eapi_func_generate(classname, fn, GET, str_bodyf);
|
if (legacy) _eapi_func_generate(classname, fn, GET, str_bodyf);
|
||||||
}
|
}
|
||||||
if (prop_write)
|
if (prop_write)
|
||||||
{
|
{
|
||||||
eo1_bind_func_generate(classname, fn, SET, str_bodyf);
|
eo1_bind_func_generate(classname, fn, SET, str_bodyf);
|
||||||
_eapi_func_generate(classname, fn, SET, str_bodyf);
|
if (legacy) _eapi_func_generate(classname, fn, SET, str_bodyf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,7 +437,7 @@ legacy_source_generate(const char *classname, int eo_version, Eina_Strbuf *buf)
|
||||||
EINA_LIST_FOREACH(eolian_class_functions_list_get(classname, METHOD_FUNC), itr, fn)
|
EINA_LIST_FOREACH(eolian_class_functions_list_get(classname, METHOD_FUNC), itr, fn)
|
||||||
{
|
{
|
||||||
eo1_bind_func_generate(classname, fn, UNRESOLVED, str_bodyf);
|
eo1_bind_func_generate(classname, fn, UNRESOLVED, str_bodyf);
|
||||||
_eapi_func_generate(classname, fn, UNRESOLVED, str_bodyf);
|
if (legacy) _eapi_func_generate(classname, fn, UNRESOLVED, str_bodyf);
|
||||||
}
|
}
|
||||||
|
|
||||||
eina_strbuf_append(buf, eina_strbuf_string_get(str_bodyf));
|
eina_strbuf_append(buf, eina_strbuf_string_get(str_bodyf));
|
||||||
|
|
|
@ -41,13 +41,14 @@ Eina_Bool legacy_header_append(const char *classname, int eo_version, Eina_Strbu
|
||||||
* code from scratch.
|
* code from scratch.
|
||||||
*
|
*
|
||||||
* @param[in] classname class name
|
* @param[in] classname class name
|
||||||
|
* @param[in] legacy indicates if the legacy has to be generated
|
||||||
* @param[in] eo_version Eo version to generate
|
* @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_Bool legacy, int eo_version, Eina_Strbuf *buf);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#define EO_SUFFIX ".eo"
|
#define EO_SUFFIX ".eo"
|
||||||
|
|
||||||
static int eo_version = 0;
|
static int eo_version = 0;
|
||||||
|
static Eina_Bool legacy_support = EINA_FALSE;
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_generate_h_file(char *filename, char *classname, Eina_Bool append)
|
_generate_h_file(char *filename, char *classname, Eina_Bool append)
|
||||||
|
@ -58,7 +59,7 @@ _generate_c_file(char *filename, char *classname, Eina_Bool append)
|
||||||
Eina_Bool ret = EINA_FALSE;
|
Eina_Bool ret = EINA_FALSE;
|
||||||
|
|
||||||
Eina_Strbuf *cfile = eina_strbuf_new();
|
Eina_Strbuf *cfile = eina_strbuf_new();
|
||||||
legacy_source_generate(classname, eo_version, cfile);
|
legacy_source_generate(classname, legacy_support, eo_version, cfile);
|
||||||
|
|
||||||
FILE* fd = fopen(filename, (append) ? "a" : "w");
|
FILE* fd = fopen(filename, (append) ? "a" : "w");
|
||||||
if (!fd)
|
if (!fd)
|
||||||
|
@ -171,6 +172,7 @@ int main(int argc, char **argv)
|
||||||
{"ah", required_argument, 0, 3},
|
{"ah", required_argument, 0, 3},
|
||||||
{"al", required_argument, 0, 4},
|
{"al", required_argument, 0, 4},
|
||||||
{"gle", required_argument, 0, 5},
|
{"gle", required_argument, 0, 5},
|
||||||
|
{"legacy", no_argument, 0, 6},
|
||||||
{"include", required_argument, 0, 'I'},
|
{"include", required_argument, 0, 'I'},
|
||||||
{"class", required_argument, 0, 'c'},
|
{"class", required_argument, 0, 'c'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
|
@ -185,6 +187,7 @@ int main(int argc, char **argv)
|
||||||
case 3: h_filename = optarg; happend = EINA_TRUE; break;
|
case 3: h_filename = optarg; happend = EINA_TRUE; break;
|
||||||
case 4: leg_filename = optarg; lappend = EINA_TRUE; break;
|
case 4: leg_filename = optarg; lappend = EINA_TRUE; break;
|
||||||
case 5: eoleg_filename = optarg; break;
|
case 5: eoleg_filename = optarg; break;
|
||||||
|
case 6: legacy_support = EINA_TRUE; break;
|
||||||
case 'V': show = EINA_TRUE; break;
|
case 'V': show = EINA_TRUE; break;
|
||||||
case 'h': help = EINA_TRUE; break;
|
case 'h': help = EINA_TRUE; break;
|
||||||
case 'I':
|
case 'I':
|
||||||
|
@ -225,13 +228,14 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
if (!files || help || !classname)
|
if (!files || help || !classname)
|
||||||
{
|
{
|
||||||
printf("Usage: %s [-h/--help] [-V/--verbose] [-I/--include input_dir] [--gh|--gc|--ah] filename [-c/--class] classname \n", argv[0]);
|
printf("Usage: %s [-h/--help] [-V/--verbose] [-I/--include input_dir] [--legacy] [--gh|--gc|--ah] filename [-c/--class] classname \n", argv[0]);
|
||||||
printf(" --eo1/--eo2 Set generator to eo1/eo2 mode. Must be specified\n");
|
printf(" --eo1/--eo2 Set generator to eo1/eo2 mode. Must be specified\n");
|
||||||
printf(" --gh Generate c header file [.h] for eo class specified by classname\n");
|
printf(" --gh Generate c header file [.h] for eo class specified by classname\n");
|
||||||
printf(" --gc Generate c source file [.c] for eo class specified by classname\n");
|
printf(" --gc Generate c source file [.c] for eo class specified by classname\n");
|
||||||
printf(" --ah Append eo class definitions to an existing c header file [.h]\n");
|
printf(" --ah Append eo class definitions to an existing c header file [.h]\n");
|
||||||
printf(" --al Append legacy function definitions to an existing c header file [.h]\n");
|
printf(" --al Append legacy function definitions to an existing c header file [.h]\n");
|
||||||
printf(" --gle Generate eo and legacy file [.h]\n");
|
printf(" --gle Generate eo and legacy file [.h]\n");
|
||||||
|
printf(" --legacy Generate legacy\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue