[vala/staging] codegen: More use of delegate_target_type and delegate_target_destroy_type



commit 70ca630391d6677732922ce18909c2a5b27570f2
Author: Jeremy Philippe <jeremy philippe gmail com>
Date:   Wed Oct 7 13:41:40 2020 +0200

    codegen: More use of delegate_target_type and delegate_target_destroy_type

 codegen/valaccodebasemodule.vala       |  2 --
 codegen/valaccodemethodcallmodule.vala | 12 ++++++------
 2 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index e782a4a58..dfbae93b4 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -338,7 +338,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
        public TypeSymbol gbytearray_type;
        public TypeSymbol gptrarray_type;
        public TypeSymbol gthreadpool_type;
-       public DataType gdestroynotify_type;
        public DataType gquark_type;
        public Struct gvalue_type;
        public Class gvariant_type;
@@ -504,7 +503,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        gbytearray_type = (TypeSymbol) glib_ns.scope.lookup ("ByteArray");
                        gptrarray_type = (TypeSymbol) glib_ns.scope.lookup ("PtrArray");
                        gthreadpool_type = (TypeSymbol) glib_ns.scope.lookup ("ThreadPool");
-                       gdestroynotify_type = new DelegateType ((Delegate) glib_ns.scope.lookup 
("DestroyNotify"));
 
                        gerror = (Class) root_symbol.scope.lookup ("GLib").scope.lookup ("Error");
                        gquark_type = new IntegerType ((Struct) glib_ns.scope.lookup ("Quark"));
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index e3293feb4..2c5be10c3 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -447,12 +447,12 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                                                } else if (get_ccode_delegate_target (param) && 
param.variable_type is DelegateType) {
                                                        var deleg_type = (DelegateType) param.variable_type;
                                                        if (deleg_type.delegate_symbol.has_target) {
-                                                               temp_var = get_temp_variable (new PointerType 
(new VoidType ()), true, null, true);
+                                                               temp_var = get_temp_variable 
(delegate_target_type, true, null, true);
                                                                emit_temp_var (temp_var);
                                                                set_delegate_target (arg, 
get_variable_cexpression (temp_var.name));
                                                                carg_map.set (get_param_pos 
(get_ccode_delegate_target_pos (param)), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, 
get_delegate_target (arg)));
                                                                if (deleg_type.is_disposable ()) {
-                                                                       temp_var = get_temp_variable 
(gdestroynotify_type, true, null, true);
+                                                                       temp_var = get_temp_variable 
(delegate_target_destroy_type, true, null, true);
                                                                        emit_temp_var (temp_var);
                                                                        set_delegate_target_destroy_notify 
(arg, get_variable_cexpression (temp_var.name));
                                                                        carg_map.set (get_param_pos 
(get_ccode_delegate_target_pos (param) + 0.01), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, 
get_delegate_target_destroy_notify (arg)));
@@ -561,7 +561,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                } else if (m != null && m.return_type is DelegateType && async_call != ccall) {
                        var deleg_type = (DelegateType) m.return_type;
                        if (get_ccode_delegate_target (m) && deleg_type.delegate_symbol.has_target) {
-                               var temp_var = get_temp_variable (new PointerType (new VoidType ()), true, 
null, true);
+                               var temp_var = get_temp_variable (delegate_target_type, true, null, true);
                                var temp_ref = get_variable_cexpression (temp_var.name);
 
                                emit_temp_var (temp_var);
@@ -571,7 +571,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                                set_delegate_target (expr, temp_ref);
 
                                if (deleg_type.is_disposable ()) {
-                                       temp_var = get_temp_variable (gdestroynotify_type, true, null, true);
+                                       temp_var = get_temp_variable (delegate_target_destroy_type, true, 
null, true);
                                        temp_ref = get_variable_cexpression (temp_var.name);
 
                                        emit_temp_var (temp_var);
@@ -626,7 +626,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                } else if (deleg != null && deleg.return_type is DelegateType && get_ccode_delegate_target 
(deleg)) {
                        var deleg_type = (DelegateType) deleg.return_type;
                        if (deleg_type.delegate_symbol.has_target) {
-                               var temp_var = get_temp_variable (new PointerType (new VoidType ()), true, 
null, true);
+                               var temp_var = get_temp_variable (delegate_target_type, true, null, true);
                                var temp_ref = get_variable_cexpression (temp_var.name);
 
                                emit_temp_var (temp_var);
@@ -636,7 +636,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                                set_delegate_target (expr, temp_ref);
 
                                if (deleg_type.is_disposable ()) {
-                                       temp_var = get_temp_variable (gdestroynotify_type, true, null, true);
+                                       temp_var = get_temp_variable (delegate_target_type, true, null, true);
                                        temp_ref = get_variable_cexpression (temp_var.name);
 
                                        emit_temp_var (temp_var);


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