eolian gen2: fix tests to match the new generator

This commit is contained in:
Daniel Kolesa 2016-10-07 13:13:27 +02:00
parent b15d0583e7
commit 82291e9cf5
12 changed files with 130 additions and 123 deletions

View File

@ -11,9 +11,9 @@ void _class_simple_b_set(Eo *obj, Evas_Simple_Data *pd);
EOAPI EFL_VOID_FUNC_BODY(efl_canvas_object_simple_b_set);
char * _class_simple_foo(Eo *obj, Evas_Simple_Data *pd, int a, char *b, double *c, int *d);
char *_class_simple_foo(Eo *obj, Evas_Simple_Data *pd, int a, char *b, double *c, int *d);
static char * __eolian_class_simple_foo(Eo *obj, Evas_Simple_Data *pd, int a, char *b, double *c, int *d)
static char *__eolian_class_simple_foo(Eo *obj, Evas_Simple_Data *pd, int a, char *b, double *c, int *d)
{
if (c) *c = 1337.600000;
return _class_simple_foo(obj, pd, a, b, c, d);
@ -21,7 +21,7 @@ static char * __eolian_class_simple_foo(Eo *obj, Evas_Simple_Data *pd, int a, ch
EOAPI EFL_FUNC_BODYV(efl_canvas_object_simple_foo, char *, NULL, EFL_FUNC_CALL(a, b, c, d), int a, char *b, double *c, int *d);
int * _class_simple_bar(Eo *obj, Evas_Simple_Data *pd, int x);
int *_class_simple_bar(Eo *obj, Evas_Simple_Data *pd, int x);
EOAPI EFL_FUNC_BODYV(efl_canvas_object_simple_bar, int *, 0, EFL_FUNC_CALL(x), int x);
@ -31,20 +31,33 @@ _class_simple_class_initializer(Efl_Class *klass)
EFL_OPS_DEFINE(ops,
EFL_OBJECT_OP_FUNC(efl_canvas_object_simple_a_set, _class_simple_a_set),
EFL_OBJECT_OP_FUNC(efl_canvas_object_simple_a_get, _class_simple_a_get),
EFL_OBJECT_OP_FUNC(efl_canvas_object_simple_foo, __eolian_class_simple_foo)
EFL_OBJECT_OP_FUNC(efl_canvas_object_simple_b_set, _class_simple_b_set),
EFL_OBJECT_OP_FUNC(efl_canvas_object_simple_foo, __eolian_class_simple_foo),
EFL_OBJECT_OP_FUNC(efl_canvas_object_simple_bar, _class_simple_bar)
);
return efl_class_functions_set(klass, &ops, NULL);
}
static const Efl_Class_Description _class_simple_class_desc = {
EO_VERSION,
"Class_Simple",
EFL_CLASS_TYPE_REGULAR,
sizeof(Evas_Simple_Data),
_class_simple_class_initializer,
NULL,
NULL
EO_VERSION,
"Class_Simple",
EFL_CLASS_TYPE_REGULAR,
sizeof(Evas_Simple_Data),
_class_simple_class_initializer,
NULL,
NULL
};
EFL_DEFINE_CLASS(class_simple_class_get, &_class_simple_class_desc, NULL, NULL);
EAPI void
evas_object_simple_b_set(Class_Simple *obj)
{
efl_canvas_object_simple_b_set(obj);
}
EAPI int *
evas_object_simple_bar(Class_Simple *obj, int x)
{
return efl_canvas_object_simple_bar(obj, x);
}

View File

@ -1,5 +1,5 @@
#ifndef _EOLIAN_OUTPUT_H_
#define _EOLIAN_OUTPUT_H_
#ifndef _EOLIAN_CLASS_SIMPLE_H_
#define _EOLIAN_CLASS_SIMPLE_H_
#ifndef _CLASS_SIMPLE_EO_CLASS_TYPE
#define _CLASS_SIMPLE_EO_CLASS_TYPE
@ -67,5 +67,4 @@ EOAPI char *efl_canvas_object_simple_foo(Eo *obj, int a, char *b, double *c, int
EOAPI int *efl_canvas_object_simple_bar(Eo *obj, int x);
#endif

View File

@ -1,5 +1,5 @@
#ifndef _EOLIAN_OUTPUT_H_
#define _EOLIAN_OUTPUT_H_
#ifndef _EOLIAN_CLASS_SIMPLE_LEGACY_H_
#define _EOLIAN_CLASS_SIMPLE_LEGACY_H_
#ifndef _CLASS_SIMPLE_EO_CLASS_TYPE
#define _CLASS_SIMPLE_EO_CLASS_TYPE
@ -13,11 +13,9 @@ typedef Eo Class_Simple;
#endif
/** Class Desc Simple
*
* @ingroup Class_Simple
*/
EAPI void evas_object_simple_b_set(Class_Simple *obj);
EAPI int *evas_object_simple_bar(Class_Simple *obj, int x);
#endif

View File

@ -1,5 +1,5 @@
#ifndef _EOLIAN_OUTPUT_H_
#define _EOLIAN_OUTPUT_H_
#ifndef _EOLIAN_DOCS_H_
#define _EOLIAN_DOCS_H_
#ifndef _DOCS_EO_CLASS_TYPE
#define _DOCS_EO_CLASS_TYPE

View File

@ -1,5 +1,5 @@
#ifndef _EOLIAN_OUTPUT_H_
#define _EOLIAN_OUTPUT_H_
#ifndef _EOLIAN_DOCS_LEGACY_H_
#define _EOLIAN_DOCS_LEGACY_H_
#ifndef _DOCS_EO_CLASS_TYPE
#define _DOCS_EO_CLASS_TYPE
@ -64,17 +64,6 @@ typedef struct _Opaque Opaque;
#endif
/**
* @brief Docs for class.
*
* More docs for class. Testing references now. @ref Foo @ref Bar @ref Alias
* @ref pants @ref docs_meth @ref docs_prop_get @ref docs_prop_get
* @ref docs_prop_set @ref Foo.field1 @ref Bar.BAR_FOO @ref Docs
*
* @since 1.18
*
* @ingroup Docs
*/
/**
* @brief Property common documentation.

View File

@ -1,4 +1,7 @@
void _override_base_constructor(Eo *obj, Override_Data *pd);
static void __eolian_override_b_set(Eo *obj EINA_UNUSED, Override_Data *pd, int idx EINA_UNUSED, float a, char b, int c)
{
a = pd->a;
@ -22,6 +25,19 @@ static int __eolian_override_c_get(Eo *obj EINA_UNUSED, Override_Data *pd EINA_U
}
EOAPI EFL_FUNC_BODYV_CONST(override_c_get, int, 50, EFL_FUNC_CALL(idx), int idx);
static void __eolian_override_base_z_get(Eo *obj EINA_UNUSED, Override_Data *pd, int *a, char *b, float *c)
{
if (a) *a = pd->a;
if (b) *b = pd->b;
if (c) *c = pd->c;
}
static void __eolian_override_base_z_set(Eo *obj EINA_UNUSED, Override_Data *pd EINA_UNUSED, int a EINA_UNUSED, char b EINA_UNUSED, float c EINA_UNUSED)
{
}
EOAPI EFL_VOID_FUNC_BODY(override_a_set);
void _override_a_get(Eo *obj, Override_Data *pd);
@ -37,50 +53,33 @@ void _override_c_set(Eo *obj, Override_Data *pd, int idx, int c);
EOAPI EFL_VOID_FUNC_BODYV(override_c_set, EFL_FUNC_CALL(idx, c), int idx, int c);
EOAPI EFL_VOID_FUNC_BODY(override_foo);
void _override_base_constructor(Eo *obj, Override_Data *pd);
static void __eolian_override_base_z_get(Eo *obj EINA_UNUSED, Override_Data *pd, int *a, char *b, float *c)
{
if (a) *a = pd->a;
if (b) *b = pd->b;
if (c) *c = pd->c;
}
static void __eolian_override_base_z_set(Eo *obj EINA_UNUSED, Override_Data *pd EINA_UNUSED, int a EINA_UNUSED, char b EINA_UNUSED, float c EINA_UNUSED)
{
}
static Eina_Bool
_override_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
EFL_OBJECT_OP_FUNC(base_constructor, _override_base_constructor),
EFL_OBJECT_OP_FUNC(base_z_get, __eolian_override_base_z_get),
EFL_OBJECT_OP_FUNC(base_z_set, __eolian_override_base_z_set),
EFL_OBJECT_OP_FUNC(override_b_set, __eolian_override_b_set),
EFL_OBJECT_OP_FUNC(override_bar, __eolian_override_bar),
EFL_OBJECT_OP_FUNC(override_c_get, __eolian_override_c_get),
EFL_OBJECT_OP_FUNC(base_z_get, __eolian_override_base_z_get),
EFL_OBJECT_OP_FUNC(base_z_set, __eolian_override_base_z_set),
EFL_OBJECT_OP_FUNC(override_a_set, NULL),
EFL_OBJECT_OP_FUNC(override_a_get, _override_a_get),
EFL_OBJECT_OP_FUNC(override_b_get, _override_b_get),
EFL_OBJECT_OP_FUNC(override_c_set, _override_c_set),
EFL_OBJECT_OP_FUNC(override_foo, NULL)
);
return efl_class_functions_set(klass, &ops, NULL);
}
static const Efl_Class_Description _override_class_desc = {
EO_VERSION,
"Override",
EFL_CLASS_TYPE_REGULAR,
sizeof(Override_Data),
_override_class_initializer,
NULL,
NULL
EO_VERSION,
"Override",
EFL_CLASS_TYPE_REGULAR,
sizeof(Override_Data),
_override_class_initializer,
NULL,
NULL
};
EFL_DEFINE_CLASS(override_class_get, &_override_class_desc, BASE_CLASS, NULL);

View File

@ -1,5 +1,5 @@
#ifndef _TYPES_OUTPUT_C_
#define _TYPES_OUTPUT_C_
#ifndef _EOLIAN_TYPEDEF_H_
#define _EOLIAN_TYPEDEF_H_
#ifndef _STRUCT_EO_CLASS_TYPE
#define _STRUCT_EO_CLASS_TYPE
@ -43,5 +43,4 @@ EOAPI char *struct_foo(Eo *obj, int idx);
EOAPI Named *struct_bar(Eo *obj);
#endif

View File

@ -1,5 +1,5 @@
#ifndef _TYPES_OUTPUT_C_STUBS
#define _TYPES_OUTPUT_C_STUBS
#ifndef _EOLIAN_TYPEDEF_STUB_H_STUBS
#define _EOLIAN_TYPEDEF_STUB_H_STUBS
typedef Eo Struct;

View File

@ -20,7 +20,7 @@ enum Enum.Bar
last_item
}
enum Elm.Object.Select_mode
enum Elm.Object.Select_Mode
{
default = 0,
always,

View File

@ -1,5 +1,5 @@
#ifndef _TYPES_OUTPUT_C_
#define _TYPES_OUTPUT_C_
#ifndef _EOLIAN_TYPEDEF_H_
#define _EOLIAN_TYPEDEF_H_
#ifndef _TYPEDEF_EO_CLASS_TYPE
#define _TYPEDEF_EO_CLASS_TYPE
@ -47,5 +47,4 @@ EWAPI const Efl_Class *typedef_class_get(void);
EOAPI char *typedef_foo(Eo *obj, int idx);
#endif

View File

@ -1,5 +1,5 @@
#ifndef _TYPES_OUTPUT_C_STUBS
#define _TYPES_OUTPUT_C_STUBS
#ifndef _EOLIAN_TYPEDEF_STUB_H_STUBS
#define _EOLIAN_TYPEDEF_STUB_H_STUBS
typedef Eo Typedef;

View File

@ -15,17 +15,20 @@
#include "eolian_suite.h"
static Eina_Bool
_files_compare (const char *ref_filename, const char *tmp_filename)
_files_compare (const char *ref_filename, const char *tmp_filename, const char *ext)
{
Eina_Bool result = EINA_FALSE;
FILE *tmp_file = NULL, *ref_file = NULL;
char *tmp_content = NULL, *ref_content = NULL;
tmp_file = fopen(tmp_filename, "rb");
char ifnbuf[PATH_MAX];
snprintf(ifnbuf, sizeof(ifnbuf), "%s.%s", tmp_filename, ext);
tmp_file = fopen(ifnbuf, "rb");
if (!tmp_file)
{
printf("Unable to open %s\n", tmp_filename);
printf("Unable to open %s\n", ifnbuf);
goto end;
}
ref_file = fopen(ref_filename, "rb");
@ -69,6 +72,14 @@ end:
return result;
}
static void
_remove_ref(const char *base, const char *ext)
{
char ifnbuf[PATH_MAX];
snprintf(ifnbuf, sizeof(ifnbuf), "%s.%s", base, ext);
remove(ifnbuf);
}
static int
_eolian_gen_execute(const char *eo_filename, const char *options, const char *output_filename)
{
@ -78,14 +89,14 @@ _eolian_gen_execute(const char *eo_filename, const char *options, const char *ou
if (getenv("EFL_RUN_IN_TREE"))
{
snprintf(eolian_gen_path, sizeof(eolian_gen_path),
"%s/src/bin/eolian/eolian_gen%s",
"%s/src/bin/eolian2/eolian_gen2%s",
PACKAGE_BUILD_DIR, EXEEXT);
}
if (eolian_gen_path[0] == '\0')
return -1;
snprintf(command, PATH_MAX,
"%s %s -I "PACKAGE_DATA_DIR"/data -o %s %s",
"%s %s -I \""PACKAGE_DATA_DIR"/data\" -o %s %s",
eolian_gen_path, options, output_filename, eo_filename);
return system(command);
}
@ -93,96 +104,96 @@ _eolian_gen_execute(const char *eo_filename, const char *options, const char *ou
START_TEST(eolian_dev_impl_code)
{
char output_filepath[PATH_MAX] = "";
snprintf(output_filepath, PATH_MAX, "%s/object_impl.c",
snprintf(output_filepath, PATH_MAX, "%s/eolian_object_impl",
eina_environment_tmp_get());
remove(output_filepath);
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/object_impl.eo", "--gi", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/object_impl_ref.c", output_filepath));
_remove_ref(output_filepath, "c");
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/object_impl.eo", "-gi", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/object_impl_ref.c", output_filepath, "c"));
/* Check that nothing is added */
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/object_impl.eo", "--gi", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/object_impl_ref.c", output_filepath));
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/object_impl_add.eo", "--gi", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/object_impl_add_ref.c", output_filepath));
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/object_impl.eo", "-gi", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/object_impl_ref.c", output_filepath, "c"));
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/object_impl_add.eo", "-gi", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/object_impl_add_ref.c", output_filepath, "c"));
}
END_TEST
START_TEST(eolian_types_generation)
{
char output_filepath[PATH_MAX] = "";
snprintf(output_filepath, PATH_MAX, "%s/types_output.c",
snprintf(output_filepath, PATH_MAX, "%s/eolian_typedef",
eina_environment_tmp_get());
remove(output_filepath);
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/typedef.eo", "--gh", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/typedef_ref.c", output_filepath));
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/struct.eo", "--gh", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/struct_ref.c", output_filepath));
_remove_ref(output_filepath, "h");
_remove_ref(output_filepath, "stub.h");
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/typedef.eo", "-gh", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/typedef_ref.c", output_filepath, "h"));
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/struct.eo", "-gh", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/struct_ref.c", output_filepath, "h"));
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/typedef.eo", "--gs", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/typedef_ref_stub.c", output_filepath));
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/struct.eo", "--gs", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/struct_ref_stub.c", output_filepath));
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/typedef.eo", "-gs", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/typedef_ref_stub.c", output_filepath, "stub.h"));
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/struct.eo", "-gs", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/struct_ref_stub.c", output_filepath, "stub.h"));
}
END_TEST
START_TEST(eolian_default_values_generation)
{
char output_filepath[PATH_MAX] = "";
snprintf(output_filepath, PATH_MAX, "%s/eolian_output.c",
snprintf(output_filepath, PATH_MAX, "%s/eolian_class_simple",
eina_environment_tmp_get());
remove(output_filepath);
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/class_simple.eo", "--gc", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/class_simple_ref.c", output_filepath));
_remove_ref(output_filepath, "c");
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/class_simple.eo", "-gc", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/class_simple_ref.c", output_filepath, "c"));
}
END_TEST
START_TEST(eolian_override_generation)
{
char output_filepath[PATH_MAX] = "";
snprintf(output_filepath, PATH_MAX, "%s/eolian_output.c",
snprintf(output_filepath, PATH_MAX, "%s/eolian_override",
eina_environment_tmp_get());
remove(output_filepath);
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/override.eo", "--gc", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/override_ref.c", output_filepath));
_remove_ref(output_filepath, "c");
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/override.eo", "-gc", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/override_ref.c", output_filepath, "c"));
}
END_TEST
START_TEST(eolian_functions_descriptions)
{
char output_filepath[PATH_MAX] = "";
snprintf(output_filepath, PATH_MAX, "%s/eolian_output.h",
snprintf(output_filepath, PATH_MAX, "%s/eolian_class_simple",
eina_environment_tmp_get());
remove(output_filepath);
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/class_simple.eo", "--gh", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/class_simple_ref_eo.h", output_filepath));
remove(output_filepath);
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/class_simple.eo", "--legacy --gh", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/class_simple_ref_legacy.h", output_filepath));
_remove_ref(output_filepath, "h");
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/class_simple.eo", "-gh", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/class_simple_ref_eo.h", output_filepath, "h"));
_remove_ref(output_filepath, "legacy.h");
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/class_simple.eo", "-gl", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/class_simple_ref_legacy.h", output_filepath, "legacy.h"));
}
END_TEST
START_TEST(eolian_import)
{
char output_filepath[PATH_MAX] = "";
snprintf(output_filepath, PATH_MAX, "%s/eolian_import_types.h",
snprintf(output_filepath, PATH_MAX, "%s/eolian_import_types",
eina_environment_tmp_get());
remove(output_filepath);
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/import_types.eot", "--gh", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/import_types_ref.h", output_filepath));
remove(output_filepath);
_remove_ref(output_filepath, "h");
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/import_types.eot", "-gh", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/import_types_ref.h", output_filepath, "h"));
}
END_TEST
START_TEST(eolian_docs)
{
char output_filepath[PATH_MAX] = "";
snprintf(output_filepath, PATH_MAX, "%s/eolian_output.h",
snprintf(output_filepath, PATH_MAX, "%s/eolian_docs",
eina_environment_tmp_get());
remove(output_filepath);
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/docs.eo", "--gh", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/docs_ref.h", output_filepath));
remove(output_filepath);
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/docs.eo", "--legacy --gh", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/docs_ref_legacy.h", output_filepath));
_remove_ref(output_filepath, "h");
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/docs.eo", "-gh", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/docs_ref.h", output_filepath, "h"));
_remove_ref(output_filepath, "legacy.h");
fail_if(0 != _eolian_gen_execute(PACKAGE_DATA_DIR"/data/docs.eo", "-gl", output_filepath));
fail_if(!_files_compare(PACKAGE_DATA_DIR"/data/docs_ref_legacy.h", output_filepath, "legacy.h"));
}
END_TEST