zmike pushed a commit to branch efl-1.22.

http://git.enlightenment.org/core/efl.git/commit/?id=2ee3bce648ebde34b2fd104859ccc39503145e30

commit 2ee3bce648ebde34b2fd104859ccc39503145e30
Author: Lauro Moura <[email protected]>
Date:   Mon Apr 15 15:45:40 2019 -0300

    csharp: Remove unused variable `methods` warning.
    
    Summary: Only generate it if there was at least one method registered.
    
    Reviewers: vitor.sousa, felipealmeida
    
    Reviewed By: vitor.sousa
    
    Subscribers: cedric, #reviewers, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D8608
---
 src/bin/eolian_mono/eolian/mono/klass.hh | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh 
b/src/bin/eolian_mono/eolian/mono/klass.hh
index 329a1c297f..fd4c629ffd 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -362,6 +362,7 @@ struct klass
                                             context);
          auto native_inherit_name = 
name_helpers::klass_native_inherit_name(cls);
          auto inherit_name = name_helpers::klass_inherit_name(cls);
+         auto implementable_methods = 
helpers::get_all_implementable_methods(cls);
          std::string base_name;
          if(!root)
            {
@@ -377,14 +378,25 @@ struct klass
              << scope_tab << "public override 
System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type 
type)\n"
              << scope_tab << "{\n"
              << scope_tab << scope_tab << "var descs = new 
System.Collections.Generic.List<Efl_Op_Description>();\n"
-             << scope_tab << scope_tab << "var methods = 
Efl.Eo.Globals.GetUserMethods(type);\n"
             )
             .generate(sink, attributes::unused, inative_cxt))
            return false;
 
          // Native wrapper registration
+         // We write them first to a temporary function as the implementable 
function list may contain
+         // only non-registrable methods like class functions, leading to 
unused `methods` variable.
+         std::string tmp_registration;
          if(!as_generator(*(function_registration(cls)))
-            .generate(sink, helpers::get_all_implementable_methods(cls), 
inative_cxt)) return false;
+            .generate(std::back_inserter(tmp_registration), 
implementable_methods, inative_cxt))
+           return false;
+
+         if (tmp_registration.find("methods") != std::string::npos)
+           if (!as_generator(
+                    scope_tab << scope_tab << "var methods = 
Efl.Eo.Globals.GetUserMethods(type);\n"
+                    << tmp_registration
+                ).generate(sink,  attributes::unused, inative_cxt))
+             return false;
+
 
          if(!root)
            if(!as_generator(scope_tab << scope_tab << 
"descs.AddRange(base.GetEoOps(type));\n").generate(sink, attributes::unused, 
inative_cxt))
@@ -415,7 +427,7 @@ struct klass
 
          // Native method definitions
          if(!as_generator(*(native_function_definition(cls)))
-            .generate(sink, helpers::get_all_implementable_methods(cls), 
inative_cxt)) return false;
+            .generate(sink, implementable_methods, inative_cxt)) return false;
 
          if(!as_generator("}\n").generate(sink, attributes::unused, 
inative_cxt)) return false;
        }

-- 


Reply via email to