[vala/staging: 1/6] codegen: Add boolean "use_inplace" ccode-attribute for methods



commit e2e0054a0d85500fe6c86a6457d910f77deb5599
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Nov 20 17:03:16 2017 +0100

    codegen: Add boolean "use_inplace" ccode-attribute for methods
    
    This can be use to avoid temp-variables for an expanding macro.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=750840

 codegen/valaccodemethodcallmodule.vala |    2 ++
 vala/valausedattr.vala                 |    3 ++-
 2 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index a22a4fe..cf2a3f5 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -803,6 +803,8 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
                        if (m != null && m.get_format_arg_index () >= 0) {
                                set_cvalue (expr, ccall_expr);
+                       } else if (m != null && m.get_attribute_bool ("CCode", "use_inplace", false)) {
+                               set_cvalue (expr, ccall_expr);
                        } else if (!return_result_via_out_param) {
                                var temp_var = get_temp_variable (result_type, result_type.value_owned, null, 
false);
                                var temp_ref = get_variable_cexpression (temp_var.name);
diff --git a/vala/valausedattr.vala b/vala/valausedattr.vala
index c43ab31..9b0a859 100644
--- a/vala/valausedattr.vala
+++ b/vala/valausedattr.vala
@@ -39,7 +39,8 @@ public class Vala.UsedAttr : CodeVisitor {
                "has_copy_function", "lower_case_csuffix", "ref_sink_function", "dup_function", 
"finish_function", "generic_type_pos",
                "array_length_type", "array_length", "array_length_cname", "array_length_cexpr", 
"array_null_terminated",
                "vfunc_name", "finish_vfunc_name", "finish_name", "free_function_address_of", "pos", 
"delegate_target", "delegate_target_cname",
-               "array_length_pos", "delegate_target_pos", "destroy_notify_pos", "ctype", "has_new_function", 
"notify", "finish_instance", "",
+               "array_length_pos", "delegate_target_pos", "destroy_notify_pos", "ctype", "has_new_function", 
"notify", "finish_instance",
+               "use_inplace", "",
 
                "Immutable", "",
                "Compact", "",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]