New python bindings for eolian

This are manually written ctype bindings for eolian, that means they
run on the standard python library (nothing to install) and can run
without any build step (in fact ctypes just open the so/dll file at runtime)

Next step will be (soon) a template based generator for eolian that will
be a lot of fun :)
This commit is contained in:
Davide Andreoli 2017-12-28 13:49:03 +01:00
parent b27ca559f6
commit 455f241463
3 changed files with 2491 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,757 @@
#!/usr/bin/env python3
# encoding: utf-8
from ctypes import CDLL, c_bool, c_int, c_uint, c_char_p, c_void_p
from ctypes.util import find_library
import os
# load the eolian so/dll already built in source tree
script_path = os.path.dirname(os.path.realpath(__file__))
root_path = os.path.abspath(os.path.join(script_path, '..', '..', '..'))
search_in = (
os.path.join(root_path, 'src', 'lib', 'eolian', '.libs'),
os.path.join(root_path, 'build', 'src', 'lib', 'eolian'),
)
search_names = ('libeolian.so', 'eolian.dll')
file_path = None
for lib_dir in search_in:
for name in search_names:
f = os.path.join(lib_dir, name)
if os.path.exists(f):
file_path = f
if not file_path:
raise RuntimeError('Error: cannot find a built eolian library in source tree')
lib = CDLL(file_path)
# EAPI int eolian_init(void);
lib.eolian_init.argtypes = []
lib.eolian_init.restype = c_int
# EAPI int eolian_shutdown(void);
lib.eolian_shutdown.argtypes = []
lib.eolian_shutdown.restype = c_int
# EAPI Eolian *eolian_new(void);
lib.eolian_new.argtypes = []
lib.eolian_new.restype = c_void_p
# EAPI void eolian_free(Eolian *state);
lib.eolian_free.argtypes = [c_void_p,]
lib.eolian_free.restype = None
# EAPI const Eolian_Unit *eolian_file_parse(Eolian *state, const char *filepath);
lib.eolian_file_parse.argtypes = [c_void_p, c_char_p]
lib.eolian_file_parse.restype = c_void_p
# EAPI Eina_Iterator *eolian_all_eo_file_paths_get(const Eolian *state);
lib.eolian_all_eo_file_paths_get.argtypes = [c_void_p,]
lib.eolian_all_eo_file_paths_get.restype = c_void_p
# EAPI Eina_Iterator *eolian_all_eot_file_paths_get(const Eolian *state);
lib.eolian_all_eot_file_paths_get.argtypes = [c_void_p,]
lib.eolian_all_eot_file_paths_get.restype = c_void_p
# EAPI Eina_Iterator *eolian_all_eo_files_get(const Eolian *state);
lib.eolian_all_eo_files_get.argtypes = [c_void_p,]
lib.eolian_all_eo_files_get.restype = c_void_p
# EAPI Eina_Iterator *eolian_all_eot_files_get(const Eolian *state);
lib.eolian_all_eot_files_get.argtypes = [c_void_p,]
lib.eolian_all_eot_files_get.restype = c_void_p
# EAPI Eina_Bool eolian_directory_scan(Eolian *state, const char *dir);
lib.eolian_directory_scan.argtypes = [c_void_p, c_char_p]
lib.eolian_directory_scan.restype = c_bool
# EAPI Eina_Bool eolian_system_directory_scan(Eolian *state);
lib.eolian_system_directory_scan.argtypes = [c_void_p,]
lib.eolian_system_directory_scan.restype = c_bool
# EAPI Eina_Bool eolian_all_eo_files_parse(Eolian *state);
lib.eolian_all_eo_files_parse.argtypes = [c_void_p,]
lib.eolian_all_eo_files_parse.restype = c_bool
# EAPI Eina_Bool eolian_all_eot_files_parse(Eolian *state);
lib.eolian_all_eot_files_parse.argtypes = [c_void_p,]
lib.eolian_all_eot_files_parse.restype = c_bool
# EAPI const Eolian_Class *eolian_class_get_by_name(const Eolian_Unit *unit, const char *class_name);
lib.eolian_class_get_by_name.argtypes = [c_void_p, c_char_p]
lib.eolian_class_get_by_name.restype = c_void_p
# EAPI const Eolian_Class *eolian_class_get_by_file(const Eolian_Unit *unit, const char *file_name);
lib.eolian_class_get_by_file.argtypes = [c_void_p, c_char_p]
lib.eolian_class_get_by_file.restype = c_void_p
# EAPI Eina_Stringshare *eolian_class_file_get(const Eolian_Class *klass);
lib.eolian_class_file_get.argtypes = [c_void_p,]
lib.eolian_class_file_get.restype = c_char_p
# EAPI Eina_Stringshare *eolian_class_full_name_get(const Eolian_Class *klass);
lib.eolian_class_full_name_get.argtypes = [c_void_p,]
lib.eolian_class_full_name_get.restype = c_char_p
# EAPI Eina_Stringshare *eolian_class_name_get(const Eolian_Class *klass);
lib.eolian_class_name_get.argtypes = [c_void_p,]
lib.eolian_class_name_get.restype = c_char_p
# EAPI Eina_Iterator *eolian_class_namespaces_get(const Eolian_Class *klass);
lib.eolian_class_namespaces_get.argtypes = [c_void_p,]
lib.eolian_class_namespaces_get.restype = c_void_p
# EAPI Eolian_Class_Type eolian_class_type_get(const Eolian_Class *klass);
lib.eolian_class_type_get.argtypes = [c_void_p,]
lib.eolian_class_type_get.restype = c_int
# EAPI Eina_Iterator *eolian_all_classes_get(const Eolian_Unit *unit);
lib.eolian_all_classes_get.argtypes = [c_void_p,]
lib.eolian_all_classes_get.restype = c_void_p
# EAPI const Eolian_Documentation *eolian_class_documentation_get(const Eolian_Class *klass);
lib.eolian_class_documentation_get.argtypes = [c_void_p,]
lib.eolian_class_documentation_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_class_legacy_prefix_get(const Eolian_Class *klass);
lib.eolian_class_legacy_prefix_get.argtypes = [c_void_p,]
lib.eolian_class_legacy_prefix_get.restype = c_char_p
# EAPI Eina_Stringshare *eolian_class_eo_prefix_get(const Eolian_Class *klass);
lib.eolian_class_eo_prefix_get.argtypes = [c_void_p,]
lib.eolian_class_eo_prefix_get.restype = c_char_p
# EAPI Eina_Stringshare* eolian_class_event_prefix_get(const Eolian_Class *klass);
lib.eolian_class_event_prefix_get.argtypes = [c_void_p,]
lib.eolian_class_event_prefix_get.restype = c_char_p
# EAPI Eina_Stringshare *eolian_class_data_type_get(const Eolian_Class *klass);
lib.eolian_class_data_type_get.argtypes = [c_void_p,]
lib.eolian_class_data_type_get.restype = c_char_p
# EAPI Eina_Iterator *eolian_class_inherits_get(const Eolian_Class *klass);
lib.eolian_class_inherits_get.argtypes = [c_void_p,]
lib.eolian_class_inherits_get.restype = c_void_p
# EAPI Eina_Iterator *eolian_class_functions_get(const Eolian_Class *klass, Eolian_Function_Type func_type);
lib.eolian_class_functions_get.argtypes = [c_void_p, c_int]
lib.eolian_class_functions_get.restype = c_void_p
# EAPI Eolian_Function_Type eolian_function_type_get(const Eolian_Function *function_id);
lib.eolian_function_type_get.argtypes = [c_void_p,]
lib.eolian_function_type_get.restype = c_int
# EAPI Eolian_Object_Scope eolian_function_scope_get(const Eolian_Function *function_id, Eolian_Function_Type ftype);
lib.eolian_function_scope_get.argtypes = [c_void_p, c_int]
lib.eolian_function_scope_get.restype = c_int
# EAPI Eina_Stringshare *eolian_function_name_get(const Eolian_Function *function_id);
lib.eolian_function_name_get.argtypes = [c_void_p,]
lib.eolian_function_name_get.restype = c_char_p
# EAPI Eina_Stringshare *eolian_function_full_c_name_get(const Eolian_Function *function_id, Eolian_Function_Type ftype, Eina_Bool use_legacy);
lib.eolian_function_full_c_name_get.argtypes = [c_void_p, c_int, c_bool]
lib.eolian_function_full_c_name_get.restype = c_void_p # Stringshare TO BE FREED
# EAPI const Eolian_Function *eolian_class_function_get_by_name(const Eolian_Class *klass, const char *func_name, Eolian_Function_Type f_type);
lib.eolian_class_function_get_by_name.argtypes = [c_void_p, c_char_p, c_int]
lib.eolian_class_function_get_by_name.restype = c_void_p
# EAPI Eina_Stringshare *eolian_function_legacy_get(const Eolian_Function *function_id, Eolian_Function_Type f_type);
lib.eolian_function_legacy_get.argtypes = [c_void_p, c_int]
lib.eolian_function_legacy_get.restype = c_char_p
# EAPI const Eolian_Implement *eolian_function_implement_get(const Eolian_Function *function_id);
lib.eolian_function_implement_get.argtypes = [c_void_p,]
lib.eolian_function_implement_get.restype = c_void_p
# EAPI Eina_Bool eolian_function_is_legacy_only(const Eolian_Function *function_id, Eolian_Function_Type ftype);
lib.eolian_function_is_legacy_only.argtypes = [c_void_p, c_int]
lib.eolian_function_is_legacy_only.restype = c_bool
# EAPI Eina_Bool eolian_function_is_class(const Eolian_Function *function_id);
lib.eolian_function_is_class.argtypes = [c_void_p,]
lib.eolian_function_is_class.restype = c_bool
# EAPI Eina_Bool eolian_function_is_beta(const Eolian_Function *function_id);
lib.eolian_function_is_beta.argtypes = [c_void_p,]
lib.eolian_function_is_beta.restype = c_bool
# EAPI Eina_Bool eolian_function_is_constructor(const Eolian_Function *function_id, const Eolian_Class *klass);
lib.eolian_function_is_constructor.argtypes = [c_void_p,c_void_p,]
lib.eolian_function_is_constructor.restype = c_bool
# TODO FIXME
# EAPI Eina_Bool eolian_function_is_function_pointer(const Eolian_Function *function_id);
# lib.eolian_function_is_function_pointer.argtypes = [c_void_p,]
# lib.eolian_function_is_function_pointer.restype = c_bool
# EAPI Eina_Iterator *eolian_function_parameters_get(const Eolian_Function *function_id);
lib.eolian_function_parameters_get.argtypes = [c_void_p,]
lib.eolian_function_parameters_get.restype = c_void_p
# EAPI Eina_Iterator *eolian_property_keys_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
lib.eolian_property_keys_get.argtypes = [c_void_p, c_int]
lib.eolian_property_keys_get.restype = c_void_p
# EAPI Eina_Iterator *eolian_property_values_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
lib.eolian_property_values_get.argtypes = [c_void_p, c_int]
lib.eolian_property_values_get.restype = c_void_p
# EAPI Eolian_Parameter_Dir eolian_parameter_direction_get(const Eolian_Function_Parameter *param);
lib.eolian_parameter_direction_get.argtypes = [c_void_p,]
lib.eolian_parameter_direction_get.restype = c_int
# EAPI const Eolian_Type *eolian_parameter_type_get(const Eolian_Function_Parameter *param);
lib.eolian_parameter_type_get.argtypes = [c_void_p,]
lib.eolian_parameter_type_get.restype = c_void_p
# EAPI const Eolian_Expression *eolian_parameter_default_value_get(const Eolian_Function_Parameter *param);
lib.eolian_parameter_default_value_get.argtypes = [c_void_p,]
lib.eolian_parameter_default_value_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_parameter_name_get(const Eolian_Function_Parameter *param);
lib.eolian_parameter_name_get.argtypes = [c_void_p,]
lib.eolian_parameter_name_get.restype = c_char_p
# EAPI const Eolian_Documentation *eolian_parameter_documentation_get(const Eolian_Function_Parameter *param);
lib.eolian_parameter_documentation_get.argtypes = [c_void_p,]
lib.eolian_parameter_documentation_get.restype = c_void_p
# EAPI Eina_Bool eolian_parameter_is_nonull(const Eolian_Function_Parameter *param_desc);
lib.eolian_parameter_is_nonull.argtypes = [c_void_p,]
lib.eolian_parameter_is_nonull.restype = c_bool
# EAPI Eina_Bool eolian_parameter_is_nullable(const Eolian_Function_Parameter *param_desc);
lib.eolian_parameter_is_nullable.argtypes = [c_void_p,]
lib.eolian_parameter_is_nullable.restype = c_bool
# EAPI Eina_Bool eolian_parameter_is_optional(const Eolian_Function_Parameter *param_desc);
lib.eolian_parameter_is_optional.argtypes = [c_void_p,]
lib.eolian_parameter_is_optional.restype = c_bool
# EAPI const Eolian_Type *eolian_function_return_type_get(const Eolian_Function *function_id, Eolian_Function_Type ftype);
lib.eolian_function_return_type_get.argtypes = [c_void_p, c_int]
lib.eolian_function_return_type_get.restype = c_void_p
# EAPI const Eolian_Expression * eolian_function_return_default_value_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
lib.eolian_function_return_default_value_get.argtypes = [c_void_p, c_int]
lib.eolian_function_return_default_value_get.restype = c_void_p
# EAPI const Eolian_Documentation *eolian_function_return_documentation_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
lib.eolian_function_return_documentation_get.argtypes = [c_void_p, c_int]
lib.eolian_function_return_documentation_get.restype = c_void_p
# EAPI Eina_Bool eolian_function_return_is_warn_unused(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
lib.eolian_function_return_is_warn_unused.argtypes = [c_void_p, c_int]
lib.eolian_function_return_is_warn_unused.restype = c_bool
# EAPI Eina_Bool eolian_function_object_is_const(const Eolian_Function *function_id);
lib.eolian_function_object_is_const.argtypes = [c_void_p,]
lib.eolian_function_object_is_const.restype = c_bool
# EAPI const Eolian_Class *eolian_function_class_get(const Eolian_Function *function_id);
lib.eolian_function_class_get.argtypes = [c_void_p,]
lib.eolian_function_class_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_implement_full_name_get(const Eolian_Implement *impl);
lib.eolian_implement_full_name_get.argtypes = [c_void_p,]
lib.eolian_implement_full_name_get.restype = c_char_p
# EAPI const Eolian_Class *eolian_implement_class_get(const Eolian_Implement *impl);
lib.eolian_implement_class_get.argtypes = [c_void_p,]
lib.eolian_implement_class_get.restype = c_void_p
# EAPI const Eolian_Function *eolian_implement_function_get(const Eolian_Implement *impl, Eolian_Function_Type *func_type);
lib.eolian_implement_function_get.argtypes = [c_void_p, c_int]
lib.eolian_implement_function_get.restype = c_void_p
# EAPI const Eolian_Documentation *eolian_implement_documentation_get(const Eolian_Implement *impl, Eolian_Function_Type f_type);
lib.eolian_implement_documentation_get.argtypes = [c_void_p, c_int]
lib.eolian_implement_documentation_get.restype = c_void_p
# EAPI Eina_Bool eolian_implement_is_auto(const Eolian_Implement *impl, Eolian_Function_Type f_type);
lib.eolian_implement_is_auto.argtypes = [c_void_p, c_int]
lib.eolian_implement_is_auto.restype = c_bool
# EAPI Eina_Bool eolian_implement_is_empty(const Eolian_Implement *impl, Eolian_Function_Type f_type);
lib.eolian_implement_is_empty.argtypes = [c_void_p, c_int]
lib.eolian_implement_is_empty.restype = c_bool
# EAPI Eina_Bool eolian_implement_is_pure_virtual(const Eolian_Implement *impl, Eolian_Function_Type f_type);
lib.eolian_implement_is_pure_virtual.argtypes = [c_void_p, c_int]
lib.eolian_implement_is_pure_virtual.restype = c_bool
# EAPI Eina_Bool eolian_implement_is_prop_get(const Eolian_Implement *impl);
lib.eolian_implement_is_prop_get.argtypes = [c_void_p,]
lib.eolian_implement_is_prop_get.restype = c_bool
# EAPI Eina_Bool eolian_implement_is_prop_set(const Eolian_Implement *impl);
lib.eolian_implement_is_prop_set.argtypes = [c_void_p,]
lib.eolian_implement_is_prop_set.restype = c_bool
# EAPI Eina_Iterator *eolian_class_implements_get(const Eolian_Class *klass);
lib.eolian_class_implements_get.argtypes = [c_void_p,]
lib.eolian_class_implements_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_constructor_full_name_get(const Eolian_Constructor *ctor);
lib.eolian_constructor_full_name_get.argtypes = [c_void_p,]
lib.eolian_constructor_full_name_get.restype = c_char_p
# EAPI const Eolian_Class *eolian_constructor_class_get(const Eolian_Constructor *ctor);
lib.eolian_constructor_class_get.argtypes = [c_void_p,]
lib.eolian_constructor_class_get.restype = c_void_p
# EAPI const Eolian_Function *eolian_constructor_function_get(const Eolian_Constructor *ctor);
lib.eolian_constructor_function_get.argtypes = [c_void_p,]
lib.eolian_constructor_function_get.restype = c_void_p
# EAPI Eina_Bool eolian_constructor_is_optional(const Eolian_Constructor *ctor);
lib.eolian_constructor_is_optional.argtypes = [c_void_p,]
lib.eolian_constructor_is_optional.restype = c_bool
# EAPI Eina_Iterator *eolian_class_constructors_get(const Eolian_Class *klass);
lib.eolian_class_constructors_get.argtypes = [c_void_p,]
lib.eolian_class_constructors_get.restype = c_void_p
# EAPI Eina_Iterator *eolian_class_events_get(const Eolian_Class *klass);
lib.eolian_class_events_get.argtypes = [c_void_p,]
lib.eolian_class_events_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_event_name_get(const Eolian_Event *event);
lib.eolian_event_name_get.argtypes = [c_void_p,]
lib.eolian_event_name_get.restype = c_char_p
# EAPI const Eolian_Type *eolian_event_type_get(const Eolian_Event *event);
lib.eolian_event_type_get.argtypes = [c_void_p,]
lib.eolian_event_type_get.restype = c_void_p
# EAPI const Eolian_Documentation *eolian_event_documentation_get(const Eolian_Event *event);
lib.eolian_event_documentation_get.argtypes = [c_void_p,]
lib.eolian_event_documentation_get.restype = c_void_p
# EAPI Eolian_Object_Scope eolian_event_scope_get(const Eolian_Event *event);
lib.eolian_event_scope_get.argtypes = [c_void_p,]
lib.eolian_event_scope_get.restype = c_int
# EAPI Eina_Bool eolian_event_is_beta(const Eolian_Event *event);
lib.eolian_event_is_beta.argtypes = [c_void_p,]
lib.eolian_event_is_beta.restype = c_bool
# EAPI Eina_Bool eolian_event_is_hot(const Eolian_Event *event);
lib.eolian_event_is_hot.argtypes = [c_void_p,]
lib.eolian_event_is_hot.restype = c_bool
# EAPI Eina_Bool eolian_event_is_restart(const Eolian_Event *event);
lib.eolian_event_is_restart.argtypes = [c_void_p,]
lib.eolian_event_is_restart.restype = c_bool
# EAPI Eina_Iterator *eolian_class_parts_get(const Eolian_Class *klass);
lib.eolian_class_parts_get.argtypes = [c_void_p,]
lib.eolian_class_parts_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_part_name_get(const Eolian_Part *part);
lib.eolian_part_name_get.argtypes = [c_void_p,]
lib.eolian_part_name_get.restype = c_char_p
# EAPI const Eolian_Class *eolian_part_class_get(const Eolian_Part *part);
lib.eolian_part_class_get.argtypes = [c_void_p,]
lib.eolian_part_class_get.restype = c_void_p
# EAPI const Eolian_Documentation *eolian_part_documentation_get(const Eolian_Part *part);
lib.eolian_part_documentation_get.argtypes = [c_void_p,]
lib.eolian_part_documentation_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_event_c_name_get(const Eolian_Event *event);
lib.eolian_event_c_name_get.argtypes = [c_void_p,]
lib.eolian_event_c_name_get.restype = c_void_p # Stringshare TO BE FREED
# EAPI const Eolian_Event *eolian_class_event_get_by_name(const Eolian_Class *klass, const char *event_name);
lib.eolian_class_event_get_by_name.argtypes = [c_void_p, c_char_p]
lib.eolian_class_event_get_by_name.restype = c_void_p
# EAPI Eina_Bool eolian_class_ctor_enable_get(const Eolian_Class *klass);
lib.eolian_class_ctor_enable_get.argtypes = [c_void_p,]
lib.eolian_class_ctor_enable_get.restype = c_bool
# EAPI Eina_Bool eolian_class_dtor_enable_get(const Eolian_Class *klass);
lib.eolian_class_dtor_enable_get.argtypes = [c_void_p,]
lib.eolian_class_dtor_enable_get.restype = c_bool
# EAPI Eina_Stringshare *eolian_class_c_get_function_name_get(const Eolian_Class *klass);
lib.eolian_class_c_get_function_name_get.argtypes = [c_void_p,]
lib.eolian_class_c_get_function_name_get.restype = c_void_p # Stringshare TO BE FREED
# EAPI Eina_Stringshare *eolian_class_c_name_get(const Eolian_Class *klass);
lib.eolian_class_c_name_get.argtypes = [c_void_p,]
lib.eolian_class_c_name_get.restype = c_void_p # Stringshare TO BE FREED
# EAPI Eina_Stringshare *eolian_class_c_data_type_get(const Eolian_Class *klass);
lib.eolian_class_c_data_type_get.argtypes = [c_void_p,]
lib.eolian_class_c_data_type_get.restype = c_void_p # Stringshare TO BE FREED
# EAPI const Eolian_Typedecl *eolian_typedecl_alias_get_by_name(const Eolian_Unit *unit, const char *name);
lib.eolian_typedecl_alias_get_by_name.argtypes = [c_void_p, c_char_p]
lib.eolian_typedecl_alias_get_by_name.restype = c_void_p
# EAPI const Eolian_Typedecl *eolian_typedecl_struct_get_by_name(const Eolian_Unit *unit, const char *name);
lib.eolian_typedecl_struct_get_by_name.argtypes = [c_void_p, c_char_p]
lib.eolian_typedecl_struct_get_by_name.restype = c_void_p
# EAPI const Eolian_Typedecl *eolian_typedecl_enum_get_by_name(const Eolian_Unit *unit, const char *name);
lib.eolian_typedecl_enum_get_by_name.argtypes = [c_void_p, c_char_p]
lib.eolian_typedecl_enum_get_by_name.restype = c_void_p
# EAPI Eina_Iterator *eolian_typedecl_aliases_get_by_file(const Eolian_Unit *unit, const char *fname);
lib.eolian_typedecl_aliases_get_by_file.argtypes = [c_void_p, c_char_p]
lib.eolian_typedecl_aliases_get_by_file.restype = c_void_p
# EAPI Eina_Iterator *eolian_typedecl_structs_get_by_file(const Eolian_Unit *unit, const char *fname);
lib.eolian_typedecl_structs_get_by_file.argtypes = [c_void_p, c_char_p]
lib.eolian_typedecl_structs_get_by_file.restype = c_void_p
# EAPI Eina_Iterator *eolian_typedecl_enums_get_by_file(const Eolian_Unit *unit, const char *fname);
lib.eolian_typedecl_enums_get_by_file.argtypes = [c_void_p, c_char_p]
lib.eolian_typedecl_enums_get_by_file.restype = c_void_p
# EAPI Eina_Iterator *eolian_typedecl_all_aliases_get(const Eolian_Unit *unit);
lib.eolian_typedecl_all_aliases_get.argtypes = [c_void_p,]
lib.eolian_typedecl_all_aliases_get.restype = c_void_p
# EAPI Eina_Iterator *eolian_typedecl_all_structs_get(const Eolian_Unit *unit);
lib.eolian_typedecl_all_structs_get.argtypes = [c_void_p,]
lib.eolian_typedecl_all_structs_get.restype = c_void_p
# EAPI Eina_Iterator *eolian_typedecl_all_enums_get(const Eolian_Unit *unit);
lib.eolian_typedecl_all_enums_get.argtypes = [c_void_p,]
lib.eolian_typedecl_all_enums_get.restype = c_void_p
# EAPI Eolian_Typedecl_Type eolian_typedecl_type_get(const Eolian_Typedecl *tp);
lib.eolian_typedecl_type_get.argtypes = [c_void_p,]
lib.eolian_typedecl_type_get.restype = c_int
# EAPI Eina_Iterator *eolian_typedecl_struct_fields_get(const Eolian_Typedecl *tp);
lib.eolian_typedecl_struct_fields_get.argtypes = [c_void_p,]
lib.eolian_typedecl_struct_fields_get.restype = c_void_p
# EAPI const Eolian_Struct_Type_Field *eolian_typedecl_struct_field_get(const Eolian_Typedecl *tp, const char *field);
lib.eolian_typedecl_struct_field_get.argtypes = [c_void_p, c_char_p]
lib.eolian_typedecl_struct_field_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_typedecl_struct_field_name_get(const Eolian_Struct_Type_Field *fl);
lib.eolian_typedecl_struct_field_name_get.argtypes = [c_void_p,]
lib.eolian_typedecl_struct_field_name_get.restype = c_char_p
# EAPI const Eolian_Documentation *eolian_typedecl_struct_field_documentation_get(const Eolian_Struct_Type_Field *fl);
lib.eolian_typedecl_struct_field_documentation_get.argtypes = [c_void_p,]
lib.eolian_typedecl_struct_field_documentation_get.restype = c_void_p
# EAPI const Eolian_Type *eolian_typedecl_struct_field_type_get(const Eolian_Struct_Type_Field *fl);
lib.eolian_typedecl_struct_field_type_get.argtypes = [c_void_p,]
lib.eolian_typedecl_struct_field_type_get.restype = c_void_p
# EAPI Eina_Iterator *eolian_typedecl_enum_fields_get(const Eolian_Typedecl *tp);
lib.eolian_typedecl_enum_fields_get.argtypes = [c_void_p,]
lib.eolian_typedecl_enum_fields_get.restype = c_void_p
# EAPI const Eolian_Enum_Type_Field *eolian_typedecl_enum_field_get(const Eolian_Typedecl *tp, const char *field);
lib.eolian_typedecl_enum_field_get.argtypes = [c_void_p, c_char_p]
lib.eolian_typedecl_enum_field_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_typedecl_enum_field_name_get(const Eolian_Enum_Type_Field *fl);
lib.eolian_typedecl_enum_field_name_get.argtypes = [c_void_p,]
lib.eolian_typedecl_enum_field_name_get.restype = c_char_p
# EAPI Eina_Stringshare *eolian_typedecl_enum_field_c_name_get(const Eolian_Enum_Type_Field *fl);
lib.eolian_typedecl_enum_field_c_name_get.argtypes = [c_void_p,]
lib.eolian_typedecl_enum_field_c_name_get.restype = c_void_p # Stringshare TO BE FREED
# EAPI const Eolian_Documentation *eolian_typedecl_enum_field_documentation_get(const Eolian_Enum_Type_Field *fl);
lib.eolian_typedecl_enum_field_documentation_get.argtypes = [c_void_p,]
lib.eolian_typedecl_enum_field_documentation_get.restype = c_void_p
# EAPI const Eolian_Expression *eolian_typedecl_enum_field_value_get(const Eolian_Enum_Type_Field *fl, Eina_Bool force);
lib.eolian_typedecl_enum_field_value_get.argtypes = [c_void_p, c_bool]
lib.eolian_typedecl_enum_field_value_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_typedecl_enum_legacy_prefix_get(const Eolian_Typedecl *tp);
lib.eolian_typedecl_enum_legacy_prefix_get.argtypes = [c_void_p,]
lib.eolian_typedecl_enum_legacy_prefix_get.restype = c_char_p
# EAPI const Eolian_Documentation *eolian_typedecl_documentation_get(const Eolian_Typedecl *tp);
lib.eolian_typedecl_documentation_get.argtypes = [c_void_p,]
lib.eolian_typedecl_documentation_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_typedecl_file_get(const Eolian_Typedecl *tp);
lib.eolian_typedecl_file_get.argtypes = [c_void_p,]
lib.eolian_typedecl_file_get.restype = c_char_p
# EAPI const Eolian_Type *eolian_typedecl_base_type_get(const Eolian_Typedecl *tp);
lib.eolian_typedecl_base_type_get.argtypes = [c_void_p,]
lib.eolian_typedecl_base_type_get.restype = c_void_p
# TODO FIXME STRANGE API (need Eolian_Unit*)
# EAPI const Eolian_Type *eolian_typedecl_aliased_base_get(const Eolian_Unit *unit, const Eolian_Typedecl *tp);
# lib.eolian_typedecl_aliased_base_get.argtypes = [c_void_p, c_void_p,]
# lib.eolian_typedecl_aliased_base_get.restype = c_void_p
# EAPI Eina_Bool eolian_typedecl_is_extern(const Eolian_Typedecl *tp);
lib.eolian_typedecl_is_extern.argtypes = [c_void_p,]
lib.eolian_typedecl_is_extern.restype = c_bool
# TODO FIXME STRANGE API (need Eolian_Unit*)
# EAPI Eina_Stringshare *eolian_typedecl_c_type_get(const Eolian_Unit *unit, const Eolian_Typedecl *tp);
# lib.eolian_typedecl_c_type_get.argtypes = [c_void_p,]
# lib.eolian_typedecl_c_type_get.restype = None
# EAPI Eina_Stringshare *eolian_typedecl_name_get(const Eolian_Typedecl *tp);
lib.eolian_typedecl_name_get.argtypes = [c_void_p,]
lib.eolian_typedecl_name_get.restype = c_char_p
# EAPI Eina_Stringshare *eolian_typedecl_full_name_get(const Eolian_Typedecl *tp);
lib.eolian_typedecl_full_name_get.argtypes = [c_void_p,]
lib.eolian_typedecl_full_name_get.restype = c_char_p
# EAPI Eina_Iterator *eolian_typedecl_namespaces_get(const Eolian_Typedecl *tp);
lib.eolian_typedecl_namespaces_get.argtypes = [c_void_p,]
lib.eolian_typedecl_namespaces_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_typedecl_free_func_get(const Eolian_Typedecl *tp);
lib.eolian_typedecl_free_func_get.argtypes = [c_void_p,]
lib.eolian_typedecl_free_func_get.restype = c_char_p
# EAPI const Eolian_Function *eolian_typedecl_function_pointer_get(const Eolian_Typedecl *tp);
lib.eolian_typedecl_function_pointer_get.argtypes = [c_void_p,]
lib.eolian_typedecl_function_pointer_get.restype = c_void_p
# EAPI Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp);
lib.eolian_type_type_get.argtypes = [c_void_p,]
lib.eolian_type_type_get.restype = c_int
# EAPI Eolian_Type_Builtin_Type eolian_type_builtin_type_get(const Eolian_Type *tp);
lib.eolian_type_builtin_type_get.argtypes = [c_void_p,]
lib.eolian_type_builtin_type_get.restype = c_int
# EAPI Eina_Stringshare *eolian_type_file_get(const Eolian_Type *tp);
lib.eolian_type_file_get.argtypes = [c_void_p,]
lib.eolian_type_file_get.restype = c_char_p
# EAPI const Eolian_Type *eolian_type_base_type_get(const Eolian_Type *tp);
lib.eolian_type_base_type_get.argtypes = [c_void_p,]
lib.eolian_type_base_type_get.restype = c_void_p
# EAPI const Eolian_Type *eolian_type_next_type_get(const Eolian_Type *tp);
lib.eolian_type_next_type_get.argtypes = [c_void_p,]
lib.eolian_type_next_type_get.restype = c_void_p
# TODO FIXME STRANGE API (need Eolian_Unit*)
# EAPI const Eolian_Typedecl *eolian_type_typedecl_get(const Eolian_Unit *unit, const Eolian_Type *tp);
# lib.eolian_type_typedecl_get.argtypes = [c_void_p,]
# lib.eolian_type_typedecl_get.restype = c_void_p
# TODO FIXME STRANGE API (need Eolian_Unit*)
# EAPI const Eolian_Type *eolian_type_aliased_base_get(const Eolian_Unit *unit, const Eolian_Type *tp);
# lib.eolian_type_aliased_base_get.argtypes = [c_void_p,]
# lib.eolian_type_aliased_base_get.restype = c_void_p
# TODO FIXME STRANGE API (need Eolian_Unit*)
# EAPI const Eolian_Class *eolian_type_class_get(const Eolian_Unit *unit, const Eolian_Type *tp);
# lib.eolian_type_class_get.argtypes = [c_void_p,]
# lib.eolian_type_class_get.restype = c_void_p
# EAPI Eina_Bool eolian_type_is_owned(const Eolian_Type *tp);
lib.eolian_type_is_owned.argtypes = [c_void_p,]
lib.eolian_type_is_owned.restype = c_bool
# EAPI Eina_Bool eolian_type_is_const(const Eolian_Type *tp);
lib.eolian_type_is_const.argtypes = [c_void_p,]
lib.eolian_type_is_const.restype = c_bool
# EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
lib.eolian_type_is_ptr.argtypes = [c_void_p,]
lib.eolian_type_is_ptr.restype = c_bool
# TODO FIXME STRANGE API (need Eolian_Unit*)
# EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Unit *unit, const Eolian_Type *tp, Eolian_C_Type_Type ctype);
# lib.eolian_type_c_type_get.argtypes = [c_void_p,]
# lib.eolian_type_c_type_get.restype = c_void_p # Stringshare TO BE FREED
# EAPI Eina_Stringshare *eolian_type_name_get(const Eolian_Type *tp);
lib.eolian_type_name_get.argtypes = [c_void_p,]
lib.eolian_type_name_get.restype = c_char_p
# EAPI Eina_Stringshare *eolian_type_full_name_get(const Eolian_Type *tp);
lib.eolian_type_full_name_get.argtypes = [c_void_p,]
lib.eolian_type_full_name_get.restype = c_char_p
# EAPI Eina_Iterator *eolian_type_namespaces_get(const Eolian_Type *tp);
lib.eolian_type_namespaces_get.argtypes = [c_void_p,]
lib.eolian_type_namespaces_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_type_free_func_get(const Eolian_Type *tp);
lib.eolian_type_free_func_get.argtypes = [c_void_p,]
lib.eolian_type_free_func_get.restype = c_char_p
# EAPI Eina_Stringshare *eolian_expression_serialize(const Eolian_Expression *expr);
lib.eolian_expression_serialize.argtypes = [c_void_p,]
lib.eolian_expression_serialize.restype = c_void_p # Stringshare TO BE FREED
# EAPI Eolian_Expression_Type eolian_expression_type_get(const Eolian_Expression *expr);
lib.eolian_expression_type_get.argtypes = [c_void_p,]
lib.eolian_expression_type_get.restype = c_int
# EAPI Eolian_Binary_Operator eolian_expression_binary_operator_get(const Eolian_Expression *expr);
lib.eolian_expression_binary_operator_get.argtypes = [c_void_p,]
lib.eolian_expression_binary_operator_get.restype = c_int
# EAPI const Eolian_Expression *eolian_expression_binary_lhs_get(const Eolian_Expression *expr);
lib.eolian_expression_binary_lhs_get.argtypes = [c_void_p,]
lib.eolian_expression_binary_lhs_get.restype = c_void_p
# EAPI const Eolian_Expression *eolian_expression_binary_rhs_get(const Eolian_Expression *expr);
lib.eolian_expression_binary_rhs_get.argtypes = [c_void_p,]
lib.eolian_expression_binary_rhs_get.restype = c_void_p
# EAPI Eolian_Unary_Operator eolian_expression_unary_operator_get(const Eolian_Expression *expr);
lib.eolian_expression_unary_operator_get.argtypes = [c_void_p,]
lib.eolian_expression_unary_operator_get.restype = c_int
# EAPI const Eolian_Expression *eolian_expression_unary_expression_get(const Eolian_Expression *expr);
lib.eolian_expression_unary_expression_get.argtypes = [c_void_p,]
lib.eolian_expression_unary_expression_get.restype = c_void_p
# EAPI const Eolian_Variable *eolian_variable_global_get_by_name(const Eolian_Unit *unit, const char *name);
lib.eolian_variable_global_get_by_name.argtypes = [c_void_p, c_char_p]
lib.eolian_variable_global_get_by_name.restype = c_void_p
# EAPI const Eolian_Variable *eolian_variable_constant_get_by_name(const Eolian_Unit *unit, const char *name);
lib.eolian_variable_constant_get_by_name.argtypes = [c_void_p, c_char_p]
lib.eolian_variable_constant_get_by_name.restype = c_void_p
# EAPI Eina_Iterator *eolian_variable_globals_get_by_file(const Eolian_Unit *unit, const char *fname);
lib.eolian_variable_globals_get_by_file.argtypes = [c_void_p, c_char_p]
lib.eolian_variable_globals_get_by_file.restype = c_void_p
# EAPI Eina_Iterator *eolian_variable_constants_get_by_file(const Eolian_Unit *unit, const char *fname);
lib.eolian_variable_constants_get_by_file.argtypes = [c_void_p, c_char_p]
lib.eolian_variable_constants_get_by_file.restype = c_void_p
# EAPI Eina_Iterator *eolian_variable_all_constants_get(const Eolian_Unit *unit);
lib.eolian_variable_all_constants_get.argtypes = [c_void_p,]
lib.eolian_variable_all_constants_get.restype = c_void_p
# EAPI Eina_Iterator *eolian_variable_all_globals_get(const Eolian_Unit *unit);
lib.eolian_variable_all_globals_get.argtypes = [c_void_p,]
lib.eolian_variable_all_globals_get.restype = c_void_p
# EAPI Eolian_Variable_Type eolian_variable_type_get(const Eolian_Variable *var);
lib.eolian_variable_type_get.argtypes = [c_void_p,]
lib.eolian_variable_type_get.restype = c_int
# EAPI const Eolian_Documentation *eolian_variable_documentation_get(const Eolian_Variable *var);
lib.eolian_variable_documentation_get.argtypes = [c_void_p,]
lib.eolian_variable_documentation_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_variable_file_get(const Eolian_Variable *var);
lib.eolian_variable_file_get.argtypes = [c_void_p,]
lib.eolian_variable_file_get.restype = c_char_p
# EAPI const Eolian_Type *eolian_variable_base_type_get(const Eolian_Variable *var);
lib.eolian_variable_base_type_get.argtypes = [c_void_p,]
lib.eolian_variable_base_type_get.restype = c_void_p
# EAPI const Eolian_Expression *eolian_variable_value_get(const Eolian_Variable *var);
lib.eolian_variable_value_get.argtypes = [c_void_p,]
lib.eolian_variable_value_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_variable_name_get(const Eolian_Variable *var);
lib.eolian_variable_name_get.argtypes = [c_void_p,]
lib.eolian_variable_name_get.restype = c_char_p
# EAPI Eina_Stringshare *eolian_variable_full_name_get(const Eolian_Variable *var);
lib.eolian_variable_full_name_get.argtypes = [c_void_p,]
lib.eolian_variable_full_name_get.restype = c_char_p
# EAPI Eina_Iterator *eolian_variable_namespaces_get(const Eolian_Variable *var);
lib.eolian_variable_namespaces_get.argtypes = [c_void_p,]
lib.eolian_variable_namespaces_get.restype = c_void_p
# EAPI Eina_Bool eolian_variable_is_extern(const Eolian_Variable *var);
lib.eolian_variable_is_extern.argtypes = [c_void_p,]
lib.eolian_variable_is_extern.restype = c_bool
# EAPI const Eolian_Declaration *eolian_declaration_get_by_name(const Eolian_Unit *unit, const char *name);
lib.eolian_declaration_get_by_name.argtypes = [c_void_p, c_char_p]
lib.eolian_declaration_get_by_name.restype = c_void_p
# EAPI Eina_Iterator *eolian_declarations_get_by_file(const Eolian *state, const char *fname);
lib.eolian_declarations_get_by_file.argtypes = [c_void_p, c_char_p]
lib.eolian_declarations_get_by_file.restype = c_void_p
# EAPI Eina_Iterator *eolian_all_declarations_get(const Eolian_Unit *unit);
lib.eolian_all_declarations_get.argtypes = [c_void_p,]
lib.eolian_all_declarations_get.restype = c_void_p
# EAPI Eolian_Declaration_Type eolian_declaration_type_get(const Eolian_Declaration *decl);
lib.eolian_declaration_type_get.argtypes = [c_void_p,]
lib.eolian_declaration_type_get.restype = c_int
# EAPI Eina_Stringshare *eolian_declaration_name_get(const Eolian_Declaration *decl);
lib.eolian_declaration_name_get.argtypes = [c_void_p,]
lib.eolian_declaration_name_get.restype = c_char_p
# EAPI const Eolian_Class *eolian_declaration_class_get(const Eolian_Declaration *decl);
lib.eolian_declaration_class_get.argtypes = [c_void_p,]
lib.eolian_declaration_class_get.restype = c_void_p
# EAPI const Eolian_Typedecl *eolian_declaration_data_type_get(const Eolian_Declaration *decl);
lib.eolian_declaration_data_type_get.argtypes = [c_void_p,]
lib.eolian_declaration_data_type_get.restype = c_void_p
# EAPI const Eolian_Variable *eolian_declaration_variable_get(const Eolian_Declaration *decl);
lib.eolian_declaration_variable_get.argtypes = [c_void_p,]
lib.eolian_declaration_variable_get.restype = c_void_p
# EAPI Eina_Stringshare *eolian_documentation_summary_get(const Eolian_Documentation *doc);
lib.eolian_documentation_summary_get.argtypes = [c_void_p,]
lib.eolian_documentation_summary_get.restype = c_char_p
# EAPI Eina_Stringshare *eolian_documentation_description_get(const Eolian_Documentation *doc);
lib.eolian_documentation_description_get.argtypes = [c_void_p,]
lib.eolian_documentation_description_get.restype = c_char_p
# EAPI Eina_Stringshare *eolian_documentation_since_get(const Eolian_Documentation *doc);
lib.eolian_documentation_since_get.argtypes = [c_void_p,]
lib.eolian_documentation_since_get.restype = c_char_p
# NOT IMPLEMENTED
# EAPI Eina_List *eolian_documentation_string_split(const char *doc);
# lib.eolian_documentation_string_split.argtypes = [c_char_p,]
# lib.eolian_documentation_string_split.restype = c_void_p
# # EAPI const char *eolian_documentation_tokenize(const char *doc, Eolian_Doc_Token *ret);
lib.eolian_documentation_tokenize.argtypes = [c_char_p, c_void_p]
lib.eolian_documentation_tokenize.restype = c_char_p
# EAPI void eolian_doc_token_init(Eolian_Doc_Token *tok);
lib.eolian_doc_token_init.argtypes = [c_void_p,]
lib.eolian_doc_token_init.restype = None
# EAPI Eolian_Doc_Token_Type eolian_doc_token_type_get(const Eolian_Doc_Token *tok);
lib.eolian_doc_token_type_get.argtypes = [c_void_p,]
lib.eolian_doc_token_type_get.restype = c_int
# EAPI char *eolian_doc_token_text_get(const Eolian_Doc_Token *tok);
lib.eolian_doc_token_text_get.argtypes = [c_void_p,]
lib.eolian_doc_token_text_get.restype = c_void_p # char* TO BE FREED
# EAPI Eolian_Doc_Ref_Type eolian_doc_token_ref_get(const Eolian_Unit *unit, const Eolian_Doc_Token *tok, const void **data, const void **data2);
# lib.eolian_doc_token_ref_get.argtypes = [c_void_p, c_void_p, ???, ???]
# lib.eolian_doc_token_ref_get.restype = c_int

