On Tue, May 10, 2011 at 7:40 AM, Cedric BAIL <[email protected]> wrote:
[...]snip[...] I already made my point of view :-)
>>>>> I don't like the idea of adding interfaces to it as it is where the
>>>>> cost come most of the time, but that's open for discussion.
>>>>
>>>> Interface is just another pointer in the type (class) definition, It
>>>> will contain a list of other types (kludge) or interface definitions
>>>> (structure with pointers + identifier).
>>>
>>> Ok, I maybe miss understand that term, but for me the interface is
>>> where come all the hugly function with virtual and other inheritance
>>> stuff. So yes, only a list of pointer with an identifier, but you need
>>> to provide a way to handle all the thing that people expect, and that
>>> have a cost that I don't see us making it better than what the other
>>> have done.
>>
>> virtuals are already handled in our Class thing (it it looks like
>> Evas_Smart_Class). Interfaces are a list that are similar to this
>> Class, with extension points. It's a way to solve the
>> multiple-inheritance, to solve "this is a widget (class) that is
>> scrollable (interface)". Then when you call
>> elm_scrollable_policy_set(object), the elm_scrollable_policy_set would
>> be implemented like:
>>
>> void ABC_scrollable_policy_set(ABC_Object *obj, int horiz, int vert) {
>> const ABC_Interface *iface;
>> const ABC_Scrollable_Iface *siface= NULL;
>> ABC_Class *cls;
>> const Eina_List *l;
>> CHECK_OBJECT_VALIDITY(obj);
>>
>> // this should be a function on its own:
>> cls = GET_OBJECT_CLASS(obj);
>> EINA_LIST_FOREACH(cls->interfaces, l, iface)
>> if (iface->type = ABC_SCROLLABLE_INTERFACE)
>> {
>> siface = iface;
>> break;
>> }
>> if (!siface) return; // does not implement interface
>>
>> // dispatch it to the interface... you could omit siface as you
>> can retrieve it again from obj
>> siface->policy_set(siface, obj, horiz, vert);
>> }
>
> Current idea of implementation would make it more like :
>
> void ABC_scrollable_policy_set(ABC_Object *obj, int horiz, int vert) {
> ABC_Scrollable_Iface *siface = NULL;
> ABC_Scrollable *o;
>
> o = GET_OBJECT(obj, ABC_Scrollable_Iface);
> siface = GET_CLASS(obj, ABC_Scrollable_Iface);
> if (!siface) return ; // does not implement interface
> siface->sfunc.policy_set(siface, o, horiz, vert);
> }
>
> The main difference is that ABC_Scrollable strcture would look like :
> struct {
> ABC_Object obj;
> ABC_Scrollable_Specific scroll;
> };
>
> And the ABC_Scrollable_Iface would look like :
> struct {
> ABC_Object_Func ofunc;
> ABC_Scrollable_Func sfunc;
> };
>
> Dispatching could be done when creating the class, but I don't know
> how to implement this at all.
This is problematic, see Elementary for an idea. We wanted to add an
scrollable interface to Entry and had to duplicate all functions. Same
for lots of other components, you have elm_*_scroll_policy_set()
replicated all around the code.
The problem with your approach is if you want to implement a
"scrollable" (ABC_Scrollable_Iface) "container" (ABC_Container_Iface)
that supports "selection" (ABC_Selection_Iface). If you want to get
functions from each of these interfaces you'd need to know the offset
in the class structure, and this would change from class-to-class,
then you still need to replicate the function (and documentation!) for
all of them, calling the function pointer at the correct offset.
We can keep the interface implementation quite simple, like I
mentioned a list of structures that start with an integer identifier,
a string to make it easier to debug/introspect and a series of
functions. Just walk the list, find your structure and give it to the
function pointer.
--
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [email protected]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel