summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorYeongjong Lee <yj34.lee@samsung.com>2019-12-23 08:18:02 +0000
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-12-23 14:29:39 -0300
commit934a93e39fea7ec157421af91f5cfc5ec94047b0 (patch)
treea538bdac842417ca031a2b42089770544fa8738e /src/bin
parent0954e501fd4008c40b3848de1f2c91bcd53b2f71 (diff)
eolian_mono: check extension part/property existence before generate ExtensionMethods
Empty ExtensionMethods class won't be generated. Reviewed-by: Felipe Magno de Almeida <felipe@expertisesolutions.com.br> Differential Revision: https://phab.enlightenment.org/D10954
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index e26121c..478c6a9 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -385,7 +385,16 @@ struct klass
385 std::copy(c.properties.begin(), c.properties.end(), std::back_inserter(implementable_properties)); 385 std::copy(c.properties.begin(), c.properties.end(), std::back_inserter(implementable_properties));
386 } 386 }
387 387
388 if (implementable_properties.size() == 0 && cls.parts.size() == 0) 388 std::stringstream extension_method_stream;
389 std::ostream_iterator<char> extension_method_iterator(extension_method_stream);
390
391 if (!as_generator
392 (*property_extension_method_definition(cls)
393 << *part_extension_method_definition(cls))
394 .generate(extension_method_iterator, std::make_tuple(implementable_properties, cls.parts), context))
395 return false;
396
397 if (extension_method_stream.tellp() <= 0)
389 return true; 398 return true;
390 399
391 if(!as_generator 400 if(!as_generator
@@ -393,12 +402,11 @@ struct klass
393 << "#pragma warning disable CS1591\n" // Disabling warnings as DocFx will hide these classes 402 << "#pragma warning disable CS1591\n" // Disabling warnings as DocFx will hide these classes
394 <<"public static class " << (string % "_") << name_helpers::klass_inherit_name(cls) 403 <<"public static class " << (string % "_") << name_helpers::klass_inherit_name(cls)
395 << "_ExtensionMethods {\n" 404 << "_ExtensionMethods {\n"
396 << *(property_extension_method_definition(cls)) 405 << extension_method_stream.str()
397 << *(part_extension_method_definition(cls))
398 << "}\n" 406 << "}\n"
399 << "#pragma warning restore CS1591\n" 407 << "#pragma warning restore CS1591\n"
400 << "#endif\n") 408 << "#endif\n")
401 .generate(sink, std::make_tuple(cls.namespaces, implementable_properties, cls.parts), context)) 409 .generate(sink, cls.namespaces, context))
402 return false; 410 return false;
403 411
404 return true; 412 return true;