Commit Graph

63 Commits

Author SHA1 Message Date
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 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 2373fd5fd2 Eo: change refcount to short from int.
A short is more than enough for reference counting.
2016-05-17 10:26:54 +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
Carsten Haitzler 3df71ab0f6 eo del interceptor: add the ability to intercept deletions of eo objects
Imagine this. You have an object. You pass this object handle as a
message to another thread. Let's say it's not a UI object, so
something you might expect to be able to be accessed from multiple
threads. In order to keep the object alive you eo_ref() it when
placing the message on a queue and eo_unref() it once the message is
"done" in the other thread. If the original sender unref()ed the
object before the message is done, then the object will be destroyed
in the reciever thread. This is bad for objects "expecting" not to be
destroyed outside their owning thread.

This allows thius situation to be fixed. A constructor in a class of
an object can set up a delete interceptor. For example if we have a
"loop ownership" class you multi-ple-inherit from/use as a mixin. This
class will set up the interceptor to ensure that on destruction if
pthread_self() != owning loop thread id, then add object to "delete
me" queue on the owning loop and wake it up. the owning loop thread
will wake up and then process this queue and delete the queued objects
nicely and safely within the "owning context".

This can also be used in this same manner to defer deletion within a
loop "until later" in the same delete_me queue.

You can even use this as a caching mechanism for objects to prevernt
their actual destruction and instead place them in a cached area to be
picked from at a later date.

The uses are many for this and this is a basic building block for
future EFL features like generic messages where a message payload
could be an eo object and thus the above loop onwership issue can
happen and needs fixing.

This adds APIs, implementation, documentation (doxy reference) and tests.

@feature
2016-03-08 16:57:22 +09:00
Tom Hacohen fc88037977 Eo: Migrate to the new syntax (Eo 4).
The syntax is described in: https://phab.enlightenment.org/w/eo/

Summary:
eo_do(obj, a_set(1)) -> a_set(obj, 1)
eo_do_super(obj, CLASS, a_set(1)) -> a_set(eo_super(obj, CLASS), 1)

eo_do_*_ret() set of functions are no longer needed.

This is the first step, the next step would be to also fix up eo_add()
which currently still uses the old syntax and is not 100% portable.

@feature
2016-03-03 09:53:23 +00:00
Tom Hacohen 1f576da49e Revert "Eo: Print an ERR when deleting an object with data refs."
Revert this in the meanwhile. See discussion on the ML. This should be
enabled though, and issues fixed.

This reverts commit ec2f92e35f.
2016-02-18 19:28:41 +00:00
Tom Hacohen ec2f92e35f Eo: Print an ERR when deleting an object with data refs. 2016-02-18 15:59:36 +00:00
Jean-Philippe Andre 9d76a44b78 Eo: Replace deprecated EO_EV_ by EO_BASE_EVENT_ 2016-01-21 13:10:05 +09:00
Tom Hacohen 9686e44b92 Eo unref: Decrease amount of checks and hint branch prediction.
This may look minor, but this is such a hot path, that this actually
speeds things up a bit.
2015-11-09 11:43:04 +00:00
Tom Hacohen 6107f235aa Eo: Remove redundant semicolon.
Thanks to Vincent Torri for spotting this one.
2015-06-29 12:52:40 +01:00
Tom Hacohen 293d286977 Eo: rename conflicting internal Eo_Base to Eo_Header
This name conflicts with the class Eo.Base and should have
been called Eo_Header from the start anyway.
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 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
Daniel Zaoui bcd7736914 Eo: fix error handling when too many deletions invocations occur.
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.
2014-12-05 03:38:16 +02:00
Jérémy Zurcher 18ceed4daf Eo: protect against recursive object destruction calls, fixes T1741
Summary:
    Eo: semantic obj->del replaced by obj->destructed
    Eo: protect against recursive object destruction calls
    Eo: add tests for bfada4b

Reviewers: JackDanielZ, tasn

Reviewed By: tasn

