[vala/staging: 2/3] codegen: Make CCodeBaseModule.generate_method_declaration() return bool



commit 91fc9702594fe7a59b06664aa077cee51960f72c
Author: Simon Werbeck <simon werbeck gmail com>
Date:   Mon Sep 30 16:37:33 2019 +0200

    codegen: Make CCodeBaseModule.generate_method_declaration() return bool
    
    This is how CCodeBaseModule.generate_enum_declaration() works already.

 codegen/valaccodebasemodule.vala   | 3 ++-
 codegen/valaccodemethodmodule.vala | 8 +++++---
 codegen/valagasyncmodule.vala      | 8 +++++---
 3 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 39303d62a..5ea9b6183 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4544,7 +4544,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
        public virtual void generate_interface_declaration (Interface iface, CCodeFile decl_space) {
        }
 
-       public virtual void generate_method_declaration (Method m, CCodeFile decl_space) {
+       public virtual bool generate_method_declaration (Method m, CCodeFile decl_space) {
+               return !add_symbol_declaration (decl_space, m, get_ccode_name (m));
        }
 
        public virtual void generate_error_domain_declaration (ErrorDomain edomain, CCodeFile decl_space) {
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 8534f662a..6c21ecadd 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -164,12 +164,12 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                ccode.add_return (new CCodeConstant ("FALSE"));
        }
 
-       public override void generate_method_declaration (Method m, CCodeFile decl_space) {
+       public override bool generate_method_declaration (Method m, CCodeFile decl_space) {
                if (m.is_async_callback) {
-                       return;
+                       return false;
                }
                if (add_symbol_declaration (decl_space, m, get_ccode_name (m))) {
-                       return;
+                       return false;
                }
 
                generate_type_declaration (new MethodType (m), decl_space);
@@ -232,6 +232,8 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                                decl_space.add_function_declaration (function);
                        }
                }
+
+               return true;
        }
 
        void register_plugin_types (Symbol sym, Set<Symbol> registered_types) {
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index cb7c28b63..e4e4edbf6 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -316,10 +316,10 @@ public class Vala.GAsyncModule : GtkModule {
                cfile.add_type_definition (structure);
        }
 
-       public override void generate_method_declaration (Method m, CCodeFile decl_space) {
+       public override bool generate_method_declaration (Method m, CCodeFile decl_space) {
                if (m.coroutine) {
                        if (add_symbol_declaration (decl_space, m, get_ccode_name (m))) {
-                               return;
+                               return false;
                        }
 
                        generate_type_declaration (new MethodType (m), decl_space);
@@ -388,8 +388,10 @@ public class Vala.GAsyncModule : GtkModule {
 
                                decl_space.add_function_declaration (function);
                        }
+
+                       return true;
                } else {
-                       base.generate_method_declaration (m, decl_space);
+                       return base.generate_method_declaration (m, decl_space);
                }
        }
 


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