[vala/wip/attributes: 71/121] Do not use type_id in DataType.compatible
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 71/121] Do not use type_id in DataType.compatible
- Date: Mon, 4 Jul 2011 17:14:44 +0000 (UTC)
commit df2f0a2deaaa40bc75553604d58a19f2327f1dfb
Author: Luca Bruno <lucabru src gnome org>
Date: Wed Jun 29 21:50:53 2011 +0200
Do not use type_id in DataType.compatible
codegen/valaccodebasemodule.vala | 6 +++++-
vala/valaarraytype.vala | 4 ++--
vala/valadatatype.vala | 4 ++--
vala/valasemanticanalyzer.vala | 2 ++
4 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 8b6fe2a..7bef714 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5137,7 +5137,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
} else {
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_variable_cexpression (decl.name)));
}
- ccall.add_argument (new CCodeIdentifier (get_ccode_type_id (type)));
+ var type_id = get_ccode_type_id (type);
+ if (type_id == "") {
+ Report.error (node.source_reference, "GValue boxing of type `%s' is not supported".printf (type.to_string ()));
+ }
+ ccall.add_argument (new CCodeIdentifier (type_id));
ccode.add_expression (ccall);
if (requires_destroy (type)) {
diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala
index ed28410..3b5e112 100644
--- a/vala/valaarraytype.vala
+++ b/vala/valaarraytype.vala
@@ -179,12 +179,12 @@ public class Vala.ArrayType : ReferenceType {
}
public override bool compatible (DataType target_type) {
- if (target_type.get_type_id () == "G_TYPE_VALUE" && element_type.data_type == CodeContext.get ().root.scope.lookup ("string")) {
+ if (target_type.data_type == CodeContext.get ().gvalue_type.data_type && element_type.data_type == CodeContext.get ().root.scope.lookup ("string")) {
// allow implicit conversion from string[] to GValue
return true;
}
- if (target_type.get_type_id () == "G_TYPE_VARIANT") {
+ if (target_type.data_type == CodeContext.get ().gvariant_type.data_type) {
// allow implicit conversion to GVariant
return true;
}
diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala
index c53ce5c..c879dcf 100644
--- a/vala/valadatatype.vala
+++ b/vala/valadatatype.vala
@@ -313,12 +313,12 @@ public abstract class Vala.DataType : CodeNode {
return false;
}
- if (target_type.get_type_id () == "G_TYPE_VALUE" && get_type_id () != null) {
+ if (target_type.data_type == CodeContext.get ().gvalue_type.data_type) {
// allow implicit conversion to GValue
return true;
}
- if (target_type.get_type_id () == "G_TYPE_VARIANT") {
+ if (target_type.data_type == CodeContext.get ().gvariant_type.data_type) {
// allow implicit conversion to GVariant
return true;
}
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index a2a3a10..97f910d 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -152,6 +152,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
public DataType type_type;
public Class object_type;
public StructValueType gvalue_type;
+ public ObjectType gvariant_type;
public DataType glist_type;
public DataType gslist_type;
public DataType garray_type;
@@ -213,6 +214,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
object_type = (Class) glib_ns.scope.lookup ("Object");
type_type = new IntegerType ((Struct) glib_ns.scope.lookup ("Type"));
gvalue_type = new StructValueType ((Struct) glib_ns.scope.lookup ("Value"));
+ gvariant_type = new ObjectType ((Class) glib_ns.scope.lookup ("Variant"));
glist_type = new ObjectType ((Class) glib_ns.scope.lookup ("List"));
gslist_type = new ObjectType ((Class) glib_ns.scope.lookup ("SList"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]