[vala/switch-to-gir: 24/51] girparser: Support aliases whose base type is a SimpleType.
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/switch-to-gir: 24/51] girparser: Support aliases whose base type is a SimpleType.
- Date: Fri, 11 Mar 2011 10:40:05 +0000 (UTC)
commit a1abbe7d9ef6880c2591e304a0bd51dab9dfdeb1
Author: Luca Bruno <lucabru src gnome org>
Date: Thu Dec 23 12:35:20 2010 +0100
girparser: Support aliases whose base type is a SimpleType.
vala/valagirparser.vala | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index d3dafd3..59a7a02 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -494,6 +494,7 @@ public class Vala.GirParser : CodeVisitor {
class Alias {
public string name;
+ public string cname;
public DataType base_type;
public Symbol parent_symbol;
public SourceReference source_reference;
@@ -1484,6 +1485,7 @@ public class Vala.GirParser : CodeVisitor {
var alias = new Alias ();
alias.source_reference = get_current_src ();
alias.name = reader.get_attribute ("name");
+ alias.cname = reader.get_attribute ("c:type");
alias.parent_symbol = current_symbol;
next ();
@@ -2839,18 +2841,26 @@ public class Vala.GirParser : CodeVisitor {
void postprocess_aliases () {
/* this is unfortunate because <alias> tag has no type information, thus we have
- to guess it from the target */
+ to guess it from the base type */
foreach (var alias in aliases) {
DataType base_type = null;
Symbol type_sym = null;
+ bool simple_type = false;
if (alias.base_type is UnresolvedType) {
base_type = alias.base_type;
type_sym = resolve_symbol (alias.parent_symbol.scope, ((UnresolvedType) base_type).unresolved_symbol);
- } else if (!(alias.base_type is VoidType)) {
+ } else if (alias.base_type is PointerType && ((PointerType) alias.base_type).base_type is VoidType) {
+ // gpointer, if it's a struct make it a simpletype
+ simple_type = true;
+ } else {
base_type = alias.base_type;
type_sym = base_type.data_type;
}
+ if (type_sym is Struct && ((Struct) type_sym).is_simple_type ()) {
+ simple_type = true;
+ }
+
if (base_type == null || type_sym == null || type_sym is Struct) {
var st = new Struct (alias.name, alias.source_reference);
st.access = SymbolAccessibility.PUBLIC;
@@ -2859,6 +2869,12 @@ public class Vala.GirParser : CodeVisitor {
st.base_type = base_type;
}
st.external = true;
+ if (alias.cname != null) {
+ st.set_cname (alias.cname);
+ }
+ if (simple_type) {
+ st.set_simple_type (true);
+ }
add_symbol_to_container (alias.parent_symbol, st);
} else if (type_sym is Class) {
var cl = new Class (alias.name, alias.source_reference);
@@ -2867,6 +2883,9 @@ public class Vala.GirParser : CodeVisitor {
cl.add_base_type (base_type);
}
cl.external = true;
+ if (alias.cname != null) {
+ cl.set_cname (alias.cname);
+ }
add_symbol_to_container (alias.parent_symbol, cl);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]