[vala/wip/attributes: 116/121] Avoid accessing CodeNode.attributes as much as possible
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 116/121] Avoid accessing CodeNode.attributes as much as possible
- Date: Mon, 4 Jul 2011 17:18:30 +0000 (UTC)
commit f23cdb2fd3f9c84c2ba0603282f03dbca54bba8f
Author: Luca Bruno <lucabru src gnome org>
Date: Sun Jul 3 21:06:23 2011 +0200
Avoid accessing CodeNode.attributes as much as possible
vala/valagirparser.vala | 27 +++++++++++++--------------
vapigen/valagidlparser.vala | 19 ++++++-------------
2 files changed, 19 insertions(+), 27 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index c4e7d0b..98d3007 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -674,19 +674,18 @@ public class Vala.GirParser : CodeVisitor {
} else if (sym is Method && !(sym is CreationMethod) && node != this) {
if (m.is_virtual || m.is_abstract) {
bool different_invoker = false;
- foreach (var attr in m.attributes) {
- if (attr.name == "NoWrapper") {
- /* no invoker but this method has the same name,
- most probably the invoker has a different name
- and g-ir-scanner missed it */
- var invoker = parser.find_invoker (this);
- if (invoker != null) {
- m.set_attribute_string ("CCode", "vfunc_name", m.name);
- m.name = invoker.symbol.name;
- m.attributes.remove (attr);
- invoker.merged = true;
- different_invoker = true;
- }
+ var attr = m.get_attribute ("NoWrapper");
+ if (attr != null) {
+ /* no invoker but this method has the same name,
+ most probably the invoker has a different name
+ and g-ir-scanner missed it */
+ var invoker = parser.find_invoker (this);
+ if (invoker != null) {
+ m.set_attribute_string ("CCode", "vfunc_name", m.name);
+ m.name = invoker.symbol.name;
+ m.attributes.remove (attr);
+ invoker.merged = true;
+ different_invoker = true;
}
}
if (!different_invoker) {
@@ -2463,7 +2462,7 @@ public class Vala.GirParser : CodeVisitor {
m.is_virtual = true;
}
if (invoker == null && !metadata.has_argument (ArgumentType.VFUNC_NAME)) {
- s.attributes.append (new Attribute ("NoWrapper", s.source_reference));
+ s.set_attribute ("NoWrapper", true, s.source_reference);
} else {
if (current.girdata["name"] != name) {
m.set_attribute_string ("CCode", "vfunc_name", current.girdata["name"]);
diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala
index c29cbfc..a7849c6 100644
--- a/vapigen/valagidlparser.vala
+++ b/vapigen/valagidlparser.vala
@@ -281,17 +281,10 @@ public class Vala.GIdlParser : CodeVisitor {
private void add_symbol_to_container (Symbol container, Symbol sym) {
if (sym is Method) {
- var a = sym.get_attribute ("CCode");
- if (a != null && a.has_argument ("cname")) {
- var cname = a.get_string ("cname");
- var default_cname = "%s%s".printf (get_lower_case_cprefix (container), sym.name);
- if (cname == default_cname) {
- // same as default, remove the argument
- a.args.remove ("cname");
- if (a.args.size == 0) {
- sym.attributes.remove (a);
- }
- }
+ var cname = sym.get_attribute_string ("CCode", "cname");
+ if (cname != null && cname == "%s%s".printf (get_lower_case_cprefix (container), sym.name)) {
+ // same as default, remove the argument
+ sym.remove_attribute_argument ("CCode", "cname");
}
}
if (container is Class) {
@@ -2150,7 +2143,7 @@ public class Vala.GIdlParser : CodeVisitor {
}
} else if (nv[0] == "destroys_instance") {
if (eval (nv[1]) == "1") {
- m.attributes.append (new Attribute ("DestroysInstance", m.source_reference));
+ m.set_attribute ("DestroysInstance", true, m.source_reference);
}
} else if (nv[0] == "nullable") {
if (eval (nv[1]) == "1") {
@@ -2511,7 +2504,7 @@ public class Vala.GIdlParser : CodeVisitor {
}
if (func == null) {
- m.attributes.append (new Attribute ("NoWrapper", null));
+ m.set_attribute ("NoWrapper", true);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]