Re: [E-devel] [EGIT] [core/efl] master 02/05: Eo: Add efl_replace() function.

2016-12-05 Thread Gustavo Sverzut Barbieri
the purpose is to properly order ref + unref so if the same object, or
dependent objects are used, the new object gets a ref before we drop
the old one.

which is not what people usually do, since we'd need an intermediate
variable or careful code, people often unref() -> ref(), if it was the
same object, ref could drop to zero and you get errors. I've seen lots
of them while doing stringshare, then stringshare replace was added.

of course it also handle the same ptr case by being "noop" with an early return


On Mon, Dec 5, 2016 at 11:30 PM, Carsten Haitzler  wrote:
> On Mon, 5 Dec 2016 13:50:12 + Tom Hacohen  said:
>
>> I never liked the stringshare function that does it, so it comes with no
>> surprise that I don't like this one either.
>>
>> Regardless of that, I find the name very confusing. I didn't understand
>> what it does when I saw the name nor when I read the docs. I had to read
>> the code to understand what it's for... I'd change the name and fix the
>> docs.
>
> i don't even know what the function is meant to do... the docs at least dont'
> tell me. they even speak of the "string pointed to by @c" ... ?
>
> it looks like it just unrefs what was there before in what storage points to,
> and adds a ref to the new object... should it even add a ref to the new 
> object?
>
>> --
>> Tom.
>>
>> On 02/12/16 17:35, Guilherme Iscaro wrote:
>> > bdilly pushed a commit to branch master.
>> >
>> > http://git.enlightenment.org/core/efl.git/commit/?id=81782414dfba9a8a69ea42a4dd5b01fc19170d88
>> >
>> > commit 81782414dfba9a8a69ea42a4dd5b01fc19170d88
>> > Author: Guilherme Iscaro 
>> > Date:   Fri Dec 2 11:16:33 2016 -0200
>> >
>> > Eo: Add efl_replace() function.
>> >
>> > This new function adds a new way to safely replace Eo pointer values.
>> > ---
>> >  src/lib/eo/Eo.h | 22 ++
>> >  1 file changed, 22 insertions(+)
>> >
>> > diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
>> > index 8c81544..244478b 100644
>> > --- a/src/lib/eo/Eo.h
>> > +++ b/src/lib/eo/Eo.h
>> > @@ -1334,6 +1334,28 @@ EAPI int efl_callbacks_cmp(const
>> > Efl_Callback_Array_Item *a, const Efl_Callback_
>> > EFL_CALLBACK_PRIORITY_DEFAULT, data)
>> >
>> >  /**
>> > + * @def Replace the previously Eo pointer with new content.
>> > + *
>> > + * @param storage The object to replace the old reference. It can not be
>> > @c NULL.
>> > + * @param new_obj The new object. It may be @c NULL.
>> > + *
>> > + * The string pointed by @c storage must be previously an Eo or
>> > + * @c NULL and it will be efl_unref(). The @a new_obj will be passed
>> > + * to efl_ref() and then assigned to @c *storage.
>> > + *
>> > + * @see efl_ref()
>> > + * @see efl_unref()
>> > + */
>> > +static inline void
>> > +efl_replace(Eo **storage, Eo *new_obj)
>> > +{
>> > +   if (!storage || *storage == new_obj) return;
>> > +   efl_ref(new_obj);
>> > +   efl_unref(*storage);
>> > +   *storage = new_obj;
>> > +}
>> > +
>> > +/**
>> >   * @}
>> >   */
>> >
>> >
>>
>>
>> --
>> ___
>> enlightenment-devel mailing list
>> enlightenment-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>>
>
>
> --
> - Codito, ergo sum - "I code, therefore I am" --
> The Rasterman (Carsten Haitzler)ras...@rasterman.com
>
>
> --
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today.http://sdm.link/xeonphi
> ___
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel



-- 
Gustavo Sverzut Barbieri
--
Mobile: +55 (16) 99354-9890

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [EGIT] [core/efl] master 02/05: Eo: Add efl_replace() function.

2016-12-05 Thread The Rasterman
On Mon, 5 Dec 2016 13:50:12 + Tom Hacohen  said:

> I never liked the stringshare function that does it, so it comes with no 
> surprise that I don't like this one either.
> 
> Regardless of that, I find the name very confusing. I didn't understand 
> what it does when I saw the name nor when I read the docs. I had to read 
> the code to understand what it's for... I'd change the name and fix the 
> docs.

i don't even know what the function is meant to do... the docs at least dont'
tell me. they even speak of the "string pointed to by @c" ... ?

it looks like it just unrefs what was there before in what storage points to,
and adds a ref to the new object... should it even add a ref to the new object?

> --
> Tom.
> 
> On 02/12/16 17:35, Guilherme Iscaro wrote:
> > bdilly pushed a commit to branch master.
> >
> > http://git.enlightenment.org/core/efl.git/commit/?id=81782414dfba9a8a69ea42a4dd5b01fc19170d88
> >
> > commit 81782414dfba9a8a69ea42a4dd5b01fc19170d88
> > Author: Guilherme Iscaro 
> > Date:   Fri Dec 2 11:16:33 2016 -0200
> >
> > Eo: Add efl_replace() function.
> >
> > This new function adds a new way to safely replace Eo pointer values.
> > ---
> >  src/lib/eo/Eo.h | 22 ++
> >  1 file changed, 22 insertions(+)
> >
> > diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
> > index 8c81544..244478b 100644
> > --- a/src/lib/eo/Eo.h
> > +++ b/src/lib/eo/Eo.h
> > @@ -1334,6 +1334,28 @@ EAPI int efl_callbacks_cmp(const
> > Efl_Callback_Array_Item *a, const Efl_Callback_
> > EFL_CALLBACK_PRIORITY_DEFAULT, data)
> >
> >  /**
> > + * @def Replace the previously Eo pointer with new content.
> > + *
> > + * @param storage The object to replace the old reference. It can not be
> > @c NULL.
> > + * @param new_obj The new object. It may be @c NULL.
> > + *
> > + * The string pointed by @c storage must be previously an Eo or
> > + * @c NULL and it will be efl_unref(). The @a new_obj will be passed
> > + * to efl_ref() and then assigned to @c *storage.
> > + *
> > + * @see efl_ref()
> > + * @see efl_unref()
> > + */
> > +static inline void
> > +efl_replace(Eo **storage, Eo *new_obj)
> > +{
> > +   if (!storage || *storage == new_obj) return;
> > +   efl_ref(new_obj);
> > +   efl_unref(*storage);
> > +   *storage = new_obj;
> > +}
> > +
> > +/**
> >   * @}
> >   */
> >
> >
> 
> 
> --
> ___
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> 


-- 
- Codito, ergo sum - "I code, therefore I am" --
The Rasterman (Carsten Haitzler)ras...@rasterman.com


--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [EGIT] [core/efl] master 02/05: Eo: Add efl_replace() function.

2016-12-05 Thread marcel-hollerbach
Hello,

maybe 'efl_ref_replace' since its a replacement of a referenced field.

Greetings
   Marcel Hollerbach

