summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/klass.hh
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-04-15 15:45:40 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-04-15 15:55:09 -0300
commit1dd25a9238c7fe65037740821f9d2b7641bc74fd (patch)
treeab312a54efe8c392aa4acfdaad21cc44412b86c2 /src/bin/eolian_mono/eolian/mono/klass.hh
parentb6529a65c6879afab39e8e2af098fbedd8971ee8 (diff)
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
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/klass.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh18
1 files 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 329a1c2..fd4c629 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
362 context); 362 context);
363 auto native_inherit_name = name_helpers::klass_native_inherit_name(cls); 363 auto native_inherit_name = name_helpers::klass_native_inherit_name(cls);
364 auto inherit_name = name_helpers::klass_inherit_name(cls); 364 auto inherit_name = name_helpers::klass_inherit_name(cls);
365 auto implementable_methods = helpers::get_all_implementable_methods(cls);
365 std::string base_name; 366 std::string base_name;
366 if(!root) 367 if(!root)
367 { 368 {
@@ -377,14 +378,25 @@ struct klass
377 << scope_tab << "public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)\n" 378 << scope_tab << "public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)\n"
378 << scope_tab << "{\n" 379 << scope_tab << "{\n"
379 << scope_tab << scope_tab << "var descs = new System.Collections.Generic.List<Efl_Op_Description>();\n" 380 << scope_tab << scope_tab << "var descs = new System.Collections.Generic.List<Efl_Op_Description>();\n"
380 << scope_tab << scope_tab << "var methods = Efl.Eo.Globals.GetUserMethods(type);\n"
381 ) 381 )
382 .generate(sink, attributes::unused, inative_cxt)) 382 .generate(sink, attributes::unused, inative_cxt))
383 return false; 383 return false;
384 384
385 // Native wrapper registration 385 // Native wrapper registration
386 // We write them first to a temporary function as the implementable function list may contain
387 // only non-registrable methods like class functions, leading to unused `methods` variable.
388 std::string tmp_registration;
386 if(!as_generator(*(function_registration(cls))) 389 if(!as_generator(*(function_registration(cls)))
387 .generate(sink, helpers::get_all_implementable_methods(cls), inative_cxt)) return false; 390 .generate(std::back_inserter(tmp_registration), implementable_methods, inative_cxt))
391 return false;
392
393 if (tmp_registration.find("methods") != std::string::npos)
394 if (!as_generator(
395 scope_tab << scope_tab << "var methods = Efl.Eo.Globals.GetUserMethods(type);\n"
396 << tmp_registration
397 ).generate(sink, attributes::unused, inative_cxt))
398 return false;
399
388 400
389 if(!root) 401 if(!root)
390 if(!as_generator(scope_tab << scope_tab << "descs.AddRange(base.GetEoOps(type));\n").generate(sink, attributes::unused, inative_cxt)) 402 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
415 427
416 // Native method definitions 428 // Native method definitions
417 if(!as_generator(*(native_function_definition(cls))) 429 if(!as_generator(*(native_function_definition(cls)))
418 .generate(sink, helpers::get_all_implementable_methods(cls), inative_cxt)) return false; 430 .generate(sink, implementable_methods, inative_cxt)) return false;
419 431
420 if(!as_generator("}\n").generate(sink, attributes::unused, inative_cxt)) return false; 432 if(!as_generator("}\n").generate(sink, attributes::unused, inative_cxt)) return false;
421 } 433 }