[gi-docgen/class-methods: 1/2] generate: Fix argument handling in class methods
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gi-docgen/class-methods: 1/2] generate: Fix argument handling in class methods
- Date: Wed, 4 Aug 2021 22:43:21 +0000 (UTC)
commit 4909d510733e0b950f478aadd527ee7c4bf4bdc5
Author: Emmanuele Bassi <ebassi gnome org>
Date: Wed Aug 4 23:41:12 2021 +0100
generate: Fix argument handling in class methods
Just like methods, class methods have an instance parameter followed by
the list of arguments.
gidocgen/gdgenerate.py | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/gidocgen/gdgenerate.py b/gidocgen/gdgenerate.py
index ec58d91..8bd51db 100644
--- a/gidocgen/gdgenerate.py
+++ b/gidocgen/gdgenerate.py
@@ -765,7 +765,7 @@ class TemplateClassMethod:
def __init__(self, namespace, cls, method):
self.name = method.name
self.identifier = method.identifier
- self.class_type_cname = cls.type_struct
+ self.class_type_cname = namespace.identifier_prefix[0] + cls.type_struct
self.throws = method.throws
@@ -780,6 +780,8 @@ class TemplateClassMethod:
else:
self.description = MISSING_DESCRIPTION
+ self.instance_parameter = TemplateArgument(namespace, method, method.instance_param)
+
self.arguments = []
for arg in method.parameters:
self.arguments.append(TemplateArgument(namespace, method, arg))
@@ -817,11 +819,11 @@ class TemplateClassMethod:
res += [f"{self.return_value.type_cname}"]
res += [f"{self.identifier} ("]
n_args = len(self.arguments)
- if n_args == 1:
- res += [f" {self.class_type_cname}* self"]
+ if n_args == 0:
+ res += [f" {self.instance_parameter.type_cname} {self.instance_parameter.name}"]
else:
- res += [f" {self.class_type_cname}* self,"]
- for (idx, arg) in enumerate(self.arguments, start=1):
+ res += [f" {self.instance_parameter.type_cname} {self.instance_parameter.name},"]
+ for (idx, arg) in enumerate(self.arguments):
if idx == n_args - 1 and not self.throws:
res += [f" {arg.c_decl}"]
else:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]