Commit c00d70c8 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

add possibility to override default cname process callback attributes

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

svn path=/trunk/; revision=287
parent 793eb6ef
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,
......
......@@ -68,6 +68,10 @@ public class Vala.AttributeProcessor : CodeVisitor {
prop.process_attributes ();
}
public override void visit_begin_callback (Callback! cb) {
cb.process_attributes ();
}
public override void visit_field (Field! f) {
f.process_attributes ();
}
......
......@@ -154,6 +154,32 @@ public class Vala.Callback : DataType {
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;
}
......
......@@ -272,11 +272,6 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
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 ();
......@@ -323,10 +318,6 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
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) {
......@@ -437,12 +428,6 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
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);
}
......@@ -560,7 +545,10 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
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);
......
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