vala r1421 - in trunk: . gobject tests



Author: juergbi
Date: Sun May 25 09:25:00 2008
New Revision: 1421
URL: http://svn.gnome.org/viewvc/vala?rev=1421&view=rev

Log:
2008-05-25  Juerg Billeter  <j bitron ch>

	* gobject/valaccodeclassbinding.vala:

	Support destructors for non-GObject classes,
	patch by Jared Moore, fixes bug 522135

	* tests/classes.exp:
	* tests/classes.vala:

	Test destructors for non-GObject classes


Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodeclassbinding.vala
   trunk/tests/classes.exp
   trunk/tests/classes.vala

Modified: trunk/gobject/valaccodeclassbinding.vala
==============================================================================
--- trunk/gobject/valaccodeclassbinding.vala	(original)
+++ trunk/gobject/valaccodeclassbinding.vala	Sun May 25 09:25:00 2008
@@ -264,6 +264,10 @@
 
 			cblock.add_statement (codegen.instance_dispose_fragment);
 
+			if (cl.destructor != null) {
+				cblock.add_statement (cl.destructor.body.ccodenode);
+			}
+
 			var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_slice_free"));
 			ccall.add_argument (new CCodeIdentifier (cl.get_cname ()));
 			ccall.add_argument (new CCodeIdentifier ("self"));

Modified: trunk/tests/classes.exp
==============================================================================
--- trunk/tests/classes.exp	(original)
+++ trunk/tests/classes.exp	Sun May 25 09:25:00 2008
@@ -6,6 +6,8 @@
 ClassWithCreationMethod
 new ClassWithNamedCreationMethod ()
 ClassWithNamedCreationMethod
+new ClassWithDestructor ()
+~ClassWithDestructor
 new SimpleGTypeInstanceClass ()
 new DerivedGTypeInstanceClass ()
 new PublicGTypeInstanceClass ()

Modified: trunk/tests/classes.vala
==============================================================================
--- trunk/tests/classes.vala	(original)
+++ trunk/tests/classes.vala	Sun May 25 09:25:00 2008
@@ -4,6 +4,15 @@
 	public int field;
 }
 
+class ClassWithDestructor {
+	~ClassWithDestructor () {
+		stdout.printf ("~ClassWithDestructor\n");
+	}
+
+	/* FIXME bug 533977 */
+	public char dummy;
+}
+
 class DerivedClass : SimpleClass {
 }
 
@@ -91,6 +100,9 @@
 		var class_with_creation_method = new ClassWithCreationMethod ();
 		stdout.printf ("new ClassWithNamedCreationMethod ()\n");
 		var class_with_named_creation_method = new ClassWithNamedCreationMethod.named ();
+		stdout.printf ("new ClassWithDestructor ()\n");
+		var class_with_destructor = new ClassWithDestructor ();
+		class_with_destructor = null;
 
 		stdout.printf ("new SimpleGTypeInstanceClass ()\n");
 		var simple_gtypeinstance_class = new SimpleGTypeInstanceClass ();



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