[vala] codegen: Fix conversion from generic pointer to long integer



commit d6bc0cc06f920a40faf778d5a622093ebf06ec05
Author: JÃrg Billeter <j bitron ch>
Date:   Mon Jul 16 21:21:05 2012 +0200

    codegen: Fix conversion from generic pointer to long integer
    
    Fixes bug 660621.

 codegen/valaccodebasemodule.vala |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 9102e70..59888f3 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5323,13 +5323,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		if (is_reference_type_argument (actual_type) || is_nullable_value_type_argument (actual_type)) {
 			result = new CCodeCastExpression (cexpr, get_ccode_name (actual_type));
 		} else if (is_signed_integer_type_argument (actual_type)) {
-			var cconv = new CCodeFunctionCall (new CCodeIdentifier ("GPOINTER_TO_INT"));
-			cconv.add_argument (cexpr);
-			result = cconv;
+			result = new CCodeCastExpression (new CCodeCastExpression (cexpr, "gintptr"), get_ccode_name (actual_type));
 		} else if (is_unsigned_integer_type_argument (actual_type)) {
-			var cconv = new CCodeFunctionCall (new CCodeIdentifier ("GPOINTER_TO_UINT"));
-			cconv.add_argument (cexpr);
-			result = cconv;
+			result = new CCodeCastExpression (new CCodeCastExpression (cexpr, "guintptr"), get_ccode_name (actual_type));
 		}
 		return result;
 	}
@@ -5337,13 +5333,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 	public CCodeExpression convert_to_generic_pointer (CCodeExpression cexpr, DataType actual_type) {
 		var result = cexpr;
 		if (is_signed_integer_type_argument (actual_type)) {
-			var cconv = new CCodeFunctionCall (new CCodeIdentifier ("GINT_TO_POINTER"));
-			cconv.add_argument (cexpr);
-			result = cconv;
+			result = new CCodeCastExpression (new CCodeCastExpression (cexpr, "gintptr"), "gpointer");
 		} else if (is_unsigned_integer_type_argument (actual_type)) {
-			var cconv = new CCodeFunctionCall (new CCodeIdentifier ("GUINT_TO_POINTER"));
-			cconv.add_argument (cexpr);
-			result = cconv;
+			result = new CCodeCastExpression (new CCodeCastExpression (cexpr, "guintptr"), "gpointer");
 		}
 		return result;
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]