[vala/wip/attributes: 13/13] codegen: Add get_ccode_ref_sink_function
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 13/13] codegen: Add get_ccode_ref_sink_function
- Date: Sun, 26 Jun 2011 15:05:58 +0000 (UTC)
commit 3aa9872a5aa75d0fd442711b4480e200d8e1a6f1
Author: Luca Bruno <lucabru src gnome org>
Date: Sun Jun 26 16:50:35 2011 +0200
codegen: Add get_ccode_ref_sink_function
codegen/valaccodebasemodule.vala | 33 +++++++++++++++++++++++++++++++--
1 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 3301a23..8640320 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5057,9 +5057,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
/* floating reference, sink it.
*/
var cl = type.data_type as ObjectTypeSymbol;
- var sink_func = (cl != null) ? cl.get_ref_sink_function () : null;
+ var sink_func = (cl != null) ? get_ccode_ref_sink_function (cl) : "";
- if (sink_func != null) {
+ if (sink_func != "") {
var csink = new CCodeFunctionCall (new CCodeIdentifier (sink_func));
csink.add_argument (result.cvalue);
@@ -5632,6 +5632,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return get_ccode_attribute(sym).unref_function;
}
+ public static string get_ccode_ref_sink_function (ObjectTypeSymbol sym) {
+ return get_ccode_attribute(sym).ref_sink_function;
+ }
+
public override void visit_class (Class cl) {
}
@@ -6081,6 +6085,15 @@ public class Vala.CCodeAttribute : AttributeCache {
}
}
+ public string ref_sink_function {
+ get {
+ if (_ref_sink_function == null) {
+ _ref_sink_function = get_default_ref_sink_function ();
+ }
+ return _ref_sink_function;
+ }
+ }
+
private string _name;
private string _const_name;
private string _type_name;
@@ -6091,6 +6104,7 @@ public class Vala.CCodeAttribute : AttributeCache {
private string _ref_function;
private bool? _ref_function_void;
private string _unref_function;
+ private string _ref_sink_function;
public CCodeAttribute (CodeNode node) {
this.node = node;
@@ -6119,6 +6133,7 @@ public class Vala.CCodeAttribute : AttributeCache {
_ref_function_void = attr.get_bool ("ref_function_void");
}
_unref_function = attr.get_string ("unref_function");
+ _ref_sink_function = attr.get_string ("ref_sink_function");
}
}
@@ -6358,4 +6373,18 @@ public class Vala.CCodeAttribute : AttributeCache {
}
return "";
}
+
+ private string get_default_ref_sink_function () {
+ if (sym is Class) {
+ return CCodeBaseModule.get_ccode_ref_sink_function (((Class) sym).base_class);
+ } else if (sym is Interface) {
+ foreach (DataType prerequisite in prerequisites) {
+ string ref_sink_func = CCodeBaseModule.get_ccode_ref_sink_function (prerequisite.data_type);
+ if (ref_sink_func != "") {
+ return ref_sink_func;
+ }
+ }
+ }
+ return "";
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]