[vala/wip/attributes: 103/119] On demand Enum.is_flags
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 103/119] On demand Enum.is_flags
- Date: Mon, 4 Jul 2011 10:30:44 +0000 (UTC)
commit a1d27719b89c257222f33681166301b7256a67c5
Author: Luca Bruno <lucabru src gnome org>
Date: Sun Jul 3 12:55:09 2011 +0200
On demand Enum.is_flags
vala/valaenum.vala | 24 ++++++++++--------------
1 files changed, 10 insertions(+), 14 deletions(-)
---
diff --git a/vala/valaenum.vala b/vala/valaenum.vala
index 367e2c8..eeabda9 100644
--- a/vala/valaenum.vala
+++ b/vala/valaenum.vala
@@ -29,12 +29,21 @@ public class Vala.Enum : TypeSymbol {
/**
* Specifies whether this is a flags enum.
*/
- public bool is_flags { get; set; }
+ public bool is_flags {
+ get {
+ if (_is_flags == null) {
+ _is_flags = get_attribute ("Flags") != null;
+ }
+ return _is_flags;
+ }
+ }
private List<EnumValue> values = new ArrayList<EnumValue> ();
private List<Method> methods = new ArrayList<Method> ();
private List<Constant> constants = new ArrayList<Constant> ();
+ private bool? _is_flags;
+
/**
* Creates a new enum.
*
@@ -147,17 +156,6 @@ public class Vala.Enum : TypeSymbol {
return false;
}
- /**
- * Process all associated attributes.
- */
- public void process_attributes () {
- foreach (Attribute a in attributes) {
- if (a.name == "Flags") {
- is_flags = true;
- }
- }
- }
-
public override bool check (CodeContext context) {
if (checked) {
return !error;
@@ -165,8 +163,6 @@ public class Vala.Enum : TypeSymbol {
checked = true;
- process_attributes ();
-
var old_source_file = context.analyzer.current_source_file;
var old_symbol = context.analyzer.current_symbol;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]