[vala/switch-to-gir] girparser: Support symbol deprecation
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/switch-to-gir] girparser: Support symbol deprecation
- Date: Fri, 27 Aug 2010 14:46:39 +0000 (UTC)
commit 7c2825ebe609eccc5fc3292a601bd4a55957fe65
Author: Luca Bruno <lethalman88 gmail com>
Date: Fri Aug 27 13:54:49 2010 +0200
girparser: Support symbol deprecation
vala/valagirparser.vala | 40 +++++++++++++++++++++-------------------
1 files changed, 21 insertions(+), 19 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 763ecfa..99bf95e 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -57,7 +57,10 @@ public class Vala.GirParser : CodeVisitor {
OWNED,
UNOWNED,
PARENT,
- NULLABLE;
+ NULLABLE,
+ DEPRECATED,
+ REPLACEMENT,
+ DEPRECATED_SINCE;
public static ArgumentType? from_string (string name) {
var enum_class = (EnumClass) typeof(ArgumentType).class_ref ();
@@ -776,23 +779,14 @@ public class Vala.GirParser : CodeVisitor {
if (owned_by_default) {
if (metadata.has_argument (ArgumentType.UNOWNED)) {
type.value_owned = !metadata.get_bool (ArgumentType.UNOWNED);
- if (&changed != null) {
- changed = true;
- }
}
} else {
if (metadata.has_argument (ArgumentType.OWNED)) {
type.value_owned = metadata.get_bool (ArgumentType.OWNED);
- if (&changed != null) {
- changed = true;
- }
}
}
if (metadata.has_argument (ArgumentType.NULLABLE)) {
type.nullable = metadata.get_bool (ArgumentType.NULLABLE);
- if (&changed != null) {
- changed = true;
- }
}
}
return type;
@@ -830,7 +824,20 @@ public class Vala.GirParser : CodeVisitor {
return name;
}
- void element_reparent (Symbol symbol) {
+ bool element_can_add () {
+ if (metadata.has_argument (ArgumentType.PARENT) || metadata.get_bool (ArgumentType.HIDDEN)) {
+ return false;
+ }
+ return true;
+ }
+
+ void element_process_symbol (Symbol symbol) {
+ // deprecation
+ symbol.replacement = metadata.get_string (ArgumentType.REPLACEMENT);
+ symbol.deprecated_since = element_get_string ("deprecated-version", ArgumentType.DEPRECATED_SINCE);
+ symbol.deprecated = metadata.get_bool (ArgumentType.DEPRECATED) || symbol.replacement != null || symbol.deprecated_since != null;
+
+ // mark to be reparented
if (metadata.has_argument (ArgumentType.PARENT)) {
var target_symbol = parse_symbol_from_string (metadata.get_string (ArgumentType.PARENT), metadata.get_source_reference (ArgumentType.PARENT));
var reparent_list = symbol_reparent_map[target_symbol];
@@ -842,13 +849,6 @@ public class Vala.GirParser : CodeVisitor {
}
}
- bool element_can_add () {
- if (metadata.has_argument (ArgumentType.PARENT) || metadata.get_bool (ArgumentType.HIDDEN)) {
- return false;
- }
- return true;
- }
-
void parse_repository () {
start_element ("repository");
next ();
@@ -1999,6 +1999,8 @@ public class Vala.GirParser : CodeVisitor {
if (throws_string == "1") {
s.add_error_type (new ErrorType (null, null));
}
+
+ element_process_symbol (s);
end_element (element_name);
return s;
}
@@ -2130,7 +2132,7 @@ public class Vala.GirParser : CodeVisitor {
var c = new Constant (name, type, null, get_current_src ());
c.access = SymbolAccessibility.PUBLIC;
c.external = true;
- element_reparent (c);
+ element_process_symbol (c);
end_element ("constant");
return c;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]