Commit Graph

222 Commits

Author SHA1 Message Date
Avi Levin fa8f786d44 back 2015-03-16 15:55:32 +02: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 40cb2cd3d4 Eo add: beef up error reporting.
In some cases object ceration would fail without an error,
this is bad and should not happen.

Thanks to cedric for reporting.
2015-01-23 16:51:18 +00:00
Nicolas Aguirre 2982b05288 Eo: use int for _eo_init_count intsead of Eina_Bool 2015-01-12 14:48:22 +01:00
Avi Levin b384cd3f62 eo: Fix bad addressing in _eo_classes array
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
2015-01-08 14:29:07 +00: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 2cd728373c Eo comp: Remove dead code following the composite fix.
This removes dead code resulting from Cedric's fix:
3550c38080.
2014-10-28 15:19:41 +00:00
Cedric BAIL 3550c38080 eo: fix composite to actually work.
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.
2014-10-27 23:44:40 +01: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 5db7a70603 Revert "Revert "Eo: Move eo_add_ref logic inside the library.""
This reverts commit 11da942184.

Can't reproduce with the non-existent bug report, thus have no choice
but consider it as working.
2014-10-10 09:30:52 +01:00
Mike Blumenkrantz 11da942184 Revert "Eo: Move eo_add_ref logic inside the library."
This reverts commit 8d16d8eb57.

this broke child object deletion in all the cases that I tested and regular object deletion in some cases as well
2014-10-09 21:07:30 -04:00
Tom Hacohen 8d16d8eb57 Eo: Move eo_add_ref logic inside the library.
It was a stupid lazy decision to leave it outside. Having it inside is safer
and cleaner.
2014-10-02 15:02:48 +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 b33372b1f6 Eo do: simplify eo_do macro.
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.
2014-09-23 14:36:20 +01:00
Jérémy Zurcher b3ffe9229a eo: call stack depth is 1024 2014-09-23 10:51:05 +02:00
Jérémy Zurcher 389c6d35f2 eo: call stack can grow/shrink when not using mmap
- if HAVE_MMAP call stack do not shrink and abort() when should grow
- otherwise it's a growing/shrinking stack using realloc
2014-09-23 10:47:24 +02:00
Jérémy Zurcher 88c5996dc1 eo: remove stack->max_size
- define EO_CALL_STACK_SIZE instead of stack->max_size
- we are talking about size here not maxsize
2014-09-23 10:43:36 +02:00
Jérémy Zurcher dc3add048f eo: remove XXX, it's ok now ... 2014-09-23 10:41:13 +02:00
Jérémy Zurcher a4c3299f41 eo: unify error msgs 2014-09-23 10:29:44 +02:00
Jérémy Zurcher 95e610d89a eo: call stack remove stack->dropcount
stack->shrink_frame does the same but more efficiently
change the value of EO_CALL_STACK_SHRINK_DROP if needed
2014-09-23 10:26:33 +02:00
Jérémy Zurcher 007efb5f05 eo: fix call stack shrink_frame
- do never shrink under EO_CALL_STACK_DEPTH_MIN size
- set shrink_frame at (current_size/2) - EO_CALL_STACK_SHRINK_OFFSET
2014-09-23 10:24:06 +02:00
Jérémy Zurcher 209a7506c3 eo: remove FIXME: Thread Local Storage
done in d39d7050
2014-09-23 10:21:26 +02:00
Cedric BAIL d86f094d67 eo: do not call eina_tls_get as often when in the main loop.
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>
2014-09-04 18:11:45 +02:00
Cedric BAIL 68384fc7ef eo: let's be consistent and use the portable flag MAP_ANON. 2014-09-03 17:14:39 +02: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
Daniel Kolesa 78acf69e20 eo, autotools: check for mmap feature rather than OS (mmap is POSIX) 2014-08-21 11:54:17 +01:00
Jean Guyomarc'h dc8e006e4f eo: mmap()/unmap() are also supported on OSX
Reviewers: raster, raoulh
@feature

Subscribers: cedric

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

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2014-08-21 12:04:53 +02: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
Jean-Philippe Andre 188ffd412c Eo: Fix crash on WIN32 (wrong check for NULL)
Thanks vtorri for the report
2014-06-10 14:57:58 +09:00
Cedric BAIL acc99074d1 eo: force zeroing memory on non Linux system.
@fix
2014-06-09 19:55:40 +02:00
Tom Hacohen 10626ff538 Eo: Fix and use the abstract class .eo file.
Until now it was just there, but never generated or used.
2014-06-03 09:19:19 +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
Guillaume Friloux 949b51af24 Fix unused param warning when building on non linux. 2014-05-30 10:38:27 +02:00
Jean-Philippe Andre f4a0c8054f Win64: Fix a bunch of warnings
Fix invalid casts.
Use printf("%z") where appropriate.
Fix unused variables warnings.

Thanks vtorri for the patch.

@fix
2014-05-29 20:02:16 +09:00
Jean-Philippe Andre 02f24d76e1 Eo: Add function name to OP desc on Windows
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
2014-05-21 18:03:53 +09:00
Tom Hacohen 8784685120 Eo: Rename descs2 to descs (remnant of the Eo2 change). 2014-05-09 08:26:25 +01:00
Jérémy Zurcher 0b97c11ea2 eo: improve error reporting, update tests 2014-05-08 13:44:47 +02:00
Jérémy Zurcher 0ce3154656 eo: improve error reporting for _eo_api_op_id_get() 2014-05-08 00:15:53 +02:00
Tom Hacohen e699087521 Eo: fixed misleading indentation. 2014-05-01 13:28:30 +01:00
Carsten Haitzler 1ed6e2cf9c improve eo call stack
it now does up to 8192 entries and madvise unused upper pages when
dropping. also delay dropping to avoi too many syscalls
2014-04-22 20:24:27 +09:00
Carsten Haitzler f21cfc0554 eo - callstack. realloc is a bad idea. use mmap and keep addr fixed
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).
2014-04-22 19:19:24 +09:00
Cedric Bail cb43636bd1 eo: do not risk dereferencing NULL.
CID 1199563.
2014-04-17 21:10:34 +02:00
Carsten Haitzler 08484aa646 formatting fix (spacing) 2014-04-17 16:35:43 +09:00
Tom Hacohen d77a7ce468 Eo: eo_do now returns called func's value + default ret fix.
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
2014-04-14 10:54:08 +01:00
Tom Hacohen 68a1f1941a Eo: Fix class checking.
Without this patch, NULL, and random garbage are detected as classes.
This fixes is.
2014-04-14 10:54:08 +01:00
Daniel Zaoui 1a895149e7 Eo: fix warning on printf 2014-04-10 11:42:54 +03:00
Tom Hacohen a77f090256 Eo2: Make internal function static + improved debug output. 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