Eolian: WIP
This commit is contained in:
parent
2ba244d263
commit
f84fef0415
|
@ -0,0 +1,11 @@
|
||||||
|
from cpython cimport PyUnicode_AsUTF8String
|
||||||
|
|
||||||
|
from efl.c_eo cimport eo_add_ref, Eo_Class, _eo_do_start, _eo_do_end, \
|
||||||
|
CFILE, CFUNC, CLINE, Eo_Event_Description
|
||||||
|
from efl.eo cimport object_from_instance, _object_mapping_register, \
|
||||||
|
Eo, _Eo
|
||||||
|
from efl.utils.conversions cimport _ctouni
|
||||||
|
|
||||||
|
from efl.eina cimport eina_hash_add, eina_hash_del, EINA_FALSE, Eina_Bool
|
||||||
|
|
||||||
|
include "generated_classes.pxi"
|
File diff suppressed because it is too large
Load Diff
|
@ -22,14 +22,14 @@ from efl.eina cimport Eina_Bool, \
|
||||||
Eina_Hash, eina_hash_string_superfast_new, eina_hash_add, eina_hash_del, \
|
Eina_Hash, eina_hash_string_superfast_new, eina_hash_add, eina_hash_del, \
|
||||||
eina_hash_find, EINA_LOG_DOM_DBG, EINA_LOG_DOM_INFO, \
|
eina_hash_find, EINA_LOG_DOM_DBG, EINA_LOG_DOM_INFO, \
|
||||||
eina_hash_pointer_new
|
eina_hash_pointer_new
|
||||||
from efl.c_eo cimport Eo as cEo, eo_init, eo_shutdown, eo_del, eo_do, \
|
from efl.c_eo cimport Eo as Eo, eo_init, eo_shutdown, eo_del, eo_do, \
|
||||||
eo_class_name_get, eo_class_get, eo_base_class_get,\
|
eo_class_name_get, eo_class_get, eo_base_class_get,\
|
||||||
eo_key_data_set, eo_key_data_get, eo_key_data_del, \
|
eo_key_data_set, eo_key_data_get, eo_key_data_del, \
|
||||||
eo_event_callback_add, eo_event_callback_del, EO_EV_DEL, \
|
eo_event_callback_add, eo_event_callback_del, EO_EV_DEL, \
|
||||||
eo_parent_get, eo_parent_set, Eo_Event_Description, \
|
eo_parent_get, eo_parent_set, Eo_Event_Description, \
|
||||||
eo_event_freeze, eo_event_thaw, eo_event_freeze_count_get, \
|
eo_event_freeze, eo_event_thaw, eo_event_freeze_count_get, \
|
||||||
eo_event_global_freeze, eo_event_global_thaw, \
|
eo_event_global_freeze, eo_event_global_thaw, \
|
||||||
eo_event_global_freeze_count_get
|
eo_event_global_freeze_count_get, eo_add_ref
|
||||||
|
|
||||||
cimport efl.eo.enums as enums
|
cimport efl.eo.enums as enums
|
||||||
|
|
||||||
|
@ -57,16 +57,16 @@ init()
|
||||||
|
|
||||||
def event_global_freeze_count_get():
|
def event_global_freeze_count_get():
|
||||||
cdef int fcount
|
cdef int fcount
|
||||||
fcount = <int>eo_do(<const cEo *>eo_base_class_get(),
|
fcount = <int>eo_do(<const Eo *>eo_base_class_get(),
|
||||||
eo_event_global_freeze_count_get())
|
eo_event_global_freeze_count_get())
|
||||||
return fcount
|
return fcount
|
||||||
|
|
||||||
def event_global_freeze():
|
def event_global_freeze():
|
||||||
eo_do(<const cEo *>eo_base_class_get(),
|
eo_do(<const Eo *>eo_base_class_get(),
|
||||||
eo_event_global_freeze())
|
eo_event_global_freeze())
|
||||||
|
|
||||||
def event_global_thaw():
|
def event_global_thaw():
|
||||||
eo_do(<const cEo *>eo_base_class_get(),
|
eo_do(<const Eo *>eo_base_class_get(),
|
||||||
eo_event_global_thaw())
|
eo_event_global_thaw())
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
@ -98,11 +98,11 @@ cdef void _object_mapping_unregister(char *name):
|
||||||
eina_hash_del(object_mapping, name, NULL)
|
eina_hash_del(object_mapping, name, NULL)
|
||||||
|
|
||||||
|
|
||||||
cdef api object object_from_instance(cEo *obj):
|
cdef api object object_from_instance(Eo *obj):
|
||||||
""" Create a python object from a C Eo object pointer. """
|
""" Create a python object from a C Eo object pointer. """
|
||||||
cdef:
|
cdef:
|
||||||
void *data
|
void *data
|
||||||
Eo o
|
_Eo o
|
||||||
const char *cls_name = eo_class_name_get(eo_class_get(obj))
|
const char *cls_name = eo_class_name_get(eo_class_get(obj))
|
||||||
type cls
|
type cls
|
||||||
void *cls_ret
|
void *cls_ret
|
||||||
|
@ -114,7 +114,7 @@ cdef api object object_from_instance(cEo *obj):
|
||||||
if data != NULL:
|
if data != NULL:
|
||||||
EINA_LOG_DOM_DBG(PY_EFL_EO_LOG_DOMAIN,
|
EINA_LOG_DOM_DBG(PY_EFL_EO_LOG_DOMAIN,
|
||||||
"Returning a Python object instance for Eo of type %s.", cls_name)
|
"Returning a Python object instance for Eo of type %s.", cls_name)
|
||||||
return <Eo>data
|
return <_Eo>data
|
||||||
|
|
||||||
if cls_name == NULL:
|
if cls_name == NULL:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
@ -143,12 +143,12 @@ cdef api object object_from_instance(cEo *obj):
|
||||||
o._set_obj(obj)
|
o._set_obj(obj)
|
||||||
return o
|
return o
|
||||||
|
|
||||||
cdef api cEo *instance_from_object(object obj):
|
cdef api Eo *instance_from_object(object obj):
|
||||||
cdef Eo o = obj
|
cdef _Eo o = obj
|
||||||
return o.obj
|
return o.obj
|
||||||
|
|
||||||
|
|
||||||
cdef void _register_decorated_callbacks(Eo obj):
|
cdef void _register_decorated_callbacks(_Eo obj):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Search every attrib of the pyobj for a __decorated_callbacks__ object,
|
Search every attrib of the pyobj for a __decorated_callbacks__ object,
|
||||||
|
@ -179,11 +179,11 @@ EO_CALLBACK_CONTINUE = enums.EO_CALLBACK_CONTINUE
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
||||||
cdef Eina_Bool _eo_event_del_cb(void *data, cEo *obj,
|
cdef Eina_Bool _eo_event_del_cb(void *data, Eo *obj,
|
||||||
const Eo_Event_Description *desc,
|
const Eo_Event_Description *desc,
|
||||||
void *event_info) with gil:
|
void *event_info) with gil:
|
||||||
cdef:
|
cdef:
|
||||||
Eo self = <Eo>data
|
_Eo self = <_Eo>data
|
||||||
const char *cls_name = eo_class_name_get(eo_class_get(obj))
|
const char *cls_name = eo_class_name_get(eo_class_get(obj))
|
||||||
|
|
||||||
EINA_LOG_DOM_DBG(PY_EFL_EO_LOG_DOMAIN, "Deleting Eo: %s", cls_name)
|
EINA_LOG_DOM_DBG(PY_EFL_EO_LOG_DOMAIN, "Deleting Eo: %s", cls_name)
|
||||||
|
@ -197,7 +197,7 @@ cdef Eina_Bool _eo_event_del_cb(void *data, cEo *obj,
|
||||||
return enums.EO_CALLBACK_STOP
|
return enums.EO_CALLBACK_STOP
|
||||||
|
|
||||||
cdef Eina_Bool _py_efl_eo_event_cb(
|
cdef Eina_Bool _py_efl_eo_event_cb(
|
||||||
void *data, cEo *obj,
|
void *data, Eo *obj,
|
||||||
const Eo_Event_Description *desc,
|
const Eo_Event_Description *desc,
|
||||||
void *event_info
|
void *event_info
|
||||||
) with gil:
|
) with gil:
|
||||||
|
@ -206,7 +206,7 @@ cdef Eina_Bool _py_efl_eo_event_cb(
|
||||||
void *tmp1
|
void *tmp1
|
||||||
void *tmp2
|
void *tmp2
|
||||||
bint ret
|
bint ret
|
||||||
Eo o
|
_Eo o
|
||||||
EventDesc py_ev_desc
|
EventDesc py_ev_desc
|
||||||
#EventInfo py_ev_info_obj
|
#EventInfo py_ev_info_obj
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ cdef class EventDesc(object):
|
||||||
# self.event_info = self.conv_to_c(val)
|
# self.event_info = self.conv_to_c(val)
|
||||||
|
|
||||||
|
|
||||||
cdef class Eo(object):
|
cdef class _Eo(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Base class used by all the object in the EFL.
|
Base class used by all the object in the EFL.
|
||||||
|
@ -282,13 +282,13 @@ cdef class Eo(object):
|
||||||
self.data = dict()
|
self.data = dict()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if type(self) is Eo:
|
if type(self) is _Eo:
|
||||||
raise TypeError("Must not instantiate Eo, but subclasses")
|
raise TypeError("Must not instantiate Eo, but subclasses")
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
cdef cEo *parent = NULL
|
cdef Eo *parent = NULL
|
||||||
if self.obj != NULL:
|
if self.obj != NULL:
|
||||||
parent = <cEo *>eo_do(self.obj, eo_parent_get())
|
parent = <Eo *>eo_do(self.obj, eo_parent_get())
|
||||||
return ("<%s object (Eo) at %#x (obj=%#x, parent=%#x, refcount=%d)>") % (
|
return ("<%s object (Eo) at %#x (obj=%#x, parent=%#x, refcount=%d)>") % (
|
||||||
type(self).__name__,
|
type(self).__name__,
|
||||||
<uintptr_t><void *>self,
|
<uintptr_t><void *>self,
|
||||||
|
@ -299,7 +299,7 @@ cdef class Eo(object):
|
||||||
def __nonzero__(self):
|
def __nonzero__(self):
|
||||||
return 1 if self.obj != NULL else 0
|
return 1 if self.obj != NULL else 0
|
||||||
|
|
||||||
cdef int _set_obj(self, cEo *obj) except 0:
|
cdef int _set_obj(self, Eo *obj) except 0:
|
||||||
assert self.obj == NULL, "Object must be clean"
|
assert self.obj == NULL, "Object must be clean"
|
||||||
assert obj != NULL, "Cannot set a NULL object"
|
assert obj != NULL, "Cannot set a NULL object"
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ cdef class Eo(object):
|
||||||
"""
|
"""
|
||||||
return bool(self.obj == NULL)
|
return bool(self.obj == NULL)
|
||||||
|
|
||||||
def parent_set(self, Eo parent):
|
def parent_set(self, _Eo parent):
|
||||||
"""Set the parent object.
|
"""Set the parent object.
|
||||||
|
|
||||||
:param parent: The object to set as parent.
|
:param parent: The object to set as parent.
|
||||||
|
@ -355,7 +355,7 @@ cdef class Eo(object):
|
||||||
:rtype: :class:`Eo`
|
:rtype: :class:`Eo`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
cdef cEo *parent = <cEo *>eo_do(self.obj, eo_parent_get())
|
cdef Eo *parent = <Eo *>eo_do(self.obj, eo_parent_get())
|
||||||
return object_from_instance(parent)
|
return object_from_instance(parent)
|
||||||
|
|
||||||
def event_freeze(self):
|
def event_freeze(self):
|
||||||
|
|
|
@ -224,6 +224,7 @@ cdef extern from "Eolian.h":
|
||||||
Eina_Bool eolian_function_is_empty(const Eolian_Function *function_id, Eolian_Function_Type f_type)
|
Eina_Bool eolian_function_is_empty(const Eolian_Function *function_id, Eolian_Function_Type f_type)
|
||||||
Eina_Bool eolian_function_is_legacy_only(const Eolian_Function *function_id, Eolian_Function_Type ftype)
|
Eina_Bool eolian_function_is_legacy_only(const Eolian_Function *function_id, Eolian_Function_Type ftype)
|
||||||
Eina_Bool eolian_function_is_class(const Eolian_Function *function_id)
|
Eina_Bool eolian_function_is_class(const Eolian_Function *function_id)
|
||||||
|
Eina_Bool eolian_function_is_constructor(const Eolian_Function *function_id, const Eolian_Class *klass)
|
||||||
const Eolian_Function_Parameter *eolian_function_parameter_get_by_name(const Eolian_Function *function_id, const char *param_name)
|
const Eolian_Function_Parameter *eolian_function_parameter_get_by_name(const Eolian_Function *function_id, const char *param_name)
|
||||||
Eina_Iterator *eolian_function_parameters_get(const Eolian_Function *function_id)
|
Eina_Iterator *eolian_function_parameters_get(const Eolian_Function *function_id)
|
||||||
Eina_Iterator *eolian_property_keys_get(const Eolian_Function *foo_id)
|
Eina_Iterator *eolian_property_keys_get(const Eolian_Function *foo_id)
|
||||||
|
@ -261,6 +262,7 @@ cdef extern from "Eolian.h":
|
||||||
Eina_Stringshare *eolian_event_c_name_get(const Eolian_Event *event)
|
Eina_Stringshare *eolian_event_c_name_get(const Eolian_Event *event)
|
||||||
Eina_Bool eolian_class_ctor_enable_get(const Eolian_Class *klass)
|
Eina_Bool eolian_class_ctor_enable_get(const Eolian_Class *klass)
|
||||||
Eina_Bool eolian_class_dtor_enable_get(const Eolian_Class *klass)
|
Eina_Bool eolian_class_dtor_enable_get(const Eolian_Class *klass)
|
||||||
|
Eina_Stringshare *eolian_class_c_get_function_name_get(const Eolian_Class *klass)
|
||||||
const Eolian_Type *eolian_type_alias_get_by_name(const char *name)
|
const Eolian_Type *eolian_type_alias_get_by_name(const char *name)
|
||||||
const Eolian_Type *eolian_type_struct_get_by_name(const char *name)
|
const Eolian_Type *eolian_type_struct_get_by_name(const char *name)
|
||||||
const Eolian_Type *eolian_type_enum_get_by_name(const char *name)
|
const Eolian_Type *eolian_type_enum_get_by_name(const char *name)
|
||||||
|
|
|
@ -895,6 +895,21 @@ cdef class Class(object):
|
||||||
def __get__(self):
|
def __get__(self):
|
||||||
return bool(eolian_class_dtor_enable_get(self.klass))
|
return bool(eolian_class_dtor_enable_get(self.klass))
|
||||||
|
|
||||||
|
property c_get_function_name:
|
||||||
|
"""Returns the name of the C function used to get the Eo_Class pointer.
|
||||||
|
|
||||||
|
:return: a stringshare containing the func name or NULL on error.
|
||||||
|
|
||||||
|
You have to delete the stringshare manually.
|
||||||
|
|
||||||
|
"""
|
||||||
|
def __get__(self):
|
||||||
|
cdef Eina_Stringshare *ret1
|
||||||
|
ret1 = eolian_class_c_get_function_name_get(self.klass)
|
||||||
|
ret2 = _ctouni(ret1)
|
||||||
|
eina_stringshare_del(ret1)
|
||||||
|
return ret2
|
||||||
|
|
||||||
def function_get_by_name(self, func_name, Eolian_Function_Type f_type):
|
def function_get_by_name(self, func_name, Eolian_Function_Type f_type):
|
||||||
"""Find a function in a class by its name and type
|
"""Find a function in a class by its name and type
|
||||||
|
|
||||||
|
@ -1049,6 +1064,16 @@ cdef class Function(object):
|
||||||
def __get__(self):
|
def __get__(self):
|
||||||
return bool(eolian_function_is_class(self.function_id))
|
return bool(eolian_function_is_class(self.function_id))
|
||||||
|
|
||||||
|
def is_constructor(self, Class klass):
|
||||||
|
"""Indicates if a function is a constructing function of a given class.
|
||||||
|
|
||||||
|
@param[in] klass the class
|
||||||
|
@param[in] function_id Id of the function
|
||||||
|
@return EINA_TRUE and EINA_FALSE respectively
|
||||||
|
|
||||||
|
"""
|
||||||
|
return bool(eolian_function_is_constructor(self.function_id, klass.klass))
|
||||||
|
|
||||||
def parameter_get_by_name(self, param_name):
|
def parameter_get_by_name(self, param_name):
|
||||||
"""Returns a parameter of a function pointed by its id.
|
"""Returns a parameter of a function pointed by its id.
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,16 @@ from efl.utils.conversions cimport eina_list_strings_to_python_list
|
||||||
from efl.eina cimport EINA_LOG_DOM_DBG, EINA_LOG_DOM_INFO, EINA_LOG_DOM_WARN
|
from efl.eina cimport EINA_LOG_DOM_DBG, EINA_LOG_DOM_INFO, EINA_LOG_DOM_WARN
|
||||||
from efl.utils.logger cimport add_logger
|
from efl.utils.logger cimport add_logger
|
||||||
|
|
||||||
|
from cpython cimport PyUnicode_AsUTF8String
|
||||||
|
|
||||||
|
from efl.c_eo cimport eo_add_ref, Eo, Eo_Class, _eo_do_start, _eo_do_end, \
|
||||||
|
CFILE, CFUNC, CLINE, Eo_Event_Description
|
||||||
|
from efl.eo cimport object_from_instance, _object_mapping_register, \
|
||||||
|
_register_decorated_callbacks, _Eo
|
||||||
|
from efl.utils.conversions cimport _ctouni
|
||||||
|
|
||||||
|
from efl.eina cimport eina_hash_add, eina_hash_del, EINA_FALSE
|
||||||
|
|
||||||
cdef int PY_EFL_EVAS_LOG_DOMAIN = add_logger(__name__).eina_log_domain
|
cdef int PY_EFL_EVAS_LOG_DOMAIN = add_logger(__name__).eina_log_domain
|
||||||
|
|
||||||
EVAS_LAYER_MIN = enums.EVAS_LAYER_MIN
|
EVAS_LAYER_MIN = enums.EVAS_LAYER_MIN
|
||||||
|
@ -343,24 +353,25 @@ class EvasLoadError(Exception):
|
||||||
Exception.__init__(self, "%s (file=%s, key=%s)" % (msg, filename, key))
|
Exception.__init__(self, "%s (file=%s, key=%s)" % (msg, filename, key))
|
||||||
|
|
||||||
|
|
||||||
include "efl.evas_rect.pxi"
|
include "generated_classes.pxi"
|
||||||
include "efl.evas_map.pxi"
|
#include "efl.evas_rect.pxi"
|
||||||
include "efl.evas_canvas_callbacks.pxi"
|
#include "efl.evas_map.pxi"
|
||||||
include "efl.evas_canvas.pxi"
|
#include "efl.evas_canvas_callbacks.pxi"
|
||||||
include "efl.evas_object_events.pxi"
|
#include "efl.evas_canvas.pxi"
|
||||||
include "efl.evas_object_callbacks.pxi"
|
#include "efl.evas_object_events.pxi"
|
||||||
include "efl.evas_object.pxi"
|
#include "efl.evas_object_callbacks.pxi"
|
||||||
include "efl.evas_object_smart.pxi"
|
#include "efl.evas_object.pxi"
|
||||||
include "efl.evas_object_image.pxi"
|
#include "efl.evas_object_smart.pxi"
|
||||||
include "efl.evas_object_line.pxi"
|
#include "efl.evas_object_image.pxi"
|
||||||
include "efl.evas_object_rectangle.pxi"
|
#include "efl.evas_object_line.pxi"
|
||||||
include "efl.evas_object_polygon.pxi"
|
#include "efl.evas_object_rectangle.pxi"
|
||||||
include "efl.evas_object_text.pxi"
|
#include "efl.evas_object_polygon.pxi"
|
||||||
include "efl.evas_object_textblock.pxi"
|
#include "efl.evas_object_text.pxi"
|
||||||
include "efl.evas_object_box.pxi"
|
#include "efl.evas_object_textblock.pxi"
|
||||||
include "efl.evas_object_textgrid.pxi"
|
#include "efl.evas_object_box.pxi"
|
||||||
include "efl.evas_object_table.pxi"
|
#include "efl.evas_object_textgrid.pxi"
|
||||||
include "efl.evas_object_grid.pxi"
|
#include "efl.evas_object_table.pxi"
|
||||||
|
#include "efl.evas_object_grid.pxi"
|
||||||
|
|
||||||
|
|
||||||
init()
|
init()
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
from efl.eina cimport Eina_Bool
|
from efl.eina cimport Eina_Bool
|
||||||
|
|
||||||
cdef extern from *:
|
cdef extern from *:
|
||||||
struct CFILE "__FILE__"
|
char *CFILE "__FILE__"
|
||||||
struct CLINE "__LINE__"
|
int CLINE "__LINE__"
|
||||||
struct CFUNC "__FUNCTION__"
|
char *CFUNC "__FUNCTION__"
|
||||||
|
|
||||||
cdef extern from "Eo.h":
|
cdef extern from "Eo.h":
|
||||||
####################################################################
|
####################################################################
|
||||||
|
@ -57,6 +57,7 @@ cdef extern from "Eo.h":
|
||||||
int eo_shutdown()
|
int eo_shutdown()
|
||||||
|
|
||||||
Eo *eo_add(const Eo_Class *klass, Eo *parent, ...)
|
Eo *eo_add(const Eo_Class *klass, Eo *parent, ...)
|
||||||
|
Eo *eo_add_ref(const Eo_Class *klass, Eo *parent, ...)
|
||||||
Eo *eo_ref(const Eo *obj)
|
Eo *eo_ref(const Eo *obj)
|
||||||
void eo_unref(const Eo *obj)
|
void eo_unref(const Eo *obj)
|
||||||
int eo_ref_get(const Eo *obj)
|
int eo_ref_get(const Eo *obj)
|
||||||
|
|
|
@ -50,6 +50,10 @@ cdef extern from "Eina.h":
|
||||||
EINA_LOG_STATE_START
|
EINA_LOG_STATE_START
|
||||||
EINA_LOG_STATE_STOP
|
EINA_LOG_STATE_STOP
|
||||||
|
|
||||||
|
enum:
|
||||||
|
EINA_FALSE
|
||||||
|
EINA_TRUE
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
# Basic Types
|
# Basic Types
|
||||||
#
|
#
|
||||||
|
@ -96,6 +100,8 @@ cdef extern from "Eina.h":
|
||||||
ctypedef struct _Eina_Inlist
|
ctypedef struct _Eina_Inlist
|
||||||
ctypedef _Eina_Inlist Eina_Inlist
|
ctypedef _Eina_Inlist Eina_Inlist
|
||||||
|
|
||||||
|
ctypedef struct Eina_Accessor
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
# Other typedefs
|
# Other typedefs
|
||||||
#
|
#
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
from efl.eina cimport Eina_Bool, Eina_List
|
from efl.eina cimport Eina_Bool, Eina_List
|
||||||
from efl.evas cimport Evas, Evas_Object
|
from efl.evas cimport Evas, Evas_Object
|
||||||
from efl.evas cimport Object as evasObject
|
from efl.evas cimport _Object as evasObject
|
||||||
|
|
||||||
cdef extern from "Emotion.h":
|
cdef extern from "Emotion.h":
|
||||||
|
|
||||||
|
|
|
@ -15,18 +15,18 @@
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
|
# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from efl.c_eo cimport Eo as cEo
|
from efl.c_eo cimport Eo
|
||||||
from efl.eina cimport Eina_Hash
|
from efl.eina cimport Eina_Hash
|
||||||
|
|
||||||
cdef:
|
cdef:
|
||||||
class Eo(object):
|
class _Eo(object):
|
||||||
cdef:
|
cdef:
|
||||||
cEo *obj
|
Eo *obj
|
||||||
Eina_Hash *event_desc_mapping
|
Eina_Hash *event_desc_mapping
|
||||||
Eina_Hash *event_conv_mapping
|
Eina_Hash *event_conv_mapping
|
||||||
readonly dict data
|
readonly dict data
|
||||||
|
|
||||||
int _set_obj(self, cEo *obj) except 0
|
int _set_obj(self, Eo *obj) except 0
|
||||||
int _set_properties_from_keyword_args(self, dict kwargs) except 0
|
int _set_properties_from_keyword_args(self, dict kwargs) except 0
|
||||||
#_add_obj(self, Eo_Class *klass, cEo *parent)
|
#_add_obj(self, Eo_Class *klass, cEo *parent)
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ cdef:
|
||||||
void _object_mapping_register(char *name, object cls) except *
|
void _object_mapping_register(char *name, object cls) except *
|
||||||
void _object_mapping_unregister(char *name)
|
void _object_mapping_unregister(char *name)
|
||||||
|
|
||||||
void _register_decorated_callbacks(Eo obj)
|
void _register_decorated_callbacks(_Eo obj)
|
||||||
|
|
||||||
cdef api:
|
cdef api:
|
||||||
object object_from_instance(cEo *obj)
|
object object_from_instance(Eo *obj)
|
||||||
cEo *instance_from_object(object o)
|
Eo *instance_from_object(object o)
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
|
# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from efl.eina cimport *
|
from efl.eina cimport *
|
||||||
from efl.eo cimport Eo
|
from efl.eo cimport _Eo
|
||||||
from efl.c_eo cimport Eo as cEo, Eo_Class
|
from efl.c_eo cimport Eo, Eo_Class
|
||||||
from efl.evas.enums cimport Evas_Event_Flags, Evas_Button_Flags, \
|
from efl.evas.enums cimport Evas_Event_Flags, Evas_Button_Flags, \
|
||||||
Evas_Font_Hinting_Flags, Evas_Aspect_Control, Evas_Render_Op, \
|
Evas_Font_Hinting_Flags, Evas_Aspect_Control, Evas_Render_Op, \
|
||||||
Evas_Callback_Type, Evas_Object_Pointer_Mode, Evas_Colorspace, \
|
Evas_Callback_Type, Evas_Object_Pointer_Mode, Evas_Colorspace, \
|
||||||
|
@ -25,7 +25,7 @@ from efl.evas.enums cimport Evas_Event_Flags, Evas_Button_Flags, \
|
||||||
Evas_Textgrid_Palette, Evas_Textgrid_Font_Style, \
|
Evas_Textgrid_Palette, Evas_Textgrid_Font_Style, \
|
||||||
Evas_Fill_Spread, Evas_Image_Scale_Hint, Evas_Image_Content_Hint, \
|
Evas_Fill_Spread, Evas_Image_Scale_Hint, Evas_Image_Content_Hint, \
|
||||||
Evas_Image_Animated_Loop_Hint, Evas_Object_Table_Homogeneous_Mode, \
|
Evas_Image_Animated_Loop_Hint, Evas_Object_Table_Homogeneous_Mode, \
|
||||||
Evas_Display_Mode
|
Evas_Display_Mode, Evas_BiDi_Direction, Evas_Touch_Point_State
|
||||||
|
|
||||||
cdef extern from "Evas.h":
|
cdef extern from "Evas.h":
|
||||||
####################################################################
|
####################################################################
|
||||||
|
@ -35,6 +35,7 @@ cdef extern from "Evas.h":
|
||||||
ctypedef int Evas_Angle
|
ctypedef int Evas_Angle
|
||||||
ctypedef int Evas_Font_Size
|
ctypedef int Evas_Font_Size
|
||||||
ctypedef unsigned long long Evas_Modifier_Mask
|
ctypedef unsigned long long Evas_Modifier_Mask
|
||||||
|
ctypedef double Evas_Real
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
# Structures
|
# Structures
|
||||||
|
@ -63,9 +64,11 @@ cdef extern from "Evas.h":
|
||||||
|
|
||||||
ctypedef struct Evas_Hash
|
ctypedef struct Evas_Hash
|
||||||
|
|
||||||
ctypedef cEo Evas
|
ctypedef Eo Evas
|
||||||
|
|
||||||
ctypedef cEo Evas_Object
|
ctypedef Eo Evas_Object
|
||||||
|
ctypedef Eo Evas_3D_Node
|
||||||
|
ctypedef Eo Evas_3D_Mesh
|
||||||
|
|
||||||
ctypedef struct Evas_Modifier
|
ctypedef struct Evas_Modifier
|
||||||
ctypedef struct Evas_Lock
|
ctypedef struct Evas_Lock
|
||||||
|
@ -257,6 +260,9 @@ cdef extern from "Evas.h":
|
||||||
|
|
||||||
ctypedef struct Evas_Map
|
ctypedef struct Evas_Map
|
||||||
|
|
||||||
|
ctypedef struct Evas_Object_Textblock_Node_Format
|
||||||
|
|
||||||
|
ctypedef struct Evas_Engine_Info
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
# Other typedefs
|
# Other typedefs
|
||||||
|
@ -863,51 +869,51 @@ cdef extern from "Evas.h":
|
||||||
####################################################################
|
####################################################################
|
||||||
# Python classes
|
# Python classes
|
||||||
#
|
#
|
||||||
cdef class Rect:
|
cdef class _Rect:
|
||||||
cdef int x0, y0, x1, y1, cx, cy, _w, _h
|
cdef int x0, y0, x1, y1, cx, cy, _w, _h
|
||||||
|
|
||||||
|
|
||||||
cdef class Canvas(Eo):
|
cdef class _Canvas(_Eo):
|
||||||
cdef list _event_callbacks
|
cdef list _event_callbacks
|
||||||
|
|
||||||
|
|
||||||
cdef class Map(object):
|
cdef class _Map(object):
|
||||||
cdef Evas_Map *map
|
cdef Evas_Map *map
|
||||||
|
|
||||||
|
|
||||||
cdef class Object(Eo):
|
cdef class _Object(_Eo):
|
||||||
cdef list _event_callbacks
|
cdef list _event_callbacks
|
||||||
cdef int _set_properties_from_keyword_args(self, dict) except 0
|
cdef int _set_properties_from_keyword_args(self, dict) except 0
|
||||||
|
|
||||||
cdef class Rectangle(Object):
|
cdef class _Rectangle(_Object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
cdef class Line(Object):
|
#cdef class _Line(_Object):
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
|
|
||||||
cdef class Image(Object):
|
#cdef class _Image(_Object):
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
|
|
||||||
cdef class FilledImage(Image):
|
#cdef class _FilledImage(_Image):
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
|
|
||||||
cdef class Polygon(Object):
|
#cdef class _Polygon(_Object):
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
|
|
||||||
cdef class Text(Object):
|
#cdef class _Text(_Object):
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
|
|
||||||
cdef class Textblock(Object):
|
#cdef class _Textblock(_Object):
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
|
|
||||||
cdef class SmartObject(Object):
|
cdef class _SmartObject(_Object):
|
||||||
cdef object _smart_callbacks
|
cdef object _smart_callbacks
|
||||||
cdef object _m_delete
|
cdef object _m_delete
|
||||||
cdef object _m_move
|
cdef object _m_move
|
||||||
|
@ -920,151 +926,151 @@ cdef class SmartObject(Object):
|
||||||
cdef object _m_calculate
|
cdef object _m_calculate
|
||||||
|
|
||||||
|
|
||||||
cdef class ClippedSmartObject(SmartObject):
|
cdef class _ClippedSmartObject(_SmartObject):
|
||||||
cdef readonly Rectangle clipper
|
cdef readonly _Rectangle clipper
|
||||||
|
|
||||||
|
|
||||||
cdef class EventPoint:
|
#cdef class EventPoint:
|
||||||
cdef Evas_Point *obj
|
# cdef Evas_Point *obj
|
||||||
|
|
||||||
cdef void _set_obj(self, Evas_Point *obj)
|
# cdef void _set_obj(self, Evas_Point *obj)
|
||||||
cdef void _unset_obj(self)
|
# cdef void _unset_obj(self)
|
||||||
cdef int _check_validity(self) except 0
|
# cdef int _check_validity(self) except 0
|
||||||
|
|
||||||
|
|
||||||
cdef class EventCoordPoint:
|
#cdef class EventCoordPoint:
|
||||||
cdef Evas_Coord_Point *obj
|
# cdef Evas_Coord_Point *obj
|
||||||
|
|
||||||
cdef void _set_obj(self, Evas_Coord_Point *obj)
|
# cdef void _set_obj(self, Evas_Coord_Point *obj)
|
||||||
cdef void _unset_obj(self)
|
# cdef void _unset_obj(self)
|
||||||
cdef int _check_validity(self) except 0
|
# cdef int _check_validity(self) except 0
|
||||||
|
|
||||||
|
|
||||||
cdef class EventPrecisionPoint:
|
#cdef class EventPrecisionPoint:
|
||||||
cdef Evas_Coord_Precision_Point *obj
|
# cdef Evas_Coord_Precision_Point *obj
|
||||||
|
|
||||||
cdef void _set_obj(self, Evas_Coord_Precision_Point *obj)
|
# cdef void _set_obj(self, Evas_Coord_Precision_Point *obj)
|
||||||
cdef void _unset_obj(self)
|
# cdef void _unset_obj(self)
|
||||||
cdef int _check_validity(self) except 0
|
# cdef int _check_validity(self) except 0
|
||||||
|
|
||||||
|
|
||||||
cdef class EventPosition:
|
#cdef class EventPosition:
|
||||||
cdef readonly EventPoint output
|
# cdef readonly EventPoint output
|
||||||
cdef readonly EventCoordPoint canvas
|
# cdef readonly EventCoordPoint canvas
|
||||||
|
|
||||||
cdef void _set_objs(self, Evas_Point *output, Evas_Coord_Point *canvas)
|
# cdef void _set_objs(self, Evas_Point *output, Evas_Coord_Point *canvas)
|
||||||
cdef void _unset_objs(self)
|
# cdef void _unset_objs(self)
|
||||||
|
|
||||||
|
|
||||||
cdef class EventPrecisionPosition:
|
#cdef class EventPrecisionPosition:
|
||||||
cdef readonly EventPoint output
|
# cdef readonly EventPoint output
|
||||||
cdef readonly EventPrecisionPoint canvas
|
# cdef readonly EventPrecisionPoint canvas
|
||||||
|
|
||||||
cdef void _set_objs(self, Evas_Point *output, Evas_Coord_Precision_Point *canvas)
|
# cdef void _set_objs(self, Evas_Point *output, Evas_Coord_Precision_Point *canvas)
|
||||||
cdef void _unset_objs(self)
|
# cdef void _unset_objs(self)
|
||||||
|
|
||||||
|
|
||||||
cdef class EventMouseIn:
|
#cdef class EventMouseIn:
|
||||||
cdef Evas_Event_Mouse_In *obj
|
# cdef Evas_Event_Mouse_In *obj
|
||||||
cdef readonly EventPosition position
|
# cdef readonly EventPosition position
|
||||||
|
|
||||||
cdef void _set_obj(self, void *ptr)
|
# cdef void _set_obj(self, void *ptr)
|
||||||
cdef void _unset_obj(self)
|
# cdef void _unset_obj(self)
|
||||||
cdef int _check_validity(self) except 0
|
# cdef int _check_validity(self) except 0
|
||||||
|
|
||||||
|
|
||||||
cdef class EventMouseOut:
|
#cdef class EventMouseOut:
|
||||||
cdef Evas_Event_Mouse_Out *obj
|
# cdef Evas_Event_Mouse_Out *obj
|
||||||
cdef readonly EventPosition position
|
# cdef readonly EventPosition position
|
||||||
|
|
||||||
cdef void _set_obj(self, void *ptr)
|
# cdef void _set_obj(self, void *ptr)
|
||||||
cdef void _unset_obj(self)
|
# cdef void _unset_obj(self)
|
||||||
cdef int _check_validity(self) except 0
|
# cdef int _check_validity(self) except 0
|
||||||
|
|
||||||
|
|
||||||
cdef class EventMouseDown:
|
#cdef class EventMouseDown:
|
||||||
cdef Evas_Event_Mouse_Down *obj
|
# cdef Evas_Event_Mouse_Down *obj
|
||||||
cdef readonly EventPosition position
|
# cdef readonly EventPosition position
|
||||||
|
|
||||||
cdef void _set_obj(self, void *ptr)
|
# cdef void _set_obj(self, void *ptr)
|
||||||
cdef void _unset_obj(self)
|
# cdef void _unset_obj(self)
|
||||||
cdef int _check_validity(self) except 0
|
# cdef int _check_validity(self) except 0
|
||||||
|
|
||||||
|
|
||||||
cdef class EventMouseUp:
|
#cdef class EventMouseUp:
|
||||||
cdef Evas_Event_Mouse_Up *obj
|
# cdef Evas_Event_Mouse_Up *obj
|
||||||
cdef readonly EventPosition position
|
# cdef readonly EventPosition position
|
||||||
|
|
||||||
cdef void _set_obj(self, void *ptr)
|
# cdef void _set_obj(self, void *ptr)
|
||||||
cdef void _unset_obj(self)
|
# cdef void _unset_obj(self)
|
||||||
cdef int _check_validity(self) except 0
|
# cdef int _check_validity(self) except 0
|
||||||
|
|
||||||
|
|
||||||
cdef class EventMouseMove:
|
#cdef class EventMouseMove:
|
||||||
cdef Evas_Event_Mouse_Move *obj
|
# cdef Evas_Event_Mouse_Move *obj
|
||||||
cdef readonly EventPosition position
|
# cdef readonly EventPosition position
|
||||||
cdef readonly EventPosition prev_position
|
# cdef readonly EventPosition prev_position
|
||||||
|
|
||||||
cdef void _set_obj(self, void *ptr)
|
# cdef void _set_obj(self, void *ptr)
|
||||||
cdef void _unset_obj(self)
|
# cdef void _unset_obj(self)
|
||||||
cdef int _check_validity(self) except 0
|
# cdef int _check_validity(self) except 0
|
||||||
|
|
||||||
|
|
||||||
cdef class EventMultiDown:
|
#cdef class EventMultiDown:
|
||||||
cdef Evas_Event_Multi_Down *obj
|
# cdef Evas_Event_Multi_Down *obj
|
||||||
cdef readonly EventPrecisionPosition position
|
# cdef readonly EventPrecisionPosition position
|
||||||
|
|
||||||
cdef void _set_obj(self, void *ptr)
|
# cdef void _set_obj(self, void *ptr)
|
||||||
cdef void _unset_obj(self)
|
# cdef void _unset_obj(self)
|
||||||
cdef int _check_validity(self) except 0
|
# cdef int _check_validity(self) except 0
|
||||||
|
|
||||||
|
|
||||||
cdef class EventMultiUp:
|
#cdef class EventMultiUp:
|
||||||
cdef Evas_Event_Multi_Up *obj
|
# cdef Evas_Event_Multi_Up *obj
|
||||||
cdef readonly EventPrecisionPosition position
|
# cdef readonly EventPrecisionPosition position
|
||||||
|
|
||||||
cdef void _set_obj(self, void *ptr)
|
# cdef void _set_obj(self, void *ptr)
|
||||||
cdef void _unset_obj(self)
|
# cdef void _unset_obj(self)
|
||||||
cdef int _check_validity(self) except 0
|
# cdef int _check_validity(self) except 0
|
||||||
|
|
||||||
|
|
||||||
cdef class EventMultiMove:
|
#cdef class EventMultiMove:
|
||||||
cdef Evas_Event_Multi_Move *obj
|
# cdef Evas_Event_Multi_Move *obj
|
||||||
cdef readonly EventPrecisionPosition position
|
# cdef readonly EventPrecisionPosition position
|
||||||
|
|
||||||
cdef void _set_obj(self, void *ptr)
|
# cdef void _set_obj(self, void *ptr)
|
||||||
cdef void _unset_obj(self)
|
# cdef void _unset_obj(self)
|
||||||
cdef int _check_validity(self) except 0
|
# cdef int _check_validity(self) except 0
|
||||||
|
|
||||||
|
|
||||||
cdef class EventMouseWheel:
|
#cdef class EventMouseWheel:
|
||||||
cdef Evas_Event_Mouse_Wheel *obj
|
# cdef Evas_Event_Mouse_Wheel *obj
|
||||||
cdef readonly EventPosition position
|
# cdef readonly EventPosition position
|
||||||
|
|
||||||
cdef void _set_obj(self, void *ptr)
|
# cdef void _set_obj(self, void *ptr)
|
||||||
cdef void _unset_obj(self)
|
# cdef void _unset_obj(self)
|
||||||
cdef int _check_validity(self) except 0
|
# cdef int _check_validity(self) except 0
|
||||||
|
|
||||||
|
|
||||||
cdef class EventKeyDown:
|
#cdef class EventKeyDown:
|
||||||
cdef Evas_Event_Key_Down *obj
|
# cdef Evas_Event_Key_Down *obj
|
||||||
|
|
||||||
cdef void _set_obj(self, void *ptr)
|
# cdef void _set_obj(self, void *ptr)
|
||||||
cdef void _unset_obj(self)
|
# cdef void _unset_obj(self)
|
||||||
cdef int _check_validity(self) except 0
|
# cdef int _check_validity(self) except 0
|
||||||
|
|
||||||
|
|
||||||
cdef class EventKeyUp:
|
#cdef class EventKeyUp:
|
||||||
cdef Evas_Event_Key_Up *obj
|
# cdef Evas_Event_Key_Up *obj
|
||||||
|
|
||||||
cdef void _set_obj(self, void *ptr)
|
# cdef void _set_obj(self, void *ptr)
|
||||||
cdef void _unset_obj(self)
|
# cdef void _unset_obj(self)
|
||||||
cdef int _check_validity(self) except 0
|
# cdef int _check_validity(self) except 0
|
||||||
|
|
||||||
|
|
||||||
cdef class EventHold:
|
#cdef class EventHold:
|
||||||
cdef Evas_Event_Hold *obj
|
# cdef Evas_Event_Hold *obj
|
||||||
|
|
||||||
cdef void _set_obj(self, void *ptr)
|
# cdef void _set_obj(self, void *ptr)
|
||||||
cdef void _unset_obj(self)
|
# cdef void _unset_obj(self)
|
||||||
cdef int _check_validity(self) except 0
|
# cdef int _check_validity(self) except 0
|
||||||
|
|
|
@ -71,12 +71,15 @@ mapping_in = {
|
||||||
"Eo": "_Eo_Base",
|
"Eo": "_Eo_Base",
|
||||||
}
|
}
|
||||||
|
|
||||||
conversions_in = {
|
conversions_in_python = {
|
||||||
# c_type: conversion
|
# c_type: conversion
|
||||||
"bool": None,
|
|
||||||
"char": "if isinstance({0}, unicode): {0} = PyUnicode_AsUTF8String({0})",
|
"char": "if isinstance({0}, unicode): {0} = PyUnicode_AsUTF8String({0})",
|
||||||
"Evas_Object": None,
|
}
|
||||||
"Eo": None,
|
|
||||||
|
conversions_in_c = {
|
||||||
|
# c_type: conversion
|
||||||
|
"Evas_Object": "instance_from_object({0})",
|
||||||
|
"Eo": "instance_from_object({0})",
|
||||||
}
|
}
|
||||||
|
|
||||||
mapping_out = {
|
mapping_out = {
|
||||||
|
@ -93,7 +96,7 @@ conversions_out = {
|
||||||
"bool": "bool({0})",
|
"bool": "bool({0})",
|
||||||
"char": '{0}.decode("utf-8")',
|
"char": '{0}.decode("utf-8")',
|
||||||
"Elm_Object_Item *": 'object_item_to_python({0})',
|
"Elm_Object_Item *": 'object_item_to_python({0})',
|
||||||
"Evas_Object *": 'object_from_instance({0})',
|
"Evas_Object": 'object_from_instance({0})',
|
||||||
"Eo": 'object_from_instance({0})',
|
"Eo": 'object_from_instance({0})',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,14 +105,20 @@ def conv_cls_name(cls):
|
||||||
if cls.namespaces:
|
if cls.namespaces:
|
||||||
lib_name = ".".join(map(unicode.lower, cls.namespaces))
|
lib_name = ".".join(map(unicode.lower, cls.namespaces))
|
||||||
name = cls.name
|
name = cls.name
|
||||||
|
if name[0].isdigit():
|
||||||
|
name = "_".join(cls.namespaces) + name
|
||||||
else:
|
else:
|
||||||
s = cls.name.split("_")
|
s = cls.name.split("_")
|
||||||
if len(s) > 1:
|
if len(s) > 1:
|
||||||
lib_name = s[0]
|
lib_name = s[0]
|
||||||
name = "_".join(s[1:])
|
name = "_".join(s[1:])
|
||||||
|
if name[0].isdigit():
|
||||||
|
name = lib_name + name
|
||||||
else:
|
else:
|
||||||
lib_name = s
|
lib_name = s
|
||||||
name = s
|
name = s
|
||||||
|
if name[0].isdigit():
|
||||||
|
name = "A" + name
|
||||||
|
|
||||||
return lib_name, name
|
return lib_name, name
|
||||||
|
|
||||||
|
@ -125,19 +134,26 @@ def convert_in_param(tp, param_name, is_nonull=None):
|
||||||
if tp.type == eolian.TypeType.POINTER:
|
if tp.type == eolian.TypeType.POINTER:
|
||||||
tp = tp.base_type
|
tp = tp.base_type
|
||||||
if tp.type == eolian.TypeType.CLASS:
|
if tp.type == eolian.TypeType.CLASS:
|
||||||
return None, "Eo", "{0}.obj".format(param_name)
|
return None, "_Eo", "instance_from_object({0})".format(param_name)
|
||||||
|
|
||||||
key = tp.name if tp.name else c_type
|
key = tp.name if tp.name else c_type
|
||||||
|
|
||||||
if key in builtin_types:
|
if key in builtin_types:
|
||||||
return "", c_type, param_name
|
return None, c_type, param_name
|
||||||
|
|
||||||
if not key in mapping_in:
|
if not key in mapping_in:
|
||||||
raise EolianTypeError("Unknown IN type: %s" % (key))
|
raise EolianTypeError("Unknown IN type: %s" % (key))
|
||||||
|
|
||||||
conv_expr = conversions_in.get(key)
|
conv_expr_1 = conversions_in_python.get(key)
|
||||||
if conv_expr is not None:
|
if conv_expr_1 is not None:
|
||||||
conv_expr = conv_expr.format(param_name)
|
conv_expr_1 = conv_expr_1.format(param_name)
|
||||||
|
|
||||||
|
if keyword.iskeyword(param_name):
|
||||||
|
param_name += "_"
|
||||||
|
|
||||||
|
conv_expr_2 = conversions_in_c.get(key)
|
||||||
|
if conv_expr_2 is not None:
|
||||||
|
param_name = conv_expr_2.format(param_name)
|
||||||
|
|
||||||
conv_t = mapping_in[key]
|
conv_t = mapping_in[key]
|
||||||
#if conv_t is None:
|
#if conv_t is None:
|
||||||
|
@ -146,18 +162,14 @@ def convert_in_param(tp, param_name, is_nonull=None):
|
||||||
if not is_nonull:
|
if not is_nonull:
|
||||||
key = "<{0}>{1} if {1} is not None else NULL".format(c_type, param_name)
|
key = "<{0}>{1} if {1} is not None else NULL".format(c_type, param_name)
|
||||||
|
|
||||||
if keyword.iskeyword(param_name):
|
return conv_expr_1, conv_t, param_name
|
||||||
param_name += "_"
|
|
||||||
|
|
||||||
return conv_expr, conv_t, param_name
|
|
||||||
|
|
||||||
|
|
||||||
def convert_out_param(tp, param_name):
|
def convert_out_param(tp, param_name):
|
||||||
if tp.type == eolian.TypeType.POINTER:
|
if tp.type == eolian.TypeType.POINTER:
|
||||||
tp = tp.base_type
|
tp = tp.base_type
|
||||||
if tp.type == eolian.TypeType.CLASS:
|
if tp.type == eolian.TypeType.CLASS:
|
||||||
# TODO: set obj
|
return tp.c_type, "object_from_instance(%s)" % (param_name)
|
||||||
return tp.c_type, param_name
|
|
||||||
|
|
||||||
key = tp.name if tp.name else tp.c_type
|
key = tp.name if tp.name else tp.c_type
|
||||||
|
|
||||||
|
@ -204,25 +216,23 @@ def event_conversion_get(tp):
|
||||||
if tp.type == eolian.TypeType.POINTER:
|
if tp.type == eolian.TypeType.POINTER:
|
||||||
tp = tp.base_type
|
tp = tp.base_type
|
||||||
if tp.type == eolian.TypeType.STRUCT:
|
if tp.type == eolian.TypeType.STRUCT:
|
||||||
#return "EventInfo%s" % tp.name
|
|
||||||
return "return <dict><%s>" % tp.c_type
|
return "return <dict><%s>" % tp.c_type
|
||||||
elif tp.type == eolian.TypeType.REGULAR:
|
elif tp.type == eolian.TypeType.REGULAR:
|
||||||
def get_alias(tp1):
|
def get_alias(tp1):
|
||||||
#print(tp1.name, tp1.type)
|
|
||||||
alias = eolian.Type.alias_get_by_name(tp1.full_name)
|
alias = eolian.Type.alias_get_by_name(tp1.full_name)
|
||||||
if not alias:
|
if not alias:
|
||||||
log.error("Unhandled event %s type %s" % (tp.c_type, tp.type))
|
log.warn("Unhandled event %s type %s" % (tp.c_type, tp.type))
|
||||||
return
|
return
|
||||||
tp2 = alias.base_type
|
tp2 = alias.base_type
|
||||||
if tp2.type == eolian.TypeType.UNKNOWN:
|
if tp2.type == eolian.TypeType.UNKNOWN:
|
||||||
log.error("UGH")
|
log.error("Event type unknown?!? %s" % (tp.c_type))
|
||||||
|
return
|
||||||
elif tp2.type == eolian.TypeType.STRUCT:
|
elif tp2.type == eolian.TypeType.STRUCT:
|
||||||
#print(tp2.name, tp2.c_type)
|
|
||||||
ret = "<dict>tmp"
|
ret = "<dict>tmp"
|
||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
return get_alias(tp2)
|
return get_alias(tp2)
|
||||||
return get_alias(tp)
|
return get_alias(tp)
|
||||||
else:
|
else:
|
||||||
log.error("Unhandled event type %s" % (tp.type))
|
log.warn("Unhandled event type %s" % (tp.type))
|
||||||
return
|
return
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import textwrap
|
import textwrap
|
||||||
import keyword
|
from keyword import iskeyword
|
||||||
#from traceback import format_exc
|
#from traceback import format_exc
|
||||||
|
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
@ -179,7 +179,7 @@ class PyxGenerator(Generator):
|
||||||
self.write(")")
|
self.write(")")
|
||||||
self.dedent()
|
self.dedent()
|
||||||
|
|
||||||
self.write("_eo_do_end(self.obj)")
|
self.write("_eo_do_end(&self.obj)")
|
||||||
|
|
||||||
|
|
||||||
class Function(object):
|
class Function(object):
|
||||||
|
@ -197,30 +197,43 @@ class Function(object):
|
||||||
|
|
||||||
self.c_params = []
|
self.c_params = []
|
||||||
|
|
||||||
|
ret_type = None
|
||||||
ftypes = eolian.FunctionType
|
ftypes = eolian.FunctionType
|
||||||
if (func.type == ftypes.PROP_SET or func.type == ftypes.PROPERTY) and not isget:
|
if (func.type == ftypes.PROP_SET or func.type == ftypes.PROPERTY) and not isget:
|
||||||
ret_type = func.return_type_get(eolian.FunctionType.PROP_SET)
|
ret_type = func.return_type_get(eolian.FunctionType.PROP_SET)
|
||||||
self.c_name += "_set"
|
self.c_name += "_set"
|
||||||
for p in func.parameters:
|
for p in func.parameters:
|
||||||
self.c_params.append((p.type.c_type, p.name))
|
name = p.name
|
||||||
|
if iskeyword(name):
|
||||||
|
name += "_"
|
||||||
|
self.c_params.append((p.type.c_type, name))
|
||||||
if (func.type == ftypes.PROP_GET or func.type == ftypes.PROPERTY) and isget:
|
if (func.type == ftypes.PROP_GET or func.type == ftypes.PROPERTY) and isget:
|
||||||
ret_type = func.return_type_get(eolian.FunctionType.PROP_GET)
|
ret_type = func.return_type_get(eolian.FunctionType.PROP_GET)
|
||||||
self.c_name += "_get"
|
self.c_name += "_get"
|
||||||
for p in func.parameters:
|
for p in func.parameters:
|
||||||
self.c_params.append((p.type.c_type + "*", p.name))
|
name = p.name
|
||||||
else:
|
if iskeyword(name):
|
||||||
|
name += "_"
|
||||||
|
self.c_params.append((p.type.c_type + "*", name))
|
||||||
|
if func.type == ftypes.METHOD:
|
||||||
ret_type = func.return_type_get(eolian.FunctionType.METHOD)
|
ret_type = func.return_type_get(eolian.FunctionType.METHOD)
|
||||||
for p in func.parameters:
|
for p in func.parameters:
|
||||||
self.c_params.append((p.type.c_type, p.name))
|
name = p.name
|
||||||
|
if iskeyword(name):
|
||||||
|
name += "_"
|
||||||
|
c_type = p.type.c_type
|
||||||
|
if p.direction == eolian.ParameterDir.OUT:
|
||||||
|
c_type += "*"
|
||||||
|
self.c_params.append((c_type, name))
|
||||||
|
|
||||||
self.c_ret_type = ret_type.c_type if ret_type else "void"
|
self.c_ret_type = ret_type.c_type if ret_type else "void"
|
||||||
|
|
||||||
def cdef_generate(self, gen):
|
def cdef_generate(self, gen):
|
||||||
func = self.func
|
func = self.func
|
||||||
ftypes = eolian.FunctionType
|
ftypes = eolian.FunctionType
|
||||||
if (func.type == ftypes.PROP_SET or func.type == ftypes.PROPERTY) and self.isget:
|
if func.type == ftypes.PROP_SET and self.isget:
|
||||||
return
|
return
|
||||||
if (func.type == ftypes.PROP_GET or func.type == ftypes.PROPERTY) and not self.isget:
|
if func.type == ftypes.PROP_GET and not self.isget:
|
||||||
return
|
return
|
||||||
rtype = self.c_ret_type
|
rtype = self.c_ret_type
|
||||||
if not rtype:
|
if not rtype:
|
||||||
|
@ -241,7 +254,7 @@ class Function(object):
|
||||||
c_call_params = []
|
c_call_params = []
|
||||||
return_params = []
|
return_params = []
|
||||||
expand_params = []
|
expand_params = []
|
||||||
conv_in_exps = []
|
conv_in_py_exps = []
|
||||||
|
|
||||||
out_cdefs = []
|
out_cdefs = []
|
||||||
|
|
||||||
|
@ -252,7 +265,7 @@ class Function(object):
|
||||||
if func.type == ftypes.METHOD:
|
if func.type == ftypes.METHOD:
|
||||||
|
|
||||||
py_name = func.name
|
py_name = func.name
|
||||||
if keyword.iskeyword(py_name): # Check if name is python reserved
|
if iskeyword(py_name): # Check if name is python reserved
|
||||||
py_name += "_"
|
py_name += "_"
|
||||||
|
|
||||||
func_params = func.parameters
|
func_params = func.parameters
|
||||||
|
@ -262,51 +275,77 @@ class Function(object):
|
||||||
di = p.direction
|
di = p.direction
|
||||||
c_type = p.type.c_type
|
c_type = p.type.c_type
|
||||||
|
|
||||||
|
p_name = p.name
|
||||||
|
if iskeyword(p_name):
|
||||||
|
p_name += "_"
|
||||||
|
|
||||||
if di == eolian.ParameterDir.IN:
|
if di == eolian.ParameterDir.IN:
|
||||||
conv_expr, c_type, name = convert_in_param(p.type, p.name, p.is_nonull)
|
conv_expr_py, c_type, name = convert_in_param(p.type, p_name, p.is_nonull)
|
||||||
conv_in_exps.append(conv_expr)
|
conv_in_py_exps.append(conv_expr_py)
|
||||||
header_params.append((c_type, p.name))
|
header_params.append((c_type, p_name))
|
||||||
c_call_params.append(name)
|
c_call_params.append(name)
|
||||||
elif di == eolian.ParameterDir.OUT:
|
elif di == eolian.ParameterDir.OUT:
|
||||||
out_cdefs.append((c_type, p.name))
|
out_cdefs.append((c_type, p.name))
|
||||||
c_type, name = convert_out_param(p.type, p.name)
|
c_type, name = convert_out_param(p.type, p_name)
|
||||||
c_call_params.append("&" + name)
|
c_call_params.append("&" + name)
|
||||||
return_params.append((p.type, name))
|
return_params.append((p.type, name))
|
||||||
elif di == eolian.ParameterDir.INOUT:
|
elif di == eolian.ParameterDir.INOUT:
|
||||||
conv_expr, c_type, name = convert_in_param(p.type, p.name, p.is_nonull)
|
conv_expr_py, c_type, name = convert_in_param(p.type, p_name, p.is_nonull)
|
||||||
header_params.append((c_type, p.name))
|
header_params.append((c_type, p_name))
|
||||||
c_call_params.append(name)
|
c_call_params.append(name)
|
||||||
c_type, name = convert_out_param(p.type, p.name)
|
c_type, name = convert_out_param(p.type, p_name)
|
||||||
return_params.append((p.type, p.name))
|
return_params.append((p.type, p_name))
|
||||||
|
|
||||||
ret_type = func.return_type_get(eolian.FunctionType.METHOD)
|
ret_type = func.return_type_get(eolian.FunctionType.METHOD)
|
||||||
|
|
||||||
if (func.type == ftypes.PROP_SET or func.type == ftypes.PROPERTY) and not self.isget:
|
if (func.type == ftypes.PROP_SET or func.type == ftypes.PROPERTY) and not self.isget:
|
||||||
py_name = "__set__"
|
py_name = "__set__"
|
||||||
c_name = "_".join((c_name, "set"))
|
|
||||||
expand_params = []
|
expand_params = []
|
||||||
|
|
||||||
for p in list(func.property_values) + list(func.property_keys):
|
for p in list(func.property_values) + list(func.property_keys):
|
||||||
conv_expr, c_type, name = convert_in_param(p.type, p.name, p.is_nonull)
|
|
||||||
|
|
||||||
conv_in_exps.append(conv_expr)
|
p_name = p.name
|
||||||
expand_params.append(p.name)
|
if iskeyword(p_name):
|
||||||
c_call_params.append(p.name)
|
p_name += "_"
|
||||||
|
|
||||||
|
try:
|
||||||
|
conv_expr_py, c_type, name = convert_in_param(p.type, p_name, p.is_nonull)
|
||||||
|
except Exception:
|
||||||
|
gen.method_header_write(py_name, (("", "value"),))
|
||||||
|
gen.indent()
|
||||||
|
gen.write("pass")
|
||||||
|
gen.dedent()
|
||||||
|
raise
|
||||||
|
|
||||||
|
conv_in_py_exps.append(conv_expr_py)
|
||||||
|
expand_params.append((c_type, p_name))
|
||||||
|
c_call_params.append(name)
|
||||||
|
|
||||||
header_params = (("", "value"),)
|
header_params = (("", "value"),)
|
||||||
ret_type = func.return_type_get(eolian.FunctionType.PROP_SET)
|
#ret_type = func.return_type_get(eolian.FunctionType.PROP_SET)
|
||||||
|
|
||||||
if (func.type == ftypes.PROP_GET or func.type == ftypes.PROPERTY) and self.isget:
|
if (func.type == ftypes.PROP_GET or func.type == ftypes.PROPERTY) and self.isget:
|
||||||
py_name = "__get__"
|
py_name = "__get__"
|
||||||
c_name = "_".join((c_name, "get"))
|
|
||||||
|
|
||||||
for p in list(func.property_values) + list(func.property_keys):
|
for p in list(func.property_values) + list(func.property_keys):
|
||||||
|
|
||||||
c_type = p.type.c_type
|
c_type = p.type.c_type
|
||||||
name = p.name
|
name = p.name
|
||||||
|
if iskeyword(name):
|
||||||
|
name += "_"
|
||||||
|
|
||||||
out_cdefs.append((c_type, name))
|
out_cdefs.append((c_type, name))
|
||||||
c_call_params.append("&%s" % (name))
|
c_call_params.append("&%s" % (name))
|
||||||
c_type, name = convert_out_param(p.type, name)
|
|
||||||
|
try:
|
||||||
|
c_type, name = convert_out_param(p.type, name)
|
||||||
|
except Exception:
|
||||||
|
gen.method_header_write(py_name, header_params)
|
||||||
|
gen.indent()
|
||||||
|
gen.write("pass")
|
||||||
|
gen.dedent()
|
||||||
|
raise
|
||||||
|
|
||||||
return_params.append((p.type, name))
|
return_params.append((p.type, name))
|
||||||
|
|
||||||
ret_type = func.return_type_get(eolian.FunctionType.PROP_GET)
|
ret_type = func.return_type_get(eolian.FunctionType.PROP_GET)
|
||||||
|
@ -318,10 +357,16 @@ class Function(object):
|
||||||
gen.indent()
|
gen.indent()
|
||||||
|
|
||||||
if expand_params:
|
if expand_params:
|
||||||
expand_params = ", ".join(expand_params)
|
tmp_prms = ", ".join(["tmp_prm%d" % (i) for i in range(len(expand_params))])
|
||||||
gen.write("%s = value" % (expand_params))
|
gen.write("%s = value" % (tmp_prms))
|
||||||
|
gen.write("cdef:")
|
||||||
|
gen.indent()
|
||||||
|
for i, (t, n) in enumerate(expand_params):
|
||||||
|
gen.write("%s %s = tmp_prm%d" % (t, n, i))
|
||||||
|
|
||||||
for e in conv_in_exps:
|
gen.dedent()
|
||||||
|
|
||||||
|
for e in conv_in_py_exps:
|
||||||
if e:
|
if e:
|
||||||
gen.write(e)
|
gen.write(e)
|
||||||
|
|
||||||
|
@ -337,13 +382,21 @@ class Function(object):
|
||||||
if return_params:
|
if return_params:
|
||||||
rparams = []
|
rparams = []
|
||||||
for t, n in return_params:
|
for t, n in return_params:
|
||||||
py_ret_type, c_ret_type = conv_type_ret(t)
|
name = n
|
||||||
rparams.append((c_ret_type, n))
|
if iskeyword(name):
|
||||||
|
name += "_"
|
||||||
|
try:
|
||||||
|
py_ret_type, c_ret_type = conv_type_ret(t)
|
||||||
|
except EolianTypeError:
|
||||||
|
gen.write("# FIXME: Unknown return type %s" % t.c_type)
|
||||||
|
gen.dedent()
|
||||||
|
raise
|
||||||
|
rparams.append((c_ret_type, name))
|
||||||
gen.write("return %s" % (", ".join([r[1] for r in rparams])))
|
gen.write("return %s" % (", ".join([r[1] for r in rparams])))
|
||||||
elif ret_type:
|
elif ret_type:
|
||||||
ret = self.RET_PARAM
|
ret = self.RET_PARAM
|
||||||
try:
|
try:
|
||||||
ret_type = convert_out_param(ret_type, ret)
|
ret_type, ret = convert_out_param(ret_type, ret)
|
||||||
except EolianTypeError:
|
except EolianTypeError:
|
||||||
gen.write("# FIXME: Unknown return type %s" % ret_type.c_type)
|
gen.write("# FIXME: Unknown return type %s" % ret_type.c_type)
|
||||||
gen.dedent()
|
gen.dedent()
|
||||||
|
@ -403,27 +456,24 @@ class Property(object):
|
||||||
try:
|
try:
|
||||||
self.getter.generate(gen)
|
self.getter.generate(gen)
|
||||||
self.setter.generate(gen)
|
self.setter.generate(gen)
|
||||||
except Exception:
|
|
||||||
gen.write("pass")
|
|
||||||
gen.write()
|
|
||||||
raise
|
|
||||||
finally:
|
finally:
|
||||||
gen.dedent()
|
gen.dedent()
|
||||||
|
|
||||||
|
|
||||||
class Constructor(object):
|
class Constructor(object):
|
||||||
|
|
||||||
def __init__(self, ctors, prefix):
|
def __init__(self, ctors, prefix, clsgetter):
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
self.ctors = ctors
|
self.ctors = ctors
|
||||||
|
self.clsgetter = clsgetter
|
||||||
|
|
||||||
def cdef_generate(self, gen):
|
def cdef_generate(self, gen):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def generate(self, gen):
|
def generate(self, gen):
|
||||||
cls_get = self.prefix + "_class_get()"
|
cls_get = self.clsgetter
|
||||||
|
|
||||||
header_params = [("_Base", "parent=None")]
|
header_params = [("_Eo", "parent=None")]
|
||||||
c_ctors = []
|
c_ctors = []
|
||||||
|
|
||||||
for ctor in self.ctors:
|
for ctor in self.ctors:
|
||||||
|
@ -434,7 +484,7 @@ class Constructor(object):
|
||||||
c_call_params = []
|
c_call_params = []
|
||||||
|
|
||||||
py_name = func.name
|
py_name = func.name
|
||||||
if keyword.iskeyword(py_name): # Check if name is python reserved
|
if iskeyword(py_name): # Check if name is python reserved
|
||||||
py_name += "_"
|
py_name += "_"
|
||||||
|
|
||||||
ftypes = eolian.FunctionType
|
ftypes = eolian.FunctionType
|
||||||
|
@ -447,7 +497,7 @@ class Constructor(object):
|
||||||
|
|
||||||
c_type = p.type.c_type
|
c_type = p.type.c_type
|
||||||
|
|
||||||
conv_expr, c_type, name = convert_in_param(p.type, p.name, p.is_nonull)
|
conv_expr_py, c_type, name = convert_in_param(p.type, p.name, p.is_nonull)
|
||||||
header_params.append((c_type, p.name))
|
header_params.append((c_type, p.name))
|
||||||
c_call_params.append(name)
|
c_call_params.append(name)
|
||||||
|
|
||||||
|
@ -457,14 +507,14 @@ class Constructor(object):
|
||||||
gen.write("def __init__(self, %s):" % (", ".join([" ".join((t, n)).strip() for t, n in header_params])))
|
gen.write("def __init__(self, %s):" % (", ".join([" ".join((t, n)).strip() for t, n in header_params])))
|
||||||
gen.indent()
|
gen.indent()
|
||||||
|
|
||||||
gen.write("cdef Eo *obj = eo_add_ref(")
|
gen.write("cdef Eo *added_obj = eo_add_ref(")
|
||||||
gen.indent()
|
gen.indent()
|
||||||
gen.write("%s, parent.obj if parent is not None else NULL," % (cls_get))
|
gen.write("%s(), parent.obj if parent is not None else NULL," % (cls_get))
|
||||||
for ctor in c_ctors:
|
for ctor in c_ctors:
|
||||||
gen.write("%s(%s)" % (ctor[0], ctor[1]))
|
gen.write("%s(%s)" % (ctor[0], ctor[1]))
|
||||||
gen.write(")")
|
gen.write(")")
|
||||||
gen.dedent()
|
gen.dedent()
|
||||||
gen.write("self._set_obj(obj)")
|
gen.write("self._set_obj(added_obj)")
|
||||||
|
|
||||||
gen.dedent()
|
gen.dedent()
|
||||||
gen.write()
|
gen.write()
|
||||||
|
@ -492,6 +542,7 @@ class Class(object):
|
||||||
self.c_name = cls.name
|
self.c_name = cls.name
|
||||||
self.full_c_name = cls.full_name
|
self.full_c_name = cls.full_name
|
||||||
self.lib_name, self.name = conv_cls_name(cls)
|
self.lib_name, self.name = conv_cls_name(cls)
|
||||||
|
self.cls_getter = cls.c_get_function_name
|
||||||
|
|
||||||
header_path = cls.filename
|
header_path = cls.filename
|
||||||
if not header_path:
|
if not header_path:
|
||||||
|
@ -511,7 +562,7 @@ class Class(object):
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
|
|
||||||
if cls.type == eolian.ClassType.REGULAR: # or cls.type == eolian.ClassType.MIXIN:
|
if cls.type == eolian.ClassType.REGULAR: # or cls.type == eolian.ClassType.MIXIN:
|
||||||
self.ctor.append(Constructor(cls.constructors, prefix))
|
self.ctor.append(Constructor(cls.constructors, prefix, cls.c_get_function_name))
|
||||||
|
|
||||||
props = cls.functions_get(eolian.FunctionType.PROPERTY)
|
props = cls.functions_get(eolian.FunctionType.PROPERTY)
|
||||||
for prop in props:
|
for prop in props:
|
||||||
|
@ -558,7 +609,9 @@ class Class(object):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def cdefs_generate(self, gen):
|
def cdefs_generate(self, gen):
|
||||||
if self.ctor or self.methods or self.props:
|
gen.write("const Eo_Class *%s()" % (self.cls_getter))
|
||||||
|
# gen.write("ctypedef Eo %s" % (self.full_c_name.replace(".", "_")))
|
||||||
|
if self.ctor or self.methods or self.props or self.events:
|
||||||
for o in self.ctor + self.methods + self.props + self.events:
|
for o in self.ctor + self.methods + self.props + self.events:
|
||||||
try:
|
try:
|
||||||
o.cdef_generate(gen)
|
o.cdef_generate(gen)
|
||||||
|
@ -574,10 +627,9 @@ class Class(object):
|
||||||
i_cls.type == eolian.ClassType.MIXIN:
|
i_cls.type == eolian.ClassType.MIXIN:
|
||||||
continue
|
continue
|
||||||
if i_cls.full_name == "Eo.Base":
|
if i_cls.full_name == "Eo.Base":
|
||||||
inherits.append("Eo")
|
inherits.append("_Eo")
|
||||||
continue
|
continue
|
||||||
lib_name, name = conv_cls_name(i_cls)
|
lib_name, name = conv_cls_name(i_cls)
|
||||||
#i = i.rpartition(".")[2]
|
|
||||||
inherits.append("_" + name)
|
inherits.append("_" + name)
|
||||||
else:
|
else:
|
||||||
log.warn("Inherited class %s is unknown" % (i))
|
log.warn("Inherited class %s is unknown" % (i))
|
||||||
|
@ -591,11 +643,15 @@ class Class(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not inherits:
|
if not inherits:
|
||||||
inherits = ("object", )
|
inherits = ("_Eo", )
|
||||||
inherits = ", ".join(inherits)
|
inherits = ", ".join(inherits)
|
||||||
|
|
||||||
gen.write("cdef class _%s(%s):" % (self.name, inherits))
|
gen.write("cdef class _%s(%s):" % (self.name, inherits))
|
||||||
gen.indent()
|
gen.indent()
|
||||||
|
gen.write()
|
||||||
|
|
||||||
|
# gen.write("cdef %s *ext_cls_obj" % self.full_c_name.replace(".", "_"))
|
||||||
|
# gen.write()
|
||||||
|
|
||||||
if self.events:
|
if self.events:
|
||||||
gen.write("def __cinit__(self):")
|
gen.write("def __cinit__(self):")
|
||||||
|
@ -649,9 +705,10 @@ class Class(object):
|
||||||
gen.dedent()
|
gen.dedent()
|
||||||
gen.write()
|
gen.write()
|
||||||
|
|
||||||
#def py_generate(self, gen):
|
# --- Py class
|
||||||
inherits = ["_" + self.name]
|
inherits = ["_" + self.name]
|
||||||
imports = [(self.lib_name, "_" + self.name)]
|
#imports = [(self.lib_name, "_" + self.name)]
|
||||||
|
imports = []
|
||||||
for i in self.inherits:
|
for i in self.inherits:
|
||||||
i_cls = eolian.Class.get_by_name(i)
|
i_cls = eolian.Class.get_by_name(i)
|
||||||
if i_cls:
|
if i_cls:
|
||||||
|
@ -659,18 +716,17 @@ class Class(object):
|
||||||
i_cls.type == eolian.ClassType.ABSTRACT:
|
i_cls.type == eolian.ClassType.ABSTRACT:
|
||||||
continue
|
continue
|
||||||
lib_name, name = conv_cls_name(i_cls)
|
lib_name, name = conv_cls_name(i_cls)
|
||||||
#i = i.rpartition(".")[2]
|
|
||||||
else:
|
else:
|
||||||
log.warn("Class %s is unknown" % (i))
|
log.warn("Class %s is unknown" % (i))
|
||||||
i = i.rpartition(".")
|
i = i.rpartition(".")
|
||||||
lib_name, name = i[0], i[2]
|
lib_name, name = i[0], i[2]
|
||||||
|
|
||||||
inherits.append("_" + name)
|
inherits.append(lib_name.replace(".", "_") + "_" + name)
|
||||||
imports.append((lib_name, "_" + name))
|
imports.append((lib_name, "_" + name))
|
||||||
|
|
||||||
for l, n in imports:
|
for l, n in imports:
|
||||||
l = PY_EFL_TOP_LEVEL_PACKAGE + "." + l.lower()
|
l2 = PY_EFL_TOP_LEVEL_PACKAGE + "." + l.lower()
|
||||||
gen.write("from %s import %s" % (l, n))
|
gen.write("from %s import %s as %s" % (l2, n, l.replace(".", "_") + n))
|
||||||
|
|
||||||
gen.write()
|
gen.write()
|
||||||
gen.write()
|
gen.write()
|
||||||
|
@ -714,7 +770,7 @@ class File(object):
|
||||||
for i in eolian.type_aliases_get_by_file(self.filepath):
|
for i in eolian.type_aliases_get_by_file(self.filepath):
|
||||||
base = i.base_type
|
base = i.base_type
|
||||||
if base.type == eolian.TypeType.REGULAR:
|
if base.type == eolian.TypeType.REGULAR:
|
||||||
gen.write("ctypedef %s %s" % (i.name, base.name))
|
gen.write("ctypedef %s %s" % (base.name, i.name))
|
||||||
elif base.type == eolian.TypeType.FUNCTION:
|
elif base.type == eolian.TypeType.FUNCTION:
|
||||||
ret_type = base.return_type
|
ret_type = base.return_type
|
||||||
if ret_type:
|
if ret_type:
|
||||||
|
@ -750,26 +806,26 @@ class File(object):
|
||||||
def pyx_generate(self):
|
def pyx_generate(self):
|
||||||
self.gencls.pyx_generate(self.pyxgen)
|
self.gencls.pyx_generate(self.pyxgen)
|
||||||
|
|
||||||
path = [args.output]
|
path = []
|
||||||
cls_name = self.cls.name.lower()
|
cls_name = self.cls.name.lower()
|
||||||
filename = cls_name + ".pxi"
|
filename = "generated_" + cls_name + ".pxi"
|
||||||
namespaces = []
|
|
||||||
for ns in self.cls.namespaces:
|
for ns in self.cls.namespaces:
|
||||||
namespaces.append(ns.lower())
|
path.append(ns.lower())
|
||||||
if not namespaces:
|
if not path:
|
||||||
log.warning("Class %s has no namespaces defined" % (self.cls.name))
|
log.warning("Class %s has no namespaces defined" % (self.cls.name))
|
||||||
nstmp = cls_name.partition("_")
|
nstmp = cls_name.partition("_")
|
||||||
namespace = nstmp[0]
|
path.append(nstmp[0])
|
||||||
filename = nstmp[2] + ".pxi"
|
filename = "generated_" + nstmp[2] + ".pxi"
|
||||||
else:
|
# else:
|
||||||
namespace = ".".join(namespaces)
|
# namespace = ".".join(namespaces)
|
||||||
filename = ".".join((namespace, filename))
|
# filename = ".".join((namespace, filename))
|
||||||
path.append(filename)
|
# path.append(filename)
|
||||||
pxi_path = os.path.join(*path)
|
path = os.path.join(*path)
|
||||||
|
pxi_path = os.path.join(args.output, path, filename)
|
||||||
|
|
||||||
self.pyxgen.printout(filepath=pxi_path)
|
self.pyxgen.printout(filepath=pxi_path)
|
||||||
|
|
||||||
generated_pxis.setdefault(namespace, []).append(pxi_path)
|
generated_pxis.setdefault(os.path.join(path), []).append((path, filename, self.cls))
|
||||||
|
|
||||||
# def py_generate(self):
|
# def py_generate(self):
|
||||||
# py_path = os.path.join(args.output, "__init__" + ".py")
|
# py_path = os.path.join(args.output, "__init__" + ".py")
|
||||||
|
@ -788,7 +844,7 @@ class Event(object):
|
||||||
|
|
||||||
def generate_name_mapping(self, gen):
|
def generate_name_mapping(self, gen):
|
||||||
gen.write(
|
gen.write(
|
||||||
'eina_hash_set(self.event_desc_mapping, "%s", %s)' % (
|
'eina_hash_add(self.event_desc_mapping, "%s", <const void *>%s)' % (
|
||||||
self.event.name, self.event.c_name
|
self.event.name, self.event.c_name
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -797,7 +853,7 @@ class Event(object):
|
||||||
conv = event_conversion_get(self.event.type)
|
conv = event_conversion_get(self.event.type)
|
||||||
if conv:
|
if conv:
|
||||||
gen.write(
|
gen.write(
|
||||||
'eina_hash_set(self.event_conv_mapping, %s, self._event_conv_%s_to_python)' % (
|
'eina_hash_add(self.event_conv_mapping, %s, <const void *>self._event_conv_%s_to_python)' % (
|
||||||
self.event.c_name, self.event.name.replace(",", "_")
|
self.event.c_name, self.event.name.replace(",", "_")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -824,9 +880,6 @@ generated_class_counter = Counter()
|
||||||
function_counter = Counter()
|
function_counter = Counter()
|
||||||
generated_function_counter = Counter()
|
generated_function_counter = Counter()
|
||||||
|
|
||||||
py_path = os.path.join(args.output, "__init__" + ".py")
|
|
||||||
if os.path.exists(py_path):
|
|
||||||
os.remove(py_path)
|
|
||||||
|
|
||||||
for path in args.paths:
|
for path in args.paths:
|
||||||
for dirpath, dirnames, filenames in os.walk(path):
|
for dirpath, dirnames, filenames in os.walk(path):
|
||||||
|
@ -865,13 +918,18 @@ for path in args.paths:
|
||||||
# continue
|
# continue
|
||||||
|
|
||||||
|
|
||||||
for ns, pxis in generated_pxis.items():
|
for pxis in generated_pxis.values():
|
||||||
filename = os.path.join(args.output, "generated_" + ns + ".pxi")
|
ns, pxi_path, cls = pxis[0]
|
||||||
|
filename = os.path.join(args.output, ns, "generated_classes.pxi")
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
log.error("File %s exists, removing" % (filename))
|
log.warn("File %s exists, removing" % (filename))
|
||||||
|
os.remove(filename)
|
||||||
with open(filename, "a") as f:
|
with open(filename, "a") as f:
|
||||||
for pxi in pxis:
|
# for ns, pxi_path, cls in pxis:
|
||||||
line = 'include "%s"\n' % (pxi)
|
# line = "ctypedef Eo %s\n" % (cls.full_name.replace(".", "_"))
|
||||||
|
# f.write(line)
|
||||||
|
for ns, pxi_path, cls in pxis:
|
||||||
|
line = 'include "%s"\n' % (pxi_path)
|
||||||
f.write(line)
|
f.write(line)
|
||||||
|
|
||||||
|
|
||||||
|
|
220
setup.py
220
setup.py
|
@ -239,6 +239,20 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
|
||||||
packages.append("efl.utils")
|
packages.append("efl.utils")
|
||||||
packages.append("efl.utils.enum")
|
packages.append("efl.utils.enum")
|
||||||
|
|
||||||
|
# === Efl (interfaces) ===
|
||||||
|
eo_cflags, eo_libs = pkg_config('Efl', 'efl', EFL_MIN_VERSION)
|
||||||
|
eo_ext = Extension(
|
||||||
|
"efl.__init__", ["efl/efl/__init__" + module_suffix],
|
||||||
|
define_macros=[
|
||||||
|
('EFL_BETA_API_SUPPORT', 1),
|
||||||
|
('EFL_EO_API_SUPPORT', 1),
|
||||||
|
],
|
||||||
|
include_dirs=['include/'],
|
||||||
|
extra_compile_args=eo_cflags,
|
||||||
|
extra_link_args=eo_libs + eina_libs
|
||||||
|
)
|
||||||
|
modules.append(eo_ext)
|
||||||
|
|
||||||
# === Evas ===
|
# === Evas ===
|
||||||
evas_cflags, evas_libs = pkg_config('Evas', 'evas', EFL_MIN_VERSION)
|
evas_cflags, evas_libs = pkg_config('Evas', 'evas', EFL_MIN_VERSION)
|
||||||
evas_ext = Extension(
|
evas_ext = Extension(
|
||||||
|
@ -249,19 +263,19 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
|
||||||
)
|
)
|
||||||
modules.append(evas_ext)
|
modules.append(evas_ext)
|
||||||
|
|
||||||
# === Ecore ===
|
# # === Ecore ===
|
||||||
ecore_cflags, ecore_libs = pkg_config('Ecore', 'ecore', EFL_MIN_VERSION)
|
# ecore_cflags, ecore_libs = pkg_config('Ecore', 'ecore', EFL_MIN_VERSION)
|
||||||
ecore_file_cflags, ecore_file_libs = pkg_config(
|
# ecore_file_cflags, ecore_file_libs = pkg_config(
|
||||||
'EcoreFile', 'ecore-file', EFL_MIN_VERSION)
|
# 'EcoreFile', 'ecore-file', EFL_MIN_VERSION)
|
||||||
ecore_exts = [
|
# ecore_exts = [
|
||||||
Extension(
|
# Extension(
|
||||||
"ecore.__init__", ["efl/ecore/__init__" + module_suffix],
|
# "ecore.__init__", ["efl/ecore/__init__" + module_suffix],
|
||||||
include_dirs=['include/'],
|
# include_dirs=['include/'],
|
||||||
extra_compile_args=list(set(ecore_cflags + ecore_file_cflags)),
|
# extra_compile_args=list(set(ecore_cflags + ecore_file_cflags)),
|
||||||
extra_link_args=ecore_libs + ecore_file_libs + eina_libs +
|
# extra_link_args=ecore_libs + ecore_file_libs + eina_libs +
|
||||||
evas_libs
|
# evas_libs
|
||||||
),
|
# ),
|
||||||
]
|
# ]
|
||||||
try:
|
try:
|
||||||
ecore_input_cflags, ecore_input_libs = pkg_config(
|
ecore_input_cflags, ecore_input_libs = pkg_config(
|
||||||
'EcoreInput', 'ecore-input', EFL_MIN_VERSION)
|
'EcoreInput', 'ecore-input', EFL_MIN_VERSION)
|
||||||
|
@ -269,88 +283,92 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
|
||||||
'EcoreX', 'ecore-x', EFL_MIN_VERSION)
|
'EcoreX', 'ecore-x', EFL_MIN_VERSION)
|
||||||
except SystemExit: # FIXME: Change pkg-config to return a value
|
except SystemExit: # FIXME: Change pkg-config to return a value
|
||||||
pass
|
pass
|
||||||
else:
|
# else:
|
||||||
ecore_exts.append(
|
# ecore_exts.append(
|
||||||
Extension(
|
# Extension(
|
||||||
"ecore.x", ["efl/ecore/x" + module_suffix],
|
# "ecore.x", ["efl/ecore/x" + module_suffix],
|
||||||
include_dirs=['include/'],
|
# include_dirs=['include/'],
|
||||||
extra_compile_args=
|
# extra_compile_args=
|
||||||
list(set(
|
# list(set(
|
||||||
ecore_cflags + ecore_file_cflags + ecore_x_cflags +
|
# ecore_cflags + ecore_file_cflags + ecore_x_cflags +
|
||||||
ecore_input_cflags
|
# ecore_input_cflags
|
||||||
)),
|
# )),
|
||||||
extra_link_args=
|
# extra_link_args=
|
||||||
ecore_libs + ecore_file_libs + ecore_x_libs +
|
# ecore_libs + ecore_file_libs + ecore_x_libs +
|
||||||
ecore_input_libs +
|
# ecore_input_libs +
|
||||||
eina_libs + evas_libs,
|
# eina_libs + evas_libs,
|
||||||
)
|
# )
|
||||||
)
|
# )
|
||||||
modules += ecore_exts
|
# modules += ecore_exts
|
||||||
packages.append("efl.ecore")
|
# packages.append("efl.ecore")
|
||||||
|
|
||||||
# === Ethumb ===
|
# # === Ethumb ===
|
||||||
ethumb_cflags, ethumb_libs = pkg_config(
|
# ethumb_cflags, ethumb_libs = pkg_config(
|
||||||
'Ethumb', 'ethumb', EFL_MIN_VERSION)
|
# 'Ethumb', 'ethumb', EFL_MIN_VERSION)
|
||||||
ethumb_ext = Extension(
|
# ethumb_ext = Extension(
|
||||||
"ethumb", ["efl/ethumb/efl.ethumb" + module_suffix],
|
# "ethumb", ["efl/ethumb/efl.ethumb" + module_suffix],
|
||||||
include_dirs=['include/'],
|
# include_dirs=['include/'],
|
||||||
extra_compile_args=ethumb_cflags,
|
# extra_compile_args=ethumb_cflags,
|
||||||
extra_link_args=ethumb_libs + eina_libs,
|
# extra_link_args=ethumb_libs + eina_libs,
|
||||||
)
|
# )
|
||||||
modules.append(ethumb_ext)
|
# modules.append(ethumb_ext)
|
||||||
|
|
||||||
ethumb_client_cflags, ethumb_client_libs = pkg_config(
|
# ethumb_client_cflags, ethumb_client_libs = pkg_config(
|
||||||
'Ethumb_Client', 'ethumb_client', EFL_MIN_VERSION)
|
# 'Ethumb_Client', 'ethumb_client', EFL_MIN_VERSION)
|
||||||
ethumb_client_ext = Extension(
|
# ethumb_client_ext = Extension(
|
||||||
"ethumb_client", ["efl/ethumb/efl.ethumb_client" + module_suffix],
|
# "ethumb_client", ["efl/ethumb/efl.ethumb_client" + module_suffix],
|
||||||
include_dirs=['include/'],
|
# include_dirs=['include/'],
|
||||||
extra_compile_args=ethumb_client_cflags,
|
# extra_compile_args=ethumb_client_cflags,
|
||||||
extra_link_args=ethumb_client_libs + eina_libs,
|
# extra_link_args=ethumb_client_libs + eina_libs,
|
||||||
)
|
# )
|
||||||
modules.append(ethumb_client_ext)
|
# modules.append(ethumb_client_ext)
|
||||||
|
|
||||||
# === Edje ===
|
# # === Edje ===
|
||||||
edje_cflags, edje_libs = pkg_config('Edje', 'edje', EFL_MIN_VERSION)
|
# edje_cflags, edje_libs = pkg_config('Edje', 'edje', EFL_MIN_VERSION)
|
||||||
edje_ext = Extension(
|
# edje_ext = Extension(
|
||||||
"edje", ["efl/edje/efl.edje" + module_suffix],
|
# "edje", ["efl/edje/efl.edje" + module_suffix],
|
||||||
include_dirs=['include/'],
|
# include_dirs=['include/'],
|
||||||
extra_compile_args=edje_cflags,
|
# extra_compile_args=edje_cflags,
|
||||||
extra_link_args=edje_libs + eina_libs + evas_libs,
|
# extra_link_args=edje_libs + eina_libs + evas_libs,
|
||||||
)
|
# )
|
||||||
modules.append(edje_ext)
|
# modules.append(edje_ext)
|
||||||
|
|
||||||
# --- Edje_Edit ---
|
# # --- Edje_Edit ---
|
||||||
edje_edit_ext = Extension(
|
# edje_edit_ext = Extension(
|
||||||
"edje_edit", ["efl/edje/efl.edje_edit" + module_suffix],
|
# "edje_edit", ["efl/edje/efl.edje_edit" + module_suffix],
|
||||||
define_macros=[('EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT', None)],
|
# define_macros=[('EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT', None)],
|
||||||
include_dirs=['include/'],
|
# include_dirs=['include/'],
|
||||||
extra_compile_args=edje_cflags,
|
# extra_compile_args=edje_cflags,
|
||||||
extra_link_args=edje_libs + eina_libs + evas_libs,
|
# extra_link_args=edje_libs + eina_libs + evas_libs,
|
||||||
)
|
# )
|
||||||
modules.append(edje_edit_ext)
|
# modules.append(edje_edit_ext)
|
||||||
|
|
||||||
# === Emotion ===
|
# # === Emotion ===
|
||||||
emotion_cflags, emotion_libs = pkg_config(
|
# emotion_cflags, emotion_libs = pkg_config(
|
||||||
'Emotion', 'emotion', EFL_MIN_VERSION)
|
# 'Emotion', 'emotion', EFL_MIN_VERSION)
|
||||||
emotion_ext = Extension(
|
# emotion_ext = Extension(
|
||||||
"emotion", ["efl/emotion/efl.emotion" + module_suffix],
|
# "emotion", ["efl/emotion/efl.emotion" + module_suffix],
|
||||||
include_dirs=['include/'],
|
# define_macros=[
|
||||||
extra_compile_args=emotion_cflags,
|
# ('EFL_BETA_API_SUPPORT', 1),
|
||||||
extra_link_args=emotion_libs +
|
# ('EFL_EO_API_SUPPORT', 1),
|
||||||
eina_libs + evas_libs,
|
# ],
|
||||||
)
|
# include_dirs=['include/'],
|
||||||
modules.append(emotion_ext)
|
# extra_compile_args=emotion_cflags,
|
||||||
|
# extra_link_args=emotion_libs +
|
||||||
|
# eina_libs + evas_libs,
|
||||||
|
# )
|
||||||
|
# modules.append(emotion_ext)
|
||||||
|
|
||||||
# === dbus mainloop integration ===
|
# # === dbus mainloop integration ===
|
||||||
dbus_cflags, dbus_libs = pkg_config('DBus', 'dbus-python', "0.83.0")
|
# dbus_cflags, dbus_libs = pkg_config('DBus', 'dbus-python', "0.83.0")
|
||||||
dbus_ml_ext = Extension(
|
# dbus_ml_ext = Extension(
|
||||||
"dbus_mainloop",
|
# "dbus_mainloop",
|
||||||
["efl/dbus_mainloop/dbus_mainloop" + module_suffix,
|
# ["efl/dbus_mainloop/dbus_mainloop" + module_suffix,
|
||||||
"efl/dbus_mainloop/e_dbus.c"],
|
# "efl/dbus_mainloop/e_dbus.c"],
|
||||||
extra_compile_args=list(set(dbus_cflags + ecore_cflags)),
|
# extra_compile_args=list(set(dbus_cflags + ecore_cflags)),
|
||||||
extra_link_args=dbus_libs + ecore_libs,
|
# extra_link_args=dbus_libs + ecore_libs,
|
||||||
)
|
# )
|
||||||
modules.append(dbus_ml_ext)
|
# modules.append(dbus_ml_ext)
|
||||||
|
|
||||||
# === Elementary ===
|
# === Elementary ===
|
||||||
elm_mods = (
|
elm_mods = (
|
||||||
|
@ -427,19 +445,19 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
|
||||||
"window",
|
"window",
|
||||||
)
|
)
|
||||||
|
|
||||||
elm_cflags, elm_libs = pkg_config(
|
# elm_cflags, elm_libs = pkg_config(
|
||||||
'Elementary', 'elementary', ELM_MIN_VERSION)
|
# 'Elementary', 'elementary', ELM_MIN_VERSION)
|
||||||
for m in elm_mods:
|
# for m in elm_mods:
|
||||||
e = Extension(
|
# e = Extension(
|
||||||
"elementary." + m,
|
# "elementary." + m,
|
||||||
["efl/elementary/" + m + module_suffix],
|
# ["efl/elementary/" + m + module_suffix],
|
||||||
include_dirs=["include/"],
|
# include_dirs=["include/"],
|
||||||
extra_compile_args=elm_cflags + ecore_x_cflags,
|
# extra_compile_args=elm_cflags + ecore_x_cflags,
|
||||||
extra_link_args=elm_libs + eina_libs + evas_libs,
|
# extra_link_args=elm_libs + eina_libs + evas_libs,
|
||||||
)
|
# )
|
||||||
modules.append(e)
|
# modules.append(e)
|
||||||
|
|
||||||
packages.append("efl.elementary")
|
# packages.append("efl.elementary")
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|
Loading…
Reference in New Issue