diff options
author | Jürg Billeter <j@bitron.ch> | 2009-01-06 22:59:20 +0000 |
---|---|---|
committer | Jürg Billeter <juergbi@src.gnome.org> | 2009-01-06 22:59:20 +0000 |
commit | 39aa92baeec56343a4c8c468aa7644054650d076 (patch) | |
tree | fb7607ff91473a541860b17303684f70aa17ec79 /gobject | |
parent | 4a56286506aee4055d8546e5bfbedb70b3ea001d (diff) | |
download | vala-39aa92baeec56343a4c8c468aa7644054650d076.tar.gz |
Support [CCode (ref_function_void = true)] attribute for bindings, based
2009-01-06 Jürg Billeter <j@bitron.ch>
* vala/valaclass.vala:
* gobject/valaccodebasemodule.vala:
Support [CCode (ref_function_void = true)] attribute for bindings,
based on patch by Andreas Brauchli, fixes bug 566078
svn path=/trunk/; revision=2279
Diffstat (limited to 'gobject')
-rw-r--r-- | gobject/valaccodebasemodule.vala | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/gobject/valaccodebasemodule.vala b/gobject/valaccodebasemodule.vala index 731a193e2..acdf90a25 100644 --- a/gobject/valaccodebasemodule.vala +++ b/gobject/valaccodebasemodule.vala @@ -2460,6 +2460,15 @@ public class Vala.CCodeBaseModule : CCodeModule { return true; } + bool is_ref_function_void (DataType type) { + var cl = type.data_type as Class; + if (cl != null && cl.ref_function_void) { + return true; + } else { + return false; + } + } + public CCodeExpression? get_ref_cexpression (DataType expression_type, CCodeExpression cexpr, Expression? expr, CodeNode node) { if (expression_type is ValueType && !expression_type.nullable) { // normal value type, no null check @@ -2521,7 +2530,8 @@ public class Vala.CCodeBaseModule : CCodeModule { var ccall = new CCodeFunctionCall (dupexpr); - if (!(expression_type is ArrayType) && expr != null && expr.is_non_null ()) { + if (!(expression_type is ArrayType) && expr != null && expr.is_non_null () + && !is_ref_function_void (expression_type)) { // expression is non-null ccall.add_argument ((CCodeExpression) expr.ccodenode); @@ -2582,6 +2592,12 @@ public class Vala.CCodeBaseModule : CCodeModule { } ccomma.append_expression (new CCodeConditionalExpression (cisnull, cifnull, ccall)); + // repeat temp variable at the end of the comma expression + // if the ref function returns void + if (is_ref_function_void (expression_type)) { + ccomma.append_expression (ctemp); + } + return ccomma; } } |