[vala/0.12] codewriter: Write enum cname when it differs from the default cname
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.12] codewriter: Write enum cname when it differs from the default cname
- Date: Sun, 29 May 2011 11:17:51 +0000 (UTC)
commit 2979d6fa1a522c1dad4693c9aeaf4f4061fa05a9
Author: Luca Bruno <lucabru src gnome org>
Date: Mon Apr 4 21:53:45 2011 +0200
codewriter: Write enum cname when it differs from the default cname
Based on patch by Evan Nemerson.
Fixes bug 615493.
vala/valacodewriter.vala | 4 ++++
vala/valaenum.vala | 11 ++++++++++-
2 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index dbbd516..3eafe22 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -591,6 +591,10 @@ public class Vala.CodeWriter : CodeVisitor {
write_string ("has_type_id = false, ");
}
+ if (en.get_cname () != en.get_default_cname ()) {
+ write_string ("cname = \"%s\", ".printf (en.get_cname ()));
+ }
+
write_string ("cheader_filename = \"%s\")]".printf (get_cheaders(en)));
if (en.is_flags) {
diff --git a/vala/valaenum.vala b/vala/valaenum.vala
index f5fca29..fed3286 100644
--- a/vala/valaenum.vala
+++ b/vala/valaenum.vala
@@ -160,12 +160,21 @@ public class Vala.Enum : TypeSymbol {
cname = attr.get_string ("cname");
}
if (cname == null) {
- cname = "%s%s".printf (parent_symbol.get_cprefix (), name);
+ cname = get_default_cname ();
}
}
return cname;
}
+ /**
+ * Returns the default name of this enum as it is used in C code.
+ *
+ * @return the name to be used in C code by default
+ */
+ public string get_default_cname () {
+ return "%s%s".printf (parent_symbol.get_cprefix (), name);
+ }
+
public void set_cname (string cname) {
this.cname = cname;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]