[vala] Write delegates as qualified types in code writer
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Write delegates as qualified types in code writer
- Date: Tue, 15 Mar 2011 21:14:42 +0000 (UTC)
commit 31bd6527da6189d72b8b7bc8cbe287c78ba70bfd
Author: Ryan Lortie <desrt desrt ca>
Date: Tue Mar 15 22:09:54 2011 +0100
Write delegates as qualified types in code writer
Fixes bug 643927.
vala/valadatatype.vala | 2 ++
vala/valadelegatetype.vala | 22 +++++++++++++++++++++-
2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala
index d13e5e0..9521aee 100644
--- a/vala/valadatatype.vala
+++ b/vala/valadatatype.vala
@@ -171,6 +171,8 @@ public abstract class Vala.DataType : CodeNode {
}
public virtual string to_qualified_string (Scope? scope = null) {
+ // logic temporarily duplicated in DelegateType class
+
string s;
if (data_type != null) {
diff --git a/vala/valadelegatetype.vala b/vala/valadelegatetype.vala
index c5f2ec8..da17014 100644
--- a/vala/valadelegatetype.vala
+++ b/vala/valadelegatetype.vala
@@ -47,7 +47,27 @@ public class Vala.DelegateType : DataType {
}
public override string to_qualified_string (Scope? scope) {
- string s = delegate_symbol.get_full_name ();
+ // logic temporarily duplicated from DataType class
+
+ Symbol global_symbol = delegate_symbol;
+ while (global_symbol.parent_symbol.name != null) {
+ global_symbol = global_symbol.parent_symbol;
+ }
+
+ Symbol sym = null;
+ Scope parent_scope = scope;
+ while (sym == null && parent_scope != null) {
+ sym = parent_scope.lookup (global_symbol.name);
+ parent_scope = parent_scope.parent_scope;
+ }
+
+ string s;
+
+ if (sym != null && global_symbol != sym) {
+ s = "global::" + delegate_symbol.get_full_name ();;
+ } else {
+ s = delegate_symbol.get_full_name ();
+ }
var type_args = get_type_arguments ();
if (type_args.size > 0) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]