[vala] Support concrete accessors for abstract properties in bindings
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Support concrete accessors for abstract properties in bindings
- Date: Mon, 22 Dec 2014 11:04:35 +0000 (UTC)
commit b43037bb56875715baed9686d31df61a8581d23b
Author: Luca Bruno <lucabru src gnome org>
Date: Mon Dec 22 12:00:17 2014 +0100
Support concrete accessors for abstract properties in bindings
Fixes bug 730744
codegen/valaccodebasemodule.vala | 4 ++++
codegen/valagtypemodule.vala | 4 ++--
vala/valagirparser.vala | 17 +++++++++++++++--
vala/valausedattr.vala | 1 +
4 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index e87b0b1..e1c6a63 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -6322,6 +6322,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return p.get_attribute ("NoAccessorMethod") != null;
}
+ public static bool get_ccode_concrete_accessor (Property p) {
+ return p.get_attribute ("ConcreteAccessor") != null;
+ }
+
public static bool get_ccode_has_type_id (TypeSymbol sym) {
return sym.get_attribute_bool ("CCode", "has_type_id", true);
}
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 8d547ef..b25cec4 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -1227,7 +1227,7 @@ public class Vala.GTypeModule : GErrorModule {
var ccast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf
(get_ccode_upper_case_name (base_type))));
ccast.add_argument (new CCodeIdentifier ("klass"));
- if (!get_ccode_no_accessor_method (prop.base_property)) {
+ if (!get_ccode_no_accessor_method (prop.base_property) &&
!get_ccode_concrete_accessor (prop.base_property)) {
if (prop.get_accessor != null) {
string cname = CCodeBaseModule.get_ccode_real_name
(prop.get_accessor);
ccode.add_assignment (new CCodeMemberAccess.pointer (ccast,
"get_%s".printf (prop.name)), new CCodeIdentifier (cname));
@@ -1393,7 +1393,7 @@ public class Vala.GTypeModule : GErrorModule {
var ciface = new CCodeIdentifier ("iface");
- if (!get_ccode_no_accessor_method (prop.base_interface_property)) {
+ if (!get_ccode_no_accessor_method (prop.base_interface_property) &&
!get_ccode_concrete_accessor (prop.base_interface_property)) {
if (prop.get_accessor != null) {
string cname = CCodeBaseModule.get_ccode_real_name
(prop.get_accessor);
if (prop.is_abstract || prop.is_virtual) {
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 270bd21..9d8ef15 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -982,7 +982,7 @@ public class Vala.GirParser : CodeVisitor {
if (prop.get_accessor != null) {
var m = getter != null ? getter.symbol as Method : null;
// ensure getter vfunc if the property is abstract
- if (m != null && (m.is_abstract || m.is_virtual ||
!prop.is_abstract)) {
+ if (m != null) {
getter.process (parser);
if (m.return_type is VoidType ||
m.get_parameters().size != 0) {
prop.set_attribute ("NoAccessorMethod", true);
@@ -994,26 +994,39 @@ public class Vala.GirParser : CodeVisitor {
}
}
}
+
prop.get_accessor.value_type.value_owned =
m.return_type.value_owned;
+
+ if (!m.is_abstract && !m.is_virtual &&
prop.is_abstract) {
+ prop.set_attribute
("ConcreteAccessor", true);
+ }
}
} else {
prop.set_attribute ("NoAccessorMethod", true);
}
}
+
if (prop.get_attribute ("NoAccessorMethod") == null &&
prop.set_accessor != null && prop.set_accessor.writable) {
var m = setter != null ? setter.symbol as Method : null;
// ensure setter vfunc if the property is abstract
- if (m != null && (m.is_abstract || m.is_virtual ||
!prop.is_abstract)) {
+ if (m != null) {
setter.process (parser);
if (!(m.return_type is VoidType) ||
m.get_parameters().size != 1) {
prop.set_attribute ("NoAccessorMethod", true);
+ prop.set_attribute ("ConcreteAccessor",
false);
} else {
prop.set_accessor.value_type.value_owned =
m.get_parameters()[0].variable_type.value_owned;
+ if (prop.get_attribute ("ConcreteAccessor")
!= null && !m.is_abstract && !m.is_virtual && prop.is_abstract) {
+ prop.set_attribute
("ConcreteAccessor", true);
+ prop.set_attribute
("NoAccessorMethod", false);
+ }
}
} else {
prop.set_attribute ("NoAccessorMethod", true);
+ prop.set_attribute ("ConcreteAccessor", false);
}
}
+
if (prop.get_attribute ("NoAccessorMethod") != null) {
// gobject defaults
if (prop.get_accessor != null) {
diff --git a/vala/valausedattr.vala b/vala/valausedattr.vala
index 7fc3259..8d9c24c 100644
--- a/vala/valausedattr.vala
+++ b/vala/valausedattr.vala
@@ -53,6 +53,7 @@ public class Vala.UsedAttr : CodeVisitor {
"GenericAccessors", "",
"Diagnostics", "",
"NoAccessorMethod", "",
+ "ConcreteAccessor", "",
"HasEmitter", "",
"ReturnsModifiedPointer", "",
"Deprecated", "since", "replacement", "",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]