diff options
author | Luca Bruno <lucabru@src.gnome.org> | 2011-07-07 11:51:30 +0200 |
---|---|---|
committer | Luca Bruno <lucabru@src.gnome.org> | 2011-08-01 18:17:04 +0200 |
commit | 567cc5fbafc33ef14230fe62f0566e76e5f69d66 (patch) | |
tree | ca8b155a8079d090fc14836ecd374bfb0bd3b596 /vala/valastruct.vala | |
parent | b1767bb713a03dd4156f9cd1f31666e50314d0b5 (diff) | |
download | vala-567cc5fbafc33ef14230fe62f0566e76e5f69d66.tar.gz |
On-demand Struct.is_boolean_type
Diffstat (limited to 'vala/valastruct.vala')
-rw-r--r-- | vala/valastruct.vala | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/vala/valastruct.vala b/vala/valastruct.vala index d32996d67..b34cd8013 100644 --- a/vala/valastruct.vala +++ b/vala/valastruct.vala @@ -38,7 +38,7 @@ public class Vala.Struct : TypeSymbol { private string type_id; private string lower_case_cprefix; private string lower_case_csuffix; - private bool boolean_type; + private bool? boolean_type; private bool integer_type; private bool floating_type; private bool decimal_floating_type; @@ -342,11 +342,12 @@ public class Vala.Struct : TypeSymbol { * @return true if this is a boolean type, false otherwise */ public bool is_boolean_type () { - if (base_type != null) { - var st = base_struct; - if (st != null && st.is_boolean_type ()) { - return true; - } + var st = base_struct; + if (st != null && st.is_boolean_type ()) { + return true; + } + if (boolean_type == null) { + boolean_type = get_attribute ("BooleanType") != null; } return boolean_type; } @@ -463,10 +464,6 @@ public class Vala.Struct : TypeSymbol { } } - private void process_boolean_type_attribute (Attribute a) { - boolean_type = true; - } - private void process_integer_type_attribute (Attribute a) { integer_type = true; if (a.has_argument ("rank")) { @@ -500,8 +497,6 @@ public class Vala.Struct : TypeSymbol { foreach (Attribute a in attributes) { if (a.name == "CCode") { process_ccode_attribute (a); - } else if (a.name == "BooleanType") { - process_boolean_type_attribute (a); } else if (a.name == "IntegerType") { process_integer_type_attribute (a); } else if (a.name == "FloatingType") { @@ -664,7 +659,7 @@ public class Vala.Struct : TypeSymbol { } if (CodeContext.get ().profile == Profile.DOVA) { - if (boolean_type) { + if (is_boolean_type ()) { return "false"; } else if (integer_type || floating_type) { return "0"; |