Subscribers: cedric

Maniphest Tasks: T1741

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

Fixes T1741

@fix
2014-11-18 15:25:34 +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 bc6b6aa457 Eo: Better define the relationship of eo_add/del/ref/unref.
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.
2014-09-30 14:53:09 +01:00
Tom Hacohen a7560dbc61 Eo: Change eo_add/del/unref behaviour.
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).
2014-09-25 17:38:45 +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 46b3643ff0 Revert "eo: replace composite_objects Eina_List with an array of Eo_Object*"
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.
2014-06-13 18:20:24 +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
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 1fbcb6ef98 Eo: Removed redundant code. 2014-04-10 04:20:21 +01:00
Tom Hacohen c32bb4fe95 Eo2: Updated naming Eo2->Eo. 2014-04-10 04:20:21 +01:00
Tom Hacohen 80faa56ed3 Eo2: Removed more Eo1 code. 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 1834e3ff12 eo2: remove dead code 2014-04-10 04:20:20 +01:00
Jérémy Zurcher 796b151c27 eo2: minor fixes after huge rebase
indentation
use _Eo_Object * instead of _Eo *
use EO_CLASS_POINTER_RETURN_VAL(), _eo_id_get(), and _eo_class_id_get().
2014-04-10 04:20:17 +01:00
Tom Hacohen 5f45e57b89 eo2: revert "eo2_add accepts non-defauld constructors"
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.
2014-04-10 04:20:17 +01:00
Jérémy Zurcher 28d66a9858 eo2: eo_del_internal use same logic as in eo_add_internal 2014-04-10 04:20:17 +01:00
Jérémy Zurcher 42ad23c5c8 eo2: eo2_add accepts non-defauld constructors 2014-04-10 04:20:17 +01:00
Jérémy Zurcher 2edd305507 eo2: set eo2_constructor and eo2_destructor chaining 2014-04-10 04:20:16 +01:00
Jérémy Zurcher 6a16edc888 eo2: call stack Proof Of Concept
no grow/shrink or thread local storage
2014-04-10 04:20:16 +01:00
Jérémy Zurcher ef09ef7489 eo: replace composite_objects Eina_List with an array of Eo_Object*
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.
2014-03-05 23:57:39 +01:00
Jérémy Zurcher c7922f92bc eo: revert 13502a1 and 7821df1
I'm running out of time, will look at it later
2014-02-27 15:02:45 +01:00
Jérémy Zurcher 7821df17dc eo: replace composite_objects Eina_List with an array of Eo_Object*
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.
2014-02-26 16:25:00 +01:00
Daniel Juyung Seo 76d8532b54 efl: Unified eina critical manro to CRI.
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.
2013-12-26 12:27:13 +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 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 ba5af54f6d Eo: Fixed the type _eo_id_get accepts. 2013-09-27 14:01:47 +01:00
Tom Hacohen e3cb9195c2 Eo: Explicitly include Eina.h in eo_private.h.
It's uses eina stuff, we can't just assume eina is already included.
2013-09-27 14:01:47 +01:00
Tom Hacohen 01effff86f Eo: Get rid of the _Eo type, it's not needed.
We have Eo_Base for that.
2013-09-27 14:01:47 +01:00
Tom Hacohen 1059f802bf Eo: Rename Eo_Header to Eo_Base. 2013-09-27 14:01:47 +01:00
Tom Hacohen e17e66db8c Eo: Get rid of handle. Use the shared header for detection. 2013-09-27 14:01:47 +01:00
Tom Hacohen 5e90d51013 Eo: Merge common part of class and object.
First step toward getting rid of "handle".
2013-09-27 14:01:47 +01:00
Tom Hacohen 8dbbc16731 Eo: Class_Id and Object_Id are now the same type. 2013-09-27 14:01:47 +01:00
Jérémy Zurcher c24775c58d eo: add union _Eo to unify objects and classes internal pointers 2013-09-27 14:01:46 +01:00