[vala] codegen: Fix criticals for interfaces without class prerequisite



commit e530c44dfa2c6f43202aea154ed077df9de8dbae
Author: Jürg Billeter <j bitron ch>
Date:   Sun May 22 23:10:26 2011 +0200

    codegen: Fix criticals for interfaces without class prerequisite
    
    Fixes bug 642804.

 codegen/valaccodebasemodule.vala |    7 ++++++-
 vala/valainterface.vala          |   10 +++++-----
 2 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index b77cd80..1277cd1 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5204,7 +5204,12 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		if (target_type.value_owned && (!type.value_owned || boxing || unboxing)) {
 			// need to copy value
 			if (requires_copy (target_type) && !(type is NullType)) {
-				result = (GLibValue) copy_value (result, node);
+				var copy = (GLibValue) copy_value (result, node);
+				if (target_type.data_type is Interface && copy == null) {
+					Report.error (node.source_reference, "missing class prerequisite for interface `%s', add GLib.Object to interface declaration if unsure".printf (target_type.data_type.get_full_name ()));
+					return result;
+				}
+				result = copy;
 				// drop this assignment when target values are guaranteed to be effect-free
 				if (!(target_type is ArrayType && ((ArrayType) target_type).fixed_length)) {
 					var decl = get_temp_variable (target_type, true, node, false);
diff --git a/vala/valainterface.vala b/vala/valainterface.vala
index 92d9cbc..d189323 100644
--- a/vala/valainterface.vala
+++ b/vala/valainterface.vala
@@ -527,7 +527,7 @@ public class Vala.Interface : ObjectTypeSymbol {
 				return type_name;
 			}
 		}
-		return null;
+		return "POINTER";
 	}
 
 	public override string? get_get_value_function () {
@@ -537,7 +537,7 @@ public class Vala.Interface : ObjectTypeSymbol {
 				return get_value_func;
 			}
 		}
-		return null;
+		return "g_value_get_pointer";
 	}
 	
 	public override string? get_set_value_function () {
@@ -547,7 +547,7 @@ public class Vala.Interface : ObjectTypeSymbol {
 				return set_value_func;
 			}
 		}
-		return null;
+		return "g_value_set_pointer";
 	}
 
 	public override string? get_take_value_function () {
@@ -557,7 +557,7 @@ public class Vala.Interface : ObjectTypeSymbol {
 				return take_value_func;
 			}
 		}
-		return null;
+		return "g_value_set_pointer";
 	}
 
 	public string? get_default_type_id () {
@@ -601,7 +601,7 @@ public class Vala.Interface : ObjectTypeSymbol {
 			}
 		}
 
-		return null;
+		return "g_param_spec_pointer";
 	}
 
 	public override bool check (CodeContext context) {



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