Commit Graph

269 Commits

Author SHA1 Message Date
Daniel Kolesa b780cf2af2 eo: move unbindable event APIs to C
In a few classes, this requires some manual expansion. This should
not break anything but it's also fairly ugly; a better solution
would be appreciated, for now we do this.

Similar changes will be done to a few other Efl.Object APIs as
well at later point.
2017-04-20 18:24:38 +02:00
Jean-Philippe Andre 86d1f2b6cd eo: Use COW to save 8~16 bytes per object
Summary:
This uses Eina_Cow to implement support for rarely used features
in EO objects. This covers:
- composite objects (eg. UI widgets: combobox, text, video, win)
- vtable for efl_object_override
- del_intercept

All of these features are quite tricky to get right and while
very useful, should still be used with great care. With this patch,
the size of an _Eo_Object struct comes down from 80 bytes (rounded
up from 72b) to 64 bytes (rounded up from 56b) on 64 bits.

Also I haven't measured precisely but I don't expect any performance
impact since the COW data is more likely to remain in L1/L2 cache,
as the default one will be used most often. Unfortunately, the
results of "make benchmark" have been quite inconsistent over
multiple runs.

This saves ~64kb in elementary_test (>4k objects) at the cost of
~100 calls to COW write (del intercept on some events).

@optimization

Reviewers: raster, cedric

Differential Revision: https://phab.enlightenment.org/D4796
2017-04-18 18:52:27 +09:00
Marcel Hollerbach ae80040331 eo: ensure the generation is correctly clamped
Summary:
when a few recursive event emissions are happening, and in some deep
recursive level a subscription to the same object is happening, the
subscription would just be executed when the complete recursion is done.
that is wrong. The subscription needs to be executed when the event is
called after the subscription is added, undepended from any recursive
level. That fixes that and adds a regression test for it.

This was discovered in e, since e gives a lot of error messages about a eo object
that is already freed. It turned out this object is returned from evas, and exactly
the above happened to the EFL_EVENT_DEL subscription of that object.

Test Plan: make check

Reviewers: tasn, cedric, stefan_schmidt

Subscribers: stefan_schmidt, netstar, zmike, raster, jpeg

Differential Revision: https://phab.enlightenment.org/D4656

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-02-16 13:37:19 -08:00
Carsten Haitzler eb3f6f06f1 efl base class - fix warning about comparing differing sizes
yes - we compare a difference between 2 ptrs and an index which is a
uint. the safe thing here is to promote the unit to the ptrdiff_t
type. reality is we cant have more than 2^32 cb's on an object
anyway... so this should be ok.
2017-02-11 23:13:00 +09:00
Carsten Haitzler a817d2f632 eo event callback frame make them single linked to save a bit of overhead
this makes the callback event frame single linked with a little less
inlist overhead asa result.
2016-12-02 21:28:15 +09:00
Marcel Hollerbach 2ce2a65148 eo: adjust generation count
raster suggested a few optimizations
2016-12-02 12:27:37 +01:00
Marcel Hollerbach a2e90e522b eo: optimize generation increase
doing it by hand here saves a function call which showed up pretty happy
on perf.
2016-12-02 12:27:37 +01:00
Marcel Hollerbach 0f72c8a031 eo: use the event stack to define behaviour
subscriptions are only executed if they were already subscriped at the
start of the event emission.
2016-12-02 12:27:37 +01:00
Marcel Hollerbach a035bc1292 eo: fix event emission for subscription while emission
This fixes T4907

The problem was that in efl_event_callback_add the internal array was
changed. If this was happening while a efl_event_callback_call was
happening the for loop got confused and skipped one event subscription.
Which led to a bug in e where the idler ufnction was not executed
probebly and so the canvas stayed frozen.
2016-12-02 12:27:37 +01:00
Andy Williams c5181470c1 eo: safety in string comparison
Avoid potential for Eo to crash if app manages to unset key
@fix
2016-11-28 00:10:30 +00:00
Carsten Haitzler ad985e73f3 eo base class - clean up some formatting around callback add/del code
just formatting changes really.
2016-11-26 18:33:56 +09:00
Cedric Bail 6b165089a6 eo: make it possible to disable batch allocation for callbacks. 2016-11-23 18:50:19 -08:00
Cedric Bail f4527c7283 eo: when there is no more callbacks, let's clean up. 2016-11-23 18:50:19 -08:00
Marcel Hollerbach 70b24abff7 eo: inc the special count
if there is a event the callback counter should be incremented not
decremented. This should fix a few crashes i found in edje, since edje
did not knew that a element was deletion.
2016-11-23 13:42:27 +01:00
Cedric Bail f511c64269 eo: refactor callback delayed cleaning code. 2016-11-21 16:03:27 -08:00
Carsten Haitzler ce8e085d6d efl object events - track del, cb add and cb del callback counts
so hunting another callback issue i noticed some of THE most popular
callbacks are:

     1411  tick
     1961  move
     4157  pointer,move
     7524  dirty
     8090  damage
    13052  render,flush,post
    13052  render,flush,pre
    13205  render,post
    13205  render,pre
    21706  recalc
    21875  idle
    27224  resize
    27779  del
    31011  idle,enter
    31011  idle,exit
    60461  callback,del
   104546  callback,add
   126400  animator,tick

as you can see callback del, add and the general obj del cb's are
right up there... so it is very likely a good idea to CHECK to see if
anyone is listening before calling the callback for these very very
very common calls.