On Mon, Dec 05, 2016 at 12:16:15PM -0200, Guilherme Íscaro wrote:
> Hello,
> 
> Well, what name do you suggest?
> 
> On Mon, Dec 5, 2016 at 11:50 AM, Tom Hacohen  wrote:
> 
> > I never liked the stringshare function that does it, so it comes with no
> > surprise that I don't like this one either.
> >
> > Regardless of that, I find the name very confusing. I didn't understand
> > what it does when I saw the name nor when I read the docs. I had to read
> > the code to understand what it's for... I'd change the name and fix the
> > docs.
> >
> > --
> > Tom.
> >
> > On 02/12/16 17:35, Guilherme Iscaro wrote:
> > > bdilly pushed a commit to branch master.
> > >
> > > http://git.enlightenment.org/core/efl.git/commit/?id=
> > 81782414dfba9a8a69ea42a4dd5b01fc19170d88
> > >
> > > commit 81782414dfba9a8a69ea42a4dd5b01fc19170d88
> > > Author: Guilherme Iscaro 
> > > Date:   Fri Dec 2 11:16:33 2016 -0200
> > >
> > > Eo: Add efl_replace() function.
> > >
> > > This new function adds a new way to safely replace Eo pointer values.
> > > ---
> > >  src/lib/eo/Eo.h | 22 ++
> > >  1 file changed, 22 insertions(+)
> > >
> > > diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
> > > index 8c81544..244478b 100644
> > > --- a/src/lib/eo/Eo.h
> > > +++ b/src/lib/eo/Eo.h
> > > @@ -1334,6 +1334,28 @@ EAPI int efl_callbacks_cmp(const
> > Efl_Callback_Array_Item *a, const Efl_Callback_
> > >   EFL_CALLBACK_PRIORITY_DEFAULT, data)
> > >
> > >  /**
> > > + * @def Replace the previously Eo pointer with new content.
> > > + *
> > > + * @param storage The object to replace the old reference. It can not
> > be @c NULL.
> > > + * @param new_obj The new object. It may be @c NULL.
> > > + *
> > > + * The string pointed by @c storage must be previously an Eo or
> > > + * @c NULL and it will be efl_unref(). The @a new_obj will be passed
> > > + * to efl_ref() and then assigned to @c *storage.
> > > + *
> > > + * @see efl_ref()
> > > + * @see efl_unref()
> > > + */
> > > +static inline void
> > > +efl_replace(Eo **storage, Eo *new_obj)
> > > +{
> > > +   if (!storage || *storage == new_obj) return;
> > > +   efl_ref(new_obj);
> > > +   efl_unref(*storage);
> > > +   *storage = new_obj;
> > > +}
> > > +
> > > +/**
> > >   * @}
> > >   */
> > >
> > >
> >
> >
> > 
> > --
> > ___
> > enlightenment-devel mailing list
> > enlightenment-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> >
> --
> ___
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

--
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [EGIT] [core/efl] master 02/05: Eo: Add efl_replace() function.

2016-12-05 Thread Guilherme Íscaro
Hello,

Well, what name do you suggest?

On Mon, Dec 5, 2016 at 11:50 AM, Tom Hacohen  wrote:

> I never liked the stringshare function that does it, so it comes with no
> surprise that I don't like this one either.
>
> Regardless of that, I find the name very confusing. I didn't understand
> what it does when I saw the name nor when I read the docs. I had to read
> the code to understand what it's for... I'd change the name and fix the
> docs.
>
> --
> Tom.
>
> On 02/12/16 17:35, Guilherme Iscaro wrote:
> > bdilly pushed a commit to branch master.
> >
> > http://git.enlightenment.org/core/efl.git/commit/?id=
> 81782414dfba9a8a69ea42a4dd5b01fc19170d88
> >
> > commit 81782414dfba9a8a69ea42a4dd5b01fc19170d88
> > Author: Guilherme Iscaro 
> > Date:   Fri Dec 2 11:16:33 2016 -0200
> >
> > Eo: Add efl_replace() function.
> >
> > This new function adds a new way to safely replace Eo pointer values.
> > ---
> >  src/lib/eo/Eo.h | 22 ++
> >  1 file changed, 22 insertions(+)
> >
> > diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
> > index 8c81544..244478b 100644
> > --- a/src/lib/eo/Eo.h
> > +++ b/src/lib/eo/Eo.h
> > @@ -1334,6 +1334,28 @@ EAPI int efl_callbacks_cmp(const
> Efl_Callback_Array_Item *a, const Efl_Callback_
> >   EFL_CALLBACK_PRIORITY_DEFAULT, data)
> >
> >  /**
> > + * @def Replace the previously Eo pointer with new content.
> > + *
> > + * @param storage The object to replace the old reference. It can not
> be @c NULL.
> > + * @param new_obj The new object. It may be @c NULL.
> > + *
> > + * The string pointed by @c storage must be previously an Eo or
> > + * @c NULL and it will be efl_unref(). The @a new_obj will be passed
> > + * to efl_ref() and then assigned to @c *storage.
> > + *
> > + * @see efl_ref()
> > + * @see efl_unref()
> > + */
> > +static inline void
> > +efl_replace(Eo **storage, Eo *new_obj)
> > +{
> > +   if (!storage || *storage == new_obj) return;
> > +   efl_ref(new_obj);
> > +   efl_unref(*storage);
> > +   *storage = new_obj;
> > +}
> > +
> > +/**
> >   * @}
> >   */
> >
> >
>
>
> 
> --
> ___
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>
--
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [EGIT] [core/efl] master 02/05: Eo: Add efl_replace() function.

