Discarding a function result using (type void)
Consider the following code where GnmRange is a structure that is copied, not ref-counted. Ignore the "(type void)" for second.
This is a perfectly reasonable C API: a structure is initialized and can be used as an argument to some function, but once it makes it into Python it's all wrong: the output will be copied to a newly-allocated GnmRange, i.e., it's no longer the same structure as the input. Major gotcha.
I though I would be clever by adding "(type void)" to make the scanner ignore the return value. Throwing away a transfer-none result ought to be harmless, after all. Do you agree that this ought to work?
In practice, it doesn't. When the result is printed in Python it comes out as a random number, probably [part of] the address. I would expect "None".
I am unsure whether this is a gobject-introspection issue or pygobject one.
My alternative is a bit of #ifdef soup to put "void" in as actual return type when the scanner sees the code.
/**
* range_init_full_sheet:
* @r: #GnmRange
* @sheet: #Sheet
*
* Updates @r to fill @sheet in its entirety.
*
* Returns: (transfer none) (type void): @r
*/
GnmRange *
range_init_full_sheet (GnmRange *r, Sheet const *sheet)
{
r->start.col = 0;
r->start.row = 0;
r->end.col = gnm_sheet_get_last_col (sheet);
r->end.row = gnm_sheet_get_last_row (sheet);
return r;
}