this is ifdef'd and turned on for now. it can be turned off. it
shouldnt use more memory due to the way memory alignment works (likely
all allocations will be multiples of 8 bytes anyway) so we're using
spare unused space. the only q is - is management of the counts AND
checking them worth it in general? it's really hard to tell given we
dont have a lot of benchmarks that cover a lot of use cases... it
doesnt seem to slow or speed anything up much in the genlist bounce
test... so i think i need something more specific.

@optimize
2016-11-17 18:41:32 +09:00
Carsten Haitzler 200490a850 eo src formatting - line up struct member 2016-11-17 18:41:32 +09:00
Carsten Haitzler 036cfc32e4 event callback call - move 0 check early before any var init
a LOT of callback calls call on objects with no cb's at all so the
earlier we check for 0 the better before we do ANYTHING.

@optimize
2016-11-17 18:41:32 +09:00
Carsten Haitzler 1ac86bb878 eo - fix ever growing callback list by actually flagging waiting dels
i found a massive slowdown that over time ended up with 10000's of
cb's in objects like the ecore loop object. this fixes that by
ACTUALLY flagging event deletions waiting to be true rather than false.
2016-11-17 18:41:32 +09:00
Carsten Haitzler 45771d47ab eo - use free queue for at least some eo core memory and pointers
this should help improve robusteness by keeping memory around for a
bit until the free queue flushes or is full

@feature
2016-11-06 13:13:10 +09:00
Tom Hacohen f736946d10 Eo: Add a method to mark objects for reuse.
This informas eo an object is going to get reused/cached, so eo can
reset the object appropriately.

@feature.
2016-10-28 13:19:10 +01:00
Cedric Bail ab18b01e1c eo: do not track NULL future. 2016-10-25 18:51:12 -07:00
Tom Hacohen 25242e6af9 Eo: Fix references of objects 2016-10-21 15:29:39 +01:00
Jean-Philippe Andre 9c95eda748 eo: Fix deadlocks with composite objects
This happens with shared objects.

The situation seems to be:
1. object has composited object a of class A in thread 1
2. call something on object a from thread 2, deadlock
In fact, do anything from thread 2 on a shared object and you deadlock.
2016-10-06 17:57:45 +09:00
Jean-Philippe Andre 6ce60a0de5 eo: Fix deadlock in efl_parent_set
If the object is shared and the given parent is invalid (eg. deleted)
then we will deadlock later. This also adds a test case with it.
2016-10-06 16:19:12 +09:00
Jean-Philippe Andre 258cfbbe80 eo: Fix deadlock with shared objects
The object pointer was passed to EO_OBJ_DONE, rather than its
eo id.
2016-10-06 12:24:59 +09:00
Carsten Haitzler 6a5ae00ffa eo - goto-ify a chunk iof code moving debug printfs out of hot paths
this moves a lot of error case handling into goto's so the code gets
out of the hot path and this should help expecially since variou
smacros do things like:

   do { char buf[256]; sprintf(buf, fmt, ptr); _eo_pointer_error(buf); } while (0)

   _Efl_Class *klass; \
   do { \
      klass = _eo_class_pointer_get(klass_id); \
      if (!klass) { \
         _EO_POINTER_ERR("Class (%p) is an invalid ref.", klass_id); \
      return ret; \
   } \
} while (0)

so putting quite a chunk of code inside a rare "if this errors"
handler that will cause l1 cache misses and this we don't want, thus
moving stuff in eo core out of hot paths to cut down on overhead. yes
it might not be pretty but it's kind of the right thing at such a core
level of efl. this also does the same to the eo base class as this is
also going to be relatively hot given it's the core of every other
object.
2016-09-29 17:45:47 +09:00
Carsten Haitzler 0f929f5546 eo id and shared domain objects - do locking properly and better
so there were a few issues. one we had a spinlokc on the eoid table
for shared objects AND then had a mutex for accessing those objects
(released on return from any eo function). BUT this missed some funcs
like eo_ref, eo_unref and so on in eo.c ... oops. so fixed. but then i
realized there was a race condition. we locked the eoid table then
unlocked with our pointer THEN locked the sharted object mutex ...
then unlocked it. that was a race condtion gap. so we should share the
same lock anyway - if it's a shared object, grab the shared object
mutex then do a lookup and if the lookup does not fail, KEEP the lock
until it is released by the return from eo function or by some special
macro/funcs that released a matching lock. since its a recursive lock
this is all fine. as its also a universal single lock for all objects
we just need the eoid to know if it's shared and needs locking based
on the domain bits. so now do this locking properly with just a single
mutex, not both a spinlock and mutex and keep the lock around until
totally done with the object. this plugs the race condition holes and
goes from 1 spinlock lock and unlock then a mutex lock and unlokc to
just a single mutex lock and unlock. this means shared objects are
actually truly safe across threads and only have the overhead of a
single recursive mutex to lock and unlock in every api call.
2016-09-28 13:38:46 +09:00
Cedric BAIL 6f2cad6439 efl: add a possibility to link death of Eo object with a future. 2016-09-08 14:58:05 -07:00
Carsten Haitzler 09f19c3c73 eo - make eo id table TLS private data for thread safety and speed
This moved all the eoid tables, eoid lookup caches, generation count
information ad eo_isa cache into a TLS segment of memory that is
thread private. There is also a shared domain for EO objects that all
threads can access, but it has an added cost of a lock. This means
objects accessed outside the thread they were created in cannot be
accessed by another thread unless they are adopted in temporarily, or
create4d with the shared domain active at the time of creation. child
objects will use their parent object domain if created with a parent
object passed in. If you were accessing EO (EFL) objects across threads
before then this will actually now cause your code to fail as it was
invalid before to do this as no actual objects were threadsafe in EFL,
so this will force things to "fail early".
ecore_thread_main_loop_begin() and end() still work as this uses the
eo domain adoption features to temporarily adopt a domain during this
section and then return it when done.

