GNOME Bugzilla – Bug 620406
support for caller-allocates annotations for structs
Last modified: 2010-06-07 09:30:34 UTC
* out caller-allocates parameters expect an already constructed structure to be passed in by reference. It is then modified and the caller uses the modified value. We support this by using only one level of pointer indirection. * Only structs are considered to be caller-allocates parameters even if they are marked as such by GI. This is because the GI scanner isn't smart enough to correctly guess 100% of the time * GValues are a special case of a caller-allocates parameter when cleaning up (e.g. g_value_unset is called). GValues make no sense in a scripting language. Developers should never deal with them.
Created attachment 162573 [details] [review] support for caller-allocates annotations for structs
Review of attachment 162573 [details] [review]: Nice, please run autogen.sh so astyle gets run. ::: gi/pygi-invoke.c @@ +300,3 @@ GIDirection direction; + GIBaseInfo *info; + Extraneous space? @@ +328,3 @@ + GITypeTag type_tag; + + /* reset to False */ I wouldn't add such comments or we'll end up with more comments than code. This is a common enough idiom. @@ +908,3 @@ + } + + g_free (state->args[i]); Before we are malloc'inf if (caller_allocates && is_struct), but here we free always that caller_allocates. ::: tests/test_everything.py @@ +78,3 @@ + self.assertEquals(struct_b.nested_a.some_int8, struct_b_clone.nested_a.some_int8) + self.assertEquals(struct_b.nested_a.some_double, struct_b_clone.nested_a.some_double) + self.assertEquals(struct_b.nested_a.some_enum, struct_b_clone.nested_a.some_enum) Aren't some of this tests already being called somewhere else?
Created attachment 162668 [details] [review] support for caller-allocates annotations for structs * out caller-allocates parameters expect an already constructed structure to be passed in by reference. It is then modified and the caller uses the modified value. We support this by using only one level of pointer indirection. * Only structs are considered to be caller-allocates parameters even if they are marked as such by GI. This is because the GI scanner isn't smart enough to correctly guess 100% of the time * GValues are a special case of a caller-allocates parameter when cleaning up (e.g. g_value_unset is called). GValues make no sense in a scripting language. Developers should never deal with them.
You would think that the tests would be called somewhere else but they weren't so I added them. Fixed up formatting, removed some comments, made sure to check for struct when freeing.
Review of attachment 162668 [details] [review]: Great!