+2007-04-24 Jürg Billeter <j@bitron.ch>
+
+ * vala/valacallback.vala: add possibility to override default cname
+ * vala/valaattributeprocessor.vala: process callback attributes
+ * vala/valainterfacewriter.vala: cleanup code to write identifiers
+
2007-04-18 Jürg Billeter <j@bitron.ch>
* vala/valacodegenerator.vala: use const types where appropriate,
prop.process_attributes ();
}
+ public override void visit_begin_callback (Callback! cb) {
+ cb.process_attributes ();
+ }
+
public override void visit_field (Field! f) {
f.process_attributes ();
}
return cname;
}
+ /**
+ * Sets the name of this callback as it is used in C code.
+ *
+ * @param cname the name to be used in C code
+ */
+ public void set_cname (string cname) {
+ this.cname = cname;
+ }
+
+ private void process_ccode_attribute (Attribute a) {
+ if (a.has_argument ("cname")) {
+ set_cname (a.get_string ("cname"));
+ }
+ }
+
+ /**
+ * Process all associated attributes.
+ */
+ public void process_attributes () {
+ foreach (Attribute a in attributes) {
+ if (a.name == "CCode") {
+ process_ccode_attribute (a);
+ }
+ }
+ }
+
public override bool is_reference_type () {
return false;
}
}
write_string (" ");
- if (f.name == "base" || f.name == "callback" ||
- f.name == "flags" || f.name == "in" ||
- f.name == "out") {
- write_string ("@");
- }
write_identifier (f.name);
write_string (";");
write_newline ();
}
write_string (" ");
- if (param.name == "callback" || param.name == "flags" ||
- param.name == "out" || param.name == "set") {
- write_string ("@");
- }
write_identifier (param.name);
if (param.default_expression != null) {
}
write_string (" ");
- if (m.name == "class" || m.name == "construct" ||
- m.name == "foreach" || m.name == "get" ||
- m.name == "lock" || m.name == "ref" ||
- m.name == "set") {
- write_string ("@");
- }
write_identifier (m.name);
}
}
private void write_identifier (string! s) {
- if (s == "namespace") {
+ if (s == "base" || s == "callback" || s == "class" ||
+ s == "construct" || s == "flags" || s == "foreach" ||
+ s == "in" || s == "interface" || s == "lock" ||
+ s == "namespace" || s == "out" || s == "ref") {
stream.putc ('@');
}
write_string (s);