This returns speed back to eo brining the overhead in my tests of
lookup for the elm genlist autobounce test in elementary from about
5-7% down to 2.5-2.6%. A steep drop.

This does not mean everything is perfect. Still to do are:

1. Tests in the test suite
2. Some API's to help for sending objects from thread to thread
3. Make the eo call cache TLS data to make it also safe
4. Look at other locks in eo and probably move them to TLS data
5. Make eo resolve and call wrappers that call the real method func do
   recursive mutex wrapping of the given object IF it is a shared object
   to provide threadsafety transparently for shared objects (but adding
   some overhead as a result)
6. Test test est, and that is why this commit is going in now for wider
   testing
7. Decide how to make this work with sending IPC (between threads)
8. Deciding what makes an object sendable (a sendable property in base?)
9. Deciding what makes an object shareable (a sharable property in base?)
2016-09-07 18:17:10 +09:00
Carsten Haitzler e14a11d9fa eo base - fix free of all callbacks to set callbacks to NULL
we set count to 0 but not ptr to NULL. this we must do after free so
when other destructors run dont go relying on this ptr to be valid!
2016-09-06 22:12:23 +09:00
Tom Hacohen f13bb9d9f5 Efl object: rename shadowing variable. 2016-09-05 16:22:33 +01:00
Cedric BAIL 3ab60a1564 eo: store registered callbacks in an array instead of a single chained list. 2016-09-02 10:19:45 -07:00
Cedric BAIL 605fec91ee eo: improve speed of walking callback array by sorting them during creation.
This improve speed of processing events in genlist scrolling benchmark by 30%
inside the efl_object_event_callback_call code. Not a really big deal as it
goes from 0.9% to 0.6% of the total time spend. Welcome to micro optimization.
2016-09-02 10:19:45 -07:00
Carsten Haitzler 90acc0216b eo - make eoid table access threadsafe - was missing a lock around it
this now makes at least eoid deref and ojbect access safe across
threads. the downside is that oeid lookup goes from 2% to ~5% of cpu.
ugh.
2016-09-01 18:59:56 +09:00
Tom Hacohen d5e321466e Efl object: Rename Eo_Event -> Efl_Event.
This is the last step of the Eo renaming efforts.
2016-08-30 13:34:10 +01:00
Carsten Haitzler a9fbe6cb8f eo callbacks - move to mempools for callback data for more speed
also help reduce fragmentation. also remove callbacks immediately if
callbacks are not being walked at the time (as opposed to just marking
them to need deletion then call a clean that if not being walked will
walk all cb's when we already know what to remove).

@optimize
2016-08-29 16:48:08 +09:00
Cedric BAIL 93a706a947 eo: general speedup of all Eo related operation.
This change rely on the fact that we do fetch the same
object id over and over again. _efl_object_call_resolve got
15% faster, efl_data_scope_get 20%.
2016-08-26 12:14:14 -07:00
Vitor Sousa 8356b16a49 Efl Object: remove legacy callback calls from event_callback_call
Efl.Object.event_callback_call no longer calls legacy smart callbacks;
calling only event callbacks registered with the given event description
pointer.

Create the method Efl.Object.event_callback_legacy_call to inherit the old
behavior from Efl.Object.event_callback_call, calling both Efl.Object events
and legacy smart callbacks.

Update all other files accordingly in order to still supply legacy
callbacks while they are necessary.
2016-08-26 15:45:07 -03:00
Tom Hacohen e65aae994e Eo: Finish the renaming of Eo to the EFL.
This renames all the rest of the API to the EFL namespace except for
Eo_Event that will follow soon.

Obviously breaks both API and ABI.
2016-08-15 15:07:42 +01:00
Tom Hacohen e64e120a51 Eo: Rename most of Eo to the Efl prefix.
This includes Eo.Base -> Efl.Object and many (but not all) of the eo
functions. This commit is only for eo itself, not the rest of the EFL.
2016-08-11 17:04:43 +01:00
Cedric BAIL d85c07e4a7 eo: rationalize naming to follow other use of ref and wref in our API. 2016-07-13 16:05:58 -07:00
Tom Hacohen a5eb66edd4 Eo refcount: Split the refcount to private and public (user).
This commit changes the way refcount is dealt with internally. Before
this commit, there was one refcount shared between Eo internals and
users. Now there is a refcount for eo operations (like for example,
function calls) and one for user refcount (eo_ref).

An example bug that this protects against (which is seemingly rather
common) is:
some_eo_func(obj);

// Inside the implementation of that func:
pd->a = 1; // The object's private data
eo_unref(obj); // To delete the object
eo_unref(obj); // A big one extra unref
pd->a = 2; // Segfault, this data has already been freed

This is a feature, but really just a fix for a class of bugs.

@feature
2016-07-12 11:09:40 +01:00
Jean-Philippe Andre 73c96c0136 eo: Fix warnins (return NULL instead of bool) 2016-07-08 12:27:29 +09:00
Carsten Haitzler f8fd74f8d2 eo base - add weak object refs as per jpeg needs
so after some discussion with jpeg, weak referenced keys are also a
good idea. these need del track handling to be weak, so i made strong
reffed keys also do del tracking again as it's just nice to do this
and be more robust. also added and improved the test suites for this
key value stuff.

@feature
2016-07-07 18:41:23 +09:00
Jean-Philippe Andre d8db7b2637 eo: Fix composite objects destruction
This walks the list and removes objects from it. Not
using EINA_LIST_FREE as the actual list_remove is done
inside eo_composite_detach.
2016-06-28 19:29:31 +09:00
Tom Hacohen d648eb5311 Eo event callbacks: Change the way callbacks are stopped.
Instead of using the return value, we now use eo_event_callback_stop()
to stop calling other callbacks.
2016-06-20 18:02:00 +01:00
Stefan Schmidt ecdbde7493 eo: remove now longer needed EO_BASE_BETA define from code base
This was needed when the eo composite object was still in beta. Since commit
d7c45e41d4 this is no longer the case. No beta
part left in eo base so we can safely remove this define.
2016-06-20 10:07:30 +02:00
Tom Hacohen aab8389a6f Eo: remove strict class checking for composite objects.
When compositing objects, we were checking that class_of(B) is in A's
inheritance tree before allowing attaching B as a composite object of A.
This is wrong and breaks a few cases, for example: B extends a class that
is in A's inheritance tree or B implements an interface that is in A's
inheritance tree.

Thanks to Marcel for reporting.
2016-06-05 10:57:07 +01:00
Tom Hacohen a6a2338962 Revert "Eo: Remove eo_del() and make eo_unref() the replacement."
This reverts commit 546ff7bbba.

It seems that eo_del() is useful and removing it was creating bugs.
The issue is that the way we defined parents in eo, both the parent and
the programmer share a reference to the object. When we eo_unref() that
reference as the programmer, eo has no way to know it's this specific
reference we are freeing, and not a general one, so in some
circumstances, for example:
eo_ref(child);
eo_unref(child); // trying to delete here
eo_unref(container); // container is deleted here
eo_unref(child); // child already has 0 refs before this point.

We would have an issue with references and objects being freed too soon
and in general, issue with the references.

Having eo_del() solves that, because this one explicitly unparents if
there is a parent, meaning the reference ownership is explicitly taken
by the programmer.

eo_del() is essentially a convenience function around "check if has
parent, and if so unparent, otherwise, unref". Which should be used when
you want to delete an object although it has a parent, and is equivalent
to eo_unref() when it doesn't have one.
2016-06-01 13:33:21 +01:00
Tom Hacohen 9c264fa028 Eo: Fix issue of too many unrefs in some cases.
This problem was that because the refcount is now shared between the
parent and the programmer in some cases we would get a double unref. An
example way of triggering it is creating a button and putting it in a
box. The box has a callback registered that when the button is deleted
it would delete itself too. The problem is that the delete callback is
called the button is removed from the box thus causing the box to unref
it again (because of the parent), although the refcount was already
accounted for.

There is another more convoluted scenario that I have yet to fix.

Thanks to raster for reporting.
2016-05-24 19:27:47 +01:00
Tom Hacohen 4bae0f135a Eo: use internal unref function intsead of public one.
This is a micro optimisation that doesn't really matetr, but since
we already have the actual eo object, we may as well use it.
2016-05-24 19:27:47 +01:00
Cedric Bail 75a53ece10 eo: for consistency use object like all our API. 2016-05-18 08:18:04 -07:00
Carsten Haitzler 43661180f7 efl - key/data/value/obj attach to eo objects - make these properties
the key data now is a property so they come out in bindings really
nicely like:

  obj.key_data["blah"] = x;

  x = obj.key_data["blah"];

etc.
2016-05-18 02:02:45 +09:00
Daniel Kolesa 7782c0bcb9 eolian: add event_prefix and have classes follow that or eo_prefix by default
Previously events used to use class name as a prefix and ignored eo_prefix
when specified. This is no longer the case. Events follow eo_prefix by default
now. In order to get around this for classes where this is undesirable, a new
field event_prefix was added which takes priority over eo_prefix. If neither
is specified, class name is used like previously.

@feature
2016-05-17 17:50:43 +01:00
Tom Hacohen 546ff7bbba Eo: Remove eo_del() and make eo_unref() the replacement.
We used to have eo_del() as the mirrored action to eo_add(). No longer,
now you just always eo_unref() to delete an object. This change makes it
so the reference of the parent is shared with the reference the
programmer has. So eo_parent_set(obj, NULL) can free an object, and so
does eo_unref() (even if there is a parent).

This means Eo no longer complains if you have a parent during deletion.
2016-05-17 16:23:23 +01:00
Tom Hacohen e9c4e7bf76 Eo name: Rename Eo.Base.id to Eo.Base.name.
This is there to reduce confusion with Eo_Id and also the name
is just better.
2016-05-17 16:00:13 +01:00
Tom Hacohen 9ef65788f4 Eo: Rename an internal function to reduce confusion.
@raster added eo_id_get() which was confusing because we already had
_eo_id_get() that was used internally.
2016-05-17 10:29:16 +01:00
Tom Hacohen 79575d8943 Eo children: Make children tracking an inlist instead of a list.
This saves us a pointer in every eo object and a pointer indirection
when accessing children.
2016-05-17 10:26:54 +01:00
Tom Hacohen fa9145d469 Eo name find: Fix possible out of bounds write in eo name find.
CID1354840
2016-05-16 17:41:59 +01:00
Tom Hacohen 537b138a23 Eo composite: change composite objects to not be tied to parent
This commit breaks behaviour!
Re-parenting no longer detaches composite objects, so watch out.

Now you can have an object be a composite object of an object although
it's not its child. This allows widgets to do things like having an
object as the child of a child object while still making it a composite
object to the main object.

With this change, composite objects don't keep a reference to the child,
but instead composite "bonds" are implicitly removed when either the
parent or the child are destructed.
2016-05-05 16:45:12 +01:00
Marcel Hollerbach c66695bedb eo: replace loop_get with object_find
Summary:
object_find is more generic, so other mechanisms can also reuse the
code.
The object itself has to support the function, so there is no need for
eo_isa which would have a negative performance impact.
The base class implementation calls interface_get on the parent, so a
override of the function can just call the super function to continue in
the recursion.

Test Plan: just run the eo test suite

Reviewers: raster, tasn, jpeg

Reviewed By: tasn, jpeg

Subscribers: felipealmeida, netstar, cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D3909
2016-05-04 10:43:55 +02:00
Tom Hacohen 42346e22f4 Eo keyed data: Refactor the code so it's mostly shared.
The code was redundant though essentially the same. This refactoring
removes a lot of this code and made everything shared.
2016-04-29 13:53:02 +01:00
Tom Hacohen 0730152deb Eo keyed data: Unify node cleanup code. 2016-04-29 13:53:02 +01:00
Tom Hacohen 9195d008da Eo keyed data: No need to register to see if a subobject was deleted.
This is completely unnecessary. We are holding a reference to the
object, it can't get deleted under our feet.
2016-04-29 13:13:02 +01:00
Tom Hacohen 393ca3c3f9 Eo keyed data: Clean up code and fix a bug with 'Value'.
This code is an absolute mess. This is the first step towards fixing that.
This cleanup let me find a bug that would have printed errors when using
Eina_Value so I fixed that too.
2016-04-29 13:08:14 +01:00
Tom Hacohen 106951a61d Eo: Make eo_del() an eo function.
This was done following a feature request by @raster. There was no real
reason for it not to be an eo function and this gives us more
flexibility.

The reason why this done was to provide a way for classes to do special
things when an object deletion was requested, for example in the case of
Evas, hide the object.
2016-04-26 16:29:18 +01:00
Carsten Haitzler 6a84ffbe5b eo base - optimize memory by extending extension memory
so geneirc data, wrefs, comments and id's are not that common so put
them all into their own memory segment that's allocated separately to
the core object so we only use this memory when needed. we already had
an extension section anyway so it's not new - just using it now for
more of the rarer bits of data. 2 more pointers gone from most objects
anyway and now extension code handling is a bit cleaner.
2016-04-24 14:40:46 +09:00
Carsten Haitzler 5e09d1307b eo base - remove the duplicated key dels and just do eo_key_del() now
this rationalizes all the duplicated key dels (key_data, key_obj and
key_value).
2016-04-21 18:02:31 +09:00
Carsten Haitzler 26b5eb8a26 eo base - add loop_get for base class
base class objects will ask their parent object to get the loop. this
means it recurses all objects regardless of type until it finds an
object that returns a proper loop object - eg a loop object returns
itself, a window, gfx/ui object returns the mainloop object etc. etc.

@feature
2016-04-21 15:19:36 +09:00
Cedric BAIL 1fd049510f eo: add support for restartable event inside nested call.
The idea is that when you are processing those events from within
they won't call twice any of the event until all of them are processed
at least once (Or one of them did return EINA_FALSE).
2016-04-20 15:50:46 -07:00
Carsten Haitzler bc4d43a1cc eo base: names - add finding functions to fund by name
this finds child objects by walking the child tree searching children
by using the search string which can be name, class:name and both
class and name can also be a glob.

@feature
2016-04-20 18:29:41 +09:00
Carsten Haitzler 45456d9e82 eo base - add value keys in addition to object and void ptr data keys
eina value would allow any value to be attached to an eo object and
also be freed nicely too. this would allow any generic data to go
there without overloading a void * that us c coders love to abuse.

@feature
2016-04-19 18:36:57 +09:00
Carsten Haitzler 1b266ff1e4 eo base - clean up base data struct formatting
just a cleanup of the struct formatting/spacing
2016-04-19 17:40:11 +09:00
Carsten Haitzler 96142eef96 eo - add object comments - esp useful for erigo and gui builders
also useful for debugging and more. this also makes both name/id and
comment an extension blob of ram so objects dont keep growing
boundlessly in memory usage/size

@feature
2016-04-19 17:21:21 +09:00
Carsten Haitzler 86e7d642d5 eo - add object names/ids esp useful for erigo as it wants object names
also evas objects have names too, so add this as this was discussed
and now the feature is in. there is nothing to find objects by name
yet. that's more api's and features to add after this.

@feature
2016-04-19 16:34:53 +09:00
Carsten Haitzler ff253bff08 eo - key obj reference - don't unref on del event callback
object is being deleted by cb - don't unref as we are already at 0.
2016-04-14 10:35:18 +09:00
Carsten Haitzler 8be56c9498 eo - add object sotrage in generic values with ref/unref
this adds eo_key_obj_set/get/del() like with data but for object
handles so the obj is ref'd as long as the key and parent obj exists
and then unreffed on deletion. it also tracks deletion of reffed
objects like weak refs and then removes the key automatically.

@feature
2016-04-13 01:06:40 +09:00
Tom Hacohen f14305024e Eo event: rename Eo_Event->event_info to Eo_Event->info.
The previous naming was redundant and too long.
2016-04-12 15:23:55 +01:00
Tom Hacohen 912f03d6e2 Eo legacy events: remove pointless string copies.
This was there because the old code modified the string. It is no
longer needed now that we just stringshare it.
2016-03-04 14:17:55 +00:00
Daniel Zaoui 66256028d5 Eo: set object as const for key_data_get
Due to Eo4 changes, const is now important for this function.
2016-03-04 13:55:07 +02:00
Tom Hacohen 23a6b12183 Fix migration script mistakes and compilation warnings.
Mostly unused vars following the removal of eo_do_ret().
However, there are some cases where the migration script got some things
wrong, and I had to manually fix them.
2016-03-03 09:58:08 +00:00
Tom Hacohen f21ade6123 Automatic migration to Eo4.
I just ran my script (email to follow) to migrate all of the EFL
automatically. This commit is *only* the automatic conversion, so it can
be easily reverted and re-run.
2016-03-03 09:58:08 +00:00
Tom Hacohen e71e6561ee Eo callbacks: Migrate all of the EFL to the new event cb signatures. 2016-02-29 11:33:27 +00:00
Tom Hacohen 56ea371dfb Eo events: Change event callback signature.
Change the Eo event callback signature to what suggested by Marcel
Hollerbach in the ML (Thread: EFL interface change - Animator).

This changes the signature of callbacks from
Eina_Bool cb(void *data, Eo *obj const Eo_Event_Description *desc, void *event_info)
to
Eina_Bool cb(void *data, const Eo_Event *event)

Where Eo_Event is a structure that holds these parameters.

This makes it less annoying to not use parameters (you end up using
EINA_UNUSED less), and allows for future extensions to callback
parameters.

@feature
2016-02-29 11:33:24 +00:00
Cedric BAIL f1bf1e58df eo: return a value when adding or removing callback to help the caller manage state. 2016-02-02 10:47:25 -08:00
Jean-Philippe Andre 9d76a44b78 Eo: Replace deprecated EO_EV_ by EO_BASE_EVENT_ 2016-01-21 13:10:05 +09:00
Jean-Philippe Andre 22324f21b3 EFL: Mark EOLIAN functions as static when possible
This affects mostly evas filters.
2016-01-13 15:34:20 +09:00
Jean-Philippe Andre 13d9f7ebcd Eo: Print object class name during Eo.Base ctor/dtor
Printing class_name(MY_CLASS) is useless information.
Printing the object's real class name is much more useful.
2016-01-05 14:54:04 +09:00
Chris Michael c94289d0b2 eo: Fix resource leak
Coverity CID1339783 says that we have a potential resource leak here.
'cb' gets allocated via calloc, but is not freed if we end up
returning here

@fix

Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
2015-12-28 10:09:36 -05:00
Tom Hacohen e992a3a1e0 Revert "Eo: Optimise event callback call"
This reverts commit 4b116627c2.

This can't be done, because the freeze state can change from within the
callbacks so you need to check if events are frozen every time.
2015-11-09 14:06:39 +00:00
Jérémy Zurcher 4b116627c2 Eo: Optimise event callback call
check if the event is frozen before walking the event list
2015-11-09 15:03:03 +01:00
Tom Hacohen f7196513d0 Eo callback call: Remove redundant safety checks.
This is already being checked by eo_do, no need to duplicate this here.
2015-11-09 11:43:04 +00:00
Tom Hacohen 5661f96c05 Eo callback call: Remove redundant refcounting.
We already get refcounting from eo_do, no need to have more refcounting here.
2015-11-09 11:43:04 +00:00
Tom Hacohen 0908422084 Eo callback call: Simplify callback desc matching code.
As part of this change, we also error on adding invalid callbacks.
2015-11-09 11:43:04 +00:00
Tom Hacohen 9d68b14313 Eo callbacks: simplify callback call code a bit.
We don't need this check because it's already checked in the match function.
2015-11-09 11:43:04 +00:00
Tom Hacohen 8e2e7bd61e Eo events: Add a struct member marking if it's a legacy event or not.
My previous patch to this piece of code
(37f84b7e96), caused a significant
performance regression. This is such a hot path, that even accessing the
strings when we don't have to slows things down drastically. It makes
more sense to just store it in the structure.

This commit breaks ABI (though most people probably won't even need to
recompile anything else because of the memory layout).
It was discussed on IRC and was decided this is a big enough issue to
warrant a fix during the freeze.

@fix
2015-10-16 11:55:07 +01:00
Tom Hacohen d889da6b12 Eo legacy events: Fix broken callback comparison
Commit 37f84b7e96 introduced a few changes
to the callback matching mechanism that made it so sometimes callbacks
would be triggered for the wrong events. The problem was there because
of the support for legacy events that forces to do string comparison
instead of the usual pointer comparison. We should only do string
comparison when we are certain one of the callbacks is a legacy
generated one.

Regression tests will follow tomorrow. Way too late here for that.

Thanks to cedric for reporting.
2015-09-29 01:01:05 +01:00
Tom Hacohen 37f84b7e96 Eo: Drop doc field from ops and events.
This hasn't been used for a while. Since we are going to break Eo a bit anyway
it's a good opportunity to drop this.

This may cause a slight performance issues with legacy events, such as
smart callbacks. This shouldn't really be a problem as we've migrated away from
them. If it does, we need to migrate the remaining parts. Only relevant
for callbacks that are added before the classes are created, which
shouldn't be possible except for smart, only for old evas callbacks.
2015-09-28 15:09:16 +01:00
Daniel Zaoui 08e4f0ce8d Eo: fix double callback deletion
Scenario:
- Same signal/function/data registered twice on e.g mouse_down
- On mouse_down, register mouse_move and mouse_up
- On mouse_up, unregister mouse_move

Result: mouse_move still invoked after mouse_up

Reason:
- When the mouse_move callback deletion is required, the cb is
flagged as deleted but is not freed as walking_list blocks.
- When the second (and same) has to be deleted, it will try to delete
the first again because the delete_me flag is not checked.

This patch fixes it by checking the delete_me flag when determining the
candidate.

@fix
2015-09-26 22:37:03 +03:00
Tom Hacohen d6b18c1e25 Eo base: print an error when an object with a parent is destructed.
This should not happen. Objects with parents must have their parents
unset before they reach refcount == 0. That's because the parent is the
one holding the refcount. This means that if we get to the destructor
(object is deleted) while a parent is still set, we have an error
scenario.
2015-08-26 14:17:28 +01:00
Tom Hacohen acc158a2bf Revert "Revert "Eo base: Change parent_set to be an assignment of ref.""
Had to revert it until I pushed the changes to elm, which I had issues
with. Now the patch can safely go back in.

This reverts commit 37abea3831.
2015-08-26 10:47:06 +01:00
Tom Hacohen 37abea3831 Revert "Eo base: Change parent_set to be an assignment of ref."
Damn, this breaks some things. Reverting until fixed.

This reverts commit 9c78ee0bf4.
2015-08-26 10:33:24 +01:00
Tom Hacohen 9c78ee0bf4 Eo base: Change parent_set to be an assignment of ref.
After this change, parent_set assigns a ref, so for example:
  obj = eo_add(CLASS, parent); /* Ref is 1 */
  eo_do(obj, eo_parent_set(parent2)); /* Ref is 1 */
  eo_ref(obj); /* Ref is 2 */
  eo_do(obj, eo_parent_set(NULL)); /* Ref is 1, giving the ref to NULL */
  eo_do(obj, eo_parent_set(parent)); /* Ref is 1 */

This is following a discussion on the ML about commit
8689d54471.

@feature
2015-08-26 10:11:18 +01:00
Tom Hacohen 93ade6f4ce Eo base: clean up parent removal in destructor.
This cleans up the changes in 8689d54471.
This commit reduces code duplication, and fixes broken handling of
overridden parent_set().
2015-08-21 17:23:13 +01:00
Carsten Haitzler a6c184502e eo - use ren not xref for children to not waste memory
optimization

xrefs keep lists of objects references. children are already in a list.
why keep both? lots of extra memory used for no value when debug is on
(pretty much most of the time).
2015-08-20 19:41:47 +09:00
Carsten Haitzler 8689d54471 eo - destruction - ensure child is removed from parent child list
this follows on from cbc1a217bf as this
code was correct, but was then causing bugs due to children staying in
their parent lists. this should never have happened and this is really
bad. this fixes this and ensures children on destruction are gone from
their parent lists.

@fix
2015-08-20 12:53:53 +09:00
Carsten Haitzler cbc1a217bf eo - fix bug vector when unparenting of an eo obj may affect others
it is possible that a destructor/parent_set override or function could
go modifying the children list of objects in a parent, this the
EINA_LIST_FREE may actually miss objects in the process since within
the "free" func the list may have been altered etc.

@fix
2015-08-18 17:23:16 +09:00
Tom Hacohen 52d998f475 Eo base: Remove the free_func parameter from key_data_set.
This was not really useful and against the Eolian guidelines.
While I promised I won't break things until the 27th, I was ill
(still am), so I'm giving myself a 1 day pass. :P
2015-05-28 17:47:59 +01:00
Tom Hacohen 92fb2917cb Eo: Remove eo_error_set() and clean up finalizer()
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.
2015-05-20 16:25:38 +01:00
Tom Hacohen 6efbfe227a Eo: Add a return value to eo_constructor().
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
2015-05-20 13:03:24 +01:00
Tom Hacohen e27f40111d Eo: Mark composite APIs as beta.
Until now we used @protected, but now we can finally properly use @beta.
2015-05-08 16:18:36 +01:00
Tom Hacohen 1506ec30ba Eo base: mark composite API as not ready. 2015-05-06 15:46:18 +01:00
Tom Hacohen a791d97bfc Eo: Remove GCCism and make it more portable.
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.
2015-02-23 17:16:02 +00:00
Tom Hacohen 01a487d881 Eo composite: Fix composite object functions to be eo functions.
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.
2014-10-21 12:37:00 +01:00
Tom Hacohen 2a0937b889 Eo base: Add a property to indicate if the object is finalized;
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()).
2014-08-29 10:26:23 +01:00
Tom Hacohen ab38ffd6ed Eo base: Fix marking of eolian functions with EOLIAN. 2014-07-24 15:35:00 +01:00
Tom Hacohen 490eebabea Eo base: Mark class methods.
Use the new @class attribute to mark class methods.
2014-07-24 15:35:00 +01:00
Cedric BAIL 3dcc172f57 eo: make parent_set a O(1) operation instead of O(n).
This does impact performance quite significantly when you have a lot
of children.
2014-07-06 13:15:21 +02:00
Tom Hacohen 6eb3bda426 Eo base: Start generating eo_base from the .eo file. 2014-06-03 11:28:02 +01:00
Tom Hacohen d9263e6571 Eo base: rename event_freeze_get to event_freeze_count_get.
This is needed because of a possible clash between the method event_freeze
and the property event_freeze with bindings.
2014-06-02 12:50:23 +01:00
Tom Hacohen f92e5d50f9 Eo: Add eo_finalize. A func that's called at the end of eo_add.
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
2014-05-30 11:22:36 +01:00
Tom Hacohen 1e1104584f Eo legacy events: Add missing addition to hash table.
This rendered the whole thing useless.