View File

@ -0,0 +1,440 @@
#!/usr/bin/env python3
# encoding: utf-8
"""
Pyolian test suite.
Just run this file to execute the full suite.
A return value of 0 means all test passed successfully.
"""
import os
import unittest
import eolian
# Use .eo files from the source tree (not the installed ones)
script_path = os.path.dirname(os.path.realpath(__file__))
root_path = os.path.abspath(os.path.join(script_path, '..', '..', '..'))
SCAN_FOLDER = os.path.join(root_path, 'src', 'lib')
# the main Eolian unit state
state = None
class TestEolianUnit(unittest.TestCase):
def test_file_listing(self):
l = list(state.all_eo_file_paths)
self.assertGreater(len(l), 400)
self.assertTrue(l[0].endswith('.eo'))
l = list(state.all_eo_files)
self.assertGreater(len(l), 400)
self.assertTrue(l[0].endswith('.eo'))
l = list(state.all_eot_file_paths)
self.assertGreater(len(l), 10)
self.assertTrue(l[0].endswith('.eot'))
l = list(state.all_eot_files)
self.assertGreater(len(l), 10)
self.assertTrue(l[0].endswith('.eot'))
def test_enum_listing(self):
l = list(state.typedecl_enums_get_by_file('efl_ui_win.eo'))
self.assertGreater(len(l), 5)
self.assertIsInstance(l[0], eolian.Typedecl)
self.assertEqual(l[0].type, eolian.Eolian_Typedecl_Type.ENUM)
all_count = 0
for enum in state.typedecl_all_enums:
self.assertIsInstance(enum, eolian.Typedecl)
self.assertEqual(enum.type, eolian.Eolian_Typedecl_Type.ENUM)
all_count += 1
self.assertGreater(all_count, 50)
def test_struct_listing(self):
l = list(state.typedecl_structs_get_by_file('eina_types.eot'))
self.assertGreater(len(l), 10)
self.assertIsInstance(l[0], eolian.Typedecl)
self.assertIn(l[0].type, (
eolian.Eolian_Typedecl_Type.STRUCT,
eolian.Eolian_Typedecl_Type.STRUCT_OPAQUE))
all_count = 0
for struct in state.typedecl_all_structs:
self.assertIsInstance(struct, eolian.Typedecl)
self.assertIn(struct.type, (
eolian.Eolian_Typedecl_Type.STRUCT,
eolian.Eolian_Typedecl_Type.STRUCT_OPAQUE))
all_count += 1
self.assertGreater(all_count, 50)
def test_alias_listing(self):
l = list(state.typedecl_aliases_get_by_file('edje_types.eot'))
self.assertGreater(len(l), 5)
self.assertIsInstance(l[0], eolian.Typedecl)
all_count = 0
for alias in state.typedecl_all_aliases:
self.assertIsInstance(alias, eolian.Typedecl)
self.assertIn(alias.type, (
eolian.Eolian_Typedecl_Type.ALIAS,
eolian.Eolian_Typedecl_Type.FUNCTION_POINTER)) # TODO is this correct ??
all_count += 1
self.assertGreater(all_count, 10)
def test_variable_listing(self):
l = list(state.variable_all_constants)
self.assertGreater(len(l), 2)
self.assertIsInstance(l[0], eolian.Variable)
l = list(state.variable_all_globals)
self.assertGreater(len(l), 20)
self.assertIsInstance(l[0], eolian.Variable)
l = list(state.variable_constants_get_by_file('efl_gfx_stack.eo'))
self.assertGreater(len(l), 1)
self.assertIsInstance(l[0], eolian.Variable)
l = list(state.variable_globals_get_by_file('efl_net_http_types.eot'))
self.assertGreater(len(l), 10)
self.assertIsInstance(l[0], eolian.Variable)
def test_declaration_listing(self):
l = list(state.declarations_get_by_file('eina_types.eot'))
self.assertGreater(len(l), 10)
self.assertIsInstance(l[0], eolian.Declaration)
l = list(state.all_declarations)
self.assertGreater(len(l), 100)
self.assertIsInstance(l[0], eolian.Declaration)
def test_class_listing(self):
all_count = 0
for cls in state.all_classes:
self.assertIsInstance(cls, eolian.Class)
all_count += 1
self.assertGreater(all_count, 400)
class TestEolianClass(unittest.TestCase):
def test_class(self):
cls = state.class_get_by_file('efl_loop_timer.eo')
self.assertIsInstance(cls, eolian.Class)
cls = state.class_get_by_name('Efl.Loop.Timer')
self.assertIsInstance(cls, eolian.Class)
self.assertEqual(cls.name, 'Timer')
self.assertEqual(cls.full_name, 'Efl.Loop.Timer')
self.assertEqual(cls.file, 'efl_loop_timer.eo')
self.assertEqual(list(cls.namespaces), ['Efl', 'Loop'])
self.assertEqual(cls.type, eolian.Eolian_Class_Type.REGULAR)
self.assertIsInstance(cls.documentation, eolian.Documentation)
self.assertEqual(cls.legacy_prefix, 'ecore_timer')
self.assertIsNone(cls.eo_prefix) # TODO fin a class with a value
self.assertIsNone(cls.event_prefix) # TODO same as above
self.assertIsNone(cls.data_type) # TODO same as above
self.assertEqual(len(list(cls.inherits)), 1)
self.assertFalse(cls.ctor_enable)
self.assertFalse(cls.dtor_enable)
self.assertEqual(cls.c_get_function_name, 'efl_loop_timer_class_get')
self.assertEqual(cls.c_name, 'EFL_LOOP_TIMER_CLASS')
self.assertEqual(cls.c_data_type, 'Efl_Loop_Timer_Data')
self.assertEqual([f.name for f in cls.methods], ['reset','loop_reset','delay'])
self.assertEqual([f.name for f in cls.properties], ['interval','pending'])
self.assertGreater(len(list(cls.implements)), 5)
self.assertIsInstance(list(cls.implements)[0], eolian.Implement)
class TestEolianFunction(unittest.TestCase):
def test_function(self):
cls = state.class_get_by_name('Efl.Loop.Timer')
f = cls.function_get_by_name('delay')
self.assertIsInstance(f, eolian.Function)
self.assertEqual(f.name, 'delay')
self.assertEqual(f.type, eolian.Eolian_Function_Type.METHOD)
self.assertEqual(f.method_scope, eolian.Eolian_Object_Scope.PUBLIC)
self.assertEqual(f.getter_scope, eolian.Eolian_Object_Scope.UNKNOWN) # TODO correct?
self.assertEqual(f.setter_scope, eolian.Eolian_Object_Scope.UNKNOWN) # TODO correct?
self.assertEqual(f.full_c_method_name, 'efl_loop_timer_delay')
self.assertEqual(f.full_c_getter_name, 'efl_loop_timer_delay_get')
self.assertEqual(f.full_c_setter_name, 'efl_loop_timer_delay_set')
self.assertEqual(f.full_c_method_name_legacy, 'ecore_timer_delay')
self.assertEqual(f.full_c_getter_name_legacy, 'ecore_timer_delay_get')
self.assertEqual(f.full_c_setter_name_legacy, 'ecore_timer_delay_set')
self.assertIsNone(f.method_return_type) # TODO correct ?
self.assertIsNone(f.setter_return_type) # TODO correct ?
self.assertIsNone(f.getter_return_type) # TODO correct ?
self.assertFalse(f.is_legacy_only(eolian.Eolian_Function_Type.PROP_GET))
self.assertFalse(f.is_class)
self.assertFalse(f.is_beta)
self.assertFalse(f.is_constructor(cls))
# # #assert f.is_function_pointer == False # TODO broken somehow
self.assertEqual(len(list(f.getter_values)), 1)
self.assertEqual(len(list(f.getter_values)), 1)
self.assertEqual(len(list(f.parameters)), 1)
self.assertFalse(f.return_is_warn_unused(eolian.Eolian_Function_Type.METHOD))
self.assertFalse(f.object_is_const)
self.assertEqual(f.class_.full_name, 'Efl.Loop.Timer')
def test_function_parameter(self):
cls = state.class_get_by_name('Efl.Loop.Timer')
f = cls.function_get_by_name('delay')
p = list(f.parameters)[0]
self.assertEqual(p.direction, eolian.Eolian_Parameter_Dir.IN)
self.assertEqual(p.name, 'add')
self.assertIsNone(p.default_value)
self.assertFalse(p.is_nonull) # TODO is correct ?? 'add' can be null?
self.assertFalse(p.is_nullable)
self.assertFalse(p.is_optional)
self.assertEqual(p.type.name, 'double')
self.assertIsInstance(p.documentation, eolian.Documentation)
class TestEolianImplement(unittest.TestCase):
def test_implement(self):
cls = state.class_get_by_name('Efl.Loop.Timer')
f = cls.function_get_by_name('delay')
im = f.implement
self.assertIsInstance(im, eolian.Implement)
self.assertEqual(im.full_name, 'Efl.Loop.Timer.delay')
self.assertIsInstance(im.class_, eolian.Class)
self.assertIsInstance(im.function_get(), eolian.Function) # TODO is UNRESOLVED correct ?
self.assertIsInstance(im.documentation_get(), eolian.Documentation) # TODO is UNRESOLVED correct ?
self.assertFalse(im.is_auto())
self.assertFalse(im.is_empty())
self.assertFalse(im.is_pure_virtual())
self.assertFalse(im.is_prop_set)
self.assertFalse(im.is_prop_get)
class TestEolianEvent(unittest.TestCase):
def test_event(self):
cls = state.class_get_by_name('Efl.Loop.Timer')
self.assertEqual([e.name for e in cls.events], ['tick'])
ev = cls.event_get_by_name('tick')
self.assertIsInstance(ev, eolian.Event)
self.assertEqual(ev.name, 'tick')
self.assertEqual(ev.c_name, 'EFL_LOOP_TIMER_EVENT_TICK')
self.assertIsNone(ev.type) # TODO is this correct
self.assertIsInstance(ev.documentation, eolian.Documentation)
self.assertEqual(ev.scope, eolian.Eolian_Object_Scope.PUBLIC)
self.assertFalse(ev.is_beta)
self.assertFalse(ev.is_hot)
self.assertFalse(ev.is_restart)
class TestEolianPart(unittest.TestCase):
def test_part(self):
cls = state.class_get_by_name('Efl.Ui.Popup')
parts = list(cls.parts)
self.assertGreater(len(parts), 0)
part = parts[0]
self.assertEqual(part.name, 'backwall')
self.assertIsInstance(part.class_, eolian.Class)
self.assertEqual(part.class_.full_name, 'Efl.Ui.Popup.Part')
self.assertIsInstance(part.documentation, eolian.Documentation)
class TestEolianConstructor(unittest.TestCase):
def test_constructor(self):
cls = state.class_get_by_name('Efl.Ui.Win')
ctors = list(cls.constructors)
self.assertGreater(len(ctors), 0)
ctor = ctors[0]
self.assertIsInstance(ctor, eolian.Constructor)
self.assertEqual(ctor.full_name, 'Efl.Ui.Win.win_name')
self.assertFalse(ctor.is_optional)
self.assertIsInstance(ctor.class_, eolian.Class)
self.assertEqual(ctor.class_.full_name, 'Efl.Ui.Win')
self.assertIsInstance(ctor.function, eolian.Function)
self.assertEqual(ctor.function.name, 'win_name')
class TestEolianDocumentation(unittest.TestCase):
def test_documentation(self):
td = state.class_get_by_name('Efl.Net.Control')
doc = td.documentation
self.assertIsInstance(doc, eolian.Documentation)
self.assertIsInstance(doc.summary, str)
self.assertGreater(len(doc.summary), 10)
self.assertIsInstance(doc.description, str)
self.assertGreater(len(doc.description), 20)
self.assertEqual(doc.since, '1.19')
class TestEolianVariable(unittest.TestCase):
def test_variable_global(self):
var = state.variable_global_get_by_name('Efl.Net.Http.Error.BAD_CONTENT_ENCODING')
self.assertIsInstance(var, eolian.Variable)
self.assertEqual(var.full_name, 'Efl.Net.Http.Error.BAD_CONTENT_ENCODING')
self.assertEqual(var.name, 'BAD_CONTENT_ENCODING')
self.assertEqual(var.type, eolian.Eolian_Variable_Type.GLOBAL)
self.assertEqual(var.file, 'efl_net_http_types.eot')
self.assertFalse(var.is_extern)
self.assertEqual(list(var.namespaces), ['Efl','Net','Http','Error'])
self.assertIsInstance(var.documentation, eolian.Documentation)
self.assertIsInstance(var.base_type, eolian.Type)
self.assertIsNone(var.value) # TODO is None correct here? no value?
def test_variable_constant(self):
var = state.variable_constant_get_by_name('Efl.Gfx.Size.Hint.Fill')
self.assertIsInstance(var, eolian.Variable)
self.assertEqual(var.full_name, 'Efl.Gfx.Size.Hint.Fill')
self.assertEqual(var.name, 'Fill')
self.assertEqual(var.type, eolian.Eolian_Variable_Type.CONSTANT)
self.assertEqual(var.file, 'efl_gfx_size_hint.eo')
self.assertFalse(var.is_extern)
self.assertEqual(list(var.namespaces), ['Efl','Gfx','Size','Hint'])
self.assertIsInstance(var.documentation, eolian.Documentation)
self.assertIsInstance(var.base_type, eolian.Type)
self.assertIsInstance(var.value, eolian.Expression)
self.assertEqual(float(var.value.serialize), +1.0)
class TestEolianTypedecl(unittest.TestCase):
def test_typedecl_enum(self):
td = state.typedecl_enum_get_by_name('Efl.Net.Http.Version')
self.assertIsInstance(td, eolian.Typedecl)
self.assertEqual(td.name, 'Version')
self.assertEqual(td.full_name, 'Efl.Net.Http.Version')
self.assertEqual(td.file, 'efl_net_http_types.eot')
self.assertEqual(list(td.namespaces), ['Efl','Net','Http'])
self.assertIsInstance(td.documentation, eolian.Documentation)
self.assertIsNone(td.base_type) # TODO find a better test
self.assertIsNone(td.free_func) # TODO find a better test
self.assertIsNone(td.function_pointer) # TODO find a better test
self.assertFalse(td.is_extern)
self.assertEqual(len(list(td.enum_fields)), 3)
def test_typedecl_enum_field(self):
td = state.typedecl_enum_get_by_name('Efl.Net.Http.Version')
field = td.enum_field_get('v1_0')
self.assertIsInstance(field, eolian.Enum_Type_Field)
self.assertEqual(field.name, 'v1_0')
self.assertEqual(field.c_name, 'EFL_NET_HTTP_VERSION_V1_0')
self.assertIsInstance(field.documentation, eolian.Documentation)
self.assertIsInstance(field.value, eolian.Expression)
def test_typedecl_struct(self):
td = state.typedecl_struct_get_by_name('Efl.Gfx.Color32')
self.assertIsInstance(td, eolian.Typedecl)
self.assertEqual(td.name, 'Color32')
self.assertEqual(td.full_name, 'Efl.Gfx.Color32')
self.assertEqual(td.file, 'efl_canvas_filter_internal.eo')
self.assertEqual(list(td.namespaces), ['Efl','Gfx'])
self.assertIsInstance(td.documentation, eolian.Documentation)
self.assertIsNone(td.base_type) # TODO find a better test
self.assertIsNone(td.free_func) # TODO find a better test
self.assertIsNone(td.function_pointer) # TODO find a better test
self.assertFalse(td.is_extern)
self.assertEqual(len(list(td.struct_fields)), 4)
def test_typedecl_struct_field(self):
td = state.typedecl_struct_get_by_name('Efl.Gfx.Color32')
field = td.struct_field_get('b')
self.assertIsInstance(field, eolian.Struct_Type_Field)
self.assertEqual(field.name, 'b')
self.assertIsInstance(field.type, eolian.Type)
self.assertIsInstance(field.documentation, eolian.Documentation)
def test_typedecl_alias(self):
alias = state.typedecl_alias_get_by_name('Eina.Error')
self.assertIsInstance(alias, eolian.Typedecl)
self.assertEqual(alias.name, 'Error')
class TestEolianType(unittest.TestCase):
def test_type_regular(self):
cls = state.class_get_by_name('Efl.Loop.Timer')
func = cls.function_get_by_name('delay')
param = list(func.parameters)[0]
t = param.type
self.assertIsInstance(t, eolian.Type)
self.assertEqual(t.name, 'double')
self.assertEqual(t.full_name, 'double')
self.assertEqual(t.type, eolian.Eolian_Type_Type.REGULAR)
self.assertEqual(t.builtin_type, eolian.Eolian_Type_Builtin_Type.DOUBLE)
self.assertEqual(t.file, 'efl_loop_timer.eo')
self.assertIsNone(t.base_type) # TODO find a better test
self.assertIsNone(t.next_type) # TODO find a better test
self.assertFalse(t.is_owned)
self.assertFalse(t.is_const)
self.assertFalse(t.is_ptr)
# self.assertEqual(list(t.namespaces), []) # TODO find a better test
self.assertIsNone(t.free_func) # TODO find a better test
class TestEolianDeclaration(unittest.TestCase):
def test_declaration(self):
d = state.declaration_get_by_name('Eina.File')
self.assertIsInstance(d, eolian.Declaration)
self.assertEqual(d.name, 'Eina.File')
self.assertEqual(d.type, eolian.Eolian_Declaration_Type.STRUCT)
# self.assertIsNone(d.class_) # TODO find a better test
# self.assertIsNone(d.variable) # TODO find a better test
self.assertIsInstance(d.data_type, eolian.Typedecl)
self.assertEqual(d.data_type.full_name, 'Eina.File')
class TestEolianExpression(unittest.TestCase):
def test_expression_simple(self):
td = state.typedecl_enum_get_by_name('Efl.Net.Http.Version')
field = td.enum_field_get('v1_0')
exp = field.value
self.assertIsInstance(exp, eolian.Expression)
self.assertEqual(exp.type, eolian.Eolian_Expression_Type.INT)
self.assertEqual(exp.serialize, '100')
def test_expression_unary(self):
var = state.variable_constant_get_by_name('Efl.Gfx.Size.Hint.Fill')
exp = var.value
self.assertIsInstance(exp, eolian.Expression)
self.assertEqual(exp.type, eolian.Eolian_Expression_Type.UNARY)
self.assertEqual(float(exp.serialize), 1.0) # TODO is this a bug? isn't -1.0 ?
self.assertEqual(exp.unary_operator, eolian.Eolian_Unary_Operator.UNM)
unary = exp.unary_expression
self.assertIsInstance(unary, eolian.Expression)
self.assertEqual(unary.type, eolian.Eolian_Expression_Type.DOUBLE)
self.assertEqual(float(exp.serialize), 1.0)
# TODO test_expression_binary
# exp.binary_operator # TODO find a better test (only works for BINARY expr)
# exp.binary_lhs # TODO find a better test (only works for BINARY expr)
# exp.binary_rhs # TODO find a better test (only works for BINARY expr)
if __name__ == '__main__':
# create main eolian state
state = eolian.Eolian()
if not isinstance(state, eolian.Eolian):
raise(RuntimeError('Eolian, failed to create Eolian state'))
# eolian system scan (BROKEN)
# if not state.system_directory_scan():
# raise(RuntimeError('Eolian, failed to scan system directories'))
# eolian source tree scan
if not state.directory_scan(SCAN_FOLDER):
raise(RuntimeError('Eolian, failed to scan source directory'))
# Parse all known eo files
if not state.all_eot_files_parse():
raise(RuntimeError('Eolian, failed to parse all EOT files'))
if not state.all_eo_files_parse():
raise(RuntimeError('Eolian, failed to parse all EO files'))
# start the test suite
suite = unittest.main(verbosity=2, exit=False)
# cleanup (or it will segfault on gc, that happend after atexit)
del state
# exit 0 (success) or 1 (failure)
exit(0 if suite.result.wasSuccessful() else 1)