[vala/staging] Consistently use get_ccode_lower_case_prefix() for function names
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] Consistently use get_ccode_lower_case_prefix() for function names
- Date: Sun, 14 Jun 2020 08:02:58 +0000 (UTC)
commit 6e08f06c9faf8515f76c8079c80b328c0a030d40
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Jun 14 08:59:51 2020 +0200
Consistently use get_ccode_lower_case_prefix() for function names
Create the expected name for "constructor" and "finalize" functions
which are non-public API.
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1008
codegen/valagobjectmodule.vala | 6 +++---
codegen/valagtypemodule.vala | 2 +-
libvaladoc/api/class.vala | 2 +-
tests/Makefile.am | 1 +
tests/objects/class-ccode-cprefix.vala | 23 +++++++++++++++++++++++
5 files changed, 29 insertions(+), 5 deletions(-)
---
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index 674f18d8a..f095e5e5e 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -63,14 +63,14 @@ public class Vala.GObjectModule : GTypeModule {
if (cl.constructor != null) {
var ccast = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_CLASS"));
ccast.add_argument (new CCodeIdentifier ("klass"));
- ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "constructor"), new
CCodeIdentifier ("%s_constructor".printf (get_ccode_lower_case_name (cl, null))));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "constructor"), new
CCodeIdentifier ("%sconstructor".printf (get_ccode_lower_case_prefix (cl))));
}
/* set finalize function */
if (cl.get_fields ().size > 0 || cl.destructor != null) {
var ccast = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_CLASS"));
ccast.add_argument (new CCodeIdentifier ("klass"));
- ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "finalize"), new
CCodeIdentifier ("%s_finalize".printf (get_ccode_lower_case_name (cl, null))));
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, "finalize"), new
CCodeIdentifier ("%sfinalize".printf (get_ccode_lower_case_prefix (cl))));
}
/* create type, dup_func, and destroy_func properties for generic types */
@@ -484,7 +484,7 @@ public class Vala.GObjectModule : GTypeModule {
push_context (new EmitContext (c));
- var function = new CCodeFunction ("%s_constructor".printf (get_ccode_lower_case_name
(cl, null)), "GObject *");
+ var function = new CCodeFunction ("%sconstructor".printf (get_ccode_lower_case_prefix
(cl)), "GObject *");
function.modifiers = CCodeModifiers.STATIC;
function.add_parameter (new CCodeParameter ("type", "GType"));
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 4e8c91702..4757b0165 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -1727,7 +1727,7 @@ public class Vala.GTypeModule : GErrorModule {
fundamental_class = fundamental_class.base_class;
}
- var func = new CCodeFunction ("%s_finalize".printf (get_ccode_lower_case_name (cl,
null)));
+ var func = new CCodeFunction ("%sfinalize".printf (get_ccode_lower_case_prefix (cl)));
func.add_parameter (new CCodeParameter ("obj", "%s *".printf (get_ccode_name
(fundamental_class))));
func.modifiers = CCodeModifiers.STATIC;
diff --git a/libvaladoc/api/class.vala b/libvaladoc/api/class.vala
index 02f4917d1..0dd8433c8 100644
--- a/libvaladoc/api/class.vala
+++ b/libvaladoc/api/class.vala
@@ -69,7 +69,7 @@ public class Valadoc.Api.Class : TypeSymbol {
this.unref_function_name = Vala.get_ccode_unref_function (data);
this.ref_function_name = Vala.get_ccode_ref_function (data);
- this.finalize_function_name = (data.is_fundamental () ? "%s_finalize".printf
(Vala.get_ccode_lower_case_name (data, null)) : null);
+ this.finalize_function_name = (data.is_fundamental () ? "%sfinalize".printf
(Vala.get_ccode_lower_case_prefix (data)) : null);
this.free_function_name = (data.is_compact ? Vala.get_ccode_free_function (data) : null);
this.take_value_function_cname = Vala.get_ccode_take_value_function (data);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index aeb1796fb..c871a4866 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -354,6 +354,7 @@ TESTS = \
delegates/bug772204.test \
delegates/bug792077.vala \
objects/chainup.vala \
+ objects/class-ccode-cprefix.vala \
objects/class_only.vala \
objects/class-destroysinstance.vala \
objects/class-inner-types.vala \
diff --git a/tests/objects/class-ccode-cprefix.vala b/tests/objects/class-ccode-cprefix.vala
new file mode 100644
index 000000000..dba5643c2
--- /dev/null
+++ b/tests/objects/class-ccode-cprefix.vala
@@ -0,0 +1,23 @@
+[CCode (lower_case_cprefix = "bar_")]
+public class Foo : Object {
+ public Foo () {
+ }
+
+ construct {
+ }
+
+ ~Foo () {
+ }
+}
+
+[CCode (lower_case_cprefix = "baz_")]
+public class Manam {
+ public Manam () {
+ }
+
+ ~Manam () {
+ }
+}
+
+void main () {
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]