[vala/wip/attributes: 68/119] Drop TypeSymbol.get_destroy_function
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 68/119] Drop TypeSymbol.get_destroy_function
- Date: Mon, 4 Jul 2011 10:27:48 +0000 (UTC)
commit 7e2fb768ce3372733a83d696ee80aab5338bae00
Author: Luca Bruno <lucabru src gnome org>
Date: Wed Jun 29 21:15:35 2011 +0200
Drop TypeSymbol.get_destroy_function
codegen/valaccodebasemodule.vala | 27 +++++++++++++++++++++++----
codegen/valaccodestructmodule.vala | 6 +++---
vala/valastruct.vala | 19 -------------------
vala/valatypesymbol.vala | 14 +-------------
4 files changed, 27 insertions(+), 39 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 6c4f47c..8e9270c 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2590,7 +2590,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
generate_struct_destroy_function (st);
}
- var destroy_call = new CCodeFunctionCall (new CCodeIdentifier (st.get_destroy_function ()));
+ var destroy_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_destroy_function (st)));
destroy_call.add_argument (new CCodeIdentifier ("self"));
ccode.add_expression (destroy_call);
}
@@ -2691,7 +2691,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (!get_ccode_has_destroy_function (st)) {
generate_struct_destroy_function (st);
}
- unref_function = st.get_destroy_function ();
+ unref_function = get_ccode_destroy_function (st);
}
}
if (unref_function == "") {
@@ -5633,6 +5633,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return get_ccode_attribute(sym).copy_function;
}
+ public static string get_ccode_destroy_function (TypeSymbol sym) {
+ return get_ccode_attribute(sym).destroy_function;
+ }
+
public static string get_ccode_dup_function (TypeSymbol sym) {
return get_ccode_copy_function(sym);
}
@@ -5824,12 +5828,12 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
void generate_struct_destroy_function (Struct st) {
- if (cfile.add_declaration (st.get_destroy_function ())) {
+ if (cfile.add_declaration (get_ccode_destroy_function (st))) {
// only generate function once per source file
return;
}
- var function = new CCodeFunction (st.get_destroy_function (), "void");
+ var function = new CCodeFunction (get_ccode_destroy_function (st), "void");
function.modifiers = CCodeModifiers.STATIC;
function.add_parameter (new CCodeParameter ("self", get_ccode_name (st) + "*"));
@@ -6258,6 +6262,19 @@ public class Vala.CCodeAttribute : AttributeCache {
}
}
+ public string destroy_function {
+ get {
+ if (_destroy_function == null) {
+ if (sym is Struct) {
+ _destroy_function = lower_case_prefix + "destroy";
+ } else {
+ _destroy_function = "";
+ }
+ }
+ return _destroy_function;
+ }
+ }
+
public string free_function {
get {
if (_free_function == null) {
@@ -6380,6 +6397,7 @@ public class Vala.CCodeAttribute : AttributeCache {
private string _unref_function;
private string _ref_sink_function;
private string _copy_function;
+ private string _destroy_function;
private string _free_function;
private string _type_id;
private string _marshaller_type_name;
@@ -6421,6 +6439,7 @@ public class Vala.CCodeAttribute : AttributeCache {
_unref_function = attr.get_string ("unref_function");
_ref_sink_function = attr.get_string ("ref_sink_function");
_copy_function = attr.get_string ("copy_function");
+ _destroy_function = attr.get_string ("destroy_function");
_free_function = attr.get_string ("free_function");
_type_id = attr.get_string ("type_id");
_marshaller_type_name = attr.get_string ("marshaller_type_name");
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index 94d1f35..d7f312f 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -136,7 +136,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
function.add_parameter (new CCodeParameter ("dest", get_ccode_name (st) + "*"));
decl_space.add_function_declaration (function);
- function = new CCodeFunction (st.get_destroy_function (), "void");
+ function = new CCodeFunction (get_ccode_destroy_function (st), "void");
if (st.is_private_symbol ()) {
function.modifiers = CCodeModifiers.STATIC;
}
@@ -236,7 +236,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
push_function (function);
if (st.is_disposable ()) {
- var destroy_call = new CCodeFunctionCall (new CCodeIdentifier (st.get_destroy_function ()));
+ var destroy_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_destroy_function (st)));
destroy_call.add_argument (new CCodeIdentifier ("self"));
ccode.add_expression (destroy_call);
}
@@ -284,7 +284,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
void begin_struct_destroy_function (Struct st) {
push_context (instance_finalize_context);
- var function = new CCodeFunction (st.get_destroy_function (), "void");
+ var function = new CCodeFunction (get_ccode_destroy_function (st), "void");
if (st.access == SymbolAccessibility.PRIVATE) {
function.modifiers = CCodeModifiers.STATIC;
}
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index ca23e90..2b5b4e6 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -45,7 +45,6 @@ public class Vala.Struct : TypeSymbol {
private bool? simple_type;
private int? rank;
private string default_value = null;
- private string destroy_function;
/**
* Specifies the base type.
@@ -439,9 +438,6 @@ public class Vala.Struct : TypeSymbol {
if (a.has_argument ("default_value")) {
set_default_value (a.get_string ("default_value"));
}
- if (a.has_argument ("destroy_function")) {
- set_destroy_function (a.get_string ("destroy_function"));
- }
}
private void process_boolean_type_attribute (Attribute a) {
@@ -613,21 +609,6 @@ public class Vala.Struct : TypeSymbol {
}
}
- public string get_default_destroy_function () {
- return get_lower_case_cprefix () + "destroy";
- }
-
- public override string? get_destroy_function () {
- if (destroy_function == null) {
- destroy_function = get_default_destroy_function ();
- }
- return destroy_function;
- }
-
- public void set_destroy_function (string name) {
- this.destroy_function = name;
- }
-
public bool is_disposable () {
if (destroy_function != null) {
return true;
diff --git a/vala/valatypesymbol.vala b/vala/valatypesymbol.vala
index 0f1f966..e10701e 100644
--- a/vala/valatypesymbol.vala
+++ b/vala/valatypesymbol.vala
@@ -60,19 +60,7 @@ public abstract class Vala.TypeSymbol : Symbol {
public virtual string? get_dup_function () {
return null;
}
-
- /**
- * Returns the C function name that destroys the contents of instances
- * of this data type. This is only applicable to structs. The specified
- * C function must accept one argument pointing to the instance to be
- * destroyed.
- *
- * @return the name of the C function if supported or null otherwise
- */
- public virtual string? get_destroy_function () {
- return null;
- }
-
+
/**
* Returns the C function name that sinks the reference count of
* "floating" instances of this data type. This is only valid for data
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]