This is another cleanup in perparation for the Eo stable release.
This is no longer needed thanks to the proper error reporting with
eo_constructor()'s new return value.
The finalizer change cleans it up a bit so it catches more cases/issues.
This also means that the finalizer cleans up the object in all cases,
and not only some.
@feature.
From now on, constructors should return a value, usually the object
being worked on, or NULL (if the constructor failed). This can also
be used for implementing singletons, by just always returning the same
object from the constructor.
This is one of the final steps towards stabilizing Eo.
@feature
Instead of "@in type name;" we now use "@in name: type;". This change
is done because of consistency with the rest of Eolian; pretty much
every other part of Eolian syntax uses the latter form.
This is a big breaking change in the .eo format, so please update your
.eo files accordingly and compile Elementary together with the EFL.
@feature
This is a convenience macro to be used by the common pattern of getting
a part and then immediately calling functions on it. For example,
without this macro, you'd have to write code like:
Eo *part;
eo_do(obj, part = efl_part_name_get("partname"));
eo_do(part, a_set(7));
while using the helper function trims it to:
eo_do_part(obj, efl_part_name_get("partname"), a_set(7));
@feature
Remove it from the constructors section.
This was wrong. This place is for functions that are allowed to be
passed to eo_add() and should be used by bindings to create
constructors.
This is wrong for both cases, as this should always be called, not
optional.
Also remove the redundant legacy: null.
This is following a last review and a discussion on IRC. Eo has been
stable (apart of a decision a few months ago to support more compilers)
for a long while. Developers are already using it for a while, and it's
stupid to break it for them anyway, so we might as well make this
promise now. There are no plans to change it anymore, and it's been
heavily used and tested throughout the EFL for a few releases now.
I'm tagging it as a feature, although it's not, I'm doing it for the
automatic changelog generation. :)
@feature.
As discussed on IRC and ML. We are in a feature freeze phase, and this
patch is not essential. Furthermore, this patch was never discussed.
This reverts commit 537c7fe9e3.
Summary: Had a chat with raster to understand the behavior of these two functions in the IRC. Thought it might be helpful if added in the documentation itself. So updated it accordingly.
Reviewers: cedric
Subscribers: cedric
Differential Revision: https://phab.enlightenment.org/D2083
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This affects eo_do() and eo_add() that used to use the ({}) GCCism.
Following a discussion with Peter de Ridder after my talk at FOSDEM,
we've decided to reopen the GCCism (works with other gcc compatible
compilers like clang and intelc) discussion, and after a bit of back and
forth it was decided to make things more portable, at the cost of ease
of use.
For example:
if (eo_do(obj, visible_get()))
is no longer allowed, the portable alternative
Eina_Bool tmp;
if (eo_do_ret(obj, tmp, visible_get()))
is to be used instead.
However:
eo_do(obj, a = a_get(), b = b_get(), bool_set(!bool_get))
are still allowed and OK.
eo_do(obj, if (a_get()) return;);
is no longer allowed, but:
eo_do(obj, if (a_get()) something());
is still allowed.
For clarity, this commit only incorporates the Eo changes, and not the
EFL changes to make the efl conform with this change.
Thanks again to Peter de Ridder for triggering this important discussion
which led to this change.
The header.id was masked before using it as index in the _eo_classes
array and was not unmasked when used.
It hasn't caused segfault (by sheer luck) but was wrong.
@fix
Before this fix, when a deletion was invoked twice on an object, a
wrong message ("...You wrongly call eo_unref() within a destructor...")
was printed. This was caused by the del_triggered flag that was not
resetted when the destruction finished.
This patch fixes this behavior by printing the right message on a double
deletion.
So I don't really understand why the code was not there before, but it resulted
in my experiment of making a combobox for elementary just impossible. Now it
work at least.
In some cases, invalid object ids (e.g 0x1) would pass validation and
represent completely different objects (0x80...01). This happened because
we weren't properly checking a given object id is actually an object id.
@fix.
For some reason, they were normal functions instead of eo functions,
which makes them harder to bind, less safe, and just wrong.
This commit fixes that.
Now it's more clear and consistent. This commit complements the previous
eo_add commit (a7560dbc61).
Now eo_add should be matched with eo_del
eo_ref with eo_unref
eo_add_ref with eo_unref + eo_del
Essentially, the change is that if you have the ref to an object, you
need to unref it. Thus making ref/unref unneeded for most people who use
things (carefully) in c. If however, you would like to delete an object
previously created by you, you should eo_del (counter-part to eo_add).
It's still recommended you ref/unref when dealing with objects in
scopes, as you can't know when an object might just get deleted as a
by-product of another call.
This fixes an issue found by JackDanielZ.
Before this change eo_add() used to create an object with 1 ref, and if
the object had a parent, a second ref.
Now, eo_add() always returns an object with 1 ref, and eo_add_ref()
preserves the old behaviour (for bindings).
eo_unref now un-parents if refcount is 0, and eo_del() is an alias for
eo_unref (will change to be a way to ensure an object is dead and goes
to zombie-land even if still refed).
This moves the mainloop check inside the function. There was never need
for it to be in client code (i.e a header/macro).
This is better suited inside eo_do_start because this is a macro some
bindings have to re-implement, and we definitely don't want it to be any
more complicated than it has to be.
This breaks ABI and makes elm 1.12 depend on efl 1.11. This is not an issue
as because of eolian and interfaces it's already the case.
eina_tls_get is really slow, having a fast path for the main loop does really
help us right now. It is also unlikely that slowing down a little bit the use
of eo in thread is going to have any impact on application speed any time soon.
I win a +10% on expedite benchmark compared to without.
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This enables checking if an object is being created, or has already been
finalized. This is useful in functions that you want to allow
only during the creation phase (i.e inside the eo_add()).
Comp objects are rare, and since we allow using classes as interfaces,
we end up allocating a lot of memory for something we don't even use.
That's why it was a linked list in the first place, and that's why it
should remain a list.
This is almost a complete revert. I reverted the code itself, and the
intent (use of array instead of list), but not the tests, or the new
return value added to comp_detach, which is useful.
This reverts commit ef09ef7489.
This function lets you hook at the end of eo_add and override it for a
class. This is essentially the first step towards killing custom
constructors. Instead of having a custom constructor, you should just
do:
eo_add(CLASS, parent, a_set(3), b_set("eou"));
eo_constructor is called at the beginning for pre-init things.
eo_finalize is called at the end, for actually finalizing and doing
things. This cleans up the API and possibly saves a lot of things that
would have been stupid and slow in the past, like loading an elm widget
with an existing theme, and then changing the theme.
** This breaks Eo ABI, please recompile elementary and everything else that
creates eo objects.
@feature
Match function names when the API pointer is out of range.
Reviewed by TAsn and modified according to his comments :)
Differential Revision: https://phab.enlightenment.org/D876
We check _current_table for NULL, and then populate it (it's a global)
through another function, but we don't really check it's not NULL before
using it, we just assume because of an indirect other variable.
This confused coveritiy, can confuse humans too, and in general risky
(if something changes).
CID 1039419
Coverity found the issue, but it's an issue we've already fixed in the
past. I don't know how it got lost, but it seems like someone did a bad
merge. Probably when migrating to Eo2.
This reverts commit 831c20464d.
this fixes and eo2 problem where when callstack grows (or shrinks)
and realloc nas to relocate memory, the frame ptrs like fptr become
invalid and all sorts of hell ensues.
this uses mmap so blowing the stack will segv, not scribble over
memory, also its separated from malloc heap, and now big enough to not
need to size ... ever (1024 entries).
due to recent changes a lot of objects are now NULL (correctly) and eo
complains on access of them. it's simply too noisy adding too many
if's all through code, so let's just make eo be sensible here.
It's now completely valid to do:
a = eo_do(obj, a_get());
or:
b = eo_do(obj, a_set(1), b_get());
Also, the default return value for eo2 functions is now also returned
when the object is invalid, not just when the object does not match
class.
It's a small refactor that fixed both issues at once.
@feature
@fix
create/destroy tls key (_eo2_call_stack_key) at eo_init()/eo_shutdown().
use _eo2_call_stack_get() to allocate the stack when required.
register _eo2_call_stack_free() as eina_tls_cb_new() delete callback.
eo_class_new() returns NULL on error in _eo2_class_funcs_set().
it covers: NULL API func, API redefined, dich func override,
overriding non-existing fct.
as op descs are sorted, we can't output fct indexes in error msgs, but
as they are sorted using api_fct as key, we can detect multiple usage of
the same api_fct which leads to an unpredictable call to whatever is
returned by _eo2_api_op_id_get()->_eo2_api_desc_get().
it is still possible to instanciate an object of a not well defined class.
"void func(void)" != "void func()" !
The former is a func that accepts 0 parameters.
The latter is a func that accepts variable number of parameters.
Watch out.
a mixin class must not inherit
- _eo2_api_desc_get()
accept NULL klass param
EO_CLASS_TYPE_REGULAR_NO_INSTANT is an acceptable extension class type for
- _eo2_class_funcs_set() do not shout if parent is NULL
there is no more difference in class or regular functions prototypes and definitions
- eo2_api_op_id_get() uses _eo_is_a_class() at runtime
- add 'void *class_data EINA_UNUSED' parameter to eo2_base class functions
- Eo2_Op_Call_Data.klass is kept only for eo2_hook_call_pre end eo2_hook_call_post,
but could be removed easily
in the EPAI, don't show that Eo* could be IDs.
in the implementation, use klass_id and obj_id
if you know or want it to be a class or an object,
use eo_id in general cases.
We want to have normal functions as non-default constructors, not va_arg
ones. What we should do is split the object creation to two parts again.
The creation, the constructing (changes using the macro) and the
verification/end part that checks the constructor has been called.
This reverts commit 2ff2ce1894f173b306a896bda595e1a7768c074d.
to protect us against bad use of break, goto, return ... in eo2_do,
we use __attribute__((cleanup(eo2_do_end))) to ensure that eo2_do_end()
is called whatever.
at class elaboration, sort the op descriptions using the function pointer.
when calling a function, do a dichotomic search in the
class op descriptions to find the corresponding OP_ID,
then keep it in a static variable.
All classes are allowed, because all classes can be used as interfaces in
order to override behaviour. This is especially needed for mixins and broke
the eo2 tests.
Was fien on the normal path but missing on the error path. Also remove
the spurious break after the return. Would never be reached. Looks like
a copy and paste bug to me.
CID 1187638
This patch sets the one before most significant bit on for classes. This
means that class ids are now very big, compared to the old ids which
were growing small integers (1, 2, 3...).
This makes accidental passing of integers (corrupted obj pointers) less
common.
@feature
Summary:
The closing @} for the main Eo group is inside the #ifdef
EFL_BETA_API_SUPPORT block, so it gets removed by the preprocessor
unless the project is configured with EFL_BETA_API_SUPPORT. Moved the
@} outside the #ifdef so it will always be there and Doxygen won't
complain.
Test Plan: make doc 2> doxyerr.log
Reviewers: raster
Reviewed By: raster
CC: cedric
Differential Revision: https://phab.enlightenment.org/D609
as we don't support multiple composites of the same class,
and know at class elaboration how many composites we should have,
we can create the composites array and pack it at the end of the object.
@fix
mixins data offsets are stored in Eo_Extension_Data_Offset[],
if the constructed class is a mixin, do not reserve space for its
private data, the class is in mixins list and will be handled at
Eo_Extension_Data_Offset computation.
see _eo_data_scope_get(...) for private data retrieval
1) Include files now have include guards
2) --gh option generates legacy header with --legacy flag and eo header
without --legacy flag
3) EOLIAN keyword is introduced to mark functions used by generated
file.
4) * for comments when comment text is empty
as we don't support multiple composites of the same class,
and know at class elaboration how many composites we should have,
we can create the composites array and pack it at the end of the object.
eo_composite_attach fail if the class of the composite is not
listed in the parent class extensions, or if there is already a
composite of the same class. The later because calls are
forwarded to the first responding composite, see _eo_op_internal().
Being annoyed by different types of eina critical macros - CRI, CRIT,
CRITICAL -, I concluded to unify them to one. Discussed on IRC and
finally, CRI was chosen to meet the consistency with other macros -
ERR, WRN, INF, DBG - in terms of the number of characters.
If there is any missing bits, please let me know.
bug T569 still shows that we have cases where, during e shutdown, we
still get eo_data_scope_get() return NULL for a parent object.
whatever this is, segfaulting is much worse than protecting and
marching on. so protect
This is an extension to raster's 0355a6a296
(eo - fix _parent_set in base clase when old_parent_pd is NULL).
I also added an error message in case this check fails.
This reverts commit ee1b0833ed
I did it manually because the code changed too much.
We actually want this type, it makes things more clear and easier to
understand.
this is the first step on the road to remove class specific EAPI from Eo.h
using this handle we will know if a Eo* is a class or an object pointer
Conflicts:
src/lib/eo/eo.c
The goal would be to replace the smart children list and friends. The
problem is that they differ in content. Smart children and Eo children are
the same, but Elm children and them differ. If I put this function as a
virtual, it would be possible to override the list of children and if we
start using it in Evas render loop, that could result in "weird" behavior.
I have added the use of a simplified Eina_Trash mempool kind of feature
to have some fast path for allocation if we start using it in Evas render
loop.
extn_data_size is not equal to extn_data_off,
current class data size and data offset must be substracted first
elementary_test bubble peak usage goes from 13.7 MiB to 12.5 MiB
- to enable this feature, compile with --with-profile=debug
- the mid tables and tables are write protected after modifications,
you will segfault if you mess with them
- because of mmap PAGE_SIZE alignement and added magic header, almost a
memory page is wasted per table and mid table allocation.
- reducing the number of tables per mid table and the number of entries
per table solves this.
- pack active flag and generation nbr in an _Eo_Id_Entry struct
- replace Eina_Trash with a fifo which lives in mmaped memory owned by eo_id.
- fifo uses indexes instead of pointers to spare memory
- never used entries are served first, then those in the fifo
are reused, thus we ensure that a freed entry won't soon be reused.
We want to introduce a new mechanism concerning the data of the Eo
objects.
The goal is to improve the memory management by defragmenting the memory
banks used by the Eo objects. The first phase has been done by raster
and consists in allocating the objects into a separate memory region
that the one used by malloc. So now, we know where our objects are
located.
Now, moving objects means moving data of objects. The issue we have here
is that a lot of data pointers are stored into data of other objects,
e.g Evas Object data into lists for rendering...
We need a way to reference the data and eo_data_get doesn't provide us
that. So we need to improve the API for data extraction by requesting
from the developer if the data will be stored or not. Five functions are
supplied:
- eo_data_scope_get: no referencing, the data pointer is no more used after
exiting the function.
- eo_data_ref: reference the data of the object. It means that while the
data is referenced, the object cannot be moved.
- eo_data_xref: reference the data of the object but for debug purpose,
we associate the objects that references. Same behavior as eo_data_ref
for non-debug.
- eo_data_unref: unreference the data of an object.
- eo_data_xunref: unreference the data of an object previously
referenced by another object.
I deprecated the eo_data_get function. Most of the time,
eo_data_scope_get needs to be used.
In the next patches, I changed the eo_data_get to the corresponding
functions, according to the usage of the data pointer.
The next step is to find all the places in the code where the data is
stored but not yet referenced. This will be done by:
- requesting from every object to unreference all data to other objects.
- moving all the objects from one region to another
- requesting from every object to rerefenrence the data.
- debugging by hunting the segmentation faults and other weird
creatures.
use of an array of the below struct instead of 3 separate arrays
leads to better cache performance and smaller memory usage
typedef struct
{
_Eo *ptr;
unsigned int active : 1;
unsigned int generation : BITS_FOR_GENERATION_COUNTER;
} _Eo_Id_Entry;
Summary: This feature replaces Eo pointers with ids to prevent bad usage
or reuse of these pointers. It doesn't change API.
The mechanism uses tables storing the real pointers to the objects.
See the src/lib/eo/eo_ptr_indirection.c file for more details on the
mechanism.
Because of the way eo is dispatching method calls of objects the usual
error log you get if you mix up objects or try to call non-existent
methods is:
ERR<12404>:eo lib/eo/eo.c:362 _eo_dov_internal() Can't find func for op
0x24 (ecore_audio_obj_in:ECORE_AUDIO_OBJ_IN_SUB_ID_SPEED_GET) for class
'ecore_audio_obj_out_pulse'. Aborting.
Of course the problem is not really in lib/eo/eo.c, but in the function
calling eo_do()
Now the macros pass source file and line number on to the _internal
functions so we can log where the error originally happened:
ERR<1938>:eo lib/eo/eo.c:362 _eo_dov_internal() in
lib/ecore_audio/ecore_audio_obj_out_pulse.c:119: Can't find func for op
0x24 (ecore_audio_obj_in:ECORE_AUDIO_OBJ_IN_SUB_ID_SPEED_GET) for class
'ecore_audio_obj_out_pulse'. Aborting.
This makes debugging with eo a lot easier.
Signed-off-by: Daniel Willmann <d.willmann@samsung.com>
These functions let you pass an array of callbacks instead of just one.
It's more memory efficient to use this if you just add a bulk of events
on the same object.
This commits breaks ABI, and breaks API of the EO_EV_CALLBACK_ADD/DEL
signals (the event info passed).
We now need to pass the current class to eo_do_super. This is faster and
more memory efficient and generally lets us do things better.
Using the eo_benchmarks we get ~20% speed-up.
It's cleaner. Should have never been a macro. This is part of the effort of
reducing the usage of ({ which is apparently a non standard extension.
We can get rid of most of it and ifdef the rest.
From now, classes implementing the Eo function with id
EO_BASE_SUB_ID_DBG_INFO_GET will be able to show in Clouseau their own
specific information.
Information contents is controlled by the class itself and no more
by Clouseau. Basic types and lists are supported..
Signed-off-by: Aharon Hillel <a.hillel@samsung.com>
SVN revision: 83410
This was stupid from the start, but now it casuse even more issues.
We'll have to just add a configure option to it when the time comes.
SVN revision: 82989
Please check.
note1: Only lib and bin for now, but should be extended to other stuff
note2: distcheck does not work because eo_suite is failing.
SVN revision: 78758