vala r1751 - in trunk: . gobject
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1751 - in trunk: . gobject
- Date: Thu, 14 Aug 2008 20:03:25 +0000 (UTC)
Author: juergbi
Date: Thu Aug 14 20:03:25 2008
New Revision: 1751
URL: http://svn.gnome.org/viewvc/vala?rev=1751&view=rev
Log:
2008-08-14 JÃrg Billeter <j bitron ch>
* gobject/valaccodeclassbinding.vala:
* gobject/valaccodegenerator.vala:
* gobject/valaccodegeneratorstruct.vala:
Use finalize instead of dispose to free instance data as dispose
should only be used where it is necessary to break reference
cycles, and this is possible by manually overriding the dispose
method
Modified:
trunk/ChangeLog
trunk/gobject/valaccodeclassbinding.vala
trunk/gobject/valaccodegenerator.vala
trunk/gobject/valaccodegeneratorstruct.vala
Modified: trunk/gobject/valaccodeclassbinding.vala
==============================================================================
--- trunk/gobject/valaccodeclassbinding.vala (original)
+++ trunk/gobject/valaccodeclassbinding.vala Thu Aug 14 20:03:25 2008
@@ -41,7 +41,7 @@
var old_prop_enum = codegen.prop_enum;
var old_class_init_fragment = codegen.class_init_fragment;
var old_instance_init_fragment = codegen.instance_init_fragment;
- var old_instance_dispose_fragment = codegen.instance_dispose_fragment;
+ var old_instance_finalize_fragment = codegen.instance_finalize_fragment;
codegen.current_symbol = cl;
codegen.current_type_symbol = cl;
codegen.current_class = cl;
@@ -64,7 +64,7 @@
codegen.prop_enum.add_value (new CCodeEnumValue ("%s_DUMMY_PROPERTY".printf (cl.get_upper_case_cname (null))));
codegen.class_init_fragment = new CCodeFragment ();
codegen.instance_init_fragment = new CCodeFragment ();
- codegen.instance_dispose_fragment = new CCodeFragment ();
+ codegen.instance_finalize_fragment = new CCodeFragment ();
}
CCodeFragment decl_frag;
@@ -175,7 +175,7 @@
if (is_gobject) {
if (cl.get_fields ().size > 0 || cl.destructor != null) {
- add_dispose_function (cl);
+ add_finalize_function (cl);
}
}
@@ -233,10 +233,6 @@
var destroy_block = new CCodeBlock ();
var get_class = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (cl.get_upper_case_cname (null))));
get_class.add_argument (new CCodeIdentifier ("self"));
- var finalize = new CCodeMemberAccess.pointer (get_class, "finalize");
- var finalize_call = new CCodeFunctionCall (finalize);
- finalize_call.add_argument (new CCodeIdentifier ("self"));
- //destroy_block.add_statement (new CCodeExpressionStatement (finalize_call));
var free = new CCodeFunctionCall (new CCodeIdentifier ("g_type_free_instance"));
free.add_argument (new CCodeCastExpression (new CCodeIdentifier ("self"), "GTypeInstance *"));
destroy_block.add_statement (new CCodeExpressionStatement (free));
@@ -269,7 +265,7 @@
var cblock = new CCodeBlock ();
- cblock.add_statement (codegen.instance_dispose_fragment);
+ cblock.add_statement (codegen.instance_finalize_fragment);
if (cl.destructor != null) {
cblock.add_statement (cl.destructor.ccodenode);
@@ -293,7 +289,7 @@
codegen.prop_enum = old_prop_enum;
codegen.class_init_fragment = old_class_init_fragment;
codegen.instance_init_fragment = old_instance_init_fragment;
- codegen.instance_dispose_fragment = old_instance_dispose_fragment;
+ codegen.instance_finalize_fragment = old_instance_finalize_fragment;
}
private void add_class_init_function (Class cl) {
@@ -344,11 +340,11 @@
init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (ccast, "constructor"), new CCodeIdentifier ("%s_constructor".printf (cl.get_lower_case_cname (null))))));
}
- /* set dispose function */
+ /* set finalize function */
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))))));
+ init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (ccast, "finalize"), new CCodeIdentifier ("%s_finalize".printf (cl.get_lower_case_cname (null))))));
}
}
@@ -657,8 +653,8 @@
codegen.source_type_member_definition.append (instance_init);
}
- private void add_dispose_function (Class cl) {
- var function = new CCodeFunction ("%s_dispose".printf (cl.get_lower_case_cname (null)), "void");
+ private void add_finalize_function (Class cl) {
+ var function = new CCodeFunction ("%s_finalize".printf (cl.get_lower_case_cname (null)), "void");
function.modifiers = CCodeModifiers.STATIC;
function.add_parameter (new CCodeFormalParameter ("obj", "GObject *"));
@@ -679,12 +675,12 @@
cblock.add_statement (cl.destructor.ccodenode);
}
- cblock.add_statement (codegen.instance_dispose_fragment);
+ cblock.add_statement (codegen.instance_finalize_fragment);
- // chain up to dispose function of the base class
+ // chain up to finalize function of the base class
var ccast = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_CLASS"));
ccast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (cl.get_lower_case_cname (null))));
- ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (ccast, "dispose"));
+ ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (ccast, "finalize"));
ccall.add_argument (new CCodeIdentifier ("obj"));
cblock.add_statement (new CCodeExpressionStatement (ccall));
Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala (original)
+++ trunk/gobject/valaccodegenerator.vala Thu Aug 14 20:03:25 2008
@@ -54,7 +54,7 @@
public CCodeFragment source_type_member_definition;
public CCodeFragment class_init_fragment;
public CCodeFragment instance_init_fragment;
- public CCodeFragment instance_dispose_fragment;
+ public CCodeFragment instance_finalize_fragment;
public CCodeFragment source_signal_marshaller_definition;
public CCodeFragment module_init_fragment;
@@ -497,8 +497,8 @@
fc.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, l));
- if (instance_dispose_fragment != null) {
- instance_dispose_fragment.append (new CCodeExpressionStatement (fc));
+ if (instance_finalize_fragment != null) {
+ instance_finalize_fragment.append (new CCodeExpressionStatement (fc));
}
}
}
@@ -640,13 +640,13 @@
}
}
- if (requires_destroy (f.field_type) && instance_dispose_fragment != null) {
+ if (requires_destroy (f.field_type) && instance_finalize_fragment != null) {
var this_access = new MemberAccess.simple ("this");
this_access.value_type = get_data_type_for_symbol ((TypeSymbol) f.parent_symbol);
this_access.ccodenode = new CCodeIdentifier ("self");
var ma = new MemberAccess (this_access, f.name);
ma.symbol_reference = f;
- instance_dispose_fragment.append (new CCodeExpressionStatement (get_unref_expression (lhs, f.field_type, ma)));
+ instance_finalize_fragment.append (new CCodeExpressionStatement (get_unref_expression (lhs, f.field_type, ma)));
}
} else if (f.binding == MemberBinding.CLASS) {
st.add_field (field_ctype, f.get_cname ());
Modified: trunk/gobject/valaccodegeneratorstruct.vala
==============================================================================
--- trunk/gobject/valaccodegeneratorstruct.vala (original)
+++ trunk/gobject/valaccodegeneratorstruct.vala Thu Aug 14 20:03:25 2008
@@ -27,10 +27,10 @@
public override void visit_struct (Struct st) {
var old_type_symbol = current_type_symbol;
var old_instance_struct = instance_struct;
- var old_instance_dispose_fragment = instance_dispose_fragment;
+ var old_instance_finalize_fragment = instance_finalize_fragment;
current_type_symbol = st;
instance_struct = new CCodeStruct ("_%s".printf (st.get_cname ()));
- instance_dispose_fragment = new CCodeFragment ();
+ instance_finalize_fragment = new CCodeFragment ();
CCodeFragment decl_frag;
CCodeFragment def_frag;
@@ -55,6 +55,6 @@
current_type_symbol = old_type_symbol;
instance_struct = old_instance_struct;
- instance_dispose_fragment = old_instance_dispose_fragment;
+ instance_finalize_fragment = old_instance_finalize_fragment;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]