[vala] Write CCode attributes for property accessors in VAPI files
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Write CCode attributes for property accessors in VAPI files
- Date: Wed, 4 Aug 2010 13:16:39 +0000 (UTC)
commit dc1786d8a21ff9e9c41c289a2a4c6fb926ee9dfc
Author: Marc-André Lureau <marcandre lureau gmail com>
Date: Mon Mar 29 01:20:33 2010 +0200
Write CCode attributes for property accessors in VAPI files
Fixes bug 614206.
vala/valacodewriter.vala | 24 ++++++++++++++++++++++++
vala/valapropertyaccessor.vala | 19 +++++++++++--------
2 files changed, 35 insertions(+), 8 deletions(-)
---
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index 89d848f..75963fb 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -1134,6 +1134,18 @@ public class Vala.CodeWriter : CodeVisitor {
write_identifier (prop.name);
write_string (" {");
if (prop.get_accessor != null) {
+ var ccode_params = new StringBuilder ();
+ var separator = "";
+
+ if (prop.get_accessor.get_cname () != prop.get_accessor.get_default_cname ()) {
+ ccode_params.append_printf ("%scname = \"%s\"", separator, prop.get_accessor.get_cname ());
+ separator = ", ";
+ }
+ if (ccode_params.len > 0) {
+ write_indent ();
+ write_string ("[CCode (%s)]".printf (ccode_params.str));
+ }
+
if (context.profile != Profile.DOVA && prop.get_accessor.value_type.is_disposable ()) {
write_string (" owned");
}
@@ -1142,6 +1154,18 @@ public class Vala.CodeWriter : CodeVisitor {
write_code_block (prop.get_accessor.body);
}
if (prop.set_accessor != null) {
+ var ccode_params = new StringBuilder ();
+ var separator = "";
+
+ if (prop.set_accessor.get_cname () != prop.set_accessor.get_default_cname ()) {
+ ccode_params.append_printf ("%scname = \"%s\"", separator, prop.set_accessor.get_cname ());
+ separator = ", ";
+ }
+ if (ccode_params.len > 0) {
+ write_indent ();
+ write_string ("[CCode (%s)]".printf (ccode_params.str));
+ }
+
if (context.profile != Profile.DOVA && prop.set_accessor.value_type.value_owned) {
write_string (" owned");
}
diff --git a/vala/valapropertyaccessor.vala b/vala/valapropertyaccessor.vala
index ca0a1c5..ee65a99 100644
--- a/vala/valapropertyaccessor.vala
+++ b/vala/valapropertyaccessor.vala
@@ -96,6 +96,16 @@ public class Vala.PropertyAccessor : Symbol {
*/
public LocalVariable? result_var { get; set; }
+ public virtual string get_default_cname () {
+ var t = (TypeSymbol) prop.parent_symbol;
+
+ if (readable) {
+ return "%sget_%s".printf (t.get_lower_case_cprefix (), prop.name);
+ } else {
+ return "%sset_%s".printf (t.get_lower_case_cprefix (), prop.name);
+ }
+ }
+
/**
* The publicly accessible name of the function that performs the
* access in C code.
@@ -104,14 +114,7 @@ public class Vala.PropertyAccessor : Symbol {
if (_cname != null) {
return _cname;
}
-
- var t = (TypeSymbol) prop.parent_symbol;
-
- if (readable) {
- return "%sget_%s".printf (t.get_lower_case_cprefix (), prop.name);
- } else {
- return "%sset_%s".printf (t.get_lower_case_cprefix (), prop.name);
- }
+ return get_default_cname ();
}
private DataType _value_type;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]