write_string ("[CCode (cprefix = \"%s\", lower_case_cprefix = \"%s\")]".printf (ns.get_cprefix (), ns.get_lower_case_cprefix ()));
write_newline ();
+ write_attributes (ns);
+
write_indent ();
write_string ("namespace ");
write_identifier (ns.name);
}
write_string ("cheader_filename = \"%s\")]".printf (cheaders));
write_newline ();
+
+ write_attributes (cl);
write_indent ();
write_accessibility (cl);
write_newline ();
}
+ write_attributes (st);
+
write_indent ();
write_accessibility (st);
write_string ("struct ");
write_string (")]");
write_newline ();
+ write_attributes (iface);
+
write_indent ();
write_accessibility (iface);
write_string ("interface ");
write_string ("[Flags]");
}
+ write_attributes (en);
+
write_indent ();
write_accessibility (en);
write_string ("enum ");
}
write_string ("[CCode (cprefix = \"%s\", cheader_filename = \"%s\")]".printf (edomain.get_cprefix (), cheaders));
+ write_attributes (edomain);
+
write_indent ();
write_accessibility (edomain);
write_string ("errordomain ");
return false;
}
+ private void write_attributes (CodeNode node) {
+ foreach (Attribute attr in node.attributes) {
+ if (!filter_attribute (attr)) {
+ write_indent ();
+ stream.printf ("[%s", attr.name);
+
+ var keys = attr.args.get_keys ();
+ if (keys.size != 0) {
+ stream.printf (" (");
+
+ string separator = "";
+ foreach (string arg_name in keys) {
+ stream.printf ("%s%s = ", separator, arg_name);
+ var expr = attr.args.get (arg_name);
+ expr.accept (this);
+ separator = ", ";
+ }
+
+ stream.printf (")");
+ }
+ stream.printf ("]");
+ write_newline ();
+ }
+ }
+ }
+
+ private bool filter_attribute (Attribute attr) {
+ if (attr.name == "CCode"
+ || attr.name == "Compact" || attr.name == "Immutable"
+ || attr.name == "SimpleType" || attr.name == "IntegerType" || attr.name == "FloatingType"
+ || attr.name == "Flags") {
+ return true;
+ }
+ return false;
+ }
+
private void write_accessibility (Symbol sym) {
if (sym.access == SymbolAccessibility.PUBLIC) {
write_string ("public ");