2016-12-05 Thread Felipe Magno de Almeida
On Mon, Dec 5, 2016 at 11:50 AM, Tom Hacohen  wrote:
> I never liked the stringshare function that does it, so it comes with no
> surprise that I don't like this one either.
>
> Regardless of that, I find the name very confusing. I didn't understand
> what it does when I saw the name nor when I read the docs. I had to read
> the code to understand what it's for... I'd change the name and fix the
> docs.

I hate the name. Every month I have to re-read the docs to understand
what it means.

> --
> Tom.

Regards,
-- 
Felipe Magno de Almeida

--
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [EGIT] [core/efl] master 02/05: Eo: Add efl_replace() function.

2016-12-05 Thread Tom Hacohen
I never liked the stringshare function that does it, so it comes with no 
surprise that I don't like this one either.

Regardless of that, I find the name very confusing. I didn't understand 
what it does when I saw the name nor when I read the docs. I had to read 
the code to understand what it's for... I'd change the name and fix the 
docs.

--
Tom.

On 02/12/16 17:35, Guilherme Iscaro wrote:
> bdilly pushed a commit to branch master.
>
> http://git.enlightenment.org/core/efl.git/commit/?id=81782414dfba9a8a69ea42a4dd5b01fc19170d88
>
> commit 81782414dfba9a8a69ea42a4dd5b01fc19170d88
> Author: Guilherme Iscaro 
> Date:   Fri Dec 2 11:16:33 2016 -0200
>
> Eo: Add efl_replace() function.
>
> This new function adds a new way to safely replace Eo pointer values.
> ---
>  src/lib/eo/Eo.h | 22 ++
>  1 file changed, 22 insertions(+)
>
> diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
> index 8c81544..244478b 100644
> --- a/src/lib/eo/Eo.h
> +++ b/src/lib/eo/Eo.h
> @@ -1334,6 +1334,28 @@ EAPI int efl_callbacks_cmp(const 
> Efl_Callback_Array_Item *a, const Efl_Callback_
>   EFL_CALLBACK_PRIORITY_DEFAULT, data)
>
>  /**
> + * @def Replace the previously Eo pointer with new content.
> + *
> + * @param storage The object to replace the old reference. It can not be @c 
> NULL.
> + * @param new_obj The new object. It may be @c NULL.
> + *
> + * The string pointed by @c storage must be previously an Eo or
> + * @c NULL and it will be efl_unref(). The @a new_obj will be passed
> + * to efl_ref() and then assigned to @c *storage.
> + *
> + * @see efl_ref()
> + * @see efl_unref()
> + */
> +static inline void
> +efl_replace(Eo **storage, Eo *new_obj)
> +{
> +   if (!storage || *storage == new_obj) return;
> +   efl_ref(new_obj);
> +   efl_unref(*storage);
> +   *storage = new_obj;
> +}
> +
> +/**
>   * @}
>   */
>
>


--
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel