[vala/wip/transform: 40/48] Drop GVariant stuff from CCodeBaseModule
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/transform: 40/48] Drop GVariant stuff from CCodeBaseModule
- Date: Wed, 11 Apr 2012 16:52:08 +0000 (UTC)
commit a7cf9a637fdf352a017ae71aaccbc9eaa4576eb2
Author: Luca Bruno <lucabru src gnome org>
Date: Thu Jan 5 13:14:58 2012 +0100
Drop GVariant stuff from CCodeBaseModule
codegen/valaccodebasemodule.vala | 126 +-------------------------------------
1 files changed, 1 insertions(+), 125 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 866e8b9..a39c558 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -312,7 +312,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public DataType gdestroynotify_type;
public DataType gquark_type;
public Struct gvalue_type;
- public Class gvariant_type;
public Struct mutex_type;
public TypeSymbol type_module_type;
public TypeSymbol dbus_proxy_type;
@@ -454,7 +453,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
gquark_type = new IntegerType ((Struct) glib_ns.scope.lookup ("Quark"));
gvalue_type = (Struct) glib_ns.scope.lookup ("Value");
- gvariant_type = (Class) glib_ns.scope.lookup ("Variant");
mutex_type = (Struct) glib_ns.scope.lookup ("StaticRecMutex");
type_module_type = (TypeSymbol) glib_ns.scope.lookup ("TypeModule");
@@ -4663,82 +4661,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return rv;
}
- int next_variant_function_id = 0;
-
- public TargetValue? try_cast_variant_to_type (TargetValue value, DataType to, CodeNode? node = null) {
- if (value.value_type == null || gvariant_type == null || value.value_type.data_type != gvariant_type) {
- return null;
- }
-
- string variant_func = "_variant_get%d".printf (++next_variant_function_id);
-
- var variant = value;
- if (value.value_type.value_owned) {
- // value leaked, destroy it
- var temp_value = store_temp_value (value, node);
- temp_ref_values.insert (0, ((GLibValue) temp_value).copy ());
- variant = temp_value;
- }
-
- var ccall = new CCodeFunctionCall (new CCodeIdentifier (variant_func));
- ccall.add_argument (get_cvalue_ (variant));
-
- var result = create_temp_value (to, false, node);
-
- var cfunc = new CCodeFunction (variant_func);
- cfunc.modifiers = CCodeModifiers.STATIC;
- cfunc.add_parameter (new CCodeParameter ("value", "GVariant*"));
-
- if (!to.is_real_non_null_struct_type ()) {
- cfunc.return_type = get_ccode_name (to);
- }
-
- if (to.is_real_non_null_struct_type ()) {
- // structs are returned via out parameter
- cfunc.add_parameter (new CCodeParameter ("result", get_ccode_name (to) + "*"));
- ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_cvalue_ (result)));
- } else if (to is ArrayType) {
- // return array length if appropriate
- // tmp = _variant_get (variant, &tmp_length);
- var array_type = (ArrayType) to;
-
- for (int dim = 1; dim <= array_type.rank; dim++) {
- ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_array_length_cvalue (result, dim)));
- cfunc.add_parameter (new CCodeParameter (get_array_length_cname ("result", dim), "int*"));
- }
- }
-
- if (!to.is_real_non_null_struct_type ()) {
- ccode.add_assignment (get_cvalue_ (result), ccall);
- } else {
- ccode.add_expression (ccall);
- }
-
- push_function (cfunc);
-
- CCodeExpression func_result = deserialize_expression (to, new CCodeIdentifier ("value"), new CCodeIdentifier ("*result"));
- if (to.is_real_non_null_struct_type ()) {
- ccode.add_assignment (new CCodeIdentifier ("*result"), func_result);
- } else {
- ccode.add_return (func_result);
- }
-
- pop_function ();
-
- cfile.add_function_declaration (cfunc);
- cfile.add_function (cfunc);
-
- return load_temp_value (result);
- }
-
- public virtual CCodeExpression? deserialize_expression (DataType type, CCodeExpression variant_expr, CCodeExpression? expr, CCodeExpression? error_expr = null, out bool may_fail = null) {
- assert_not_reached ();
- }
-
- public virtual CCodeExpression? serialize_expression (DataType type, CCodeExpression expr) {
- assert_not_reached ();
- }
-
public override void visit_cast_expression (CastExpression expr) {
var valuecast = try_cast_value_to_type (get_cvalue (expr.inner), expr.inner.value_type, expr.type_reference, expr);
if (valuecast != null) {
@@ -4746,12 +4668,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return;
}
- var variantcast = try_cast_variant_to_type (expr.inner.target_value, expr.type_reference, expr);
- if (variantcast != null) {
- expr.target_value = variantcast;
- return;
- }
-
generate_type_declaration (expr.type_reference, cfile);
var cl = expr.type_reference.data_type as Class;
@@ -5255,11 +5171,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
&& target_type.data_type == gvalue_type
&& !(type is NullType)
&& get_ccode_type_id (type) != "G_TYPE_VALUE");
- bool gvariant_boxing = (context.profile == Profile.GOBJECT
- && target_type != null
- && target_type.data_type == gvariant_type
- && !(type is NullType)
- && type.data_type != gvariant_type);
if (type.value_owned
&& (target_type == null || !target_type.value_owned || boxing || unboxing)
@@ -5338,41 +5249,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
result = (GLibValue) temp_value;
requires_temp_value = false;
- } else if (gvariant_boxing) {
- // implicit conversion to GVariant
- string variant_func = "_variant_new%d".printf (++next_variant_function_id);
-
- var ccall = new CCodeFunctionCall (new CCodeIdentifier (variant_func));
- ccall.add_argument (result.cvalue);
-
- var cfunc = new CCodeFunction (variant_func, "GVariant*");
- cfunc.modifiers = CCodeModifiers.STATIC;
- cfunc.add_parameter (new CCodeParameter ("value", get_ccode_name (type)));
-
- if (type is ArrayType) {
- // return array length if appropriate
- var array_type = (ArrayType) type;
-
- for (int dim = 1; dim <= array_type.rank; dim++) {
- ccall.add_argument (get_array_length_cvalue (value, dim));
- cfunc.add_parameter (new CCodeParameter (get_array_length_cname ("value", dim), "gint"));
- }
- }
-
- push_function (cfunc);
-
- // sink floating reference
- var sink = new CCodeFunctionCall (new CCodeIdentifier ("g_variant_ref_sink"));
- sink.add_argument (serialize_expression (type, new CCodeIdentifier ("value")));
- ccode.add_return (sink);
-
- pop_function ();
-
- cfile.add_function_declaration (cfunc);
- cfile.add_function (cfunc);
-
- result.cvalue = ccall;
- requires_temp_value = true;
} else if (boxing) {
// value needs to be boxed
@@ -5397,7 +5273,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
result = (GLibValue) store_temp_value (result, node);
}
- if (!gvalue_boxing && !gvariant_boxing && target_type.value_owned && (!type.value_owned || boxing || unboxing) && requires_copy (target_type) && !(type is NullType)) {
+ if (!gvalue_boxing && target_type.value_owned && (!type.value_owned || boxing || unboxing) && requires_copy (target_type) && !(type is NullType)) {
// need to copy value
var copy = (GLibValue) copy_value (result, node);
if (target_type.data_type is Interface && copy == null) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]