[vala] codegen: Add ref_sink_function_void argument to CCode
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Add ref_sink_function_void argument to CCode
- Date: Mon, 8 Aug 2011 10:40:10 +0000 (UTC)
commit e684342ffb5c5958be2f2398e73a5298c0049c75
Author: Luca Bruno <lucabru src gnome org>
Date: Sun Aug 7 21:25:46 2011 +0200
codegen: Add ref_sink_function_void argument to CCode
codegen/valaccodeattribute.vala | 19 +++++++++++++++++++
codegen/valaccodebasemodule.vala | 22 +++++++++++++++++++---
2 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodeattribute.vala b/codegen/valaccodeattribute.vala
index e974064..19e3de1 100644
--- a/codegen/valaccodeattribute.vala
+++ b/codegen/valaccodeattribute.vala
@@ -163,6 +163,24 @@ public class Vala.CCodeAttribute : AttributeCache {
}
}
+ public bool ref_sink_function_void {
+ get {
+ if (_ref_sink_function_void == null) {
+ if (ccode != null && ccode.has_argument ("ref_sink_function_void")) {
+ _ref_sink_function_void = ccode.get_bool ("ref_sink_function_void");
+ } else {
+ var cl = (Class) sym;
+ if (cl.base_class != null) {
+ _ref_sink_function_void = CCodeBaseModule.get_ccode_ref_sink_function_void (cl.base_class);
+ } else {
+ _ref_sink_function_void = false;
+ }
+ }
+ }
+ return _ref_sink_function_void;
+ }
+ }
+
public string unref_function {
get {
if (!unref_function_set) {
@@ -439,6 +457,7 @@ public class Vala.CCodeAttribute : AttributeCache {
private string? _unref_function;
private bool unref_function_set;
private string _ref_sink_function;
+ private bool? _ref_sink_function_void;
private string? _copy_function;
private bool copy_function_set;
private string? _destroy_function;
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index c189a6f..26f88ee 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -3769,6 +3769,15 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
}
+ bool is_ref_sink_function_void (DataType type) {
+ var cl = type.data_type as Class;
+ if (cl != null) {
+ return get_ccode_ref_sink_function_void (cl);
+ } else {
+ return false;
+ }
+ }
+
public virtual TargetValue? copy_value (TargetValue value, CodeNode node) {
var type = value.value_type;
var cexpr = get_cvalue_ (value);
@@ -5048,9 +5057,12 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (sink_func != "") {
var csink = new CCodeFunctionCall (new CCodeIdentifier (sink_func));
csink.add_argument (result.cvalue);
-
- result.cvalue = csink;
- requires_temp_value = true;
+ if (!is_ref_sink_function_void (type)) {
+ result.cvalue = csink;
+ requires_temp_value = true;
+ } else {
+ ccode.add_expression (csink);
+ }
} else {
Report.error (null, "type `%s' does not support floating references".printf (type.data_type.name));
}
@@ -5598,6 +5610,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return get_ccode_attribute(cl).ref_function_void;
}
+ public static bool get_ccode_ref_sink_function_void (Class cl) {
+ return get_ccode_attribute(cl).ref_sink_function_void;
+ }
+
public static string get_ccode_unref_function (ObjectTypeSymbol sym) {
return get_ccode_attribute(sym).unref_function;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]