Initial python bindings for Eolian
This commit is contained in:
parent
a0ecc41572
commit
4e700fe0d3
|
@ -53,6 +53,7 @@ params = {
|
|||
"edje": ("include", "Edje", "edje"),
|
||||
"emotion": ("include", "Emotion", "emotion"),
|
||||
"elementary": ("efl/elementary", "Elementary", "elm"),
|
||||
"eolian": ("efl/eolian", "Eolian", "eolian")
|
||||
}
|
||||
|
||||
EFL_MIN_VERSION = "1.9.99"
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
from efl.eina cimport Eina_Inlist, Eina_Bool, Eina_List, Eina_Stringshare
|
||||
from enums cimport Eolian_Function_Type, Eolian_Parameter_Dir, \
|
||||
Eolian_Class_Type, Eolian_Function_Scope
|
||||
|
||||
cdef extern from "Eolian.h":
|
||||
#Class type used to extract information on classes
|
||||
ctypedef struct _Class_Desc
|
||||
ctypedef _Class_Desc* Eolian_Class
|
||||
|
||||
# Function Id used to extract information on class functions
|
||||
ctypedef struct _Function_Id
|
||||
ctypedef _Function_Id* Eolian_Function
|
||||
|
||||
# Parameter/return type.
|
||||
ctypedef Eina_Inlist* Eolian_Type
|
||||
|
||||
# Class function parameter information
|
||||
ctypedef struct _Parameter_Desc
|
||||
ctypedef _Parameter_Desc* Eolian_Function_Parameter
|
||||
|
||||
# Class implement information
|
||||
ctypedef struct _Implement_Desc
|
||||
ctypedef _Implement_Desc* Eolian_Implement
|
||||
|
||||
# Event information
|
||||
ctypedef struct _Event_Desc
|
||||
ctypedef _Event_Desc* Eolian_Event
|
||||
|
||||
#define EOLIAN_LEGACY "legacy"
|
||||
#define EOLIAN_LEGACY_GET "legacy_get"
|
||||
#define EOLIAN_LEGACY_SET "legacy_set"
|
||||
#define EOLIAN_COMMENT "comment"
|
||||
#define EOLIAN_COMMENT_SET "comment_set"
|
||||
#define EOLIAN_COMMENT_GET "comment_get"
|
||||
|
||||
|
||||
Eina_Bool eolian_eo_file_parse(const char *filename)
|
||||
int eolian_init()
|
||||
int eolian_shutdown()
|
||||
Eina_Bool eolian_directory_scan(const char *dir)
|
||||
Eina_Bool eolian_all_eo_files_parse()
|
||||
Eina_Bool eolian_show(const Eolian_Class klass)
|
||||
Eolian_Class eolian_class_find_by_name(const char *class_name)
|
||||
Eolian_Class eolian_class_find_by_file(const char *file_name)
|
||||
const char *eolian_class_file_get(const Eolian_Class klass)
|
||||
const char *eolian_class_full_name_get(const Eolian_Class klass)
|
||||
const char *eolian_class_name_get(const Eolian_Class klass)
|
||||
const Eina_List *eolian_class_namespaces_list_get(const Eolian_Class klass)
|
||||
Eolian_Class_Type eolian_class_type_get(const Eolian_Class klass)
|
||||
const Eina_List *eolian_class_names_list_get()
|
||||
const char *eolian_class_description_get(const Eolian_Class klass)
|
||||
const char *eolian_class_legacy_prefix_get(const Eolian_Class klass)
|
||||
const char* eolian_class_eo_prefix_get(const Eolian_Class klass)
|
||||
const char*eolian_class_data_type_get(const Eolian_Class klass)
|
||||
const Eina_List *eolian_class_inherits_list_get(const Eolian_Class klass)
|
||||
const Eina_List *eolian_class_functions_list_get(const Eolian_Class klass, Eolian_Function_Type func_type)
|
||||
Eolian_Function_Type eolian_function_type_get(Eolian_Function function_id)
|
||||
Eolian_Function_Scope eolian_function_scope_get(Eolian_Function function_id)
|
||||
const char *eolian_function_name_get(Eolian_Function function_id)
|
||||
Eolian_Function eolian_class_function_find_by_name(const Eolian_Class klass, const char *func_name, Eolian_Function_Type f_type)
|
||||
const char *eolian_function_data_get(Eolian_Function function_id, const char *key)
|
||||
Eina_Bool eolian_function_is_virtual_pure(Eolian_Function function_id, Eolian_Function_Type f_type)
|
||||
Eolian_Function_Parameter eolian_function_parameter_get(const Eolian_Function function_id, const char *param_name)
|
||||
const Eina_List *eolian_property_keys_list_get(Eolian_Function foo_id)
|
||||
const Eina_List *eolian_property_values_list_get(Eolian_Function foo_id)
|
||||
const Eina_List *eolian_parameters_list_get(Eolian_Function function_id)
|
||||
void eolian_parameter_information_get(const Eolian_Function_Parameter param_desc, Eolian_Parameter_Dir *param_dir, const char **type, const char **name, const char **description)
|
||||
Eolian_Type eolian_type_information_get(Eolian_Type etype, const char **type, Eina_Bool *own)
|
||||
Eina_Stringshare *eolian_parameter_type_get(const Eolian_Function_Parameter param)
|
||||
Eolian_Type eolian_parameter_types_list_get(const Eolian_Function_Parameter param)
|
||||
Eina_Stringshare *eolian_parameter_name_get(const Eolian_Function_Parameter param)
|
||||
Eina_Bool eolian_parameter_const_attribute_get(Eolian_Function_Parameter param_desc, Eina_Bool is_get)
|
||||
Eina_Bool eolian_parameter_is_nonull(Eolian_Function_Parameter param_desc)
|
||||
const char *eolian_function_return_type_get(Eolian_Function function_id, Eolian_Function_Type ftype)
|
||||
Eolian_Type eolian_function_return_types_list_get(Eolian_Function foo_id, Eolian_Function_Type ftype)
|
||||
const char *eolian_function_return_dflt_value_get(Eolian_Function foo_id, Eolian_Function_Type ftype)
|
||||
const char *eolian_function_return_comment_get(Eolian_Function foo_id, Eolian_Function_Type ftype)
|
||||
Eina_Bool eolian_function_return_is_warn_unused(Eolian_Function foo_id, Eolian_Function_Type ftype)
|
||||
Eina_Bool eolian_function_object_is_const(Eolian_Function function_id)
|
||||
Eina_Stringshare * eolian_implement_full_name_get(const Eolian_Implement impl)
|
||||
Eina_Bool eolian_implement_information_get(const Eolian_Implement impl, Eolian_Class *klass, Eolian_Function *function, Eolian_Function_Type *type)
|
||||
const Eina_List *eolian_class_implements_list_get(const Eolian_Class klass)
|
||||
const Eina_List *eolian_class_events_list_get(const Eolian_Class klass)
|
||||
Eina_Bool eolian_class_event_information_get(Eolian_Event event, const char **event_name, const char **event_type, const char **event_desc)
|
||||
Eina_Bool eolian_class_ctor_enable_get(const Eolian_Class klass)
|
||||
Eina_Bool eolian_class_dtor_enable_get(const Eolian_Class klass)
|
||||
Eolian_Type eolian_type_find_by_alias(const char *alias)
|
|
@ -0,0 +1,802 @@
|
|||
"""
|
||||
|
||||
Enumerations
|
||||
============
|
||||
|
||||
.. _Eolian_Function_Type:
|
||||
|
||||
Function Type
|
||||
-------------
|
||||
|
||||
.. data:: EOLIAN_UNRESOLVED
|
||||
.. data:: EOLIAN_PROPERTY
|
||||
.. data:: EOLIAN_PROP_SET
|
||||
.. data:: EOLIAN_PROP_GET
|
||||
.. data:: EOLIAN_METHOD
|
||||
.. data:: EOLIAN_CTOR
|
||||
|
||||
|
||||
.. _Eolian_Parameter_Dir:
|
||||
|
||||
Parameter Direction
|
||||
-------------------
|
||||
|
||||
.. data:: EOLIAN_IN_PARAM
|
||||
.. data:: EOLIAN_OUT_PARAM
|
||||
.. data:: EOLIAN_INOUT_PARAM
|
||||
|
||||
|
||||
.. _Eolian_Class_Type:
|
||||
|
||||
Class Type
|
||||
----------
|
||||
|
||||
.. data:: EOLIAN_CLASS_UNKNOWN_TYPE
|
||||
.. data:: EOLIAN_CLASS_REGULAR
|
||||
.. data:: EOLIAN_CLASS_ABSTRACT
|
||||
.. data:: EOLIAN_CLASS_MIXIN
|
||||
.. data:: EOLIAN_CLASS_INTERFACE
|
||||
|
||||
|
||||
.. _Eolian_Function_Scope:
|
||||
|
||||
Function Scope
|
||||
--------------
|
||||
|
||||
.. data:: EOLIAN_SCOPE_PUBLIC
|
||||
.. data:: EOLIAN_SCOPE_PROTECTED
|
||||
|
||||
"""
|
||||
|
||||
from libc.stdint cimport uintptr_t
|
||||
from cpython cimport PyUnicode_AsUTF8String
|
||||
from efl.utils.conversions cimport _ctouni, eina_list_strings_to_python_list
|
||||
cimport enums
|
||||
|
||||
|
||||
EOLIAN_UNRESOLVED = enums.EOLIAN_UNRESOLVED
|
||||
EOLIAN_PROPERTY = enums.EOLIAN_PROPERTY
|
||||
EOLIAN_PROP_SET = enums.EOLIAN_PROP_SET
|
||||
EOLIAN_PROP_GET = enums.EOLIAN_PROP_GET
|
||||
EOLIAN_METHOD = enums.EOLIAN_METHOD
|
||||
EOLIAN_CTOR = enums.EOLIAN_CTOR
|
||||
|
||||
EOLIAN_IN_PARAM = enums.EOLIAN_IN_PARAM
|
||||
EOLIAN_OUT_PARAM = enums.EOLIAN_OUT_PARAM
|
||||
EOLIAN_INOUT_PARAM = enums.EOLIAN_INOUT_PARAM
|
||||
|
||||
EOLIAN_CLASS_UNKNOWN_TYPE = enums.EOLIAN_CLASS_UNKNOWN_TYPE
|
||||
EOLIAN_CLASS_REGULAR = enums.EOLIAN_CLASS_REGULAR
|
||||
EOLIAN_CLASS_ABSTRACT = enums.EOLIAN_CLASS_ABSTRACT
|
||||
EOLIAN_CLASS_MIXIN = enums.EOLIAN_CLASS_MIXIN
|
||||
EOLIAN_CLASS_INTERFACE = enums.EOLIAN_CLASS_INTERFACE
|
||||
|
||||
EOLIAN_SCOPE_PUBLIC = enums.EOLIAN_SCOPE_PUBLIC
|
||||
EOLIAN_SCOPE_PROTECTED = enums.EOLIAN_SCOPE_PROTECTED
|
||||
|
||||
|
||||
cdef list eina_list_obj_to_python_list(const Eina_List *lst, object cls):
|
||||
cdef:
|
||||
list ret = list()
|
||||
while lst:
|
||||
o = eolian_obj_to_python_obj(<uintptr_t>lst.data, cls)
|
||||
ret.append(o)
|
||||
lst = lst.next
|
||||
return ret
|
||||
|
||||
|
||||
cdef object eolian_obj_to_python_obj(uintptr_t ptr, object cls):
|
||||
ret = cls.__new__(cls)
|
||||
ret._set_obj(ptr)
|
||||
return ret
|
||||
|
||||
|
||||
def eo_file_parse(filename):
|
||||
"""Parse a given .eo file and fill the database.
|
||||
|
||||
During parsing, the class described into the .eo file is created with
|
||||
all the information related to this class.
|
||||
|
||||
:param filename: Name of the file to parse.
|
||||
|
||||
"""
|
||||
if isinstance(filename, unicode): filename = PyUnicode_AsUTF8String(filename)
|
||||
return bool(eolian_eo_file_parse(filename))
|
||||
|
||||
def init():
|
||||
"""Init Eolian.
|
||||
|
||||
:rtype: int
|
||||
|
||||
"""
|
||||
return eolian_init()
|
||||
|
||||
def shutdown():
|
||||
"""Shutdown Eolian.
|
||||
|
||||
:rtype: int
|
||||
|
||||
"""
|
||||
return eolian_shutdown()
|
||||
|
||||
def directory_scan(directory):
|
||||
"""Scan the given directory and search for .eo files.
|
||||
|
||||
The found files are just open to extract the class name.
|
||||
|
||||
@param[in] dir the directory to scan
|
||||
@return EINA_TRUE on success, EINA_FALSE otherwise.
|
||||
|
||||
"""
|
||||
if isinstance(directory, unicode): directory = PyUnicode_AsUTF8String(directory)
|
||||
return bool(eolian_directory_scan(directory))
|
||||
|
||||
def all_eo_files_parse():
|
||||
"""Force parsing of all the files located in the directories
|
||||
given in eolian_directory_scan..
|
||||
|
||||
@return EINA_TRUE on success, EINA_FALSE otherwise.
|
||||
|
||||
@see eolian_directory_scan
|
||||
|
||||
"""
|
||||
return bool(eolian_all_eo_files_parse())
|
||||
|
||||
def show(Class klass):
|
||||
"""Show information about a given class.
|
||||
|
||||
If klass is NULL, this function will print information of
|
||||
all the classes stored into the database.
|
||||
|
||||
@param[in] klass the class to show
|
||||
|
||||
"""
|
||||
return bool(eolian_show(klass.klass))
|
||||
|
||||
def class_find_by_name(class_name):
|
||||
"""Finds a class by its name
|
||||
|
||||
@param[in] class_name name of the class to find.
|
||||
@return the class
|
||||
|
||||
"""
|
||||
if isinstance(class_name, unicode): class_name = PyUnicode_AsUTF8String(class_name)
|
||||
return eolian_obj_to_python_obj(
|
||||
<uintptr_t>eolian_class_find_by_name(class_name), Class
|
||||
)
|
||||
|
||||
def class_find_by_file(file_name):
|
||||
"""Finds a class by its location (.eo file)
|
||||
|
||||
@param[in] file_name filename where the class is stored.
|
||||
@return the class stored in the file
|
||||
|
||||
"""
|
||||
if isinstance(file_name, unicode): file_name = PyUnicode_AsUTF8String(file_name)
|
||||
return eolian_obj_to_python_obj(
|
||||
<uintptr_t>eolian_class_find_by_file(file_name), Class
|
||||
)
|
||||
|
||||
|
||||
cdef class Class(object):
|
||||
|
||||
cdef Eolian_Class klass
|
||||
|
||||
cdef _set_obj(self, uintptr_t obj):
|
||||
self.klass = <Eolian_Class>obj
|
||||
|
||||
property filename:
|
||||
"""Returns the name of the file containing the given class.
|
||||
|
||||
:type: string
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return _ctouni(eolian_class_file_get(self.klass))
|
||||
|
||||
property full_name:
|
||||
"""Returns the full name of the given class.
|
||||
|
||||
:type: string
|
||||
|
||||
The full name and the name of a class will be different if namespaces
|
||||
are used.
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return _ctouni(eolian_class_full_name_get(self.klass))
|
||||
|
||||
property name:
|
||||
"""Returns the name of the given class.
|
||||
|
||||
:type: string
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return _ctouni(eolian_class_name_get(self.klass))
|
||||
|
||||
property namespaces_list:
|
||||
"""Returns the namespaces list of the given class.
|
||||
|
||||
@param[in] class the class.
|
||||
@return the namespaces list of the class on success or NULL otherwise.
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return eina_list_strings_to_python_list(eolian_class_namespaces_list_get(self.klass))
|
||||
|
||||
property type:
|
||||
"""Returns the class type of the given class
|
||||
|
||||
@param[in] klass the class
|
||||
@return the class type
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return eolian_class_type_get(self.klass)
|
||||
|
||||
property description:
|
||||
"""Returns the description of a class.
|
||||
|
||||
:type: string
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return _ctouni(eolian_class_description_get(self.klass))
|
||||
|
||||
property legacy_prefix:
|
||||
"""Returns the legacy prefix of a class
|
||||
|
||||
:type: string
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return _ctouni(eolian_class_legacy_prefix_get(self.klass))
|
||||
|
||||
property eo_prefix:
|
||||
"""Returns the eo prefix of a class
|
||||
|
||||
:type: string
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return _ctouni(eolian_class_eo_prefix_get(self.klass))
|
||||
|
||||
property data_type:
|
||||
"""Returns the data type of a class
|
||||
|
||||
:type: string
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return _ctouni(eolian_class_data_type_get(self.klass))
|
||||
|
||||
property inherits_list:
|
||||
"""Returns the names list of the inherit classes of a class
|
||||
|
||||
@param[in] klass the class
|
||||
@return the list
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return eina_list_strings_to_python_list(eolian_class_inherits_list_get(self.klass))
|
||||
|
||||
def functions_list_get(self, Eolian_Function_Type func_type):
|
||||
"""Returns a list of functions of a class.
|
||||
|
||||
@param[in] klass the class
|
||||
@param[in] func_type type of the functions to insert into the list.
|
||||
@return the list of Eolian_Function
|
||||
|
||||
"""
|
||||
return eina_list_obj_to_python_list(
|
||||
eolian_class_functions_list_get(
|
||||
self.klass, func_type
|
||||
),
|
||||
Function
|
||||
)
|
||||
|
||||
property implements:
|
||||
"""Get the list of overriding functions defined in a class.
|
||||
|
||||
@param[in] klass the class.
|
||||
@return a list of Eolian_Implement handles
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return eina_list_obj_to_python_list(
|
||||
eolian_class_implements_list_get(self.klass), Implement
|
||||
)
|
||||
|
||||
property events:
|
||||
"""Get the list of events defined in a class.
|
||||
|
||||
@param[in] klass the class.
|
||||
@return a list of Eolian_Event handles
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return eina_list_obj_to_python_list(
|
||||
eolian_class_events_list_get(self.klass), Event
|
||||
)
|
||||
|
||||
property constructor_enabled:
|
||||
"""Indicates if the class constructor has to invoke
|
||||
a non-generated class constructor function.
|
||||
|
||||
@param[in] klass the class.
|
||||
@return EINA_TRUE if the invocation is needed, EINA_FALSE otherwise.
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return bool(eolian_class_ctor_enable_get(self.klass))
|
||||
|
||||
property destructor_enabled:
|
||||
"""Indicates if the class destructor has to invoke
|
||||
a non-generated class destructor function.
|
||||
|
||||
@param[in] klass the class.
|
||||
@return EINA_TRUE if the invocation is needed, EINA_FALSE otherwise.
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return bool(eolian_class_dtor_enable_get(self.klass))
|
||||
|
||||
def function_find_by_name(self, func_name, Eolian_Function_Type f_type):
|
||||
"""Find a function in a class by its name and type
|
||||
|
||||
@param[in] klass the class
|
||||
@param[in] func_name name of the function
|
||||
@param[in] f_type type of the function
|
||||
@return the function id if found, NULL otherwise.
|
||||
|
||||
"""
|
||||
if isinstance(func_name, unicode): func_name = PyUnicode_AsUTF8String(func_name)
|
||||
return eolian_obj_to_python_obj(
|
||||
<uintptr_t>eolian_class_function_find_by_name(
|
||||
self.klass, func_name, f_type
|
||||
),
|
||||
Function
|
||||
)
|
||||
|
||||
|
||||
def class_names_list_get():
|
||||
"""Returns the names list of all the classes stored into the database.
|
||||
|
||||
@return the list
|
||||
|
||||
Returns the list of class names of the database
|
||||
|
||||
"""
|
||||
return eina_list_strings_to_python_list(eolian_class_names_list_get())
|
||||
|
||||
|
||||
|
||||
cdef class Function(object):
|
||||
|
||||
cdef Eolian_Function function_id
|
||||
|
||||
cdef _set_obj(self, uintptr_t obj):
|
||||
self.function_id = <Eolian_Function>obj
|
||||
|
||||
property type:
|
||||
"""Returns the type of a function
|
||||
|
||||
@param[in] function_id Id of the function
|
||||
@return the function type
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return eolian_function_type_get(self.function_id)
|
||||
|
||||
property scope:
|
||||
"""Returns the scope of a function
|
||||
|
||||
@param[in] function_id Id of the function
|
||||
@return the function scope
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return eolian_function_scope_get(self.function_id)
|
||||
|
||||
property name:
|
||||
"""Returns the name of a function
|
||||
|
||||
@param[in] function_id Id of the function
|
||||
@return the function name
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return _ctouni(eolian_function_name_get(self.function_id))
|
||||
|
||||
def data_get(self, key):
|
||||
"""Returns a specific data for a function.
|
||||
|
||||
@param[in] function_id Id of the function
|
||||
@param[in] key key to access the data
|
||||
@return the data.
|
||||
|
||||
"""
|
||||
if isinstance(key, unicode): key = PyUnicode_AsUTF8String(key)
|
||||
return _ctouni(eolian_function_data_get(self.function_id, key))
|
||||
|
||||
def is_virtual_pure_get(self, Eolian_Function_Type f_type):
|
||||
"""Indicates if a function is virtual pure.
|
||||
|
||||
@param[in] function_id Id of the function
|
||||
@return EINA_TRUE if virtual pure, EINA_FALSE othrewise..
|
||||
|
||||
"""
|
||||
return bool(eolian_function_is_virtual_pure(self.function_id, f_type))
|
||||
|
||||
def description_get(self, key):
|
||||
"""Returns a specific description for a function.
|
||||
|
||||
@param[in] function_id Id of the function
|
||||
@param[in] key key to access the description
|
||||
@return the description.
|
||||
|
||||
"""
|
||||
if isinstance(key, unicode): key = PyUnicode_AsUTF8String(key)
|
||||
return _ctouni(eolian_function_data_get(self.function_id, key))
|
||||
|
||||
def parameter_get(self, param_name):
|
||||
"""Returns a parameter of a function pointed by its id.
|
||||
|
||||
@param[in] function_id Id of the function
|
||||
@param[in] param_name Name of the parameter
|
||||
@return a handle to this parameter.
|
||||
|
||||
"""
|
||||
if isinstance(param_name, unicode): param_name = PyUnicode_AsUTF8String(param_name)
|
||||
return eolian_obj_to_python_obj(
|
||||
<uintptr_t>eolian_function_parameter_get(
|
||||
self.function_id, param_name
|
||||
),
|
||||
FunctionParameter
|
||||
)
|
||||
|
||||
property property_keys_list:
|
||||
"""Returns a list of keys params of a given function.
|
||||
|
||||
@param[in] function_id Id of the function
|
||||
@return list of Eolian_Function_Parameter
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return eina_list_obj_to_python_list(
|
||||
eolian_property_keys_list_get(self.function_id), FunctionParameter
|
||||
)
|
||||
|
||||
property property_values_list:
|
||||
"""Returns a list of values params of a given function.
|
||||
|
||||
@param[in] function_id Id of the function
|
||||
@return list of Eolian_Function_Parameter
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return eina_list_obj_to_python_list(
|
||||
eolian_property_values_list_get(self.function_id), FunctionParameter
|
||||
)
|
||||
|
||||
property parameters_list:
|
||||
"""Returns a list of parameter handles for a method/ctor/dtor.
|
||||
|
||||
@param[in] function_id Id of the function
|
||||
@return list of Eolian_Function_Parameter
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return eina_list_obj_to_python_list(
|
||||
eolian_parameters_list_get(self.function_id), FunctionParameter
|
||||
)
|
||||
|
||||
def return_type_get(self, Eolian_Function_Type ftype):
|
||||
"""Get the return type of a function.
|
||||
|
||||
@param[in] function_id id of the function
|
||||
@param[in] ftype type of the function
|
||||
@return the return type of the function
|
||||
|
||||
The type of the function is needed because a given function can represent a
|
||||
property, that can be set and get functions.
|
||||
|
||||
"""
|
||||
return _ctouni(eolian_function_return_type_get(
|
||||
self.function_id, ftype
|
||||
))
|
||||
|
||||
def return_types_list_get(self, Eolian_Function_Type ftype):
|
||||
"""Get a list of all the types of a function return
|
||||
|
||||
@param[in] foo_id Function Id
|
||||
@param[in] ftype Function Type
|
||||
@return the types of the function return
|
||||
|
||||
"""
|
||||
return eolian_obj_to_python_obj(
|
||||
<uintptr_t>eolian_function_return_types_list_get(
|
||||
self.function_id, ftype
|
||||
),
|
||||
Type
|
||||
)
|
||||
|
||||
def return_dflt_value_get(self, Eolian_Function_Type ftype):
|
||||
"""Get the return default value of a function.
|
||||
|
||||
@param[in] function_id id of the function
|
||||
@param[in] ftype type of the function
|
||||
@return the return default value of the function
|
||||
|
||||
The return default value is needed to return an appropriate
|
||||
value if an error occurs (eo_do failure...).
|
||||
The default value is not mandatory, so NULL can be returned.
|
||||
|
||||
"""
|
||||
return _ctouni(eolian_function_return_dflt_value_get(
|
||||
self.function_id, ftype
|
||||
))
|
||||
|
||||
def return_comment_get(self, Eolian_Function_Type ftype):
|
||||
"""Get the return comment of a function.
|
||||
|
||||
@param[in] function_id id of the function
|
||||
@param[in] ftype type of the function
|
||||
@return the return comment of the function
|
||||
|
||||
The type of the function is needed because a given function can represent a
|
||||
property, that can be set and get functions.
|
||||
|
||||
"""
|
||||
return _ctouni(eolian_function_return_comment_get(
|
||||
self.function_id, ftype
|
||||
))
|
||||
|
||||
def return_is_warn_unused_get(self, Eolian_Function_Type ftype):
|
||||
"""Indicates if a function return is warn-unused.
|
||||
|
||||
@param[in] function_id id of the function
|
||||
@param[in] ftype type of the function
|
||||
@return EINA_TRUE is warn-unused, EINA_FALSE otherwise.
|
||||
|
||||
The type of the function is needed because a given function can represent a
|
||||
property, that can be set and get functions.
|
||||
|
||||
"""
|
||||
return bool(eolian_function_return_is_warn_unused(
|
||||
self.function_id, ftype
|
||||
))
|
||||
|
||||
property object_is_const:
|
||||
"""Indicates if a function object is const.
|
||||
|
||||
@param[in] function_id id of the function
|
||||
@return EINA_TRUE if the object is const, EINA_FALSE otherwise
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return bool(eolian_function_object_is_const(self.function_id))
|
||||
|
||||
|
||||
cdef class FunctionParameter(object):
|
||||
|
||||
cdef Eolian_Function_Parameter param
|
||||
|
||||
cdef _set_obj(self, uintptr_t obj):
|
||||
self.param = <Eolian_Function_Parameter>obj
|
||||
|
||||
property information:
|
||||
"""Get information about a function parameter
|
||||
|
||||
@param[in] param_desc parameter handle
|
||||
@param[out] param_dir in/out/inout
|
||||
@param[out] type type of the parameter
|
||||
@param[out] name name of the parameter
|
||||
@param[out] description description of the parameter
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
cdef:
|
||||
Eolian_Parameter_Dir param_dir
|
||||
const char *type
|
||||
const char *name
|
||||
const char *description
|
||||
eolian_parameter_information_get(
|
||||
self.param, ¶m_dir, &type, &name, &description
|
||||
)
|
||||
return (param_dir, _ctouni(type), _ctouni(name), _ctouni(description))
|
||||
|
||||
property type:
|
||||
"""Get type of a parameter
|
||||
|
||||
@param[in] param_desc parameter handle
|
||||
@return the type of the parameter
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return _ctouni(eolian_parameter_type_get(self.param))
|
||||
|
||||
property types_list:
|
||||
"""Get a list of all the types of a parameter
|
||||
|
||||
@param[in] param_desc parameter handle
|
||||
@return the types of the parameter
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return eolian_obj_to_python_obj(
|
||||
<uintptr_t>eolian_parameter_types_list_get(self.param), Type
|
||||
)
|
||||
|
||||
property name:
|
||||
"""Get name of a parameter
|
||||
|
||||
@param[in] param_desc parameter handle
|
||||
@return the name of the parameter
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return _ctouni(eolian_parameter_name_get(self.param))
|
||||
|
||||
def const_attribute_get(self, bint is_get):
|
||||
"""Indicates if a parameter has a const attribute.
|
||||
|
||||
This function is relevant for properties, to know if a parameter is a
|
||||
const parameter in the get operation.
|
||||
|
||||
@param[in] param_desc parameter handle
|
||||
@param[in] is_get indicates if the information needed is for get or set.
|
||||
@return EINA_TRUE if const in get, EINA_FALSE otherwise
|
||||
|
||||
"""
|
||||
return bool(eolian_parameter_const_attribute_get(self.param, is_get))
|
||||
|
||||
property is_nonull:
|
||||
"""Indicates if a parameter cannot be NULL.
|
||||
|
||||
@param[in] param_desc parameter handle
|
||||
@return EINA_TRUE if cannot be NULL, EINA_FALSE otherwise
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return bool(eolian_parameter_is_nonull(self.param))
|
||||
|
||||
|
||||
cdef class Type(object):
|
||||
|
||||
cdef Eolian_Type etype
|
||||
|
||||
cdef _set_obj(self, uintptr_t obj):
|
||||
self.etype = <Eolian_Type>obj
|
||||
|
||||
def __next__(self):
|
||||
cdef:
|
||||
const char *type
|
||||
Eina_Bool own
|
||||
Eolian_Type etype
|
||||
|
||||
etype = eolian_type_information_get(
|
||||
self.etype, &type, &own
|
||||
)
|
||||
if etype == NULL:
|
||||
raise StopIteration
|
||||
|
||||
self.etype = etype
|
||||
return _ctouni(type), bool(own)
|
||||
|
||||
property information:
|
||||
"""Get information on given type.
|
||||
|
||||
An Eolian type is an inlist of basic C types. For example:
|
||||
Eina_List * <Eo *> contains two basic types.
|
||||
The first Eolian type of the list stores Eina_List *, the next one Eo *.
|
||||
|
||||
@param[in] etype Eolian type
|
||||
@param[out] type C type
|
||||
@param[out] own indicates if the ownership has to pass to the caller/callee.
|
||||
@return the next type of the list.
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
cdef:
|
||||
const char *type
|
||||
Eina_Bool own
|
||||
Eolian_Type etype
|
||||
|
||||
etype = eolian_type_information_get(
|
||||
self.etype, &type, &own
|
||||
)
|
||||
if etype == NULL:
|
||||
return None
|
||||
|
||||
self.etype = etype
|
||||
return _ctouni(type), bool(own)
|
||||
|
||||
cdef class Implement(object):
|
||||
|
||||
cdef Eolian_Implement impl
|
||||
|
||||
cdef _set_obj(self, uintptr_t obj):
|
||||
self.impl = <Eolian_Implement>obj
|
||||
|
||||
property full_name:
|
||||
"""Get full string of an overriding function (implement).
|
||||
|
||||
@param[in] impl handle of the implement
|
||||
@return the full string.
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
return _ctouni(eolian_implement_full_name_get(self.impl))
|
||||
|
||||
property information:
|
||||
"""Get information about an overriding function (implement).
|
||||
|
||||
@param[in] impl handle of the implement
|
||||
@param[out] class overridden class
|
||||
@param[out] func overridden function
|
||||
@param[out] type type of the overridden function
|
||||
@return EINA_TRUE on success, EINA_FALSE otherwise.
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
cdef:
|
||||
Eolian_Class klass
|
||||
Eolian_Function function
|
||||
Eolian_Function_Type type
|
||||
if not eolian_implement_information_get(self.impl,
|
||||
&klass,
|
||||
&function,
|
||||
&type
|
||||
):
|
||||
raise RuntimeError("Could not fetch information")
|
||||
|
||||
return (
|
||||
eolian_obj_to_python_obj(<uintptr_t>klass, Class),
|
||||
eolian_obj_to_python_obj(<uintptr_t>function, Function),
|
||||
type
|
||||
)
|
||||
|
||||
|
||||
cdef class Event(object):
|
||||
|
||||
cdef Eolian_Event event
|
||||
|
||||
cdef _set_obj(self, uintptr_t obj):
|
||||
self.event = <Eolian_Event>obj
|
||||
|
||||
property information:
|
||||
"""Get information about an event.
|
||||
|
||||
@param[in] event handle of the event
|
||||
@param[out] event_name name of the event
|
||||
@param[out] event_desc description of the event
|
||||
@return EINA_TRUE on success, EINA_FALSE otherwise.
|
||||
|
||||
"""
|
||||
def __get__(self):
|
||||
cdef:
|
||||
const char *event_name
|
||||
const char *event_type
|
||||
const char *event_desc
|
||||
|
||||
if not eolian_class_event_information_get(
|
||||
self.event, &event_name, &event_type, &event_desc
|
||||
):
|
||||
raise RuntimeError("could not fetch event information")
|
||||
|
||||
return (event_name, event_type, event_desc)
|
||||
|
||||
|
||||
def type_find_by_alias(alias):
|
||||
"""Find the type for a certain alias
|
||||
|
||||
@param[in] alias alias of the type definition
|
||||
@return real type of the type definition
|
||||
|
||||
"""
|
||||
if isinstance(alias, unicode): alias = PyUnicode_AsUTF8String(alias)
|
||||
return eolian_obj_to_python_obj(
|
||||
<uintptr_t>eolian_type_find_by_alias(alias), Type
|
||||
)
|
|
@ -0,0 +1,24 @@
|
|||
cdef extern from "Eolian.h":
|
||||
ctypedef enum Eolian_Function_Type:
|
||||
EOLIAN_UNRESOLVED
|
||||
EOLIAN_PROPERTY
|
||||
EOLIAN_PROP_SET
|
||||
EOLIAN_PROP_GET
|
||||
EOLIAN_METHOD
|
||||
EOLIAN_CTOR
|
||||
|
||||
ctypedef enum Eolian_Parameter_Dir:
|
||||
EOLIAN_IN_PARAM
|
||||
EOLIAN_OUT_PARAM
|
||||
EOLIAN_INOUT_PARAM
|
||||
|
||||
ctypedef enum Eolian_Class_Type:
|
||||
EOLIAN_CLASS_UNKNOWN_TYPE
|
||||
EOLIAN_CLASS_REGULAR
|
||||
EOLIAN_CLASS_ABSTRACT
|
||||
EOLIAN_CLASS_MIXIN
|
||||
EOLIAN_CLASS_INTERFACE
|
||||
|
||||
ctypedef enum Eolian_Function_Scope:
|
||||
EOLIAN_SCOPE_PUBLIC
|
||||
EOLIAN_SCOPE_PROTECTED
|
|
@ -93,6 +93,9 @@ cdef extern from "Eina.h":
|
|||
const char *name # Domain name
|
||||
size_t namelen # strlen(name)
|
||||
|
||||
ctypedef struct _Eina_Inlist
|
||||
ctypedef _Eina_Inlist Eina_Inlist
|
||||
|
||||
####################################################################
|
||||
# Other typedefs
|
||||
#
|
||||
|
|
12
setup.py
12
setup.py
|
@ -189,6 +189,18 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
|
|||
)
|
||||
modules.append(eo_ext)
|
||||
|
||||
# === Eolian ===
|
||||
eol_cflags, eol_libs = pkg_config('Eolian', 'eolian', EFL_MIN_VERSION)
|
||||
eol_ext = Extension(
|
||||
"eolian", ["efl/eolian/__init__" + module_suffix],
|
||||
define_macros=[('EFL_BETA_API_SUPPORT', None)],
|
||||
#include_dirs=['include/'],
|
||||
extra_compile_args=eol_cflags + eina_cflags,
|
||||
extra_link_args=eol_libs + eina_libs
|
||||
)
|
||||
modules.append(eol_ext)
|
||||
packages.append("efl.eolian")
|
||||
|
||||
# === Utilities ===
|
||||
utils_ext = [
|
||||
Extension(
|
||||
|
|
Loading…
Reference in New Issue