[gi-docgen/ebassi/argument-annotation: 8/8] generate: Decouple transfer notes for methods
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gi-docgen/ebassi/argument-annotation: 8/8] generate: Decouple transfer notes for methods
- Date: Fri, 21 May 2021 14:11:14 +0000 (UTC)
commit 422e491879e044c2be26694681945c7a32a6ace3
Author: Emmanuele Bassi <ebassi gnome org>
Date: Fri May 21 15:08:56 2021 +0100
generate: Decouple transfer notes for methods
Methods refer to an instance, so we can have a different blurb for the
ownership transfer note.
gidocgen/gdgenerate.py | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/gidocgen/gdgenerate.py b/gidocgen/gdgenerate.py
index dc737f1..3d1ab75 100644
--- a/gidocgen/gdgenerate.py
+++ b/gidocgen/gdgenerate.py
@@ -32,8 +32,21 @@ ARG_TRANSFER_MODES = {
'full': 'The called function takes ownership of the data, and is responsible for freeing it.',
}
+METHOD_ARG_TRANSFER_MODES = {
+ 'none': 'The data is owned by the caller of the function.',
+ 'container': 'The instance takes ownership of the data container, but not the data inside it.',
+ 'full': 'The instance takes ownership of the data, and is responsible for freeing it.',
+}
+
RETVAL_TRANSFER_MODES = {
- 'none': 'The data is owned by the called function',
+ 'none': 'The data is owned by the called function.',
+ 'container': 'The caller of the function takes ownership of the data container, but not the data inside
it.',
+ 'full': 'The caller of the function takes ownership of the data, and is responsible for freeing it.',
+ 'floating': 'The returned data has a floating reference.',
+}
+
+METHOD_RETVAL_TRANSFER_MODES = {
+ 'none': 'The data is owned by the instance.',
'container': 'The caller of the function takes ownership of the data container, but not the data inside
it.',
'full': 'The caller of the function takes ownership of the data, and is responsible for freeing it.',
'floating': 'The returned data has a floating reference.',
@@ -348,7 +361,10 @@ class TemplateArgument:
self.is_varargs = isinstance(argument.target, gir.VarArgs)
self.is_macro = isinstance(call, gir.FunctionMacro)
self.transfer = argument.transfer or 'none'
- self.transfer_note = ARG_TRANSFER_MODES[argument.transfer or 'none']
+ if isinstance(call, gir.Method):
+ self.transfer_note = METHOD_ARG_TRANSFER_MODES[argument.transfer or 'none']
+ else:
+ self.transfer_note = ARG_TRANSFER_MODES[argument.transfer or 'none']
self.direction = argument.direction or 'in'
self.direction_note = DIRECTION_MODES[argument.direction]
self.optional = argument.optional
@@ -416,7 +432,10 @@ class TemplateReturnValue:
self.is_array = isinstance(retval.target, gir.ArrayType)
self.is_list = isinstance(retval.target, gir.ListType)
self.transfer = retval.transfer or 'none'
- self.transfer_note = RETVAL_TRANSFER_MODES[retval.transfer or 'none']
+ if isinstance(call, gir.Method):
+ self.transfer_note = METHOD_RETVAL_TRANSFER_MODES[retval.transfer or 'none']
+ else:
+ self.transfer_note = RETVAL_TRANSFER_MODES[retval.transfer or 'none']
self.nullable = retval.nullable
if self.is_array:
self.value_type = retval.target.value_type.name
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]