Hello,

On Fri, Jun 10, 2016 at 07:20:28AM -0500, Stephen Houston wrote:
> You wouldn't have to allocate it and free it for every function... if it
> doesn't exist, allocate it, otherwise update the values. Then on del, free
> it if it exists.

You dont have to alloc it at all, you can just put it on your stack,
use a "Eina_Rectangle viewport;" for example. So you dont have to handle
free etc. Only the value of the struct gets passed, not the
reference.

> I don't think this simplifies the code though. Whether you pass the
> structure or pass the individual values, the developer is still typing out
> the same number of values and the lib is still assigning/manipulating the
> same number of values. And as you said, it would be a massive change, with
> little value imo.

Thats not true, the below code snippet is 1:1 copied from elm_scroller.c

   const char *dir = params;
   Evas_Coord x = 0;
   Evas_Coord y = 0;
   Evas_Coord c_x = 0;
   Evas_Coord c_y = 0;
   Evas_Coord v_x = 0;
   Evas_Coord v_y = 0;
   Evas_Coord v_w = 0;
   Evas_Coord v_h = 0;
   Evas_Coord max_x = 0;
   Evas_Coord max_y = 0;
   Evas_Coord page_x = 0;
   Evas_Coord page_y = 0;
   Evas_Coord step_x = 0;
   Evas_Coord step_y = 0;
   Evas_Object *current_focus = NULL;
   Eina_List *can_focus_list = NULL;
   Evas_Object *new_focus = NULL;
   Elm_Object_Item *new_focus_item = NULL;
   Evas_Coord f_x = 0;
   Evas_Coord f_y = 0;
   Evas_Coord f_w = 0;
   Evas_Coord f_h = 0;

This could simply be

   ELM_SCROLLER_DATA_GET(obj, sd);
   const char *dir = params;
        Eina_Rectangle rect, c, v, f; (the names are poor, they should be
more descriptive)
   Evas_Coord max_x = 0;
   Evas_Coord max_y = 0;
   Evas_Coord page_x = 0;
   Evas_Coord page_y = 0;
   Evas_Coord step_x = 0;
   Evas_Coord step_y = 0;
   Evas_Object *current_focus = NULL;
   Eina_List *can_focus_list = NULL;
   Evas_Object *new_focus = NULL;
   Elm_Object_Item *new_focus_item = NULL;

And max_x max_y could also be replaced with simple eina_rectangle_max_x 
or max_y functions. So in the end its way easier to handle this kind of api.
Also modifing geometries based on other geometies is very easy. Declaring 4 vars
& pass them 8 times. Is way more work than declaring 1 rectangle var and 
pass it 2 times.

Also in elm there is even a macro to check if 2 rects are intersecting.
Which gets 8 parameters, if you would have 2 rects it would simply be a call to 
eina_rectangle_ functions.

> On Jun 9, 2016 11:55 PM, "Davide Andreoli" <d...@gurumeditation.it> wrote:
> 
> 2016-06-10 4:10 GMT+02:00 Jean-Philippe André <j...@videolan.org>:
> 
> > Hi,
> >
> >
> > This is bu5hman's idea mostly, but I'd like to bring the question to the
> > attention of everyone, as I had the same idea before.
> >
> > For simple structs (think Eina.Rectangle, and Efl.Gfx.Color), would it be
> > acceptable to pass them by value instead of reference, in C?
> > That is:
> >
> > Eina_Rectangle a = {1, 2, 3, 4};
> > rect_set(obj, rect);
> > Eina_Rectangle b = rect_get(obj);
> >
> > Or even (non portable way, but applications could feel free to use this):
> > rect_set(obj, (Eina_Rectangle){.w = 13, .h = 37});
> >
> >
> > I understand this could simplify some code.
> >
> >
> > My main problem with it is a concern about ABI compatibility. It seems GCC
> > itself has various ways to pass structs by value. See:
> >
> >
> http://stackoverflow.com/questions/161788/are-there-any-downsides-to-passing-structs-by-value-in-c-rather-than-passing-a
> >
> >
> > Does anyone have real-life knowledge about this? How is it on Windows?
> > Any strong arguments in favor or against?
> >
> 
> I'm against this changes for 2 main reason:
> 1. API coherence: if we use rect, color, and maybe pos in some api, then we
> should use them
> in ALL the api that use rect, color, geom, etc... this will be a massive
> change.

I dont see a problem with this massive change, since the complete api is 
changing ...

Greetings
   bu5hm4n

> 2. Will make bindings a lot slower, for each function call we need to
> allocate the struct, fill with value
> provided by user and pass this struct to the C function.. and then free it.
> All this for each function call.
> 
> just my 2 cents
> 
> 
> >
> >
> > --
> > Jean-Philippe André
> >
> >
> ------------------------------------------------------------------------------
> > What NetFlow Analyzer can do for you? Monitors network bandwidth and
> > traffic
> > patterns at an interface-level. Reveals which users, apps, and protocols
> > are
> > consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> > J-Flow, sFlow and other flows. Make informed decisions using capacity
> > planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> > _______________________________________________
> > enlightenment-devel mailing list
> > enlightenment-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> >
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> _______________________________________________
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are 
> consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
> J-Flow, sFlow and other flows. Make informed decisions using capacity 
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> _______________________________________________
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to