ability to rename or copy a method for g-i
Submitted by Simon McVittie
Link to original bug (#675295)
Description
It would be useful to be able to rename or alias methods in the g-i output.
Telepathy uses the same naming convention as GVariant/GValue, in which "get" means "don't copy" and "dup" means "copy", so we often get this situation:
-
TpThing is an object
-
tp_thing_dup_stuff() returns a copy of, or new ref to, a TpStuff
-
tp_thing_get_stuff() doesn't exist, because we newly construct the TpStuff object on-demand, or because we want to be able to be thread-safe later, or whatever
It would be useful for Python/JS users to be able to call Thing.get_stuff() anyway, since they shouldn't need to care about the distinction between "borrow" and "copy" C semantics.
I tried to use "Rename to: tp_thing_get_stuff", but that annotation doesn't work (issues a warning and is ignored) when tp_thing_get_stuff doesn't exist. (Example diff and warning below.)
14:33 < walters>
so...yeah the original use case for rename-to wasn't this, but
we could probably make it work relatively easily
14:33 < smcv>
walters: probably what we really want tbh is "Copy to"
14:34 < walters>
right
14:34 < smcv>
or /** tp_connection_dup_detailed_error: (introspect-as
get_detailed_error)
14:34 < smcv>
or something
14:35 < smcv>
g-i users shouldn't have to care about whether a function copies
its argument or not, but at the same time we like to make it
obvious for C users
14:36 < walters>
the problem with rename-to is that it reveals our total lack
of generated documentation that would help one understand
"where did this C function go"
14:36 < walters>
copy-to doesn't have that issue as much
diff --git a/telepathy-glib/connection.c b/telepathy-glib/connection.c index 53cb4b3..464f920 100644 --- a/telepathy-glib/connection.c +++ b/telepathy-glib/connection.c @@ -2880,6 +2880,8 @@ tp_connection_get_detailed_error (TpConnection *self,
- Returns: (transfer full) (allow-none): a D-Bus error name, or %NULL.
- Since: 0.19.UNRELEASED
-
-
- Rename to: tp_connection_get_detailed_error_vardict */ gchar * tp_connection_dup_detailed_error_vardict (TpConnection *self,
GISCAN TelepathyGLib-1.gir /home/smcv/src/fdo/tpglib/telepathy-glib/connection.h:175: Warning: TelepathyGLib: Can't find symbol 'tp_connection_get_detailed_error_vardict' referenced by Rename annotation
<unknown>
:: Fatal: TelepathyGLib: warnings configured as fatal<unknown>
:: Fatal: TelepathyGLib: warnings configured as fatal