vala r1273 - in trunk: . gobject vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1273 - in trunk: . gobject vala
- Date: Sat, 19 Apr 2008 17:33:41 +0100 (BST)
Author: juergbi
Date: Sat Apr 19 16:33:40 2008
New Revision: 1273
URL: http://svn.gnome.org/viewvc/vala?rev=1273&view=rev
Log:
2008-04-19 Juerg Billeter <j bitron ch>
* vala/valaclass.vala:, vala/valadestructor.vala,
vala/valasemanticanalyzer.vala, gobject/valaccodeclassbinding.vala:
support `this' access in destructors, fixes bug 527997
Modified:
trunk/ChangeLog
trunk/gobject/valaccodeclassbinding.vala
trunk/vala/valaclass.vala
trunk/vala/valadestructor.vala
trunk/vala/valasemanticanalyzer.vala
Modified: trunk/gobject/valaccodeclassbinding.vala
==============================================================================
--- trunk/gobject/valaccodeclassbinding.vala (original)
+++ trunk/gobject/valaccodeclassbinding.vala Sat Apr 19 16:33:40 2008
@@ -334,7 +334,7 @@
}
/* set dispose function */
- if (cl.get_fields ().size > 0) {
+ if (cl.get_fields ().size > 0 || cl.destructor != null) {
var ccast = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_CLASS"));
ccast.add_argument (new CCodeIdentifier ("klass"));
init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (ccast, "dispose"), new CCodeIdentifier ("%s_dispose".printf (cl.get_lower_case_cname (null))))));
Modified: trunk/vala/valaclass.vala
==============================================================================
--- trunk/vala/valaclass.vala (original)
+++ trunk/vala/valaclass.vala Sat Apr 19 16:33:40 2008
@@ -97,13 +97,27 @@
/**
* Specifies the instance destructor.
*/
- public Destructor destructor { get; set; }
+ public Destructor? destructor {
+ get { return _destructor; }
+ set {
+ _destructor = value;
+ if (_destructor != null) {
+ if (_destructor.this_parameter != null) {
+ _destructor.scope.remove (_destructor.this_parameter.name);
+ }
+ _destructor.this_parameter = new FormalParameter ("this", new ClassType (this));
+ _destructor.scope.add (_destructor.this_parameter.name, _destructor.this_parameter);
+ }
+ }
+ }
/**
* Specifies whether this class denotes an error base.
*/
public bool is_error_base { get; set ; }
+ Destructor? _destructor;
+
/**
* Creates a new class.
*
Modified: trunk/vala/valadestructor.vala
==============================================================================
--- trunk/vala/valadestructor.vala (original)
+++ trunk/vala/valadestructor.vala Sat Apr 19 16:33:40 2008
@@ -1,6 +1,6 @@
/* valadestructor.vala
*
- * Copyright (C) 2006-2007 JÃrg Billeter
+ * Copyright (C) 2006-2008 JÃrg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -31,16 +31,16 @@
*/
public Block body { get; set; }
- private bool _instance = true;
-
+ /**
+ * Specifies the generated `this' parameter for instance methods.
+ */
+ public FormalParameter this_parameter { get; set; }
+
/**
* Specifies whether this is an instance or a class destructor.
*/
- public bool instance {
- get { return _instance; }
- set { _instance = value; }
- }
-
+ public bool instance { get; set; default = true; }
+
/**
* Creates a new destructor.
*
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Sat Apr 19 16:33:40 2008
@@ -2166,6 +2166,8 @@
} else if (sym is Constructor) {
var c = (Constructor) sym;
return c.instance;
+ } else if (sym is Destructor) {
+ return true;
} else if (sym is Property) {
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]