stream.printf ("<namespace name=\"%s\" version=\"1.0\">\n", ns.name);
indent++;
+ write_annotations (ns);
+
ns.accept_children (this);
indent--;
stream.printf ("</implements>\n");
}
+ write_annotations (cl);
+
cl.accept_children (this);
indent--;
stream.printf (">\n");
indent++;
+ write_annotations (cl);
+
cl.accept_children (this);
indent--;
stream.printf (">\n");
indent++;
+ write_annotations (st);
+
st.accept_children (this);
indent--;
stream.printf ("</requires>\n");
}
+ write_annotations (iface);
+
iface.accept_children (this);
indent--;
stream.printf (">\n");
indent++;
+ write_annotations (en);
+
enum_value = 0;
en.accept_children (this);
stream.printf ("<errordomain name=\"%s\"", edomain.name);
stream.printf (" get-quark=\"%squark\"", edomain.get_lower_case_cprefix ());
stream.printf (" codes=\"%s\"", edomain.name);
- stream.printf ("/>\n");
+ stream.printf (">\n");
+
+ write_annotations (edomain);
+
+ stream.printf ("</errordomain>\n");
write_indent ();
stream.printf ("<enumeration name=\"%s\"", edomain.name);
stream.printf (">\n");
indent++;
+ write_annotations (f);
+
write_type (f.field_type);
indent--;
stream.printf (">\n");
indent++;
+ write_annotations (param);
+
write_type (param.parameter_type);
indent--;
stream.printf (">\n");
indent++;
+ write_annotations (cb);
+
write_params (cb.get_parameters ());
write_return_type (cb.return_type);
stream.printf (">\n");
indent++;
+ write_annotations (m);
+
DataType instance_type = null;
if (instance) {
instance_type = CCodeBaseModule.get_data_type_for_symbol ((TypeSymbol) m.parent_symbol);
stream.printf (">\n");
indent++;
+ write_annotations (m);
+
write_params (m.get_parameters ());
var datatype = CCodeBaseModule.get_data_type_for_symbol ((TypeSymbol) m.parent_symbol);
stream.printf (">\n");
indent++;
+ write_annotations (prop);
+
write_type (prop.property_type);
indent--;
stream.printf (">\n");
indent++;
+ write_annotations (sig);
+
write_params (sig.get_parameters ());
write_return_type (sig.return_type);
}
}
+ private void write_annotations (CodeNode node) {
+ foreach (Attribute attr in node.attributes) {
+ string name = camel_case_to_canonical (attr.name);
+ foreach (string arg_name in attr.args.get_keys ()) {
+ var arg = attr.args.get (arg_name);
+
+ string value = literal_expression_to_value_string ((Literal) arg);
+
+ if (value != null) {
+ write_indent ();
+ stream.printf ("<annotation key=\"%s.%s\" value=\"%s\"/>\n",
+ name, camel_case_to_canonical (arg_name), value);
+ }
+ }
+ }
+ }
+
private string gi_type_name (TypeSymbol type_symbol) {
return vala_to_gi_type_name (type_symbol.get_full_name());
}
.replace ("\"", """);
}
+ private string camel_case_to_canonical (string name) {
+ return Symbol.camel_case_to_lower_case (name).replace ("_", "-");
+ }
+
private bool check_accessibility (Symbol sym) {
if (sym.access == SymbolAccessibility.PUBLIC ||
sym.access == SymbolAccessibility.PROTECTED) {