[vala/staging] codegen: Allow underscores in type parameter names
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Allow underscores in type parameter names
- Date: Thu, 3 Nov 2016 21:40:26 +0000 (UTC)
commit 457743fa935c668dcda5b7e9e57187f648357801
Author: Severin Heiniger <severinheiniger gmail com>
Date: Thu Jun 26 22:12:14 2014 -0700
codegen: Allow underscores in type parameter names
https://bugzilla.gnome.org/show_bug.cgi?id=644938
codegen/valagobjectmodule.vala | 15 +++++++++------
tests/Makefile.am | 1 +
tests/objects/bug644938.vala | 12 ++++++++++++
3 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index d4b8887..33bb878 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -79,8 +79,11 @@ public class Vala.GObjectModule : GTypeModule {
CCodeConstant func_name_constant;
CCodeFunctionCall cinst, cspec;
- func_name = "%s_type".printf (type_param.name.ascii_down ());
- func_name_constant = new CCodeConstant ("\"%s-type\"".printf
(type_param.name.ascii_down ()));
+ var name_prefix = type_param.name.down ();
+ var canonical_prefix = name_prefix.replace ("_", "-");
+
+ func_name = "%s_type".printf (name_prefix);
+ func_name_constant = new CCodeConstant ("\"%s-type\"".printf (canonical_prefix));
enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null),
func_name).ascii_up ();
cinst = new CCodeFunctionCall (new CCodeIdentifier
("g_object_class_install_property"));
cinst.add_argument (ccall);
@@ -96,8 +99,8 @@ public class Vala.GObjectModule : GTypeModule {
prop_enum.add_value (new CCodeEnumValue (enum_value));
- func_name = "%s_dup_func".printf (type_param.name.ascii_down ());
- func_name_constant = new CCodeConstant ("\"%s-dup-func\"".printf
(type_param.name.ascii_down ()));
+ func_name = "%s_dup_func".printf (name_prefix);
+ func_name_constant = new CCodeConstant ("\"%s-dup-func\"".printf (canonical_prefix));
enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null),
func_name).ascii_up ();
cinst = new CCodeFunctionCall (new CCodeIdentifier
("g_object_class_install_property"));
cinst.add_argument (ccall);
@@ -112,8 +115,8 @@ public class Vala.GObjectModule : GTypeModule {
prop_enum.add_value (new CCodeEnumValue (enum_value));
- func_name = "%s_destroy_func".printf (type_param.name.ascii_down ());
- func_name_constant = new CCodeConstant ("\"%s-destroy-func\"".printf
(type_param.name.ascii_down ()));
+ func_name = "%s_destroy_func".printf (name_prefix);
+ func_name_constant = new CCodeConstant ("\"%s-destroy-func\"".printf
(canonical_prefix));
enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null),
func_name).ascii_up ();
cinst = new CCodeFunctionCall (new CCodeIdentifier
("g_object_class_install_property"));
cinst.add_argument (ccall);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2a2ea07..50d0e23 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -170,6 +170,7 @@ TESTS = \
objects/bug641828.vala \
objects/bug642809.vala \
objects/bug643711.vala \
+ objects/bug644938.vala \
objects/bug646362.vala \
objects/bug646792.vala \
objects/bug647018.vala \
diff --git a/tests/objects/bug644938.vala b/tests/objects/bug644938.vala
new file mode 100644
index 0000000..eed56c8
--- /dev/null
+++ b/tests/objects/bug644938.vala
@@ -0,0 +1,12 @@
+public abstract class Foo<TYPE_PARAM> : Object {
+ public abstract void method (TYPE_PARAM o);
+}
+
+public class Bar : Foo<int> {
+ public override void method (int i) {
+ }
+}
+
+void main () {
+ var bar = new Bar ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]