New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement support for inline allocated Boxed types #1234
Conversation
See gtk-rs/gtk-rs-core#284 for the code making use of this. |
Useful for graphene and code reduction in various other places. See gtk-rs/gtk-rs-core#211
Previously only AutoBoxed was considered boxed, which caused wrong code generation for special functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I almost forgot: please update gir book! And please also provide explanations on which type should or shouldn't use boxed_inline
.
Good idea. I should probably also update the |
@GuillaumeGomez Can you shortly check the docs? :) |
book/src/config_api.md
Outdated
|
||
By default the memory is zero-initialized and copying is done via | ||
`std::ptr::copy()`. If the boxed type contains memory that needs to be freed | ||
then these functions must be provided. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After reading this, I still have no clue what the rule for boxed_inline
is. 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's written just one line above:
Some boxed types are passed as
out
parameters to functions and the caller is required to allocate them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read but I don't understand it... T_T
Can you provide a simple example please? Or just ignore me, maybe I'm the one in fault here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from that you would use it for types where the second sentence is something you want
configured as inline-allocated boxed type, i.e. the memory of is not allocated on the heap but directly as part of the value e.g. on the stack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, that explains exactly the two cases where you would want this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide a simple example please?
gtk::TreeIter
, which is allocated by the caller, then a pointer to it is passed to function, then the function fills it in.glib::Value
, which is allocated by the caller, then a pointer is passed to e.g.g_object_get_property()
and the function fills it in.gdk::RGBA
, which is allocated by the caller, then a pointer is passed to various functions and they fill it in.- All the graphene types, which ... see above :)
For a case where this not required by useful
gst_video::VideoTimeCode
, which is just a few integers and you really don't want to pay the heap allocations for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GuillaumeGomez Does that help in any way?
Useful for graphene and code reduction in various other places.
See gtk-rs/gtk-rs-core#211