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

Improve custom cname support for enum values

2008-10-17  Jürg Billeter  <j@bitron.ch>

	* vala/valaenumvalue.vala:
	* vala/valainterfacewriter.vala:

	Improve custom cname support for enum values

svn path=/trunk/; revision=1852
parent 3776d2d4
2008-10-17 Jürg Billeter <j@bitron.ch>
* vala/valaenumvalue.vala:
* vala/valainterfacewriter.vala:
Improve custom cname support for enum values
2008-10-17 Jürg Billeter <j@bitron.ch>
* vala/valainterface.vala:
......
......@@ -107,7 +107,6 @@ public class Vala.EnumValue : Symbol {
}
}
/**
* Returns the name of this enum value as it is used in C code.
*
......@@ -115,9 +114,22 @@ public class Vala.EnumValue : Symbol {
*/
public string get_cname () {
if (cname == null) {
var en = (Enum) parent_symbol;
cname = "%s%s".printf (en.get_cprefix (), name);
cname = get_default_cname ();
}
return cname;
}
public string get_default_cname () {
var en = (Enum) parent_symbol;
return "%s%s".printf (en.get_cprefix (), name);
}
/**
* Sets the name of this enum value to be used in C code.
*
* @param cname the name to be used in C code
*/
public void set_cname (string cname) {
this.cname = cname;
}
}
......@@ -412,6 +412,10 @@ public class Vala.InterfaceWriter : CodeVisitor {
write_newline ();
}
if (ev.get_cname () != ev.get_default_cname ()) {
write_indent ();
write_string ("[CCode (cname = \"%s\")]".printf (ev.get_cname ()));
}
write_indent ();
write_identifier (ev.name);
}
......
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