Re: Using By-Value Compound Getters (Re: gtk_widget_get_allocation)



On Tue, 2009-04-21 at 20:00 +0200, Tim Janik wrote:
> To sum up our getter options:
> 
> a)
>     /* force adding lots of helper variables into user code */
>     void gtk_widget_get_allocation (GtkWidget     *widget,
>                                     GtkAllocation *allocation);
> 
> b)
>     /* convenient access, no garbage collection problem */
>     GtkAllocation gtk_widget_get_allocation (GtkWidget *widget);
> 
> c)
>     /* tie ourselves into always keeping the handed out GtkAllocation
>      * allocated in the widget, which can be different from the
>      * actual widget->allocation.
>      */
>     const GtkAllocation* gtk_widget_get_allocation (GtkWidget
> *widget);
> 
> d)
>     /* force caller to free returned allocation, most often forces
>      * an extra GtkAllocation *helper; variable.
>      */
>     GtkAllocation* /*freeme*/ gtk_widget_get_allocation (GtkWidget
> *widget);

Thanks Tim,

I don't have a strong opinion on this between options A and B.  But I am
trying to push forward with getting things in shape for a 3.0 branch,
and this is a blocker so I'm hoping this thread can lead to a decision.
Whichever option is chosen, I can prepare a patch that includes it as
well as fixing all instances of foo->allocation to use the new style
API.  Same applies to GtkRequisition, so once some consensus can be made
then I'll prepare branches to fix up all of gtk+ to use the new API.

fwiw, I'm not a fan of options C or D.

In the past few days I've been doing some work on enhancing Richard
Hult's code rewriter.  It was capable of rewriting code using option B
already, and I've since improved it so that if option A is chosen it can
work with that by injecting new variables to the top of the function and
calling the get-by-reference accessor.  As I go through more of the
GSEAL deprecations I can continue to improve the code rewriter to fit
new patterns in the API.  Right now there are still issues with nested
macros, and after an email with Richard he says he believes this is
fixable using the latest llvm/clang (which I'm using now, I just need to
figure out how to fix this issue using it).  So far I've held off really
blogging about my improvements to the rewriter until I can solve the
nested macro issues, but for anyone interested I have posted my repo to
github [1].

I believe we'll also need a gtk_widget_set_allocation() to be used in
size_allocate() implementations; I guess the two options are
  a: set_allocation(GtkWidget*, GtkAllocation*) or
  b: set_allocation(GtkWidget*, GtkAllocation)

So while we're discussing the get method, please consider the set method
as well.

Thanks everyone,
   Cody

[1]. http://github.com/bratsche/clang/tree/gtkrewriter




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]