[vala/wip/attributes: 45/121] gidlparser: Drop usage of CodeNode.get_cname
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 45/121] gidlparser: Drop usage of CodeNode.get_cname
- Date: Mon, 4 Jul 2011 17:12:33 +0000 (UTC)
commit 7e5da4a09cac92f064f8baa2d542e56e612eacae
Author: Luca Bruno <lucabru src gnome org>
Date: Wed Jun 29 12:58:24 2011 +0200
gidlparser: Drop usage of CodeNode.get_cname
vapigen/valagidlparser.vala | 40 ++++++++++++++++++++++++++--------------
1 files changed, 26 insertions(+), 14 deletions(-)
---
diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala
index 31bf858..17b2e01 100644
--- a/vapigen/valagidlparser.vala
+++ b/vapigen/valagidlparser.vala
@@ -88,8 +88,8 @@ public class Vala.GIdlParser : CodeVisitor {
}
private void visit_type (TypeSymbol t) {
- if (!cname_type_map.contains (t.get_cname ())) {
- cname_type_map[t.get_cname ()] = t;
+ if (!cname_type_map.contains (get_cname (t))) {
+ cname_type_map[get_cname (t)] = t;
}
}
@@ -196,17 +196,29 @@ public class Vala.GIdlParser : CodeVisitor {
return const_name;
}
+ private string get_cname (Symbol sym) {
+ var cname = sym.get_attribute_string ("CCode", "cname");
+ if (cname != null) {
+ return cname;
+ }
+ if (sym is Method) {
+ return "%s%s".printf (sym.parent_symbol.get_lower_case_cprefix (), sym.name);
+ } else {
+ return "%s%s".printf (sym.parent_symbol.get_cprefix (), sym.name);
+ }
+ }
+
private string[] get_attributes_for_node (IdlNode node) {
string name;
if (node.type == IdlNodeTypeId.FUNCTION) {
name = ((IdlNodeFunction) node).symbol;
} else if (node.type == IdlNodeTypeId.SIGNAL) {
- name = "%s::%s".printf (current_data_type.get_cname (), node.name);
+ name = "%s::%s".printf (get_cname (current_data_type), node.name);
} else if (node.type == IdlNodeTypeId.PROPERTY) {
- name = "%s:%s".printf (current_data_type.get_cname (), node.name);
+ name = "%s:%s".printf (get_cname (current_data_type), node.name);
} else if (node.type == IdlNodeTypeId.FIELD) {
- name = "%s.%s".printf (current_data_type.get_cname (), node.name);
+ name = "%s.%s".printf (get_cname (current_data_type), node.name);
} else {
name = node.name;
}
@@ -1622,7 +1634,7 @@ public class Vala.GIdlParser : CodeVisitor {
if (finish_method == null) {
var method_cname = m.get_finish_cname ();
foreach (Method method in type_symbol.get_methods ()) {
- if (method.get_cname () == method_cname) {
+ if (get_cname (method) == method_cname) {
finish_method = method;
break;
}
@@ -2031,7 +2043,7 @@ public class Vala.GIdlParser : CodeVisitor {
// gtk widgets) add an attribute to the creation method indicating the used
// return type.
if (current_data_type is Class && res != null) {
- if ("%s*".printf (current_data_type.get_cname()) != res.type.unparsed) {
+ if ("%s*".printf (get_cname (current_data_type)) != res.type.unparsed) {
m.custom_return_type_cname = res.type.unparsed;
}
}
@@ -2045,7 +2057,7 @@ public class Vala.GIdlParser : CodeVisitor {
}
if (current_data_type != null) {
- var sig_attributes = get_attributes ("%s::%s".printf (current_data_type.get_cname (), name));
+ var sig_attributes = get_attributes ("%s::%s".printf (get_cname (current_data_type), name));
if (sig_attributes != null) {
foreach (string attr in sig_attributes) {
var nv = attr.split ("=", 2);
@@ -2178,14 +2190,14 @@ public class Vala.GIdlParser : CodeVisitor {
current_data_type != null &&
param.type.is_interface &&
(param_node.name == "self" ||
- param type interface has_suffix (current_data_type.get_cname ()))) {
+ param type interface has_suffix (get_cname (current_data_type)))) {
// instance method
continue;
} else if (!(m is CreationMethod) &&
current_data_type != null &&
param.type.is_interface &&
(param_node.name == "klass" ||
- param type interface has_suffix ("%sClass".printf(current_data_type.get_cname ())))) {
+ param type interface has_suffix ("%sClass".printf(get_cname (current_data_type))))) {
// class method
m.binding = MemberBinding.CLASS;
if (m.name.has_prefix ("class_")) {
@@ -2507,7 +2519,7 @@ public class Vala.GIdlParser : CodeVisitor {
}
}
- var attributes = get_attributes ("%s:%s".printf (current_data_type.get_cname (), node.name));
+ var attributes = get_attributes ("%s:%s".printf (get_cname (current_data_type), node.name));
if (attributes != null) {
foreach (string attr in attributes) {
var nv = attr.split ("=", 2);
@@ -2616,7 +2628,7 @@ public class Vala.GIdlParser : CodeVisitor {
bool experimental = false;
bool no_delegate_target = false;
- var attributes = get_attributes ("%s.%s".printf (current_data_type.get_cname (), node.name));
+ var attributes = get_attributes ("%s.%s".printf (get_cname (current_data_type), node.name));
if (attributes != null) {
foreach (string attr in attributes) {
var nv = attr.split ("=", 2);
@@ -2824,7 +2836,7 @@ public class Vala.GIdlParser : CodeVisitor {
var sig = new Signal (fix_prop_name (node.name), parse_param (sig_node.result), current_source_reference);
sig.access = SymbolAccessibility.PUBLIC;
- var attributes = get_attributes ("%s::%s".printf (current_data_type.get_cname (), sig.name));
+ var attributes = get_attributes ("%s::%s".printf (get_cname (current_data_type), sig.name));
if (attributes != null) {
string ns_name = null;
foreach (string attr in attributes) {
@@ -2887,7 +2899,7 @@ public class Vala.GIdlParser : CodeVisitor {
bool hide_param = false;
bool show_param = false;
- attributes = get_attributes ("%s::%s.%s".printf (current_data_type.get_cname (), sig.name, param_node.name));
+ attributes = get_attributes ("%s::%s.%s".printf (get_cname (current_data_type), sig.name, param_node.name));
if (attributes != null) {
string ns_name = null;
foreach (string attr in attributes) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]