summaryrefslogtreecommitdiff
path: root/vala
diff options
context:
space:
mode:
authorJuerg Billeter <j@bitron.ch>2007-10-19 13:29:18 +0000
committerJürg Billeter <juergbi@src.gnome.org>2007-10-19 13:29:18 +0000
commit65c666cfe78f61f136c50cf60128e60179a2c5d1 (patch)
treeac3b418877ad7a370176fb84ee5174c52e01d419 /vala
parent01571e2dcba66b9547b6567e251ea99725c3c348 (diff)
downloadvala-65c666cfe78f61f136c50cf60128e60179a2c5d1.tar.gz
support Flags attribute support Flags and ErrorDomain attributes for enums
2007-10-19 Juerg Billeter <j@bitron.ch> * vala/valaenum.vala: support Flags attribute * vala/valainterfacewriter.vala: support Flags and ErrorDomain attributes for enums and add `break' to keyword list svn path=/trunk/; revision=656
Diffstat (limited to 'vala')
-rw-r--r--vala/valaenum.vala7
-rw-r--r--vala/valainterfacewriter.vala19
2 files changed, 21 insertions, 5 deletions
diff --git a/vala/valaenum.vala b/vala/valaenum.vala
index d9da96628..2c20e6f6b 100644
--- a/vala/valaenum.vala
+++ b/vala/valaenum.vala
@@ -28,6 +28,11 @@ using Gee;
*/
public class Vala.Enum : DataType {
/**
+ * Specifies whether this is a flags enum.
+ */
+ public bool is_flags { get; set; }
+
+ /**
* Specifies whether this enum represents an error domain.
*/
public bool error_domain { get; set; }
@@ -192,6 +197,8 @@ public class Vala.Enum : DataType {
foreach (Attribute a in attributes) {
if (a.name == "CCode") {
process_ccode_attribute (a);
+ } else if (a.name == "Flags") {
+ is_flags = true;
} else if (a.name == "ErrorDomain") {
error_domain = true;
}
diff --git a/vala/valainterfacewriter.vala b/vala/valainterfacewriter.vala
index 4d72ab39d..594bd140d 100644
--- a/vala/valainterfacewriter.vala
+++ b/vala/valainterfacewriter.vala
@@ -301,6 +301,15 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
write_string ("[CCode (cprefix = \"%s\", cheader_filename = \"%s\")]".printf (en.get_cprefix (), cheaders));
+ if (en.is_flags) {
+ write_indent ();
+ write_string ("[Flags]");
+ }
+ if (en.error_domain) {
+ write_indent ();
+ write_string ("[ErrorDomain]");
+ }
+
write_indent ();
write_string ("public enum ");
write_identifier (en.name);
@@ -639,11 +648,11 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
private void write_identifier (string! s) {
- if (s == "base" || s == "class" ||s == "construct" ||
- s == "delegate" || s == "do" || s == "foreach" ||
- s == "in" || s == "interface" || s == "lock" ||
- s == "namespace" || s == "new" || s == "out" ||
- s == "ref" || s == "signal") {
+ if (s == "base" || s == "break" || s == "class" ||
+ s == "construct" || s == "delegate" || s == "do" ||
+ s == "foreach" || s == "in" || s == "interface" ||
+ s == "lock" || s == "namespace" || s == "new" ||
+ s == "out" || s == "ref" || s == "signal") {
stream.putc ('@');
}
write_string (s);