Eolian: WIP
This commit is contained in:
parent
0c930094cb
commit
c18d8880a0
|
@ -131,7 +131,7 @@
|
||||||
#./elm_app_server.eo
|
#./elm_app_server.eo
|
||||||
#./elm_progressbar.eo
|
#./elm_progressbar.eo
|
||||||
#./elm_atspi_app_object.eo
|
#./elm_atspi_app_object.eo
|
||||||
#./elm_bg.eo
|
./elm_bg.eo
|
||||||
#./elm_photo.eo
|
#./elm_photo.eo
|
||||||
#./elm_bubble.eo
|
#./elm_bubble.eo
|
||||||
#./elm_interface_scrollable.eo
|
#./elm_interface_scrollable.eo
|
||||||
|
@ -141,10 +141,10 @@
|
||||||
#./elm_flip.eo
|
#./elm_flip.eo
|
||||||
#./elm_video.eo
|
#./elm_video.eo
|
||||||
#./elm_gengrid_pan.eo
|
#./elm_gengrid_pan.eo
|
||||||
#./elm_image.eo
|
./elm_image.eo
|
||||||
#./elm_calendar.eo
|
#./elm_calendar.eo
|
||||||
#./elm_naviframe.eo
|
#./elm_naviframe.eo
|
||||||
#./elm_layout.eo
|
./elm_layout.eo
|
||||||
#./elm_map_pan.eo
|
#./elm_map_pan.eo
|
||||||
#./elm_genlist_pan.eo
|
#./elm_genlist_pan.eo
|
||||||
#./elm_interface_atspi_component.eo
|
#./elm_interface_atspi_component.eo
|
||||||
|
|
|
@ -208,7 +208,7 @@ cdef Eina_Bool _py_efl_eo_event_cb(
|
||||||
bint ret
|
bint ret
|
||||||
_Eo o
|
_Eo o
|
||||||
EventDesc py_ev_desc
|
EventDesc py_ev_desc
|
||||||
#EventInfo py_ev_info_obj
|
# EventStruct py_ev_info_obj
|
||||||
|
|
||||||
func = <object>data
|
func = <object>data
|
||||||
o = object_from_instance(obj)
|
o = object_from_instance(obj)
|
||||||
|
@ -216,21 +216,22 @@ cdef Eina_Bool _py_efl_eo_event_cb(
|
||||||
py_ev_desc = EventDesc.__new__(EventDesc)
|
py_ev_desc = EventDesc.__new__(EventDesc)
|
||||||
py_ev_desc.desc = desc
|
py_ev_desc.desc = desc
|
||||||
|
|
||||||
#tmp1 = eina_hash_find(o.event_conv_to_py_mapping, desc)
|
# tmp1 = eina_hash_find(o.event_conv_mapping, desc)
|
||||||
#tmp2 = eina_hash_find(o.event_conv_to_c_mapping, desc)
|
# tmp2 = eina_hash_find(o.event_conv_to_c_mapping, desc)
|
||||||
#if tmp1 == NULL:
|
# if tmp1 == NULL:
|
||||||
# py_ev_info_obj = None
|
# py_ev_info_obj = None
|
||||||
#else:
|
# else:
|
||||||
#py_ev_info_cls = <object>tmp
|
# py_ev_info_cls = <object>tmp1
|
||||||
# use a generic class and set some conv func??
|
# use a generic class and set some conv func??
|
||||||
#py_ev_info_obj = py_ev_info_cls.__new__(py_ev_info_cls)
|
# py_ev_info_obj = py_ev_info_cls.__new__(py_ev_info_cls)
|
||||||
#py_ev_info_obj = EventInfo.__new__(EventInfo)
|
# py_ev_info_obj = EventStruct.__new__(EventStruct)
|
||||||
#py_ev_info_obj.event_info = event_info
|
# py_ev_info_obj.event_info = event_info
|
||||||
#py_ev_info_obj.conv_to_python = tmp1
|
# py_ev_info_obj.conv_to_python_func = tmp1
|
||||||
#py_ev_info_obj.conv_to_c = tmp2
|
# py_ev_info_obj.conv_to_c = tmp2
|
||||||
|
|
||||||
#ret = func(py_ev_desc, py_ev_info_obj) # o as first param?
|
# ret = func(py_ev_desc, py_ev_info_obj) # o as first param?
|
||||||
#return ret
|
ret = func(py_ev_desc, None)
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
cdef class EventDesc(object):
|
cdef class EventDesc(object):
|
||||||
|
@ -253,18 +254,18 @@ cdef class EventDesc(object):
|
||||||
return bool(self.desc.unfreezable)
|
return bool(self.desc.unfreezable)
|
||||||
|
|
||||||
|
|
||||||
#cdef class EventStruct(object):
|
# cdef class EventStruct(object):
|
||||||
|
|
||||||
# cdef:
|
# cdef:
|
||||||
# void *event_info
|
# void *event_info
|
||||||
|
# void *conv_to_python_func
|
||||||
|
|
||||||
# property value:
|
# property value:
|
||||||
# def __get__(self):
|
# def __get__(self):
|
||||||
# return self.conv_to_python(self.event_info)
|
# return self.conv_to_python_func(self.event_info)
|
||||||
|
|
||||||
# def __set__(self, val):
|
# def __set__(self, val):
|
||||||
# self.event_info = self.conv_to_c(val)
|
# self.event_info = self.conv_to_c(val)
|
||||||
|
|
||||||
|
|
||||||
cdef class _Eo(object):
|
cdef class _Eo(object):
|
||||||
|
@ -390,10 +391,13 @@ cdef class _Eo(object):
|
||||||
if desc is NULL:
|
if desc is NULL:
|
||||||
raise RuntimeError("Unknown Eo event name: %s" % (event_name))
|
raise RuntimeError("Unknown Eo event name: %s" % (event_name))
|
||||||
|
|
||||||
eo_event_callback_add(
|
eo_do(
|
||||||
<Eo_Event_Description *>desc,
|
self.obj,
|
||||||
_py_efl_eo_event_cb,
|
eo_event_callback_add(
|
||||||
<const void *>func
|
<Eo_Event_Description *>desc,
|
||||||
|
_py_efl_eo_event_cb,
|
||||||
|
<const void *>func
|
||||||
|
)
|
||||||
)
|
)
|
||||||
Py_INCREF(func)
|
Py_INCREF(func)
|
||||||
|
|
||||||
|
@ -411,9 +415,12 @@ cdef class _Eo(object):
|
||||||
if desc is NULL:
|
if desc is NULL:
|
||||||
raise RuntimeError("Unknown Eo event name: %s" % (event_name))
|
raise RuntimeError("Unknown Eo event name: %s" % (event_name))
|
||||||
|
|
||||||
eo_event_callback_del(
|
eo_do(
|
||||||
<Eo_Event_Description *>desc,
|
self.obj,
|
||||||
_py_efl_eo_event_cb,
|
eo_event_callback_del(
|
||||||
<const void *>func
|
<Eo_Event_Description *>desc,
|
||||||
|
_py_efl_eo_event_cb,
|
||||||
|
<const void *>func
|
||||||
|
)
|
||||||
)
|
)
|
||||||
Py_DECREF(func)
|
Py_DECREF(func)
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
import logging
|
||||||
|
efllog = logging.getLogger("efl")
|
||||||
|
efllog.addHandler(logging.StreamHandler())
|
||||||
|
|
||||||
|
import sys
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
sys.exit("Usage: %s <file1> [file2] ... [fileN]".format(sys.argv[0]))
|
||||||
|
|
||||||
|
w, h = 600, 600
|
||||||
|
|
||||||
|
from efl import elementary as elm
|
||||||
|
elm.init()
|
||||||
|
|
||||||
|
win = elm.Win("pydemo", 1)
|
||||||
|
win.title = "Python demo"
|
||||||
|
win.autodel = False
|
||||||
|
win.size = (w, h)
|
||||||
|
win.event_callback_add("delete,request", lambda x, y: elm.exit())
|
||||||
|
|
||||||
|
bg = elm.Bg(win)
|
||||||
|
bg.size_hint_weight = (1.0, 1.0)
|
||||||
|
win.resize_object_add(bg)
|
||||||
|
bg.show()
|
||||||
|
|
||||||
|
img = elm.Image(win)
|
||||||
|
img.size_hint_weight = (1.0, 1.0)
|
||||||
|
img.smooth = True
|
||||||
|
img.aspect_fixed = True
|
||||||
|
img.file = sys.argv[1], ""
|
||||||
|
img.position = (0, 0)
|
||||||
|
img.size = (w, h)
|
||||||
|
|
||||||
|
file_idx = 1
|
||||||
|
def _mouse_down_cb(*args):
|
||||||
|
global file_idx
|
||||||
|
file_idx += 1
|
||||||
|
if file_idx > len(sys.argv):
|
||||||
|
file_idx = 1
|
||||||
|
global img
|
||||||
|
img.file = sys.argv[file_idx], ""
|
||||||
|
return True
|
||||||
|
|
||||||
|
img.event_callback_add("mouse,down", _mouse_down_cb)
|
||||||
|
img.show()
|
||||||
|
|
||||||
|
win.show()
|
||||||
|
elm.run()
|
||||||
|
elm.shutdown()
|
|
@ -57,7 +57,8 @@ builtin_types = ( # automatically converted by cython
|
||||||
#"bool",
|
#"bool",
|
||||||
#"void",
|
#"void",
|
||||||
"Evas_Coord",
|
"Evas_Coord",
|
||||||
"Evas_Real"
|
"Evas_Real",
|
||||||
|
"Elm_Win_Type"
|
||||||
)
|
)
|
||||||
|
|
||||||
complex_types = (
|
complex_types = (
|
||||||
|
@ -67,9 +68,9 @@ complex_types = (
|
||||||
mapping_in = {
|
mapping_in = {
|
||||||
# c_type: pyx_type
|
# c_type: pyx_type
|
||||||
"bool": "bint",
|
"bool": "bint",
|
||||||
#"char": "",
|
"char": None,
|
||||||
"Evas_Object": "_Eo_Base",
|
"Evas_Object": "_Eo",
|
||||||
"Eo": "_Eo_Base",
|
"Eo": "_Eo",
|
||||||
}
|
}
|
||||||
|
|
||||||
conversions_in_python = {
|
conversions_in_python = {
|
||||||
|
@ -88,8 +89,8 @@ mapping_out = {
|
||||||
"bool": "bint",
|
"bool": "bint",
|
||||||
"char": "unicode",
|
"char": "unicode",
|
||||||
#"Elm_Object_Item": "_ObjectItem",
|
#"Elm_Object_Item": "_ObjectItem",
|
||||||
"Evas_Object": "_Eo_Base",
|
"Evas_Object": "_Eo",
|
||||||
"Eo": "_Eo_Base",
|
"Eo": "_Eo",
|
||||||
}
|
}
|
||||||
|
|
||||||
conversions_out = {
|
conversions_out = {
|
||||||
|
@ -161,7 +162,7 @@ def convert_in_param(tp, param_name, is_nonull=None):
|
||||||
conv_t = mapping_in[key]
|
conv_t = mapping_in[key]
|
||||||
if conv_t is None:
|
if conv_t is None:
|
||||||
# conv_t = ""
|
# conv_t = ""
|
||||||
conv_t = c_type
|
conv_t = ""
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -12,7 +12,7 @@ formatter = logging.Formatter("%(name)s %(levelname)s: %(message)s")
|
||||||
handler.setFormatter(formatter)
|
handler.setFormatter(formatter)
|
||||||
log = logging.getLogger("eolian")
|
log = logging.getLogger("eolian")
|
||||||
log.addHandler(handler)
|
log.addHandler(handler)
|
||||||
log_level = logging.ERROR
|
log_level = logging.WARN
|
||||||
log.setLevel(log_level)
|
log.setLevel(log_level)
|
||||||
|
|
||||||
import eolian
|
import eolian
|
||||||
|
@ -380,7 +380,7 @@ class Function(object):
|
||||||
gen.write("cdef:")
|
gen.write("cdef:")
|
||||||
gen.indent()
|
gen.indent()
|
||||||
for i, (t, n) in enumerate(expand_params):
|
for i, (t, n) in enumerate(expand_params):
|
||||||
gen.write("%s %s = tmp_prm%d" % (t, n, i))
|
gen.write("%s = tmp_prm%d" % (" ".join((t, n)).strip(), i))
|
||||||
|
|
||||||
gen.dedent()
|
gen.dedent()
|
||||||
|
|
||||||
|
@ -491,7 +491,7 @@ class Constructor(object):
|
||||||
def generate(self, gen):
|
def generate(self, gen):
|
||||||
cls_get = self.clsgetter
|
cls_get = self.clsgetter
|
||||||
|
|
||||||
header_params = [("_Eo", "parent=None")]
|
header_params = []
|
||||||
c_ctors = []
|
c_ctors = []
|
||||||
|
|
||||||
for ctor in self.ctors:
|
for ctor in self.ctors:
|
||||||
|
@ -522,6 +522,8 @@ class Constructor(object):
|
||||||
c_call_params = ", ".join(c_call_params)
|
c_call_params = ", ".join(c_call_params)
|
||||||
c_ctors.append((c_name, c_call_params))
|
c_ctors.append((c_name, c_call_params))
|
||||||
|
|
||||||
|
header_params.append(("_Eo", "parent=None"))
|
||||||
|
|
||||||
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()
|
||||||
|
|
||||||
|
@ -698,9 +700,10 @@ class Class(object):
|
||||||
try:
|
try:
|
||||||
o.generate(gen)
|
o.generate(gen)
|
||||||
except EolianTypeError:
|
except EolianTypeError:
|
||||||
log.info("Skipping %r because of unknown type", o)
|
raise
|
||||||
|
#log.error("Skipping %s constructor because of unknown type", self.full_c_name)
|
||||||
except Exception:
|
except Exception:
|
||||||
log.exception("Error while generating %r", o)
|
log.exception("Error while generating %s constructor", self.full_c_name)
|
||||||
|
|
||||||
for o in (
|
for o in (
|
||||||
list(self.methods) +
|
list(self.methods) +
|
||||||
|
@ -738,7 +741,8 @@ class Class(object):
|
||||||
imports.append((lib_name, "_" + name))
|
imports.append((lib_name, "_" + name))
|
||||||
|
|
||||||
for l, n in imports:
|
for l, n in imports:
|
||||||
l2 = PY_EFL_TOP_LEVEL_PACKAGE + "." + l.lower()
|
#l2 = PY_EFL_TOP_LEVEL_PACKAGE + "." + l.lower()
|
||||||
|
l2 = l.lower()
|
||||||
gen.write("from %s import %s as %s" % (l2, n, l.replace(".", "_") + n))
|
gen.write("from %s import %s as %s" % (l2, n, l.replace(".", "_") + n))
|
||||||
|
|
||||||
gen.write()
|
gen.write()
|
||||||
|
@ -747,10 +751,10 @@ class Class(object):
|
||||||
gen.write("class %s(%s):" % (self.name, ", ".join(inherits)))
|
gen.write("class %s(%s):" % (self.name, ", ".join(inherits)))
|
||||||
gen.indent()
|
gen.indent()
|
||||||
|
|
||||||
gen.write("def __init__(self, parent=None, *args, **kwargs):")
|
gen.write("def __init__(self, *args, **kwargs):")
|
||||||
gen.indent()
|
gen.indent()
|
||||||
gen.write(
|
gen.write(
|
||||||
"_%s.__init__(self, parent=None, *args, **kwargs)" % (
|
"_%s.__init__(self, *args, **kwargs)" % (
|
||||||
self.name
|
self.name
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -101,6 +101,7 @@ cdef extern from "Eina.h":
|
||||||
ctypedef _Eina_Inlist Eina_Inlist
|
ctypedef _Eina_Inlist Eina_Inlist
|
||||||
|
|
||||||
ctypedef struct Eina_Accessor
|
ctypedef struct Eina_Accessor
|
||||||
|
ctypedef struct Eina_File
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
# Other typedefs
|
# Other typedefs
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
from libc.stdint cimport uintptr_t
|
from libc.stdint cimport uintptr_t
|
||||||
|
|
||||||
from efl.evas cimport Eina_List, Eina_Bool
|
from efl.eina cimport Eina_File, Eina_List, Eina_Bool
|
||||||
from efl.evas cimport Evas_Object, Evas_Font_Size, Evas_Coord
|
from efl.evas cimport Evas_Object, Evas_Font_Size, Evas_Coord
|
||||||
from efl.evas cimport Evas_Event_Flags, Evas_Display_Mode
|
from efl.evas cimport Evas_Event_Flags, Evas_Display_Mode
|
||||||
from efl.evas.enums cimport Evas_Callback_Type
|
from efl.evas.enums cimport Evas_Callback_Type
|
||||||
|
@ -27,7 +27,7 @@ from efl.elementary.enums cimport Elm_Sys_Notify_Closed_Reason, \
|
||||||
Elm_Illume_Command, Elm_Win_Keyboard_Mode, \
|
Elm_Illume_Command, Elm_Win_Keyboard_Mode, \
|
||||||
Elm_Win_Indicator_Opacity_Mode, Elm_Win_Indicator_Mode, \
|
Elm_Win_Indicator_Opacity_Mode, Elm_Win_Indicator_Mode, \
|
||||||
Elm_Scroller_Movement_Block, Elm_Scroller_Policy, \
|
Elm_Scroller_Movement_Block, Elm_Scroller_Policy, \
|
||||||
Elm_Scroller_Single_Direction
|
Elm_Scroller_Single_Direction, Elm_Bg_Option, Elm_Image_Orient
|
||||||
|
|
||||||
cdef extern from "time.h":
|
cdef extern from "time.h":
|
||||||
struct tm:
|
struct tm:
|
||||||
|
@ -179,4 +179,6 @@ cdef extern from "Elementary.h":
|
||||||
ctypedef void (*Elm_Interface_Scrollable_Min_Limit_Cb)(Evas_Object *obj, Eina_Bool w, Eina_Bool h)
|
ctypedef void (*Elm_Interface_Scrollable_Min_Limit_Cb)(Evas_Object *obj, Eina_Bool w, Eina_Bool h)
|
||||||
ctypedef void (*Elm_Interface_Scrollable_Resize_Cb)(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
ctypedef void (*Elm_Interface_Scrollable_Resize_Cb)(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
||||||
|
|
||||||
|
ctypedef struct Elm_Layout_Part_Alias_Description
|
||||||
|
|
||||||
cdef int PY_EFL_ELM_LOG_DOMAIN
|
cdef int PY_EFL_ELM_LOG_DOMAIN
|
||||||
|
|
|
@ -31,6 +31,8 @@ cdef:
|
||||||
#_add_obj(self, Eo_Class *klass, cEo *parent)
|
#_add_obj(self, Eo_Class *klass, cEo *parent)
|
||||||
|
|
||||||
|
|
||||||
|
object (*conv_to_python)(void *c_ei)
|
||||||
|
|
||||||
int PY_REFCOUNT(object o)
|
int PY_REFCOUNT(object o)
|
||||||
|
|
||||||
void _object_mapping_register(char *name, object cls) except *
|
void _object_mapping_register(char *name, object cls) except *
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -323,7 +323,7 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
|
||||||
output_path = "/".join((PY_EFL_TOP_LEVEL_PACKAGE, library_name))
|
output_path = "/".join((PY_EFL_TOP_LEVEL_PACKAGE, library_name))
|
||||||
generate_pxis(library_name, header_name, output_path)
|
generate_pxis(library_name, header_name, output_path)
|
||||||
efl_ext = Extension(
|
efl_ext = Extension(
|
||||||
".".join((library_name, "__init__")), ["/".join((output_path, "__init__" + module_suffix))],
|
"efl", ["/".join((output_path, "efl.efl" + module_suffix))],
|
||||||
define_macros=[
|
define_macros=[
|
||||||
('EFL_BETA_API_SUPPORT', 1),
|
('EFL_BETA_API_SUPPORT', 1),
|
||||||
('EFL_EO_API_SUPPORT', 1),
|
('EFL_EO_API_SUPPORT', 1),
|
||||||
|
|
Loading…
Reference in New Issue