[vala/0.46] girwriter: Use appropriate get_ccode_* functions
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.46] girwriter: Use appropriate get_ccode_* functions
- Date: Thu, 30 Jul 2020 11:03:08 +0000 (UTC)
commit 8100b4935320b6cce09e81cfc1f36b830943046b
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Jul 28 13:53:29 2020 +0200
girwriter: Use appropriate get_ccode_* functions
This will pick up possible CCode.*name attributes
codegen/valagirwriter.vala | 55 +++++++++++---------------------
tests/girwriter/GirTest-1.0.gir-expected | 2 +-
2 files changed, 20 insertions(+), 37 deletions(-)
---
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index 9c98be05d..5dab2df44 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -506,38 +506,32 @@ public class Vala.GIRWriter : CodeVisitor {
foreach (Method m in cl.get_methods ()) {
if (m.is_abstract || m.is_virtual) {
if (m.coroutine) {
- string finish_name = m.name;
- if (finish_name.has_suffix ("_async")) {
- finish_name = finish_name.substring (0,
finish_name.length - "_async".length);
- }
- finish_name += "_finish";
-
write_indent ();
- buffer.append_printf("<field name=\"%s\"", m.name);
+ buffer.append_printf("<field name=\"%s\"",
get_ccode_vfunc_name (m));
write_symbol_attributes (m);
buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, m.name,
get_ccode_name (m), m.get_async_begin_parameters (), new VoidType (), false, false, false);
+ do_write_signature (m, "callback", true, get_ccode_vfunc_name
(m), get_ccode_name (m), m.get_async_begin_parameters (), new VoidType (), false, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
write_indent ();
- buffer.append_printf("<field name=\"%s\"", finish_name);
+ buffer.append_printf("<field name=\"%s\"",
get_ccode_finish_vfunc_name (m));
write_symbol_attributes (m);
buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, finish_name,
get_ccode_finish_name (m), m.get_async_end_parameters (), m.return_type, m.tree_can_fail, false, false);
+ do_write_signature (m, "callback", true,
get_ccode_finish_vfunc_name (m), get_ccode_finish_name (m), m.get_async_end_parameters (), m.return_type,
m.tree_can_fail, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
} else {
write_indent ();
- buffer.append_printf("<field name=\"%s\"", m.name);
+ buffer.append_printf("<field name=\"%s\"",
get_ccode_vfunc_name (m));
write_symbol_attributes (m);
buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, m.name,
get_ccode_name (m), m.get_parameters (), m.return_type, m.tree_can_fail, false, false);
+ do_write_signature (m, "callback", true, get_ccode_vfunc_name
(m), get_ccode_name (m), m.get_parameters (), m.return_type, m.tree_can_fail, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
@@ -693,38 +687,32 @@ public class Vala.GIRWriter : CodeVisitor {
foreach (Method m in iface.get_methods ()) {
if (m.is_abstract || m.is_virtual) {
if (m.coroutine) {
- string finish_name = m.name;
- if (finish_name.has_suffix ("_async")) {
- finish_name = finish_name.substring (0, finish_name.length -
"_async".length);
- }
- finish_name += "_finish";
-
write_indent ();
- buffer.append_printf("<field name=\"%s\"", m.name);
+ buffer.append_printf("<field name=\"%s\"", get_ccode_vfunc_name (m));
write_symbol_attributes (m);
buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, m.name, get_ccode_name (m),
m.get_async_begin_parameters (), new VoidType (), false, false, false);
+ do_write_signature (m, "callback", true, get_ccode_vfunc_name (m),
get_ccode_name (m), m.get_async_begin_parameters (), new VoidType (), false, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
write_indent ();
- buffer.append_printf("<field name=\"%s\"", finish_name);
+ buffer.append_printf("<field name=\"%s\"",
get_ccode_finish_vfunc_name (m));
write_symbol_attributes (m);
buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, finish_name,
get_ccode_finish_name (m), m.get_async_end_parameters (), m.return_type, m.tree_can_fail, false, false);
+ do_write_signature (m, "callback", true, get_ccode_finish_vfunc_name
(m), get_ccode_finish_name (m), m.get_async_end_parameters (), m.return_type, m.tree_can_fail, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
} else {
write_indent ();
- buffer.append_printf("<field name=\"%s\"", m.name);
+ buffer.append_printf("<field name=\"%s\"", get_ccode_vfunc_name (m));
write_symbol_attributes (m);
buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, m.name, get_ccode_name (m),
m.get_parameters (), m.return_type, m.tree_can_fail, false, false);
+ do_write_signature (m, "callback", true, get_ccode_vfunc_name (m),
get_ccode_name (m), m.get_parameters (), m.return_type, m.tree_can_fail, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
@@ -737,11 +725,11 @@ public class Vala.GIRWriter : CodeVisitor {
if (prop.get_accessor != null) {
var m = prop.get_accessor.get_method ();
write_indent ();
- buffer.append_printf("<field name=\"%s\"", m.name);
+ buffer.append_printf("<field name=\"%s\"", get_ccode_vfunc_name (m));
write_symbol_attributes (m);
buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, m.name, get_ccode_name (m),
m.get_parameters (), m.return_type, m.tree_can_fail, false, false);
+ do_write_signature (m, "callback", true, get_ccode_vfunc_name (m),
get_ccode_name (m), m.get_parameters (), m.return_type, m.tree_can_fail, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
@@ -750,11 +738,11 @@ public class Vala.GIRWriter : CodeVisitor {
if (prop.set_accessor != null && prop.set_accessor.writable) {
var m = prop.set_accessor.get_method ();
write_indent ();
- buffer.append_printf("<field name=\"%s\"", m.name);
+ buffer.append_printf("<field name=\"%s\"", get_ccode_vfunc_name (m));
write_symbol_attributes (m);
buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, m.name, get_ccode_name (m),
m.get_parameters (), m.return_type, m.tree_can_fail, false, false);
+ do_write_signature (m, "callback", true, get_ccode_vfunc_name (m),
get_ccode_name (m), m.get_parameters (), m.return_type, m.tree_can_fail, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
@@ -1302,15 +1290,10 @@ public class Vala.GIRWriter : CodeVisitor {
}
if (m.coroutine) {
- string finish_name = name;
- if (finish_name.has_suffix ("_async")) {
- finish_name = finish_name.substring (0, finish_name.length - "_async".length);
- }
- finish_name += "_finish";
- do_write_signature (m, tag_name, instance, name, get_ccode_name (m),
m.get_async_begin_parameters (), new VoidType (), false, true, write_attributes);
- do_write_signature (m, tag_name, instance, finish_name, get_ccode_finish_name (m),
m.get_async_end_parameters (), m.return_type, m.tree_can_fail, false, write_attributes);
+ do_write_signature (m, tag_name, instance, get_ccode_vfunc_name (m), get_ccode_name
(m), m.get_async_begin_parameters (), new VoidType (), false, true, write_attributes);
+ do_write_signature (m, tag_name, instance, get_ccode_finish_vfunc_name (m),
get_ccode_finish_name (m), m.get_async_end_parameters (), m.return_type, m.tree_can_fail, false,
write_attributes);
} else {
- do_write_signature (m, tag_name, instance, name, get_ccode_name (m), m.get_parameters
(), m.return_type, m.tree_can_fail, true, write_attributes);
+ do_write_signature (m, tag_name, instance, get_ccode_vfunc_name (m), get_ccode_name
(m), m.get_parameters (), m.return_type, m.tree_can_fail, true, write_attributes);
}
}
diff --git a/tests/girwriter/GirTest-1.0.gir-expected b/tests/girwriter/GirTest-1.0.gir-expected
index 52f41d7de..a1dd5f76d 100644
--- a/tests/girwriter/GirTest-1.0.gir-expected
+++ b/tests/girwriter/GirTest-1.0.gir-expected
@@ -858,7 +858,7 @@
</callback>
</field>
<field name="signal_with_default_handlder">
- <callback name="object_test_signal_with_default_handlder"
c:type="object_test_signal_with_default_handlder">
+ <callback name="signal_with_default_handlder" c:type="signal_with_default_handlder">
<return-value transfer-ownership="full">
<type name="none" c:type="void"/>
</return-value>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]