2014-05-01 05:05:33 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2016-02-04 06:04:45 -08:00
|
|
|
#include <Eina.h>
|
|
|
|
#include <Eolian.h>
|
|
|
|
|
2014-05-01 05:05:33 -07:00
|
|
|
#include "eolian_suite.h"
|
|
|
|
|
2014-05-25 03:53:49 -07:00
|
|
|
START_TEST(eolian_namespaces)
|
|
|
|
{
|
2017-10-25 07:23:57 -07:00
|
|
|
const Eolian_Class *class11, *class112, *class21, *class_no, *impl_class,
|
|
|
|
*iclass;
|
2014-07-11 03:52:45 -07:00
|
|
|
const Eolian_Function *fid;
|
2014-07-23 05:44:42 -07:00
|
|
|
Eina_Iterator *iter;
|
2014-05-25 03:53:49 -07:00
|
|
|
Eolian_Function_Type func_type;
|
2017-10-25 07:23:57 -07:00
|
|
|
const char *val1, *val2;
|
2014-07-23 05:44:42 -07:00
|
|
|
const Eolian_Implement *impl;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2014-07-23 05:44:42 -07:00
|
|
|
void *dummy;
|
2014-05-25 03:53:49 -07:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
/* Parsing */
|
2014-07-30 07:35:57 -07:00
|
|
|
fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/nmsp1_class1.eo")));
|
2014-05-25 03:53:49 -07:00
|
|
|
|
|
|
|
/* Classes existence */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(class11 = eolian_class_get_by_name(unit, "nmsp1.class1")));
|
|
|
|
fail_if(!(class112 = eolian_class_get_by_name(unit, "nmsp1.nmsp11.class2")));
|
|
|
|
fail_if(!(class21 = eolian_class_get_by_name(unit, "nmsp2.class1")));
|
|
|
|
fail_if(!(class_no = eolian_class_get_by_name(unit, "no_nmsp")));
|
2014-05-25 03:53:49 -07:00
|
|
|
|
|
|
|
/* Check names and namespaces*/
|
|
|
|
fail_if(strcmp(eolian_class_name_get(class11), "class1"));
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(iter = eolian_class_namespaces_get(class11)));
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&val1)));
|
|
|
|
fail_if(eina_iterator_next(iter, &dummy));
|
|
|
|
fail_if(strcmp(val1, "nmsp1"));
|
|
|
|
eina_iterator_free(iter);
|
2014-05-25 03:53:49 -07:00
|
|
|
|
|
|
|
fail_if(strcmp(eolian_class_name_get(class112), "class2"));
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(iter = eolian_class_namespaces_get(class112)));
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&val1)));
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&val2)));
|
|
|
|
fail_if(eina_iterator_next(iter, &dummy));
|
|
|
|
fail_if(strcmp(val1, "nmsp1"));
|
|
|
|
fail_if(strcmp(val2, "nmsp11"));
|
|
|
|
eina_iterator_free(iter);
|
2014-05-25 03:53:49 -07:00
|
|
|
|
|
|
|
fail_if(strcmp(eolian_class_name_get(class21), "class1"));
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(iter = eolian_class_namespaces_get(class21)));
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&val1)));
|
|
|
|
fail_if(eina_iterator_next(iter, &dummy));
|
|
|
|
fail_if(strcmp(val1, "nmsp2"));
|
|
|
|
eina_iterator_free(iter);
|
2014-05-25 03:53:49 -07:00
|
|
|
|
|
|
|
fail_if(strcmp(eolian_class_name_get(class_no), "no_nmsp"));
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(eolian_class_namespaces_get(class_no));
|
2014-05-25 03:53:49 -07:00
|
|
|
|
|
|
|
/* Inherits */
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(iter = eolian_class_inherits_get(class11)));
|
2017-10-25 07:23:57 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&iclass)));
|
|
|
|
fail_if(iclass != class112);
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&iclass)));
|
|
|
|
fail_if(iclass != class21);
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&iclass)));
|
|
|
|
fail_if(iclass != class_no);
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(eina_iterator_next(iter, &dummy));
|
|
|
|
eina_iterator_free(iter);
|
2014-05-25 03:53:49 -07:00
|
|
|
|
|
|
|
/* Implements */
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(iter = eolian_class_implements_get(class11)));
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&impl)));
|
2014-08-13 05:09:03 -07:00
|
|
|
fail_if(!(impl_class = eolian_implement_class_get(impl)));
|
|
|
|
fail_if(!(fid = eolian_implement_function_get(impl, &func_type)));
|
2014-05-29 04:42:16 -07:00
|
|
|
fail_if(impl_class != class112);
|
|
|
|
fail_if(strcmp(eolian_function_name_get(fid), "a"));
|
2014-05-25 03:53:49 -07:00
|
|
|
fail_if(func_type != EOLIAN_PROP_SET);
|
2014-05-29 04:42:16 -07:00
|
|
|
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&impl)));
|
2014-08-13 05:09:03 -07:00
|
|
|
fail_if(!(impl_class = eolian_implement_class_get(impl)));
|
|
|
|
fail_if(!(fid = eolian_implement_function_get(impl, &func_type)));
|
2014-05-29 04:42:16 -07:00
|
|
|
fail_if(impl_class != class_no);
|
|
|
|
fail_if(strcmp(eolian_function_name_get(fid), "foo"));
|
2014-05-25 03:53:49 -07:00
|
|
|
fail_if(func_type != EOLIAN_METHOD);
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(eina_iterator_next(iter, &dummy));
|
|
|
|
eina_iterator_free(iter);
|
2014-05-25 03:53:49 -07:00
|
|
|
|
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-05-23 07:38:39 -07:00
|
|
|
START_TEST(eolian_events)
|
|
|
|
{
|
2014-07-11 03:52:45 -07:00
|
|
|
const Eolian_Class *class;
|
2014-07-23 05:44:42 -07:00
|
|
|
Eina_Iterator *iter;
|
2015-06-05 04:15:51 -07:00
|
|
|
const char *name, *type_name;
|
2014-07-11 03:52:45 -07:00
|
|
|
const Eolian_Type *type;
|
2014-07-23 05:44:42 -07:00
|
|
|
const Eolian_Event *ev;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2014-07-23 05:44:42 -07:00
|
|
|
void *dummy;
|
2014-05-23 07:38:39 -07:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
/* Parsing */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/events.eo")));
|
2014-05-23 07:38:39 -07:00
|
|
|
|
|
|
|
/* Class */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Events")));
|
2016-05-17 09:14:47 -07:00
|
|
|
fail_if(strcmp(eolian_class_event_prefix_get(class), "totally_not_events"));
|
2014-05-23 07:38:39 -07:00
|
|
|
|
|
|
|
/* Events */
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(iter = eolian_class_events_get(class)));
|
2014-05-23 07:38:39 -07:00
|
|
|
/* Clicked */
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&ev)));
|
2014-08-13 05:09:03 -07:00
|
|
|
fail_if(!(name = eolian_event_name_get(ev)));
|
|
|
|
fail_if(eolian_event_type_get(ev));
|
2014-05-23 07:38:39 -07:00
|
|
|
fail_if(strcmp(name, "clicked"));
|
2015-05-08 06:37:02 -07:00
|
|
|
fail_if(!eolian_event_is_beta(ev));
|
2016-02-02 09:55:01 -08:00
|
|
|
fail_if(eolian_event_is_hot(ev));
|
2016-04-20 15:53:33 -07:00
|
|
|
fail_if(eolian_event_is_restart(ev));
|
2014-05-23 07:38:39 -07:00
|
|
|
/* Clicked,double */
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&ev)));
|
2014-08-13 05:09:03 -07:00
|
|
|
fail_if(!(name = eolian_event_name_get(ev)));
|
|
|
|
fail_if(!(type = eolian_event_type_get(ev)));
|
2014-05-23 07:38:39 -07:00
|
|
|
fail_if(strcmp(name, "clicked,double"));
|
2014-07-11 03:52:45 -07:00
|
|
|
type_name = eolian_type_name_get(type);
|
|
|
|
fail_if(strcmp(type_name, "Evas_Event_Clicked_Double_Info"));
|
2015-05-08 06:37:02 -07:00
|
|
|
fail_if(eolian_event_is_beta(ev));
|
2016-02-02 09:55:01 -08:00
|
|
|
fail_if(eolian_event_is_hot(ev));
|
2016-04-20 15:53:33 -07:00
|
|
|
fail_if(eolian_event_is_restart(ev));
|
2016-02-02 09:55:01 -08:00
|
|
|
/* Hot */
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&ev)));
|
|
|
|
fail_if(!(name = eolian_event_name_get(ev)));
|
|
|
|
fail_if(eolian_event_type_get(ev));
|
|
|
|
fail_if(strcmp(name, "hot"));
|
|
|
|
fail_if(eolian_event_is_beta(ev));
|
|
|
|
fail_if(!eolian_event_is_hot(ev));
|
2016-04-20 15:53:33 -07:00
|
|
|
fail_if(eolian_event_is_restart(ev));
|
|
|
|
/* Restart */
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&ev)));
|
|
|
|
fail_if(!(name = eolian_event_name_get(ev)));
|
|
|
|
fail_if(eolian_event_type_get(ev));
|
|
|
|
fail_if(strcmp(name, "restart"));
|
|
|
|
fail_if(eolian_event_is_beta(ev));
|
|
|
|
fail_if(eolian_event_is_hot(ev));
|
|
|
|
fail_if(!eolian_event_is_restart(ev));
|
|
|
|
/* Hot Restart */
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&ev)));
|
|
|
|
fail_if(!(name = eolian_event_name_get(ev)));
|
|
|
|
fail_if(eolian_event_type_get(ev));
|
|
|
|
fail_if(strcmp(name, "hot_restart"));
|
|
|
|
fail_if(eolian_event_is_beta(ev));
|
|
|
|
fail_if(!eolian_event_is_hot(ev));
|
|
|
|
fail_if(!eolian_event_is_restart(ev));
|
|
|
|
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(eina_iterator_next(iter, &dummy));
|
|
|
|
eina_iterator_free(iter);
|
2015-04-28 04:27:01 -07:00
|
|
|
/* Check eolian_class_event_get_by_name */
|
|
|
|
fail_if(!eolian_class_event_get_by_name(class, "clicked,double"));
|
|
|
|
fail_if(eolian_class_event_get_by_name(class, "clicked,triple"));
|
2014-05-23 07:38:39 -07:00
|
|
|
|
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-05-21 03:56:31 -07:00
|
|
|
START_TEST(eolian_override)
|
|
|
|
{
|
2014-07-23 05:44:42 -07:00
|
|
|
Eina_Iterator *iter;
|
2014-07-11 03:52:45 -07:00
|
|
|
const Eolian_Class *impl_class = NULL;
|
|
|
|
const Eolian_Function *impl_func = NULL;
|
|
|
|
const Eolian_Class *class, *base;
|
2014-07-23 05:44:42 -07:00
|
|
|
const Eolian_Implement *impl;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2014-05-21 03:56:31 -07:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
/* Parsing */
|
|
|
|
fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/override.eo")));
|
2014-05-21 03:56:31 -07:00
|
|
|
|
|
|
|
/* Class */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Override")));
|
|
|
|
fail_if(!(base = eolian_class_get_by_name(unit, "Base")));
|
2014-05-21 03:56:31 -07:00
|
|
|
|
2014-09-04 03:06:41 -07:00
|
|
|
/* Implements */
|
|
|
|
fail_if(!(iter = eolian_class_implements_get(class)));
|
2017-01-16 06:51:11 -08:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&impl))); /* skip a */
|
2014-09-04 03:06:41 -07:00
|
|
|
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&impl)));
|
2017-01-11 10:25:54 -08:00
|
|
|
fail_if(!eolian_implement_is_auto(impl, EOLIAN_PROP_SET));
|
|
|
|
fail_if(eolian_implement_is_empty(impl, EOLIAN_PROP_SET));
|
2017-01-13 06:40:29 -08:00
|
|
|
fail_if(eolian_implement_is_pure_virtual(impl, EOLIAN_PROP_SET));
|
2014-09-04 03:06:41 -07:00
|
|
|
fail_if(!(impl_class = eolian_implement_class_get(impl)));
|
|
|
|
fail_if(!(impl_func = eolian_implement_function_get(impl, NULL)));
|
|
|
|
fail_if(impl_class != class);
|
|
|
|
fail_if(strcmp(eolian_function_name_get(impl_func), "b"));
|
2017-01-16 06:51:11 -08:00
|
|
|
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&impl))); /* skip c */
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&impl))); /* skip foo */
|
2014-09-04 03:06:41 -07:00
|
|
|
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&impl)));
|
2017-01-11 10:25:54 -08:00
|
|
|
fail_if(eolian_implement_is_auto(impl, EOLIAN_METHOD));
|
|
|
|
fail_if(!eolian_implement_is_empty(impl, EOLIAN_METHOD));
|
2017-01-13 06:40:29 -08:00
|
|
|
fail_if(eolian_implement_is_pure_virtual(impl, EOLIAN_METHOD));
|
2014-09-04 03:06:41 -07:00
|
|
|
fail_if(!(impl_class = eolian_implement_class_get(impl)));
|
|
|
|
fail_if(!(impl_func = eolian_implement_function_get(impl, NULL)));
|
|
|
|
fail_if(impl_class != class);
|
|
|
|
fail_if(strcmp(eolian_function_name_get(impl_func), "bar"));
|
2017-01-16 06:51:11 -08:00
|
|
|
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&impl)));
|
|
|
|
fail_if(eolian_implement_is_auto(impl, EOLIAN_METHOD));
|
|
|
|
fail_if(eolian_implement_is_empty(impl, EOLIAN_METHOD));
|
|
|
|
fail_if(eolian_implement_is_pure_virtual(impl, EOLIAN_METHOD));
|
|
|
|
fail_if(!(impl_class = eolian_implement_class_get(impl)));
|
|
|
|
fail_if(!(impl_func = eolian_implement_function_get(impl, NULL)));
|
|
|
|
fail_if(impl_class != base);
|
|
|
|
fail_if(strcmp(eolian_function_name_get(impl_func), "constructor"));
|
2014-09-04 03:06:41 -07:00
|
|
|
|
|
|
|
eina_iterator_free(iter);
|
|
|
|
|
2014-05-21 03:56:31 -07:00
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-05-21 01:39:16 -07:00
|
|
|
START_TEST(eolian_consts)
|
|
|
|
{
|
2014-07-11 03:52:45 -07:00
|
|
|
const Eolian_Function *fid = NULL;
|
|
|
|
const Eolian_Class *class;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2014-05-21 01:39:16 -07:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
/* Parsing */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/consts.eo")));
|
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Consts")));
|
2014-05-21 01:39:16 -07:00
|
|
|
|
|
|
|
/* Method */
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
|
2014-05-21 01:39:16 -07:00
|
|
|
fail_if(EINA_FALSE == eolian_function_object_is_const(fid));
|
|
|
|
|
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-05-01 05:05:33 -07:00
|
|
|
START_TEST(eolian_ctor_dtor)
|
|
|
|
{
|
2014-07-23 05:44:42 -07:00
|
|
|
Eina_Iterator *iter;
|
2014-07-11 03:52:45 -07:00
|
|
|
const Eolian_Class *impl_class = NULL;
|
|
|
|
const Eolian_Function *impl_func = NULL;
|
|
|
|
const Eolian_Class *class, *base;
|
2014-07-23 05:44:42 -07:00
|
|
|
const Eolian_Implement *impl;
|
2014-09-01 07:53:35 -07:00
|
|
|
const Eolian_Constructor *ctor;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2014-07-23 05:44:42 -07:00
|
|
|
void *dummy;
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
/* Parsing */
|
|
|
|
fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/ctor_dtor.eo")));
|
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Ctor_Dtor")));
|
|
|
|
fail_if(!(base = eolian_class_get_by_name(unit, "Base")));
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
/* Class ctor/dtor */
|
2014-05-22 07:24:50 -07:00
|
|
|
fail_if(!eolian_class_ctor_enable_get(class));
|
|
|
|
fail_if(!eolian_class_dtor_enable_get(class));
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
/* Base ctor/dtor */
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(iter = eolian_class_implements_get(class)));
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&impl)));
|
2017-01-16 06:51:11 -08:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&impl)));
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&impl)));
|
2014-08-13 05:09:03 -07:00
|
|
|
fail_if(!(impl_class = eolian_implement_class_get(impl)));
|
|
|
|
fail_if(!(impl_func = eolian_implement_function_get(impl, NULL)));
|
2014-05-29 04:42:16 -07:00
|
|
|
fail_if(impl_class != base);
|
|
|
|
fail_if(strcmp(eolian_function_name_get(impl_func), "constructor"));
|
2014-09-12 13:09:48 -07:00
|
|
|
fail_if(!eolian_function_is_constructor(impl_func, base));
|
|
|
|
fail_if(!eolian_function_is_constructor(impl_func, class));
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&impl)));
|
2014-08-13 05:09:03 -07:00
|
|
|
fail_if(!(impl_class = eolian_implement_class_get(impl)));
|
|
|
|
fail_if(!(impl_func = eolian_implement_function_get(impl, NULL)));
|
2014-05-29 04:42:16 -07:00
|
|
|
fail_if(impl_class != base);
|
|
|
|
fail_if(strcmp(eolian_function_name_get(impl_func), "destructor"));
|
2014-09-12 13:09:48 -07:00
|
|
|
fail_if(eolian_function_is_constructor(impl_func, base));
|
|
|
|
fail_if(eolian_function_is_constructor(impl_func, class));
|
2014-07-23 05:44:42 -07:00
|
|
|
eina_iterator_free(iter);
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
/* Custom ctors/dtors */
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!eolian_class_function_get_by_name(base, "destructor", EOLIAN_METHOD));
|
2014-09-01 07:53:35 -07:00
|
|
|
fail_if(!(iter = eolian_class_constructors_get(class)));
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&ctor)));
|
2014-11-20 07:21:44 -08:00
|
|
|
fail_if(eolian_constructor_is_optional(ctor));
|
2014-09-01 07:53:35 -07:00
|
|
|
fail_if(!(impl_class = eolian_constructor_class_get(ctor)));
|
|
|
|
fail_if(!(impl_func = eolian_constructor_function_get(ctor)));
|
|
|
|
fail_if(impl_class != class);
|
|
|
|
fail_if(strcmp(eolian_function_name_get(impl_func), "custom_constructor_1"));
|
2014-09-12 13:09:48 -07:00
|
|
|
fail_if(!eolian_function_is_constructor(impl_func, class));
|
|
|
|
fail_if(eolian_function_is_constructor(impl_func, base));
|
2014-09-01 07:53:35 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)&ctor)));
|
2014-11-20 07:21:44 -08:00
|
|
|
fail_if(!eolian_constructor_is_optional(ctor));
|
2014-09-01 07:53:35 -07:00
|
|
|
fail_if(!(impl_class = eolian_constructor_class_get(ctor)));
|
|
|
|
fail_if(!(impl_func = eolian_constructor_function_get(ctor)));
|
|
|
|
fail_if(impl_class != class);
|
|
|
|
fail_if(strcmp(eolian_function_name_get(impl_func), "custom_constructor_2"));
|
2014-09-12 13:09:48 -07:00
|
|
|
fail_if(!eolian_function_is_constructor(impl_func, class));
|
|
|
|
fail_if(eolian_function_is_constructor(impl_func, base));
|
2014-09-01 07:53:35 -07:00
|
|
|
fail_if(eina_iterator_next(iter, &dummy));
|
|
|
|
eina_iterator_free(iter);
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
START_TEST(eolian_typedef)
|
|
|
|
{
|
2016-02-19 05:18:36 -08:00
|
|
|
const Eolian_Type *type = NULL;
|
|
|
|
const Eolian_Typedecl *tdl = NULL;
|
2014-05-01 05:05:33 -07:00
|
|
|
const char *type_name = NULL;
|
2014-06-27 07:39:19 -07:00
|
|
|
Eina_Iterator *iter = NULL;
|
2014-07-11 03:52:45 -07:00
|
|
|
const Eolian_Class *class;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2014-07-21 04:03:51 -07:00
|
|
|
const char *file;
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
/* Parsing */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/typedef.eo")));
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
/* Check that the class Dummy is still readable */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Typedef")));
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
/* Basic type */
|
2017-05-25 05:56:44 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_alias_get_by_name(unit, "Evas.Coord")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_ALIAS);
|
|
|
|
fail_if(!(type_name = eolian_typedecl_name_get(tdl)));
|
2014-07-21 09:12:35 -07:00
|
|
|
fail_if(strcmp(type_name, "Coord"));
|
2017-05-26 06:09:49 -07:00
|
|
|
fail_if(!(type_name = eolian_typedecl_c_type_get(unit, tdl)));
|
2014-07-22 04:11:06 -07:00
|
|
|
fail_if(strcmp(type_name, "typedef int Evas_Coord"));
|
|
|
|
eina_stringshare_del(type_name);
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
|
2014-06-27 07:39:19 -07:00
|
|
|
fail_if(!(type_name = eolian_type_name_get(type)));
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(eolian_type_is_owned(type));
|
2014-06-27 07:39:19 -07:00
|
|
|
fail_if(eolian_type_is_const(type));
|
|
|
|
fail_if(eolian_type_base_type_get(type));
|
2014-05-01 05:05:33 -07:00
|
|
|
fail_if(strcmp(type_name, "int"));
|
|
|
|
|
2014-07-21 04:03:51 -07:00
|
|
|
/* File */
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(file = eolian_typedecl_file_get(tdl)));
|
2014-07-21 04:03:51 -07:00
|
|
|
fail_if(strcmp(file, "typedef.eo"));
|
|
|
|
|
2015-11-18 08:02:15 -08:00
|
|
|
/* Lowest alias base */
|
2017-05-25 05:56:44 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_alias_get_by_name(unit, "Evas.Coord3")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(type = eolian_typedecl_aliased_base_get(tdl)));
|
|
|
|
fail_if(strcmp(eolian_type_name_get(type), "int"));
|
2015-11-18 08:02:15 -08:00
|
|
|
|
2014-05-01 05:05:33 -07:00
|
|
|
/* Complex type */
|
2017-05-25 05:56:44 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_alias_get_by_name(unit, "List_Objects")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(type_name = eolian_typedecl_name_get(tdl)));
|
2014-07-21 09:12:35 -07:00
|
|
|
fail_if(strcmp(type_name, "List_Objects"));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(eolian_type_is_owned(type));
|
2014-05-01 05:05:33 -07:00
|
|
|
fail_if(strcmp(type_name, "Eina_List *"));
|
2014-06-27 07:39:19 -07:00
|
|
|
eina_stringshare_del(type_name);
|
2016-06-10 06:28:19 -07:00
|
|
|
fail_if(!(type = eolian_type_base_type_get(type)));
|
|
|
|
fail_if(!!eolian_type_next_type_get(type));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
|
2014-05-01 05:05:33 -07:00
|
|
|
fail_if(strcmp(type_name, "Eo *"));
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(eolian_type_is_owned(type));
|
2014-06-27 07:39:19 -07:00
|
|
|
eina_stringshare_del(type_name);
|
2014-05-01 05:05:33 -07:00
|
|
|
|
2014-07-22 05:14:44 -07:00
|
|
|
/* List */
|
2017-05-25 06:17:29 -07:00
|
|
|
fail_if(!(iter = eolian_typedecl_aliases_get_by_file(unit, "typedef.eo")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!eina_iterator_next(iter, (void**)&tdl));
|
|
|
|
fail_if(!(type_name = eolian_typedecl_name_get(tdl)));
|
2014-07-22 05:14:44 -07:00
|
|
|
fail_if(strcmp(type_name, "Coord"));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!eina_iterator_next(iter, (void**)&tdl));
|
|
|
|
fail_if(!(type_name = eolian_typedecl_name_get(tdl)));
|
2014-07-22 05:14:44 -07:00
|
|
|
fail_if(strcmp(type_name, "List_Objects"));
|
2015-11-18 08:02:15 -08:00
|
|
|
/* coord2 and coord3, skip */
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!eina_iterator_next(iter, (void**)&tdl));
|
|
|
|
fail_if(!eina_iterator_next(iter, (void**)&tdl));
|
2015-05-29 03:24:55 -07:00
|
|
|
/* not generated extern, skip */
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!eina_iterator_next(iter, (void**)&tdl));
|
2015-06-10 08:42:12 -07:00
|
|
|
/* not generated undefined type, skip */
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!eina_iterator_next(iter, (void**)&tdl));
|
2017-04-21 06:47:12 -07:00
|
|
|
/* free cb, tested by generation tests */
|
2016-03-14 10:16:41 -07:00
|
|
|
fail_if(!eina_iterator_next(iter, (void**)&tdl));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(eina_iterator_next(iter, (void**)&tdl));
|
2014-07-22 05:14:44 -07:00
|
|
|
|
2014-05-01 05:05:33 -07:00
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
START_TEST(eolian_complex_type)
|
|
|
|
{
|
2014-07-11 03:52:45 -07:00
|
|
|
const Eolian_Function *fid = NULL;
|
|
|
|
const Eolian_Function_Parameter *param = NULL;
|
|
|
|
const Eolian_Type *type = NULL;
|
2014-05-01 05:05:33 -07:00
|
|
|
const char *type_name = NULL;
|
2014-06-27 07:39:19 -07:00
|
|
|
Eina_Iterator *iter = NULL;
|
2014-07-11 03:52:45 -07:00
|
|
|
const Eolian_Class *class;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2014-07-23 05:44:42 -07:00
|
|
|
void *dummy;
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
/* Parsing */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/complex_type.eo")));
|
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Complex_Type")));
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
/* Properties return type */
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "a", EOLIAN_PROPERTY)));
|
2014-06-27 07:39:19 -07:00
|
|
|
fail_if(!(type = eolian_function_return_type_get(fid, EOLIAN_PROP_SET)));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_RETURN)));
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(!eolian_type_is_owned(type));
|
2017-09-22 11:58:36 -07:00
|
|
|
fail_if(eolian_type_builtin_type_get(type) != EOLIAN_TYPE_BUILTIN_LIST);
|
2014-05-01 05:05:33 -07:00
|
|
|
fail_if(strcmp(type_name, "Eina_List *"));
|
2014-06-27 07:39:19 -07:00
|
|
|
eina_stringshare_del(type_name);
|
2016-06-10 06:28:19 -07:00
|
|
|
fail_if(!(type = eolian_type_base_type_get(type)));
|
|
|
|
fail_if(!!eolian_type_next_type_get(type));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(eolian_type_is_owned(type));
|
2017-09-22 11:58:36 -07:00
|
|
|
fail_if(eolian_type_builtin_type_get(type) != EOLIAN_TYPE_BUILTIN_ARRAY);
|
2014-05-01 05:05:33 -07:00
|
|
|
fail_if(strcmp(type_name, "Eina_Array *"));
|
2014-06-27 07:39:19 -07:00
|
|
|
eina_stringshare_del(type_name);
|
2016-06-10 06:28:19 -07:00
|
|
|
fail_if(!(type = eolian_type_base_type_get(type)));
|
|
|
|
fail_if(!!eolian_type_next_type_get(type));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(!eolian_type_is_owned(type));
|
2016-11-10 07:20:19 -08:00
|
|
|
fail_if(strcmp(type_name, "Eo *"));
|
2014-06-27 07:39:19 -07:00
|
|
|
eina_stringshare_del(type_name);
|
2014-05-01 05:05:33 -07:00
|
|
|
/* Properties parameter type */
|
2015-05-20 09:03:14 -07:00
|
|
|
fail_if(!(iter = eolian_property_values_get(fid, EOLIAN_PROP_GET)));
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
|
|
|
fail_if(eina_iterator_next(iter, &dummy));
|
|
|
|
eina_iterator_free(iter);
|
2014-05-01 05:05:33 -07:00
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "value"));
|
2014-06-27 07:39:19 -07:00
|
|
|
fail_if(!(type = eolian_parameter_type_get(param)));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(!eolian_type_is_owned(type));
|
2014-05-01 05:05:33 -07:00
|
|
|
fail_if(strcmp(type_name, "Eina_List *"));
|
2014-06-27 07:39:19 -07:00
|
|
|
eina_stringshare_del(type_name);
|
2016-06-10 06:28:19 -07:00
|
|
|
fail_if(!(type = eolian_type_base_type_get(type)));
|
|
|
|
fail_if(!!eolian_type_next_type_get(type));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(eolian_type_is_owned(type));
|
2014-05-01 05:05:33 -07:00
|
|
|
fail_if(strcmp(type_name, "int"));
|
2014-06-27 07:39:19 -07:00
|
|
|
eina_stringshare_del(type_name);
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
/* Methods return type */
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
|
2014-06-27 07:39:19 -07:00
|
|
|
fail_if(!(type = eolian_function_return_type_get(fid, EOLIAN_METHOD)));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_RETURN)));
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(!eolian_type_is_owned(type));
|
2014-05-01 05:05:33 -07:00
|
|
|
fail_if(strcmp(type_name, "Eina_List *"));
|
2014-06-27 07:39:19 -07:00
|
|
|
eina_stringshare_del(type_name);
|
2016-06-10 06:28:19 -07:00
|
|
|
fail_if(!(type = eolian_type_base_type_get(type)));
|
|
|
|
fail_if(!!eolian_type_next_type_get(type));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT)));
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(eolian_type_is_owned(type));
|
2017-09-22 11:58:36 -07:00
|
|
|
fail_if(eolian_type_builtin_type_get(type) != EOLIAN_TYPE_BUILTIN_STRINGSHARE);
|
2014-05-01 05:05:33 -07:00
|
|
|
fail_if(strcmp(type_name, "Eina_Stringshare *"));
|
2014-06-27 07:39:19 -07:00
|
|
|
eina_stringshare_del(type_name);
|
2014-05-01 05:05:33 -07:00
|
|
|
/* Methods parameter type */
|
2014-07-23 06:17:19 -07:00
|
|
|
fail_if(!(iter = eolian_function_parameters_get(fid)));
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
|
|
|
fail_if(eina_iterator_next(iter, &dummy));
|
|
|
|
eina_iterator_free(iter);
|
2014-05-01 05:05:33 -07:00
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "buf"));
|
2014-06-27 07:39:19 -07:00
|
|
|
fail_if(!(type = eolian_parameter_type_get(param)));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(!eolian_type_is_owned(type));
|
2017-09-22 11:58:36 -07:00
|
|
|
fail_if(eolian_type_builtin_type_get(type) != EOLIAN_TYPE_BUILTIN_MSTRING);
|
2014-05-01 05:05:33 -07:00
|
|
|
fail_if(strcmp(type_name, "char *"));
|
2014-06-27 07:39:19 -07:00
|
|
|
eina_stringshare_del(type_name);
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
START_TEST(eolian_scope)
|
|
|
|
{
|
2014-07-11 03:52:45 -07:00
|
|
|
const Eolian_Function *fid = NULL;
|
|
|
|
const Eolian_Class *class;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
/* Parsing */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/scope.eo")));
|
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Scope")));
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
/* Property scope */
|
2017-01-12 07:56:49 -08:00
|
|
|
fail_if(eolian_class_function_get_by_name(class, "a", EOLIAN_PROPERTY));
|
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "a", EOLIAN_PROP_GET)));
|
|
|
|
fail_if(eolian_function_scope_get(fid, EOLIAN_PROP_GET) != EOLIAN_SCOPE_PROTECTED);
|
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "b", EOLIAN_PROP_GET)));
|
|
|
|
fail_if(eolian_function_scope_get(fid, EOLIAN_PROP_GET) != EOLIAN_SCOPE_PUBLIC);
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "c", EOLIAN_PROPERTY)));
|
2016-06-09 08:54:43 -07:00
|
|
|
fail_if(eolian_function_scope_get(fid, EOLIAN_PROP_GET) != EOLIAN_SCOPE_PUBLIC);
|
|
|
|
fail_if(eolian_function_scope_get(fid, EOLIAN_PROP_SET) != EOLIAN_SCOPE_PROTECTED);
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
/* Method scope */
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
|
2016-06-09 08:54:43 -07:00
|
|
|
fail_if(eolian_function_scope_get(fid, EOLIAN_METHOD) != EOLIAN_SCOPE_PUBLIC);
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "bar", EOLIAN_METHOD)));
|
2016-06-09 08:54:43 -07:00
|
|
|
fail_if(eolian_function_scope_get(fid, EOLIAN_METHOD) != EOLIAN_SCOPE_PROTECTED);
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "foobar", EOLIAN_METHOD)));
|
2016-06-09 08:54:43 -07:00
|
|
|
fail_if(eolian_function_scope_get(fid, EOLIAN_METHOD) != EOLIAN_SCOPE_PUBLIC);
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
START_TEST(eolian_simple_parsing)
|
|
|
|
{
|
2014-07-11 03:52:45 -07:00
|
|
|
const Eolian_Function *fid = NULL;
|
2014-08-13 06:08:00 -07:00
|
|
|
const char *string = NULL, *ptype = NULL;
|
2014-07-11 03:52:45 -07:00
|
|
|
const Eolian_Function_Parameter *param = NULL;
|
2014-08-08 03:22:41 -07:00
|
|
|
const Eolian_Expression *expr = NULL;
|
2014-07-11 03:52:45 -07:00
|
|
|
const Eolian_Class *class;
|
|
|
|
const Eolian_Type *tp;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2014-07-23 05:44:42 -07:00
|
|
|
Eina_Iterator *iter;
|
2014-08-18 05:12:08 -07:00
|
|
|
Eolian_Value v;
|
2014-07-23 05:44:42 -07:00
|
|
|
void *dummy;
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
/* Parsing */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/class_simple.eo")));
|
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Class_Simple")));
|
|
|
|
fail_if(eolian_class_get_by_file(unit, "class_simple.eo") != class);
|
2014-07-23 09:19:34 -07:00
|
|
|
fail_if(strcmp(eolian_class_file_get(class), "class_simple.eo"));
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
/* Class */
|
2014-05-22 07:24:50 -07:00
|
|
|
fail_if(eolian_class_type_get(class) != EOLIAN_CLASS_REGULAR);
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(eolian_class_inherits_get(class) != NULL);
|
2014-05-22 07:24:50 -07:00
|
|
|
fail_if(strcmp(eolian_class_legacy_prefix_get(class), "evas_object_simple"));
|
2016-06-20 21:26:15 -07:00
|
|
|
fail_if(strcmp(eolian_class_eo_prefix_get(class), "efl_canvas_object_simple"));
|
2014-05-22 07:24:50 -07:00
|
|
|
fail_if(strcmp(eolian_class_data_type_get(class), "Evas_Simple_Data"));
|
2016-10-13 05:54:12 -07:00
|
|
|
Eina_Stringshare *dt = eolian_class_c_data_type_get(class);
|
|
|
|
fail_if(strcmp(dt, "Evas_Simple_Data"));
|
|
|
|
eina_stringshare_del(dt);
|
2014-05-01 05:05:33 -07:00
|
|
|
|
2014-10-02 03:30:36 -07:00
|
|
|
/* c get func */
|
|
|
|
fail_if(!(string = eolian_class_c_get_function_name_get(class)));
|
|
|
|
fail_if(strcmp(string, "class_simple_class_get"));
|
|
|
|
eina_stringshare_del(string);
|
|
|
|
|
2016-10-12 05:56:22 -07:00
|
|
|
/* c name */
|
|
|
|
fail_if(!(string = eolian_class_c_name_get(class)));
|
|
|
|
fail_if(strcmp(string, "CLASS_SIMPLE_CLASS"));
|
|
|
|
eina_stringshare_del(string);
|
|
|
|
|
2014-05-01 05:05:33 -07:00
|
|
|
/* Property */
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "a", EOLIAN_PROPERTY)));
|
2014-05-01 05:05:33 -07:00
|
|
|
fail_if(strcmp(eolian_function_name_get(fid), "a"));
|
2015-05-08 06:12:27 -07:00
|
|
|
fail_if(!eolian_function_is_beta(fid));
|
2015-03-16 08:04:44 -07:00
|
|
|
fail_if(eolian_function_class_get(fid) != class);
|
2014-05-01 05:05:33 -07:00
|
|
|
/* Set return */
|
2014-06-27 07:39:19 -07:00
|
|
|
tp = eolian_function_return_type_get(fid, EOLIAN_PROP_SET);
|
|
|
|
fail_if(!tp);
|
2017-09-22 11:58:36 -07:00
|
|
|
printf("BUILT %d\n", (int)eolian_type_builtin_type_get(tp));
|
|
|
|
fail_if(eolian_type_builtin_type_get(tp) != EOLIAN_TYPE_BUILTIN_BOOL);
|
2014-08-08 03:22:41 -07:00
|
|
|
fail_if(strcmp(eolian_type_name_get(tp), "bool"));
|
|
|
|
expr = eolian_function_return_default_value_get(fid, EOLIAN_PROP_SET);
|
|
|
|
fail_if(!expr);
|
2017-05-25 07:18:10 -07:00
|
|
|
v = eolian_expression_eval(unit, expr, EOLIAN_MASK_BOOL);
|
2014-08-18 05:12:08 -07:00
|
|
|
fail_if(v.type != EOLIAN_EXPR_BOOL);
|
2014-05-01 05:05:33 -07:00
|
|
|
/* Get return */
|
2014-06-27 07:39:19 -07:00
|
|
|
tp = eolian_function_return_type_get(fid, EOLIAN_PROP_GET);
|
|
|
|
fail_if(tp);
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
/* Function parameters */
|
2015-05-20 09:03:14 -07:00
|
|
|
fail_if(eolian_property_keys_get(fid, EOLIAN_PROP_GET) != NULL);
|
|
|
|
fail_if(!(iter = eolian_property_values_get(fid, EOLIAN_PROP_GET)));
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
|
|
|
fail_if(eina_iterator_next(iter, &dummy));
|
|
|
|
eina_iterator_free(iter);
|
2014-08-13 06:08:00 -07:00
|
|
|
fail_if(strcmp(eolian_type_name_get(eolian_parameter_type_get(param)), "int"));
|
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "value"));
|
2014-09-02 03:00:19 -07:00
|
|
|
expr = eolian_parameter_default_value_get(param);
|
|
|
|
fail_if(!expr);
|
2017-05-25 07:18:10 -07:00
|
|
|
v = eolian_expression_eval(unit, expr, EOLIAN_MASK_INT);
|
2014-09-02 03:00:19 -07:00
|
|
|
fail_if(v.type != EOLIAN_EXPR_INT);
|
|
|
|
fail_if(v.value.i != 100);
|
2014-05-01 05:05:33 -07:00
|
|
|
|
2014-12-03 07:04:40 -08:00
|
|
|
/* legacy only + c only */
|
2017-01-12 07:56:49 -08:00
|
|
|
fail_if(eolian_class_function_get_by_name(class, "b", EOLIAN_PROPERTY));
|
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "b", EOLIAN_PROP_SET)));
|
2014-08-18 06:58:35 -07:00
|
|
|
fail_if(eolian_function_is_legacy_only(fid, EOLIAN_PROP_GET));
|
|
|
|
fail_if(!eolian_function_is_legacy_only(fid, EOLIAN_PROP_SET));
|
2015-05-08 06:12:27 -07:00
|
|
|
fail_if(eolian_function_is_beta(fid));
|
2014-08-18 06:58:35 -07:00
|
|
|
|
2014-05-01 05:05:33 -07:00
|
|
|
/* Method */
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
|
2015-05-08 06:12:27 -07:00
|
|
|
fail_if(!eolian_function_is_beta(fid));
|
2016-11-10 07:20:19 -08:00
|
|
|
fail_if(!eolian_type_is_ptr(eolian_function_return_type_get(fid, EOLIAN_METHOD)));
|
2014-05-01 05:05:33 -07:00
|
|
|
/* Function return */
|
2014-06-27 07:39:19 -07:00
|
|
|
tp = eolian_function_return_type_get(fid, EOLIAN_METHOD);
|
|
|
|
fail_if(!tp);
|
2017-08-10 03:47:56 -07:00
|
|
|
string = eolian_type_c_type_get(tp, EOLIAN_C_TYPE_RETURN);
|
2014-05-01 05:05:33 -07:00
|
|
|
fail_if(!string);
|
|
|
|
fail_if(strcmp(string, "char *"));
|
2014-06-27 07:39:19 -07:00
|
|
|
eina_stringshare_del(string);
|
2014-08-08 03:22:41 -07:00
|
|
|
expr = eolian_function_return_default_value_get(fid, EOLIAN_METHOD);
|
|
|
|
fail_if(!expr);
|
2017-05-25 07:18:10 -07:00
|
|
|
v = eolian_expression_eval(unit, expr, EOLIAN_MASK_NULL);
|
2014-08-18 05:12:08 -07:00
|
|
|
fail_if(v.type != EOLIAN_EXPR_NULL);
|
2014-08-18 06:58:35 -07:00
|
|
|
fail_if(eolian_function_is_legacy_only(fid, EOLIAN_METHOD));
|
2014-05-01 05:05:33 -07:00
|
|
|
|
|
|
|
/* Function parameters */
|
2015-05-20 09:03:14 -07:00
|
|
|
fail_if(!(iter = eolian_function_parameters_get(fid)));
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
2014-08-13 06:08:00 -07:00
|
|
|
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
|
|
|
|
fail_if(strcmp(eolian_type_name_get(eolian_parameter_type_get(param)), "int"));
|
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "a"));
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
2014-08-13 06:08:00 -07:00
|
|
|
fail_if(eolian_parameter_direction_get(param) != EOLIAN_INOUT_PARAM);
|
|
|
|
ptype = eolian_type_name_get(eolian_parameter_type_get(param));
|
2014-07-08 06:15:36 -07:00
|
|
|
fail_if(strcmp(ptype, "char"));
|
2014-08-13 06:08:00 -07:00
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "b"));
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
2014-08-13 06:08:00 -07:00
|
|
|
fail_if(eolian_parameter_direction_get(param) != EOLIAN_OUT_PARAM);
|
2017-09-22 11:58:36 -07:00
|
|
|
fail_if(eolian_type_builtin_type_get(eolian_parameter_type_get(param)) != EOLIAN_TYPE_BUILTIN_DOUBLE);
|
2014-08-13 06:08:00 -07:00
|
|
|
fail_if(strcmp(eolian_type_name_get(eolian_parameter_type_get(param)), "double"));
|
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "c"));
|
2014-09-02 03:00:19 -07:00
|
|
|
expr = eolian_parameter_default_value_get(param);
|
|
|
|
fail_if(!expr);
|
2017-05-25 07:18:10 -07:00
|
|
|
v = eolian_expression_eval(unit, expr, EOLIAN_MASK_FLOAT);
|
2014-09-02 03:00:19 -07:00
|
|
|
fail_if(v.type != EOLIAN_EXPR_DOUBLE);
|
|
|
|
fail_if(v.value.d != 1337.6);
|
2016-06-06 07:22:56 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
2016-06-08 07:49:09 -07:00
|
|
|
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
|
2016-06-06 07:22:56 -07:00
|
|
|
fail_if(strcmp(eolian_type_name_get(eolian_parameter_type_get(param)), "int"));
|
2016-11-03 06:21:57 -07:00
|
|
|
fail_if(!eolian_type_is_ptr(eolian_parameter_type_get(param)));
|
2016-06-06 07:22:56 -07:00
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "d"));
|
2014-07-23 05:44:42 -07:00
|
|
|
fail_if(eina_iterator_next(iter, &dummy));
|
|
|
|
eina_iterator_free(iter);
|
2014-05-01 05:05:33 -07:00
|
|
|
|
2014-12-03 07:04:40 -08:00
|
|
|
/* legacy only + c only */
|
2014-08-18 06:58:35 -07:00
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "bar", EOLIAN_METHOD)));
|
|
|
|
fail_if(!eolian_function_is_legacy_only(fid, EOLIAN_METHOD));
|
2015-05-08 06:12:27 -07:00
|
|
|
fail_if(eolian_function_is_beta(fid));
|
2016-11-03 06:21:57 -07:00
|
|
|
fail_if(!eolian_type_is_ptr(eolian_function_return_type_get(fid, EOLIAN_METHOD)));
|
2014-08-18 06:58:35 -07:00
|
|
|
|
2014-05-01 05:05:33 -07:00
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-07-14 04:11:48 -07:00
|
|
|
START_TEST(eolian_struct)
|
|
|
|
{
|
2014-08-22 08:56:41 -07:00
|
|
|
const Eolian_Struct_Type_Field *field = NULL;
|
2015-05-12 09:07:26 -07:00
|
|
|
const Eolian_Type *type = NULL, *ftype = NULL;
|
2016-02-19 05:18:36 -08:00
|
|
|
const Eolian_Typedecl *tdl = NULL;
|
2014-07-14 04:11:48 -07:00
|
|
|
const Eolian_Class *class;
|
2015-10-21 10:14:22 -07:00
|
|
|
const Eolian_Function *func;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2014-07-14 04:11:48 -07:00
|
|
|
const char *type_name;
|
2014-07-21 04:03:51 -07:00
|
|
|
const char *file;
|
2014-07-14 04:11:48 -07:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
|
|
|
|
/* Parsing */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/struct.eo")));
|
2014-07-14 04:11:48 -07:00
|
|
|
|
|
|
|
/* Check that the class Dummy is still readable */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Struct")));
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
|
2014-07-14 04:11:48 -07:00
|
|
|
|
|
|
|
/* named struct */
|
2017-05-25 06:11:08 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Named")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(type_name = eolian_typedecl_name_get(tdl)));
|
|
|
|
fail_if(!(file = eolian_typedecl_file_get(tdl)));
|
|
|
|
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
|
2014-07-14 04:11:48 -07:00
|
|
|
fail_if(strcmp(type_name, "Named"));
|
2014-07-21 04:03:51 -07:00
|
|
|
fail_if(strcmp(file, "struct.eo"));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "field")));
|
|
|
|
fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
|
2016-11-03 06:21:57 -07:00
|
|
|
fail_if(!eolian_type_is_ptr(ftype));
|
2014-08-22 08:56:41 -07:00
|
|
|
fail_if(!(type_name = eolian_type_name_get(ftype)));
|
2014-07-14 04:11:48 -07:00
|
|
|
fail_if(strcmp(type_name, "int"));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "something")));
|
|
|
|
fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
|
2016-11-03 06:21:57 -07:00
|
|
|
fail_if(eolian_type_is_ptr(ftype));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(ftype, EOLIAN_C_TYPE_DEFAULT)));
|
2014-07-14 04:11:48 -07:00
|
|
|
fail_if(strcmp(type_name, "const char *"));
|
|
|
|
eina_stringshare_del(type_name);
|
|
|
|
|
|
|
|
/* referencing */
|
2017-05-25 06:11:08 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Another")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(type_name = eolian_typedecl_name_get(tdl)));
|
|
|
|
fail_if(!(file = eolian_typedecl_file_get(tdl)));
|
|
|
|
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
|
2014-07-14 04:11:48 -07:00
|
|
|
fail_if(strcmp(type_name, "Another"));
|
2014-07-21 04:03:51 -07:00
|
|
|
fail_if(strcmp(file, "struct.eo"));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "field")));
|
|
|
|
fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
|
2014-08-22 08:56:41 -07:00
|
|
|
fail_if(!(type_name = eolian_type_name_get(ftype)));
|
2014-07-14 04:11:48 -07:00
|
|
|
fail_if(strcmp(type_name, "Named"));
|
2015-05-12 08:15:29 -07:00
|
|
|
fail_if(eolian_type_type_get(ftype) != EOLIAN_TYPE_REGULAR);
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(eolian_typedecl_type_get(eolian_type_typedecl_get(ftype))
|
|
|
|
!= EOLIAN_TYPEDECL_STRUCT);
|
2014-07-14 04:11:48 -07:00
|
|
|
|
2014-08-13 08:43:18 -07:00
|
|
|
/* opaque struct */
|
2017-05-25 06:11:08 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Opaque")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT_OPAQUE);
|
2014-08-13 08:43:18 -07:00
|
|
|
|
2015-10-21 10:14:22 -07:00
|
|
|
/* use in function */
|
|
|
|
fail_if(!(func = eolian_class_function_get_by_name(class, "bar", EOLIAN_METHOD)));
|
|
|
|
fail_if(!(type = eolian_function_return_type_get(func, EOLIAN_METHOD)));
|
|
|
|
fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_REGULAR);
|
2016-11-10 07:20:19 -08:00
|
|
|
fail_if(!eolian_type_is_ptr(type));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(tdl = eolian_type_typedecl_get(type)));
|
|
|
|
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
|
2015-10-21 10:14:22 -07:00
|
|
|
|
2014-07-14 04:11:48 -07:00
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-07-15 07:50:58 -07:00
|
|
|
START_TEST(eolian_extern)
|
|
|
|
{
|
2016-02-19 05:18:36 -08:00
|
|
|
const Eolian_Typedecl *tdl = NULL;
|
2014-07-15 07:50:58 -07:00
|
|
|
const Eolian_Class *class;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2014-07-15 07:50:58 -07:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
|
|
|
|
/* Parsing */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/extern.eo")));
|
2014-07-15 07:50:58 -07:00
|
|
|
|
|
|
|
/* Check that the class Dummy is still readable */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Extern")));
|
2014-07-23 06:13:21 -07:00
|
|
|
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
|
2014-07-15 07:50:58 -07:00
|
|
|
|
|
|
|
/* regular type */
|
2017-05-25 05:56:44 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_alias_get_by_name(unit, "Foo")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(eolian_typedecl_is_extern(tdl));
|
2014-07-15 07:50:58 -07:00
|
|
|
|
|
|
|
/* extern type */
|
2017-05-25 05:56:44 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_alias_get_by_name(unit, "Evas.Coord")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!eolian_typedecl_is_extern(tdl));
|
2014-07-15 07:50:58 -07:00
|
|
|
|
|
|
|
/* regular struct */
|
2017-05-25 06:11:08 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "X")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(eolian_typedecl_is_extern(tdl));
|
2014-07-15 07:50:58 -07:00
|
|
|
|
|
|
|
/* extern struct */
|
2017-05-25 06:11:08 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Y")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!eolian_typedecl_is_extern(tdl));
|
2014-07-15 07:50:58 -07:00
|
|
|
|
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-08-08 08:28:31 -07:00
|
|
|
START_TEST(eolian_var)
|
|
|
|
{
|
|
|
|
const Eolian_Variable *var = NULL;
|
|
|
|
const Eolian_Expression *exp = NULL;
|
|
|
|
const Eolian_Type *type = NULL;
|
|
|
|
const Eolian_Class *class;
|
2017-05-18 07:31:03 -07:00
|
|
|
const Eolian_Unit *unit;
|
2014-08-18 05:12:08 -07:00
|
|
|
Eolian_Value v;
|
2014-08-08 08:28:31 -07:00
|
|
|
const char *name;
|
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
|
|
|
|
/* Parsing */
|
2017-05-18 07:31:03 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/var.eo")));
|
2014-08-08 08:28:31 -07:00
|
|
|
|
|
|
|
/* Check that the class Dummy is still readable */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Var")));
|
2014-08-08 08:28:31 -07:00
|
|
|
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
|
|
|
|
|
|
|
|
/* regular constant */
|
2017-05-18 07:31:03 -07:00
|
|
|
fail_if(!(var = eolian_variable_constant_get_by_name(unit, "Foo")));
|
2014-08-08 08:28:31 -07:00
|
|
|
fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT);
|
|
|
|
fail_if(eolian_variable_is_extern(var));
|
|
|
|
fail_if(!(type = eolian_variable_base_type_get(var)));
|
|
|
|
fail_if(!(name = eolian_type_name_get(type)));
|
|
|
|
fail_if(strcmp(name, "int"));
|
|
|
|
fail_if(!(exp = eolian_variable_value_get(var)));
|
2017-05-25 07:18:10 -07:00
|
|
|
v = eolian_expression_eval_type(unit, exp, type);
|
2014-08-18 05:12:08 -07:00
|
|
|
fail_if(v.type != EOLIAN_EXPR_INT);
|
|
|
|
fail_if(v.value.i != 5);
|
2014-08-08 08:28:31 -07:00
|
|
|
|
|
|
|
/* regular global */
|
2017-05-18 07:31:03 -07:00
|
|
|
fail_if(!(var = eolian_variable_global_get_by_name(unit, "Bar")));
|
2014-08-08 08:28:31 -07:00
|
|
|
fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_GLOBAL);
|
|
|
|
fail_if(eolian_variable_is_extern(var));
|
|
|
|
fail_if(!(type = eolian_variable_base_type_get(var)));
|
|
|
|
fail_if(!(name = eolian_type_name_get(type)));
|
|
|
|
fail_if(strcmp(name, "float"));
|
|
|
|
fail_if(!(exp = eolian_variable_value_get(var)));
|
2017-05-25 07:18:10 -07:00
|
|
|
v = eolian_expression_eval_type(unit, exp, type);
|
2014-08-18 05:12:08 -07:00
|
|
|
fail_if(v.type != EOLIAN_EXPR_FLOAT);
|
|
|
|
fail_if(((int)v.value.f) != 10);
|
2014-08-08 08:28:31 -07:00
|
|
|
|
|
|
|
/* no-value global */
|
2017-05-18 07:31:03 -07:00
|
|
|
fail_if(!(var = eolian_variable_global_get_by_name(unit, "Baz")));
|
2014-08-08 08:28:31 -07:00
|
|
|
fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_GLOBAL);
|
|
|
|
fail_if(eolian_variable_is_extern(var));
|
|
|
|
fail_if(!(type = eolian_variable_base_type_get(var)));
|
|
|
|
fail_if(!(name = eolian_type_name_get(type)));
|
|
|
|
fail_if(strcmp(name, "long"));
|
|
|
|
fail_if(eolian_variable_value_get(var));
|
|
|
|
|
|
|
|
/* extern global */
|
2017-05-18 07:31:03 -07:00
|
|
|
fail_if(!(var = eolian_variable_global_get_by_name(unit, "Bah")));
|
2014-08-08 08:28:31 -07:00
|
|
|
fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_GLOBAL);
|
|
|
|
fail_if(!eolian_variable_is_extern(var));
|
|
|
|
fail_if(!(type = eolian_variable_base_type_get(var)));
|
|
|
|
fail_if(!(name = eolian_type_name_get(type)));
|
|
|
|
fail_if(strcmp(name, "double"));
|
|
|
|
fail_if(eolian_variable_value_get(var));
|
|
|
|
|
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-08-12 08:29:02 -07:00
|
|
|
START_TEST(eolian_enum)
|
|
|
|
{
|
2014-08-22 08:56:41 -07:00
|
|
|
const Eolian_Enum_Type_Field *field = NULL;
|
2014-08-12 08:46:53 -07:00
|
|
|
const Eolian_Variable *var = NULL;
|
2016-02-19 05:18:36 -08:00
|
|
|
const Eolian_Typedecl *tdl = NULL;
|
2014-08-12 08:29:02 -07:00
|
|
|
const Eolian_Type *type = NULL;
|
|
|
|
const Eolian_Class *class;
|
2014-08-12 08:46:53 -07:00
|
|
|
const Eolian_Expression *exp;
|
2017-05-18 07:31:03 -07:00
|
|
|
const Eolian_Unit *unit;
|
2015-05-12 09:04:54 -07:00
|
|
|
Eina_Stringshare *cname;
|
2014-08-12 08:46:53 -07:00
|
|
|
const char *name;
|
2014-08-18 05:12:08 -07:00
|
|
|
Eolian_Value v;
|
2014-08-12 08:29:02 -07:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
|
|
|
|
/* Parsing */
|
2017-05-18 07:31:03 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/enum.eo")));
|
2014-08-12 08:29:02 -07:00
|
|
|
|
|
|
|
/* Check that the class Dummy is still readable */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Enum")));
|
2014-08-12 08:29:02 -07:00
|
|
|
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
|
|
|
|
|
2017-05-25 06:15:04 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_enum_get_by_name(unit, "Foo")));
|
2014-08-12 08:46:53 -07:00
|
|
|
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "first")));
|
|
|
|
fail_if(!(exp = eolian_typedecl_enum_field_value_get(field, EINA_FALSE)));
|
2017-05-25 07:18:10 -07:00
|
|
|
v = eolian_expression_eval(unit, exp, EOLIAN_MASK_ALL);
|
2014-08-18 05:12:08 -07:00
|
|
|
fail_if(v.type != EOLIAN_EXPR_INT);
|
|
|
|
fail_if(v.value.i != 0);
|
2014-08-12 08:46:53 -07:00
|
|
|
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "bar")));
|
|
|
|
fail_if(eolian_typedecl_enum_field_value_get(field, EINA_FALSE));
|
2014-08-12 08:46:53 -07:00
|
|
|
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "baz")));
|
|
|
|
fail_if(!(exp = eolian_typedecl_enum_field_value_get(field, EINA_FALSE)));
|
2017-05-25 07:18:10 -07:00
|
|
|
v = eolian_expression_eval(unit, exp, EOLIAN_MASK_ALL);
|
2014-08-18 05:12:08 -07:00
|
|
|
fail_if(v.type != EOLIAN_EXPR_INT);
|
|
|
|
fail_if(v.value.i != 15);
|
2014-08-12 08:46:53 -07:00
|
|
|
|
2017-05-25 06:15:04 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_enum_get_by_name(unit, "Bar")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(strcmp(eolian_typedecl_enum_legacy_prefix_get(tdl), "test"));
|
2014-08-12 08:46:53 -07:00
|
|
|
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "foo")));
|
|
|
|
fail_if(!(exp = eolian_typedecl_enum_field_value_get(field, EINA_FALSE)));
|
2017-05-25 07:18:10 -07:00
|
|
|
v = eolian_expression_eval(unit, exp, EOLIAN_MASK_ALL);
|
2014-08-18 05:12:08 -07:00
|
|
|
fail_if(v.type != EOLIAN_EXPR_INT);
|
|
|
|
fail_if(v.value.i != 15);
|
2014-08-12 08:46:53 -07:00
|
|
|
|
2016-02-19 05:18:36 -08:00
|
|
|
cname = eolian_typedecl_enum_field_c_name_get(field);
|
2015-05-12 09:04:54 -07:00
|
|
|
fail_if(strcmp(cname, "TEST_FOO"));
|
|
|
|
eina_stringshare_del(cname);
|
|
|
|
|
2017-05-25 06:15:04 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_enum_get_by_name(unit, "Baz")));
|
2014-08-12 08:46:53 -07:00
|
|
|
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "flag1")));
|
|
|
|
fail_if(!(exp = eolian_typedecl_enum_field_value_get(field, EINA_FALSE)));
|
2017-05-25 07:18:10 -07:00
|
|
|
v = eolian_expression_eval(unit, exp, EOLIAN_MASK_ALL);
|
2014-08-18 05:12:08 -07:00
|
|
|
fail_if(v.type != EOLIAN_EXPR_INT);
|
|
|
|
fail_if(v.value.i != (1 << 0));
|
2014-08-12 08:46:53 -07:00
|
|
|
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "flag2")));
|
|
|
|
fail_if(!(exp = eolian_typedecl_enum_field_value_get(field, EINA_FALSE)));
|
2017-05-25 07:18:10 -07:00
|
|
|
v = eolian_expression_eval(unit, exp, EOLIAN_MASK_ALL);
|
2014-08-18 05:12:08 -07:00
|
|
|
fail_if(v.type != EOLIAN_EXPR_INT);
|
|
|
|
fail_if(v.value.i != (1 << 1));
|
2014-08-12 08:46:53 -07:00
|
|
|
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "flag3")));
|
|
|
|
fail_if(!(exp = eolian_typedecl_enum_field_value_get(field, EINA_FALSE)));
|
2017-05-25 07:18:10 -07:00
|
|
|
v = eolian_expression_eval(unit, exp, EOLIAN_MASK_ALL);
|
2014-08-18 05:12:08 -07:00
|
|
|
fail_if(v.type != EOLIAN_EXPR_INT);
|
|
|
|
fail_if(v.value.i != (1 << 2));
|
2014-08-12 08:46:53 -07:00
|
|
|
|
2017-05-25 06:15:04 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_enum_get_by_name(unit, "Name.Spaced")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(field = eolian_typedecl_enum_field_get(tdl, "pants")));
|
2015-05-18 08:37:42 -07:00
|
|
|
|
2016-02-19 05:18:36 -08:00
|
|
|
cname = eolian_typedecl_enum_field_c_name_get(field);
|
2015-05-18 08:37:42 -07:00
|
|
|
fail_if(strcmp(cname, "NAME_SPACED_PANTS"));
|
|
|
|
eina_stringshare_del(cname);
|
|
|
|
|
2017-05-18 07:31:03 -07:00
|
|
|
fail_if(!(var = eolian_variable_constant_get_by_name(unit, "Bah")));
|
2014-08-12 08:46:53 -07:00
|
|
|
fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT);
|
|
|
|
fail_if(eolian_variable_is_extern(var));
|
|
|
|
fail_if(!(type = eolian_variable_base_type_get(var)));
|
|
|
|
fail_if(!(name = eolian_type_name_get(type)));
|
2015-05-13 09:22:25 -07:00
|
|
|
fail_if(strcmp(name, "Baz"));
|
2014-08-12 08:46:53 -07:00
|
|
|
fail_if(!(exp = eolian_variable_value_get(var)));
|
2017-05-25 07:18:10 -07:00
|
|
|
v = eolian_expression_eval(unit, exp, EOLIAN_MASK_ALL);
|
2014-08-18 05:12:08 -07:00
|
|
|
fail_if(v.type != EOLIAN_EXPR_INT);
|
|
|
|
fail_if(v.value.i != (1 << 0));
|
2014-08-12 08:46:53 -07:00
|
|
|
|
2017-05-18 07:31:03 -07:00
|
|
|
fail_if(!(var = eolian_variable_constant_get_by_name(unit, "Pants")));
|
2015-05-13 09:15:20 -07:00
|
|
|
fail_if(eolian_variable_type_get(var) != EOLIAN_VAR_CONSTANT);
|
|
|
|
fail_if(!(exp = eolian_variable_value_get(var)));
|
2017-05-25 07:18:10 -07:00
|
|
|
v = eolian_expression_eval(unit, exp, EOLIAN_MASK_ALL);
|
2015-05-13 09:15:20 -07:00
|
|
|
fail_if(v.type != EOLIAN_EXPR_INT);
|
|
|
|
fail_if(v.value.i != 5);
|
|
|
|
|
2014-08-12 08:29:02 -07:00
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-07-24 06:01:33 -07:00
|
|
|
START_TEST(eolian_class_funcs)
|
|
|
|
{
|
|
|
|
const Eolian_Function *fid = NULL;
|
|
|
|
const Eolian_Class *class;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2014-07-24 06:01:33 -07:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
/* Parsing */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/class_funcs.eo")));
|
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Class_Funcs")));
|
2014-07-24 06:01:33 -07:00
|
|
|
|
|
|
|
/* Class properties */
|
2017-01-12 07:56:49 -08:00
|
|
|
fail_if(eolian_class_function_get_by_name(class, "a", EOLIAN_PROPERTY));
|
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "a", EOLIAN_PROP_GET)));
|
2014-07-24 06:01:33 -07:00
|
|
|
fail_if(!eolian_function_is_class(fid));
|
2017-01-12 07:56:49 -08:00
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "b", EOLIAN_PROP_GET)));
|
2014-07-24 06:01:33 -07:00
|
|
|
fail_if(eolian_function_is_class(fid));
|
|
|
|
|
|
|
|
/* Class methods */
|
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
|
|
|
|
fail_if(!eolian_function_is_class(fid));
|
2016-06-09 08:54:43 -07:00
|
|
|
fail_if(eolian_function_scope_get(fid, EOLIAN_METHOD) != EOLIAN_SCOPE_PUBLIC);
|
2014-07-24 06:01:33 -07:00
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "bar", EOLIAN_METHOD)));
|
|
|
|
fail_if(eolian_function_is_class(fid));
|
2016-06-09 08:54:43 -07:00
|
|
|
fail_if(eolian_function_scope_get(fid, EOLIAN_METHOD) != EOLIAN_SCOPE_PUBLIC);
|
2014-07-24 06:01:33 -07:00
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "baz", EOLIAN_METHOD)));
|
|
|
|
fail_if(!eolian_function_is_class(fid));
|
2016-06-09 08:54:43 -07:00
|
|
|
fail_if(eolian_function_scope_get(fid, EOLIAN_METHOD) != EOLIAN_SCOPE_PROTECTED);
|
2014-07-24 06:01:33 -07:00
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "bah", EOLIAN_METHOD)));
|
|
|
|
fail_if(eolian_function_is_class(fid));
|
2016-06-09 08:54:43 -07:00
|
|
|
fail_if(eolian_function_scope_get(fid, EOLIAN_METHOD) != EOLIAN_SCOPE_PROTECTED);
|
2014-07-24 06:01:33 -07:00
|
|
|
|
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-08-19 07:55:31 -07:00
|
|
|
START_TEST(eolian_free_func)
|
|
|
|
{
|
|
|
|
const Eolian_Class *class;
|
2016-02-19 05:18:36 -08:00
|
|
|
const Eolian_Typedecl *tdl;
|
2014-08-19 07:55:31 -07:00
|
|
|
const Eolian_Type *type;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2014-08-19 07:55:31 -07:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
|
|
|
|
/* Parsing */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/free_func.eo")));
|
2014-08-19 07:55:31 -07:00
|
|
|
|
|
|
|
/* Check that the class Dummy is still readable */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Free_Func")));
|
2014-08-19 07:55:31 -07:00
|
|
|
fail_if(!eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD));
|
|
|
|
|
|
|
|
/* regular struct */
|
2017-05-25 06:11:08 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Named1")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(eolian_typedecl_free_func_get(tdl));
|
2017-05-25 06:11:08 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Named2")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(strcmp(eolian_typedecl_free_func_get(tdl), "test_free"));
|
2014-08-19 07:55:31 -07:00
|
|
|
|
|
|
|
/* typedef */
|
2017-05-25 05:56:44 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_alias_get_by_name(unit, "Typedef1")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(eolian_typedecl_free_func_get(tdl));
|
2017-05-25 05:56:44 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_alias_get_by_name(unit, "Typedef2")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(strcmp(eolian_typedecl_free_func_get(tdl), "def_free"));
|
2014-08-19 07:55:31 -07:00
|
|
|
|
|
|
|
/* opaque struct */
|
2017-05-25 06:11:08 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Opaque1")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(eolian_typedecl_free_func_get(tdl));
|
2017-05-25 06:11:08 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Opaque2")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(strcmp(eolian_typedecl_free_func_get(tdl), "opaque_free"));
|
2014-08-19 07:55:31 -07:00
|
|
|
|
|
|
|
/* pointer */
|
2017-05-25 05:56:44 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_alias_get_by_name(unit, "Pointer1")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
|
2014-08-19 07:55:31 -07:00
|
|
|
fail_if(eolian_type_free_func_get(type));
|
2017-05-25 05:56:44 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_alias_get_by_name(unit, "Pointer2")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(type = eolian_typedecl_base_type_get(tdl)));
|
2014-08-19 07:55:31 -07:00
|
|
|
fail_if(strcmp(eolian_type_free_func_get(type), "ptr_free"));
|
|
|
|
|
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2015-02-12 05:42:57 -08:00
|
|
|
START_TEST(eolian_null)
|
|
|
|
{
|
|
|
|
const Eolian_Class *class;
|
|
|
|
const Eolian_Function *func;
|
|
|
|
const Eolian_Function_Parameter *param;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2015-05-20 09:42:00 -07:00
|
|
|
Eina_Iterator *iter;
|
2015-02-12 05:42:57 -08:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
|
|
|
|
/* Parsing */
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/null.eo")));
|
2015-02-12 05:42:57 -08:00
|
|
|
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Null")));
|
2015-02-12 05:42:57 -08:00
|
|
|
fail_if(!(func = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
|
|
|
|
|
2015-05-20 09:42:00 -07:00
|
|
|
fail_if(!(iter = eolian_function_parameters_get(func)));
|
|
|
|
|
2015-02-12 05:42:57 -08:00
|
|
|
/* no qualifiers */
|
2015-05-20 09:42:00 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "x"));
|
2015-02-12 05:42:57 -08:00
|
|
|
fail_if(eolian_parameter_is_nullable(param));
|
|
|
|
fail_if(eolian_parameter_is_optional(param));
|
|
|
|
|
|
|
|
/* nullable */
|
2015-05-20 09:42:00 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "y"));
|
2015-02-12 05:42:57 -08:00
|
|
|
fail_if(!eolian_parameter_is_nullable(param));
|
|
|
|
fail_if(eolian_parameter_is_optional(param));
|
|
|
|
|
|
|
|
/* optional */
|
2015-05-20 09:42:00 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "z"));
|
2015-02-12 05:42:57 -08:00
|
|
|
fail_if(eolian_parameter_is_nullable(param));
|
|
|
|
fail_if(!eolian_parameter_is_optional(param));
|
|
|
|
|
|
|
|
/* both */
|
2015-05-20 09:42:00 -07:00
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "w"));
|
2015-02-12 05:42:57 -08:00
|
|
|
fail_if(!eolian_parameter_is_nullable(param));
|
|
|
|
fail_if(!eolian_parameter_is_optional(param));
|
|
|
|
|
2015-05-20 09:42:00 -07:00
|
|
|
fail_if(eina_iterator_next(iter, (void**)¶m));
|
|
|
|
eina_iterator_free(iter);
|
|
|
|
|
2015-02-12 05:42:57 -08:00
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2015-05-19 07:38:31 -07:00
|
|
|
START_TEST(eolian_import)
|
|
|
|
{
|
|
|
|
const Eolian_Class *class;
|
2016-02-19 05:18:36 -08:00
|
|
|
const Eolian_Typedecl *tdl;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2015-05-19 07:38:31 -07:00
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
|
|
|
|
fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
|
|
|
|
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/import.eo")));
|
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Import")));
|
2015-05-19 07:38:31 -07:00
|
|
|
|
2017-05-25 05:56:44 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_alias_get_by_name(unit, "Imported")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(strcmp(eolian_typedecl_file_get(tdl), "import_types.eot"));
|
2015-05-19 07:38:31 -07:00
|
|
|
|
2017-05-25 06:11:08 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Imported_Struct")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(strcmp(eolian_typedecl_file_get(tdl), "import_types.eot"));
|
2015-05-19 07:38:31 -07:00
|
|
|
|
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2015-06-01 07:24:00 -07:00
|
|
|
START_TEST(eolian_decl)
|
|
|
|
{
|
|
|
|
const Eolian_Declaration *decl;
|
2016-02-19 05:18:36 -08:00
|
|
|
const Eolian_Typedecl *tdl;
|
2015-06-01 07:24:00 -07:00
|
|
|
const Eolian_Class *class;
|
|
|
|
const Eolian_Variable *var;
|
2017-05-24 08:35:34 -07:00
|
|
|
const Eolian_Unit *unit;
|
2015-06-01 07:24:00 -07:00
|
|
|
Eina_Iterator *itr;
|
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
|
|
|
|
fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
|
|
|
|
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/decl.eo")));
|
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Decl")));
|
2015-06-01 07:24:00 -07:00
|
|
|
|
|
|
|
fail_if(!(itr = eolian_declarations_get_by_file("decl.eo")));
|
|
|
|
|
|
|
|
fail_if(!eina_iterator_next(itr, (void**)&decl));
|
2015-07-07 02:56:53 -07:00
|
|
|
fail_if(eolian_declaration_type_get(decl) != EOLIAN_DECL_STRUCT);
|
2015-06-01 07:24:00 -07:00
|
|
|
fail_if(strcmp(eolian_declaration_name_get(decl), "A"));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(tdl = eolian_declaration_data_type_get(decl)));
|
|
|
|
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_STRUCT);
|
|
|
|
fail_if(strcmp(eolian_typedecl_name_get(tdl), "A"));
|
2015-06-01 07:24:00 -07:00
|
|
|
|
|
|
|
fail_if(!eina_iterator_next(itr, (void**)&decl));
|
2015-07-07 02:56:53 -07:00
|
|
|
fail_if(eolian_declaration_type_get(decl) != EOLIAN_DECL_ENUM);
|
2015-06-01 07:24:00 -07:00
|
|
|
fail_if(strcmp(eolian_declaration_name_get(decl), "B"));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(tdl = eolian_declaration_data_type_get(decl)));
|
|
|
|
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_ENUM);
|
|
|
|
fail_if(strcmp(eolian_typedecl_name_get(tdl), "B"));
|
2015-06-01 07:24:00 -07:00
|
|
|
|
|
|
|
fail_if(!eina_iterator_next(itr, (void**)&decl));
|
2015-07-07 02:56:53 -07:00
|
|
|
fail_if(eolian_declaration_type_get(decl) != EOLIAN_DECL_ALIAS);
|
2015-06-01 07:24:00 -07:00
|
|
|
fail_if(strcmp(eolian_declaration_name_get(decl), "C"));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(tdl = eolian_declaration_data_type_get(decl)));
|
|
|
|
fail_if(eolian_typedecl_type_get(tdl) != EOLIAN_TYPEDECL_ALIAS);
|
|
|
|
fail_if(strcmp(eolian_typedecl_name_get(tdl), "C"));
|
2015-06-01 07:24:00 -07:00
|
|
|
|
|
|
|
fail_if(!eina_iterator_next(itr, (void**)&decl));
|
2015-07-07 02:56:53 -07:00
|
|
|
fail_if(eolian_declaration_type_get(decl) != EOLIAN_DECL_VAR);
|
2015-06-01 07:24:00 -07:00
|
|
|
fail_if(strcmp(eolian_declaration_name_get(decl), "pants"));
|
|
|
|
fail_if(!(var = eolian_declaration_variable_get(decl)));
|
|
|
|
fail_if(strcmp(eolian_variable_name_get(var), "pants"));
|
|
|
|
|
|
|
|
fail_if(!eina_iterator_next(itr, (void**)&decl));
|
2015-07-07 02:56:53 -07:00
|
|
|
fail_if(eolian_declaration_type_get(decl) != EOLIAN_DECL_CLASS);
|
2015-06-01 07:24:00 -07:00
|
|
|
fail_if(strcmp(eolian_declaration_name_get(decl), "Decl"));
|
|
|
|
fail_if(eolian_declaration_class_get(decl) != class);
|
|
|
|
|
|
|
|
fail_if(eina_iterator_next(itr, (void**)&decl));
|
|
|
|
|
2015-07-07 02:56:53 -07:00
|
|
|
fail_if(!(decl = eolian_declaration_get_by_name("pants")));
|
|
|
|
fail_if(eolian_declaration_type_get(decl) != EOLIAN_DECL_VAR);
|
|
|
|
|
|
|
|
fail_if(!(decl = eolian_declaration_get_by_name("A")));
|
|
|
|
fail_if(eolian_declaration_type_get(decl) != EOLIAN_DECL_STRUCT);
|
|
|
|
|
2015-06-01 07:24:00 -07:00
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2015-06-03 04:06:36 -07:00
|
|
|
START_TEST(eolian_docs)
|
|
|
|
{
|
2016-02-19 05:18:36 -08:00
|
|
|
const Eolian_Typedecl *tdl;
|
2015-06-03 08:16:53 -07:00
|
|
|
const Eolian_Class *class;
|
|
|
|
const Eolian_Event *event;
|
|
|
|
const Eolian_Variable *var;
|
|
|
|
const Eolian_Function *fid;
|
|
|
|
const Eolian_Documentation *doc;
|
|
|
|
const Eolian_Function_Parameter *par;
|
|
|
|
const Eolian_Struct_Type_Field *sfl;
|
|
|
|
const Eolian_Enum_Type_Field *efl;
|
2017-05-18 07:31:03 -07:00
|
|
|
const Eolian_Unit *unit;
|
2015-06-03 08:16:53 -07:00
|
|
|
Eina_Iterator *itr;
|
|
|
|
|
2015-06-03 04:06:36 -07:00
|
|
|
eolian_init();
|
|
|
|
|
|
|
|
fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
|
|
|
|
|
2017-05-18 07:31:03 -07:00
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/docs.eo")));
|
2015-06-03 08:16:53 -07:00
|
|
|
|
2017-05-25 06:11:08 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Foo")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(doc = eolian_typedecl_documentation_get(tdl)));
|
2015-06-03 08:16:53 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
2015-06-04 07:41:52 -07:00
|
|
|
"This is struct Foo. It does stuff."));
|
2015-06-03 08:16:53 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_description_get(doc),
|
2015-09-14 06:10:32 -07:00
|
|
|
"Note: This is a note.\n\n"
|
2015-06-03 08:16:53 -07:00
|
|
|
"This is a longer description for struct Foo.\n\n"
|
2015-09-14 06:10:32 -07:00
|
|
|
"Warning: This is a warning. You can only use Warning: "
|
|
|
|
"and Note: at the beginning of a paragraph.\n\n"
|
2015-06-03 08:16:53 -07:00
|
|
|
"This is another paragraph."));
|
2015-06-08 07:55:02 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_since_get(doc),
|
|
|
|
"1.66"));
|
2015-06-03 08:16:53 -07:00
|
|
|
|
2016-12-01 07:37:01 -08:00
|
|
|
const char *sdesc = eolian_documentation_description_get(doc);
|
|
|
|
Eina_List *sdoc = eolian_documentation_string_split(sdesc);
|
|
|
|
|
|
|
|
char *dpar = eina_list_data_get(sdoc);
|
|
|
|
fail_if(strcmp(dpar, "Note: This is a note."));
|
|
|
|
sdoc = eina_list_remove_list(sdoc, sdoc);
|
|
|
|
dpar = eina_list_data_get(sdoc);
|
|
|
|
fail_if(strcmp(dpar, "This is a longer description for struct Foo."));
|
|
|
|
EINA_LIST_FREE(sdoc, dpar)
|
|
|
|
free(dpar);
|
|
|
|
|
2016-12-06 10:08:42 -08:00
|
|
|
const char *tdoc = "Note: This is $something, see @pants, "
|
|
|
|
"@Docs.meth, \\@ref foo and @[Things.Stuffs.foo,bar].";
|
2016-12-01 07:37:01 -08:00
|
|
|
|
|
|
|
Eolian_Doc_Token tok;
|
|
|
|
eolian_doc_token_init(&tok);
|
|
|
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_UNKNOWN);
|
|
|
|
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
|
|
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_MARK_NOTE);
|
|
|
|
char *txt = eolian_doc_token_text_get(&tok);
|
|
|
|
fail_if(strcmp(txt, "Note: "));
|
|
|
|
free(txt);
|
|
|
|
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
|
|
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_TEXT);
|
|
|
|
txt = eolian_doc_token_text_get(&tok);
|
|
|
|
fail_if(strcmp(txt, "This is "));
|
|
|
|
free(txt);
|
|
|
|
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
|
|
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_MARKUP_MONOSPACE);
|
|
|
|
txt = eolian_doc_token_text_get(&tok);
|
|
|
|
fail_if(strcmp(txt, "something"));
|
|
|
|
free(txt);
|
|
|
|
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
|
|
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_TEXT);
|
|
|
|
txt = eolian_doc_token_text_get(&tok);
|
|
|
|
fail_if(strcmp(txt, ", see "));
|
|
|
|
free(txt);
|
|
|
|
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
|
|
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_REF);
|
|
|
|
txt = eolian_doc_token_text_get(&tok);
|
2016-12-06 10:08:42 -08:00
|
|
|
fail_if(strcmp(txt, "pants"));
|
2017-05-26 06:01:00 -07:00
|
|
|
fail_if(eolian_doc_token_ref_get(unit, &tok, NULL, NULL) != EOLIAN_DOC_REF_VAR);
|
2016-12-01 07:37:01 -08:00
|
|
|
free(txt);
|
|
|
|
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
|
|
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_TEXT);
|
|
|
|
txt = eolian_doc_token_text_get(&tok);
|
|
|
|
fail_if(strcmp(txt, ", "));
|
|
|
|
free(txt);
|
|
|
|
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
|
|
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_REF);
|
|
|
|
txt = eolian_doc_token_text_get(&tok);
|
2016-12-06 10:08:42 -08:00
|
|
|
fail_if(strcmp(txt, "Docs.meth"));
|
2017-05-26 06:01:00 -07:00
|
|
|
fail_if(eolian_doc_token_ref_get(unit, &tok, NULL, NULL) != EOLIAN_DOC_REF_FUNC);
|
2016-12-01 07:37:01 -08:00
|
|
|
free(txt);
|
|
|
|
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
|
|
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_TEXT);
|
|
|
|
txt = eolian_doc_token_text_get(&tok);
|
|
|
|
fail_if(strcmp(txt, ", @ref foo and "));
|
|
|
|
free(txt);
|
|
|
|
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
2016-12-06 10:08:42 -08:00
|
|
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_REF);
|
2016-12-01 07:37:01 -08:00
|
|
|
txt = eolian_doc_token_text_get(&tok);
|
|
|
|
fail_if(strcmp(txt, "[Things.Stuffs.foo,bar]"));
|
|
|
|
free(txt);
|
|
|
|
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
|
|
|
fail_if(tdoc[0] != '\0');
|
|
|
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_TEXT);
|
|
|
|
txt = eolian_doc_token_text_get(&tok);
|
|
|
|
fail_if(strcmp(txt, "."));
|
|
|
|
free(txt);
|
|
|
|
tdoc = eolian_documentation_tokenize(tdoc, &tok);
|
|
|
|
fail_if(tdoc != NULL);
|
|
|
|
fail_if(eolian_doc_token_type_get(&tok) != EOLIAN_DOC_TOKEN_UNKNOWN);
|
|
|
|
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(sfl = eolian_typedecl_struct_field_get(tdl, "field1")));
|
|
|
|
fail_if(!(doc = eolian_typedecl_struct_field_documentation_get(sfl)));
|
2015-06-03 08:16:53 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Field documentation."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
|
|
|
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(sfl = eolian_typedecl_struct_field_get(tdl, "field2")));
|
|
|
|
fail_if(eolian_typedecl_struct_field_documentation_get(sfl));
|
2015-06-03 08:16:53 -07:00
|
|
|
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(sfl = eolian_typedecl_struct_field_get(tdl, "field3")));
|
|
|
|
fail_if(!(doc = eolian_typedecl_struct_field_documentation_get(sfl)));
|
2015-06-03 08:16:53 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Another field documentation."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
|
|
|
|
2017-05-25 06:15:04 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_enum_get_by_name(unit, "Bar")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(doc = eolian_typedecl_documentation_get(tdl)));
|
2015-06-03 08:16:53 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Docs for enum Bar."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
2015-06-08 07:55:02 -07:00
|
|
|
fail_if(eolian_documentation_since_get(doc));
|
2015-06-03 08:16:53 -07:00
|
|
|
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(efl = eolian_typedecl_enum_field_get(tdl, "blah")));
|
|
|
|
fail_if(eolian_typedecl_enum_field_documentation_get(efl));
|
2015-06-03 08:16:53 -07:00
|
|
|
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(efl = eolian_typedecl_enum_field_get(tdl, "foo")));
|
|
|
|
fail_if(!(doc = eolian_typedecl_enum_field_documentation_get(efl)));
|
2015-06-03 08:16:53 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Docs for foo."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
|
|
|
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(efl = eolian_typedecl_enum_field_get(tdl, "bar")));
|
|
|
|
fail_if(!(doc = eolian_typedecl_enum_field_documentation_get(efl)));
|
2015-06-03 08:16:53 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Docs for bar."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
|
|
|
|
2017-05-25 05:56:44 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_alias_get_by_name(unit, "Alias")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(doc = eolian_typedecl_documentation_get(tdl)));
|
2015-06-03 08:16:53 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Docs for typedef."));
|
|
|
|
fail_if(strcmp(eolian_documentation_description_get(doc),
|
|
|
|
"More docs for typedef. See @Bar."));
|
2015-06-08 07:55:02 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_since_get(doc),
|
|
|
|
"2.0"));
|
2015-06-03 08:16:53 -07:00
|
|
|
|
2017-05-18 07:31:03 -07:00
|
|
|
fail_if(!(var = eolian_variable_global_get_by_name(unit, "pants")));
|
2015-06-03 08:16:53 -07:00
|
|
|
fail_if(!(doc = eolian_variable_documentation_get(var)));
|
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Docs for var."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
|
|
|
|
2017-05-25 06:11:08 -07:00
|
|
|
fail_if(!(tdl = eolian_typedecl_struct_get_by_name(unit, "Opaque")));
|
2016-02-19 05:18:36 -08:00
|
|
|
fail_if(!(doc = eolian_typedecl_documentation_get(tdl)));
|
2015-06-03 08:16:53 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Opaque struct docs. See @Foo for another struct."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
|
|
|
|
2017-05-24 08:35:34 -07:00
|
|
|
fail_if(!(class = eolian_class_get_by_name(unit, "Docs")));
|
2015-06-03 08:16:53 -07:00
|
|
|
fail_if(!(doc = eolian_class_documentation_get(class)));
|
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Docs for class."));
|
|
|
|
fail_if(strcmp(eolian_documentation_description_get(doc),
|
2015-07-07 09:19:13 -07:00
|
|
|
"More docs for class. Testing references now. "
|
|
|
|
"@Foo @Bar @Alias @pants @Docs.meth @Docs.prop "
|
|
|
|
"@Docs.prop.get @Docs.prop.set @Foo.field1 @Bar.foo @Docs"));
|
2015-06-03 08:16:53 -07:00
|
|
|
|
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "meth", EOLIAN_METHOD)));
|
2017-01-19 05:46:40 -08:00
|
|
|
const Eolian_Implement *fimp = eolian_function_implement_get(fid);
|
|
|
|
fail_if(!(doc = eolian_implement_documentation_get(fimp, EOLIAN_METHOD)));
|
2015-06-03 08:16:53 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Method documentation."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
|
|
|
|
|
|
|
fail_if(!(itr = eolian_function_parameters_get(fid)));
|
|
|
|
|
|
|
|
fail_if(!eina_iterator_next(itr, (void**)&par));
|
|
|
|
fail_if(!(doc = eolian_parameter_documentation_get(par)));
|
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Param documentation."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
|
|
|
|
|
|
|
fail_if(!eina_iterator_next(itr, (void**)&par));
|
|
|
|
fail_if(eolian_parameter_documentation_get(par));
|
|
|
|
|
|
|
|
fail_if(!eina_iterator_next(itr, (void**)&par));
|
|
|
|
fail_if(!(doc = eolian_parameter_documentation_get(par)));
|
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Another param documentation."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
|
|
|
|
|
|
|
fail_if(eina_iterator_next(itr, (void**)&par));
|
|
|
|
eina_iterator_free(itr);
|
|
|
|
|
|
|
|
fail_if(!(doc = eolian_function_return_documentation_get(fid, EOLIAN_METHOD)));
|
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Return documentation."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
|
|
|
|
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(class, "prop", EOLIAN_PROPERTY)));
|
2017-01-19 05:46:40 -08:00
|
|
|
fimp = eolian_function_implement_get(fid);
|
|
|
|
fail_if(!(doc = eolian_implement_documentation_get(fimp, EOLIAN_PROPERTY)));
|
2015-06-03 08:16:53 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Property common documentation."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
2015-06-08 07:55:02 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_since_get(doc),
|
|
|
|
"1.18"));
|
2017-01-19 05:46:40 -08:00
|
|
|
fail_if(!(doc = eolian_implement_documentation_get(fimp, EOLIAN_PROP_GET)));
|
2015-06-03 08:16:53 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Get documentation."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
2017-01-19 05:46:40 -08:00
|
|
|
fail_if(!(doc = eolian_implement_documentation_get(fimp, EOLIAN_PROP_SET)));
|
2015-06-03 08:16:53 -07:00
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Set documentation."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
|
|
|
|
|
|
|
fail_if(!(itr = eolian_property_values_get(fid, EOLIAN_PROP_GET)));
|
|
|
|
|
|
|
|
fail_if(!eina_iterator_next(itr, (void**)&par));
|
|
|
|
fail_if(!(doc = eolian_parameter_documentation_get(par)));
|
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Value documentation."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
|
|
|
|
|
|
|
fail_if(eina_iterator_next(itr, (void**)&par));
|
|
|
|
eina_iterator_free(itr);
|
|
|
|
|
|
|
|
fail_if(!(event = eolian_class_event_get_by_name(class, "clicked")));
|
|
|
|
fail_if(!(doc = eolian_event_documentation_get(event)));
|
|
|
|
fail_if(strcmp(eolian_documentation_summary_get(doc),
|
|
|
|
"Event docs."));
|
|
|
|
fail_if(eolian_documentation_description_get(doc));
|
2015-06-03 04:06:36 -07:00
|
|
|
|
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2017-04-07 09:54:55 -07:00
|
|
|
START_TEST(eolian_function_types)
|
|
|
|
{
|
|
|
|
const Eolian_Typedecl *decl = NULL;
|
|
|
|
const Eolian_Typedecl *arg_decl = NULL;
|
|
|
|
const Eolian_Type *type = NULL;
|
|
|
|
const Eolian_Function *fid = NULL;
|
|
|
|
const Eolian_Function_Parameter *param = NULL;
|
|
|
|
const Eolian_Unit *unit = NULL;
|
|
|
|
Eina_Iterator *iter = NULL;
|
|
|
|
const char* type_name = NULL;
|
|
|
|
void *dummy;
|
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
|
|
|
|
fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
|
|
|
|
|
|
|
|
/* Parsing */
|
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/function_types.eot")));
|
|
|
|
|
|
|
|
/* void func(void); */
|
|
|
|
fail_if(!(decl = eolian_typedecl_alias_get_by_name(unit, "VoidFunc")));
|
|
|
|
fail_if(eolian_typedecl_type_get(decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER);
|
|
|
|
|
|
|
|
fail_if(!(fid = eolian_typedecl_function_pointer_get(decl)));
|
|
|
|
fail_if(eolian_function_type_get(fid) != EOLIAN_FUNCTION_POINTER);
|
|
|
|
|
|
|
|
fail_if((eolian_function_return_type_get(fid, EOLIAN_FUNCTION_POINTER))); // void is null_return_type?
|
|
|
|
fail_if((eolian_function_parameters_get(fid)));
|
|
|
|
|
|
|
|
/* Function pointer with return and parameters */
|
|
|
|
fail_if(!(decl = eolian_typedecl_alias_get_by_name(unit, "SimpleFunc")));
|
|
|
|
fail_if(eolian_typedecl_type_get(decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER);
|
|
|
|
|
|
|
|
fail_if(!(fid = eolian_typedecl_function_pointer_get(decl)));
|
|
|
|
fail_if(eolian_function_type_get(fid) != EOLIAN_FUNCTION_POINTER);
|
|
|
|
fail_if(strcmp(eolian_function_name_get(fid), "SimpleFunc"));
|
|
|
|
|
|
|
|
fail_if(!(type = eolian_function_return_type_get(fid, EOLIAN_FUNCTION_POINTER))); // void is null_return_type?
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_RETURN)));
|
2017-04-07 09:54:55 -07:00
|
|
|
fail_if(strcmp(type_name, "const char *"));
|
|
|
|
fail_if(!(iter = (eolian_function_parameters_get(fid))));
|
|
|
|
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "a"));
|
|
|
|
fail_if(!(type = eolian_parameter_type_get(param)));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
|
2017-04-07 09:54:55 -07:00
|
|
|
fail_if(strcmp(type_name, "int"));
|
|
|
|
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "b"));
|
|
|
|
fail_if(!(type = eolian_parameter_type_get(param)));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
|
2017-04-07 09:54:55 -07:00
|
|
|
fail_if(strcmp(type_name, "double"));
|
|
|
|
|
|
|
|
fail_if(eina_iterator_next(iter, &dummy));
|
|
|
|
|
|
|
|
/* Function pointer with parameter attributes (in/out) */
|
|
|
|
fail_if(!(decl = eolian_typedecl_alias_get_by_name(unit, "ComplexFunc")));
|
|
|
|
fail_if(eolian_typedecl_type_get(decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER);
|
|
|
|
|
|
|
|
fail_if(!(fid = eolian_typedecl_function_pointer_get(decl)));
|
|
|
|
fail_if(eolian_function_type_get(fid) != EOLIAN_FUNCTION_POINTER);
|
|
|
|
|
|
|
|
fail_if(!(type = eolian_function_return_type_get(fid, EOLIAN_FUNCTION_POINTER)));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_RETURN)));
|
2017-04-07 09:54:55 -07:00
|
|
|
fail_if(strcmp(type_name, "double"));
|
|
|
|
fail_if(!(iter = (eolian_function_parameters_get(fid))));
|
|
|
|
|
|
|
|
/* in string */
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "c"));
|
|
|
|
fail_if(!(type = eolian_parameter_type_get(param)));
|
|
|
|
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(eolian_type_is_owned(type));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
|
2017-04-07 09:54:55 -07:00
|
|
|
fail_if(strcmp(type_name, "const char *"));
|
|
|
|
|
|
|
|
/*out own string */
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "d"));
|
|
|
|
fail_if(eolian_parameter_direction_get(param) != EOLIAN_OUT_PARAM);
|
|
|
|
fail_if(!(type = eolian_parameter_type_get(param)));
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(!eolian_type_is_owned(type));
|
2017-08-10 03:47:56 -07:00
|
|
|
fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_PARAM)));
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(strcmp(type_name, "char *"));
|
2017-04-07 09:54:55 -07:00
|
|
|
|
|
|
|
fail_if(eina_iterator_next(iter, &dummy));
|
|
|
|
|
|
|
|
/* Function pointer receiving another function pointer */
|
|
|
|
fail_if(!(decl = eolian_typedecl_alias_get_by_name(unit, "FuncAsArgFunc")));
|
|
|
|
fail_if(eolian_typedecl_type_get(decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER);
|
|
|
|
|
|
|
|
fail_if(!(fid = eolian_typedecl_function_pointer_get(decl)));
|
|
|
|
fail_if(eolian_function_type_get(fid) != EOLIAN_FUNCTION_POINTER);
|
|
|
|
|
|
|
|
fail_if(eolian_function_return_type_get(fid, EOLIAN_FUNCTION_POINTER));
|
|
|
|
|
|
|
|
fail_if(!(iter = (eolian_function_parameters_get(fid))));
|
|
|
|
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "cb"));
|
|
|
|
fail_if(!(type = eolian_parameter_type_get(param)));
|
|
|
|
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(eolian_type_is_owned(type));
|
2017-04-07 09:54:55 -07:00
|
|
|
fail_if(!(type_name = eolian_type_name_get(type)));
|
|
|
|
fail_if(strcmp(type_name, "VoidFunc"));
|
|
|
|
fail_if(!(arg_decl = eolian_type_typedecl_get(type)));
|
|
|
|
fail_if(eolian_typedecl_type_get(arg_decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER);
|
|
|
|
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "another_cb"));
|
|
|
|
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
|
|
|
|
fail_if(!(type = eolian_parameter_type_get(param)));
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(eolian_type_is_owned(type));
|
2017-04-07 09:54:55 -07:00
|
|
|
fail_if(eolian_type_type_get(type) != EOLIAN_TYPE_REGULAR);
|
|
|
|
fail_if(!(type_name = eolian_type_name_get(type)));
|
|
|
|
fail_if(strcmp(type_name, "SimpleFunc"));
|
|
|
|
fail_if(!(arg_decl = eolian_type_typedecl_get(type)));
|
|
|
|
fail_if(eolian_typedecl_type_get(arg_decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER);
|
|
|
|
|
|
|
|
fail_if(eina_iterator_next(iter, &dummy));
|
|
|
|
|
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
START_TEST(eolian_function_as_arguments)
|
|
|
|
{
|
|
|
|
const Eolian_Class *cls = NULL;
|
|
|
|
const Eolian_Function *fid = NULL;
|
|
|
|
const Eolian_Type *type = NULL;
|
|
|
|
const Eolian_Typedecl *arg_decl = NULL;
|
|
|
|
const Eolian_Function_Parameter *param = NULL;
|
|
|
|
const Eolian_Unit *unit = NULL;
|
|
|
|
Eina_Iterator *iter = NULL;
|
|
|
|
const char *type_name = NULL;
|
|
|
|
void *dummy;
|
|
|
|
|
|
|
|
eolian_init();
|
|
|
|
|
|
|
|
fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
|
|
|
|
|
|
|
|
fail_if(!(unit = eolian_file_parse(PACKAGE_DATA_DIR"/data/function_as_argument.eo")));
|
|
|
|
|
|
|
|
fail_if(!(cls = eolian_class_get_by_name(unit, "Function_As_Argument")));
|
|
|
|
|
|
|
|
fail_if(!(fid = eolian_class_function_get_by_name(cls, "set_cb", EOLIAN_METHOD)));
|
|
|
|
|
|
|
|
fail_if(!(iter = (eolian_function_parameters_get(fid))));
|
|
|
|
|
|
|
|
fail_if(!(eina_iterator_next(iter, (void**)¶m)));
|
|
|
|
fail_if(strcmp(eolian_parameter_name_get(param), "cb"));
|
|
|
|
fail_if(!(type = eolian_parameter_type_get(param)));
|
|
|
|
fail_if(eolian_parameter_direction_get(param) != EOLIAN_IN_PARAM);
|
2017-09-15 08:48:28 -07:00
|
|
|
fail_if(eolian_type_is_owned(type));
|
2017-04-07 09:54:55 -07:00
|
|
|
fail_if(!(type_name = eolian_type_name_get(type)));
|
|
|
|
fail_if(strcmp(type_name, "SimpleFunc"));
|
|
|
|
fail_if(!(arg_decl = eolian_type_typedecl_get(type)));
|
|
|
|
fail_if(eolian_typedecl_type_get(arg_decl) != EOLIAN_TYPEDECL_FUNCTION_POINTER);
|
|
|
|
|
|
|
|
fail_if(eina_iterator_next(iter, &dummy));
|
|
|
|
|
|
|
|
eolian_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-05-01 05:05:33 -07:00
|
|
|
void eolian_parsing_test(TCase *tc)
|
|
|
|
{
|
|
|
|
tcase_add_test(tc, eolian_simple_parsing);
|
|
|
|
tcase_add_test(tc, eolian_ctor_dtor);
|
|
|
|
tcase_add_test(tc, eolian_scope);
|
|
|
|
tcase_add_test(tc, eolian_complex_type);
|
|
|
|
tcase_add_test(tc, eolian_typedef);
|
2014-05-21 01:39:16 -07:00
|
|
|
tcase_add_test(tc, eolian_consts);
|
2014-05-21 03:56:31 -07:00
|
|
|
tcase_add_test(tc, eolian_override);
|
2014-05-23 07:38:39 -07:00
|
|
|
tcase_add_test(tc, eolian_events);
|
2014-05-25 03:53:49 -07:00
|
|
|
tcase_add_test(tc, eolian_namespaces);
|
2014-07-14 04:11:48 -07:00
|
|
|
tcase_add_test(tc, eolian_struct);
|
2014-07-15 07:50:58 -07:00
|
|
|
tcase_add_test(tc, eolian_extern);
|
2014-08-08 08:28:31 -07:00
|
|
|
tcase_add_test(tc, eolian_var);
|
2014-08-12 08:29:02 -07:00
|
|
|
tcase_add_test(tc, eolian_enum);
|
2014-07-24 06:01:33 -07:00
|
|
|
tcase_add_test(tc, eolian_class_funcs);
|
2014-08-19 07:55:31 -07:00
|
|
|
tcase_add_test(tc, eolian_free_func);
|
2015-02-12 05:42:57 -08:00
|
|
|
tcase_add_test(tc, eolian_null);
|
2015-05-19 07:38:31 -07:00
|
|
|
tcase_add_test(tc, eolian_import);
|
2015-06-01 07:24:00 -07:00
|
|
|
tcase_add_test(tc, eolian_decl);
|
2015-06-03 04:06:36 -07:00
|
|
|
tcase_add_test(tc, eolian_docs);
|
2017-04-07 09:54:55 -07:00
|
|
|
tcase_add_test(tc, eolian_function_types);
|
|
|
|
tcase_add_test(tc, eolian_function_as_arguments);
|
2014-05-01 05:05:33 -07:00
|
|
|
}
|