Found thanks to coverity.
CID 1216616
CID 1216617
2014-05-29 09:24:28 +01:00
Tom Hacohen 50a6e371a1 Eo: Support mixing legacy and non-legacy callbacks. 2014-05-28 12:28:18 +01:00
Tom Hacohen c58b3401c3 Eo/evas events: Move legacy events dynamic generator to eo. 2014-05-28 12:28:17 +01:00
Tom Hacohen cdea54dd40 Eo callbacks: Fix a possible issue of corrupted callback list.
This happens when we delete more than one callback at the beginning
of the list (i.e 2 or more) in one go.
2014-05-16 14:33:36 +01:00
Tom Hacohen ecc445b47c Eo: Don't write to pointer after free.
Fixes coverity: CID 1039898.
2014-05-16 14:33:36 +01:00
Tom Hacohen 9b265b0065 Revert "Eo: Fix deref after free."
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.
2014-05-16 14:33:00 +01:00
Tom Hacohen 831c20464d Eo: Fix deref after free.
In some rare cases it was possible for a pointer to be referenced after
it was already freed. This is now fixed thanks to coverity.

@fix

CID 1039898
2014-05-16 14:28:57 +01:00
Tom Hacohen 1fe084b78c Eo: Made some functions class functions again.
This broke in the transition to Eo2.
2014-05-01 13:58:27 +01:00
Lukasz Stanislawski 80b1ca8e43 eo: fix broken children iterator, remove redundant fields.
@fix

