Commit 65c666cf authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

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
parent 01571e2d
2007-10-19 Jürg 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
2007-10-19 Jürg Billeter <j@bitron.ch>
* vapi/packages/gstreamer-0.10/gstreamer-0.10.metadata: add ellipsis
......
......@@ -27,6 +27,11 @@ using Gee;
* Represents an enum declaration in the source code.
*/
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.
*/
......@@ -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;
}
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment