[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:47:02 +0000 (UTC)
commit 6addb01e10c6e539c0bb250fcdd89b6a24eef5c3
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 6473617..5272200 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5059,9 +5059,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);
@@ -5634,6 +5634,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) {
}
@@ -6083,6 +6087,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;
@@ -6093,6 +6106,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;
@@ -6121,6 +6135,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");
}
}
@@ -6359,4 +6374,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 (var prereq in ((Interface) sym).get_prerequisites ()) {
+ string ref_sink_func = CCodeBaseModule.get_ccode_ref_sink_function ((ObjectTypeSymbol) prereq.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]