On 06/05/15 20:25, Davide Andreoli wrote:
> 2015-05-06 19:04 GMT+02:00 Tom Hacohen <[email protected]>:
>
>> tasn pushed a commit to branch master.
>>
>>
>> http://git.enlightenment.org/core/efl.git/commit/?id=6cb22bae35a8e621e0857fc2738657ff068478f8
>>
>> commit 6cb22bae35a8e621e0857fc2738657ff068478f8
>> Author: Tom Hacohen <[email protected]>
>> Date:   Fri Apr 17 14:31:19 2015 +0100
>>
>>      Eo: Add eo_do_part.
>>
>>      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
>>
>
> Is there a reason why efl_part_name_get() is named like this?
> It seems to me the name for the function is wrong, or confusing at
> least...
> *_name_get means: get the name of the part,
> while the function actually does the contrary. No?
>
> And why not just make the macro call the part_get function internally?
> So that it can be used like:
> eo_do_part(obj, "partname", a_set(7));
> This seems much more natural to me
>

Hey,

efl_part_name_get() is not named like anything. It doesn't exist. This 
part_get feature is an experiment I'd like to see if it picks up. 
However, nothing is using it at the moment.

The problem with eo_do_part() the way you've suggested it, is that it 
limits us to a specific function and a specific number of arguments. I 
see it as something that will be used like:
eo_do_part(obj, efl_list_first_get(), a_set(7));
too and many other variations on that.

--
Tom.

>
>
>> ---
>>   src/lib/eo/Eo.h                           |  7 +++++++
>>   src/tests/eo/suite/eo_test_class_simple.c | 10 +++++++++
>>   src/tests/eo/suite/eo_test_class_simple.h |  1 +
>>   src/tests/eo/suite/eo_test_general.c      | 34
>> +++++++++++++++++++++++++++++++
>>   4 files changed, 52 insertions(+)
>>
>> diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
>> index c1ff090..0825f90 100644
>> --- a/src/lib/eo/Eo.h
>> +++ b/src/lib/eo/Eo.h
>> @@ -605,6 +605,13 @@ EAPI Eo * _eo_add_end(void);
>>
>>   #define eo_do_super_ret(eoid, clsid, ret_tmp, func)
>> _eo_do_common_ret(eoid, clsid, EINA_TRUE, ret_tmp, func)
>>
>> +#define eo_do_part(eoid, part_func, ...) \
>> +  do { \
>> +       Eo *__eo_part = eoid; \
>> +       eo_do(eoid, __eo_part = part_func); \
>> +       eo_do(__eo_part, __VA_ARGS__); \
>> +  } while (0)
>> +
>>
>>   
>> /*****************************************************************************/
>>
>>   /**
>> diff --git a/src/tests/eo/suite/eo_test_class_simple.c
>> b/src/tests/eo/suite/eo_test_class_simple.c
>> index cbefee7..4bc3904 100644
>> --- a/src/tests/eo/suite/eo_test_class_simple.c
>> +++ b/src/tests/eo/suite/eo_test_class_simple.c
>> @@ -45,6 +45,15 @@ _class_hi_print(Eo_Class *klass, void *data EINA_UNUSED)
>>      return EINA_TRUE;
>>   }
>>
>> +EO_FUNC_BODYV(simple_part_get, Eo *, NULL, EO_FUNC_CALL(name), const char
>> *name);
>> +
>> +static Eo *
>> +_part_get(Eo *obj, void *class_data EINA_UNUSED, const char *name
>> EINA_UNUSED)
>> +{
>> +   /* A normal part get will do something saner, we just create objects.
>> */
>> +   return eo_add(SIMPLE_CLASS, obj);
>> +}
>> +
>>   EO_VOID_FUNC_BODYV(simple_recursive, EO_FUNC_CALL(n), int n);
>>
>>   static void
>> @@ -83,6 +92,7 @@ static Eo_Op_Description op_descs[] = {
>>        EO_OP_FUNC(simple_a_print, _a_print, "Print property a"),
>>        EO_OP_CLASS_FUNC(simple_class_hi_print, _class_hi_print, "Print
>> property a"),
>>        EO_OP_FUNC(simple_recursive, _recursive, "Recursive function"),
>> +     EO_OP_FUNC(simple_part_get, _part_get, "Part getter"),
>>        EO_OP_FUNC(simple_pure_virtual, NULL, "Pure Virtual function"),
>>        EO_OP_SENTINEL
>>   };
>> diff --git a/src/tests/eo/suite/eo_test_class_simple.h
>> b/src/tests/eo/suite/eo_test_class_simple.h
>> index 7d774b7..2fce591 100644
>> --- a/src/tests/eo/suite/eo_test_class_simple.h
>> +++ b/src/tests/eo/suite/eo_test_class_simple.h
>> @@ -13,6 +13,7 @@ EAPI Eina_Bool simple_class_hi_print(void);
>>   EAPI void simple_recursive(int n);
>>   EAPI void simple_pure_virtual(void);
>>   EAPI void simple_no_implementation(void);
>> +EAPI Eo *simple_part_get(const char *name);
>>
>>   extern const Eo_Event_Description _EV_A_CHANGED;
>>   #define EV_A_CHANGED (&(_EV_A_CHANGED))
>> diff --git a/src/tests/eo/suite/eo_test_general.c
>> b/src/tests/eo/suite/eo_test_general.c
>> index 684a05c..b0dc77a 100644
>> --- a/src/tests/eo/suite/eo_test_general.c
>> +++ b/src/tests/eo/suite/eo_test_general.c
>> @@ -939,6 +939,39 @@ START_TEST(eo_add_failures)
>>   }
>>   END_TEST
>>
>> +START_TEST(eo_parts)
>> +{
>> +   int a = 0;
>> +
>> +   eo_init();
>> +
>> +   Eo *obj = eo_add(SIMPLE_CLASS, NULL);
>> +
>> +   eo_do(obj, simple_a_set(3), a = simple_a_get());
>> +   ck_assert_int_eq(a, 3);
>> +
>> +   eo_do_part(obj, simple_part_get("test"),
>> +         simple_a_set(7),
>> +         a = simple_a_get()
>> +         );
>> +   ck_assert_int_eq(a, 7);
>> +
>> +   eo_do(obj, simple_a_set(3), a = simple_a_get());
>> +   ck_assert_int_eq(a, 3);
>> +
>> +   /* Faking a call, just asserting NULL as the part to check default
>> values. */
>> +   eo_do_part(obj, NULL,
>> +         simple_a_set(7),
>> +         a = simple_a_get()
>> +         );
>> +   ck_assert_int_eq(a, 0);
>> +
>> +   eo_del(obj);
>> +
>> +   eo_shutdown();
>> +}
>> +END_TEST
>> +
>>   void eo_test_general(TCase *tc)
>>   {
>>      tcase_add_test(tc, eo_simple);
>> @@ -956,4 +989,5 @@ void eo_test_general(TCase *tc)
>>      tcase_add_test(tc, eo_add_do_and_custom);
>>      tcase_add_test(tc, eo_pointers_indirection);
>>      tcase_add_test(tc, eo_add_failures);
>> +   tcase_add_test(tc, eo_parts);
>>   }
>>
>> --
>>
>>
>>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> enlightenment-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to