[vala/wip/attributes: 9/121] codegen: Add get_ccode_lower_case_suffix
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 9/121] codegen: Add get_ccode_lower_case_suffix
- Date: Mon, 4 Jul 2011 17:09:31 +0000 (UTC)
commit c43de6d86087fa122019d3d0dde07b29d26a2c7d
Author: Luca Bruno <lucabru src gnome org>
Date: Sun Jun 26 13:54:02 2011 +0200
codegen: Add get_ccode_lower_case_suffix
codegen/valaccodebasemodule.vala | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index f6d2c33..507fe64 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5586,6 +5586,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return get_ccode_attribute(sym).lower_case_prefix;
}
+ public static string get_ccode_lower_case_suffix (Symbol sym) {
+ return get_ccode_attribute(sym).lower_case_suffix;
+ }
+
public override void visit_class (Class cl) {
}
@@ -5994,12 +5998,22 @@ public class Vala.CCodeAttribute : AttributeCache {
}
}
+ public string get_lower_case_suffix {
+ get {
+ if (_lower_case_suffix == null) {
+ _lower_case_suffix = get_default_lower_case_suffix ();
+ }
+ return _lower_case_suffix;
+ }
+ }
+
private string _name;
private string _const_name;
private string _type_name;
private List<string> _header_filenames;
private string _prefix;
private string _lower_case_prefix;
+ private string _lower_case_suffix;
public CCodeAttribute (CodeNode node) {
this.node = node;
@@ -6204,4 +6218,23 @@ public class Vala.CCodeAttribute : AttributeCache {
return "%s_".printf (sym.get_lower_case_cname (null));
}
}
+
+ private string get_default_lower_case_suffix () {
+ if (sym is ObjectTypeSymbol) {
+ var csuffix = Symbol.camel_case_to_lower_case (sym.name);
+
+ // remove underscores in some cases to avoid conflicts of type macros
+ if (csuffix.has_prefix ("type_")) {
+ csuffix = "type" + csuffix.substring ("type_".length);
+ } else if (csuffix.has_prefix ("is_")) {
+ csuffix = "is" + csuffix.substring ("is_".length);
+ }
+ if (csuffix.has_suffix ("_class")) {
+ csuffix = csuffix.substring (0, csuffix.length - "_class".length) + "class";
+ }
+ return csuffix;
+ } else {
+ return Symbol.camel_case_to_lower_case (sym.name);
+ }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]