Summary: Tests added.

Reviewers: raster, JackDanielZ, tasn

CC: cedric

Differential Revision: https://phab.enlightenment.org/D763

Signed-off-by: Cedric Bail <cedric.bail@free.fr>
2014-04-17 19:36:12 +02:00
Tom Hacohen 8c025ee4d9 Eo: Renamed eo files from eo2* to eo*. 2014-04-10 04:20:21 +01:00
Tom Hacohen 3c46e7dab8 Eo2: Removed a lot of Eo1 code. 2014-04-10 04:20:21 +01:00
Jérémy Zurcher 2490a1bef2 eo2: better op_descs integration
struct _Eo_Class_Description swallows
Eo2_Op_Description *descs2;
2014-04-10 04:20:15 +01:00
Jérémy Zurcher f05f51dd60 eo2: _Eo_Class_Description swallows op_descs
remove OpDescs argument from macros,
eo2_get_op_id() uses binary search
2014-04-10 04:20:15 +01:00
Tom Hacohen c5af1a7305 Eo: Add an error message when old parent is wrong.
This is an addition to raster's fix in
55d8156414
(eo - base class protection against NULL old_parent_pd)
2013-11-26 10:10:24 +00:00
Carsten Haitzler 55d8156414 eo - base class protection against NULL old_parent_pd
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
2013-11-26 17:03:50 +09:00
Tom Hacohen cad3cf30a4 Eo: Check parent is valid in eo_parent_set.
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.
2013-11-20 12:23:18 +00:00
Carsten Haitzler 0355a6a296 eo - fix _parent_set in base clase when old_parent_pd is NULL
this should fix T538
2013-11-20 20:25:33 +09:00
Tom Hacohen a52751d065 Eo: Fixed potential infinite loop with child deletion.
It looks like it should get into a loop for every object that has
children.
2013-11-08 12:11:27 +00:00
Tom Hacohen c7addf4083 Changed Eo class names to be consistent.
All the class names are now of the format: Lib_Type_Subtype_Extra.
2013-11-07 11:17:52 +00:00
Carsten Haitzler 69e27abdc3 eina - and e3fl in general - stop using eina_error_get/set - useless really 2013-10-11 16:50:40 +09:00
Cedric Bail 435caae51a eo: use Eina_Spinlock instead of Eina_Lock.
This is an ABI/API break for Eo, you will need to rebuild everything that use Eo.
2013-10-11 11:08:17 +09:00
Tom Hacohen 104a57b58a Eo callbacks: Fix a possible issue of corrupted callback list.
This happens when we delete more than one callback at the beginning
of the list (i.e 2 or more) in one go.
2013-09-30 14:16:46 +01:00
Tom Hacohen f5d4a807c8 Eo: Don't write to pointer after free.
Fixes coverity: CID 1039898.
2013-09-30 14:15:37 +01:00
Daniel Zaoui 334ac705f3 Eo: fix when detaching the composite of its parent ... that has to exist 2013-09-29 08:50:32 +03:00
Tom Hacohen 832fc5b5ce Manually revert "eo: replace Eo_Class with Eo"
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.
2013-09-27 16:40:32 +01:00
Tom Hacohen 2a82ff95e4 Eo: unify the class func and normal func prototypes.
Conflicts:
	src/lib/eo/eo.c
2013-09-27 14:01:47 +01:00
Jérémy Zurcher 41bd91379e eo: _Eo -> _Eo_Object
Conflicts:
	src/lib/eo/eo.c
2013-09-27 14:01:46 +01:00
Jérémy Zurcher ee1b0833ed eo: replace Eo_Class with Eo 2013-09-27 14:01:46 +01:00