aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-02-28 17:15:48 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-02-28 17:20:53 -0300
commitc3ed0791a6c07773e90ff38149838bdc818ba292 (patch)
treea5c860b5ea292269c484d65b0833ae2aa739803c
parentecore: prevent duplication of children for Efl.Composite_Model and enable dum... (diff)
downloadefl-c3ed0791a6c07773e90ff38149838bdc818ba292.tar.gz
efl-csharp: Fix variable generation for Roslyn
Summary: Mono's old compiler (mcs) accepts LL as suffix for longs while Roslyn (csc) is strict, allowing only a single L. Test Plan: Run tests Reviewers: vitor.sousa, felipealmeida Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8061
-rw-r--r--src/bin/eolian_mono/eolian/mono/utils.hh8
-rw-r--r--src/bin/eolian_mono/eolian/mono/variable_definition.hh6
-rw-r--r--src/tests/efl_mono/Eo.cs4
3 files changed, 16 insertions, 2 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/utils.hh b/src/bin/eolian_mono/eolian/mono/utils.hh
index 0912db8a71..cbea48afa3 100644
--- a/src/bin/eolian_mono/eolian/mono/utils.hh
+++ b/src/bin/eolian_mono/eolian/mono/utils.hh
@@ -70,6 +70,14 @@ namespace eolian_mono { namespace utils {
name.erase(std::remove(name.begin(), name.end(), target), name.end());
return name;
}
+
+ inline bool ends_with(std::string const& source, std::string suffix)
+ {
+ if (source.size() > suffix.size())
+ return (0 == source.compare(source.size() - suffix.size(), suffix.size(), suffix));
+ else
+ return false;
+ }
} }
#endif
diff --git a/src/bin/eolian_mono/eolian/mono/variable_definition.hh b/src/bin/eolian_mono/eolian/mono/variable_definition.hh
index 2a0eac30d6..d143d7e138 100644
--- a/src/bin/eolian_mono/eolian/mono/variable_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/variable_definition.hh
@@ -47,8 +47,14 @@ struct constant_definition_generator
auto lit = ::eolian_expression_value_to_literal(&constant.expression_value);
if (!lit)
return false;
+
literal = lit;
::eina_stringshare_del(lit);
+
+ // Cleanup suffix. Roslyn does not accept ULL/LL as it has only longs.
+ if (utils::ends_with(literal, "LL") || utils::ends_with(literal, "ll"))
+ literal = literal.substr(0, literal.size() -1);
+
}
// declare variable
diff --git a/src/tests/efl_mono/Eo.cs b/src/tests/efl_mono/Eo.cs
index 3e7f662151..9da7752e4b 100644
--- a/src/tests/efl_mono/Eo.cs
+++ b/src/tests/efl_mono/Eo.cs
@@ -199,8 +199,8 @@ class TestVariables
Test.AssertEquals(Dummy.Constants.ConstvarUInt, 65533U);
Test.AssertEquals(Dummy.Constants.ConstvarLong, -2147483644L);
Test.AssertEquals(Dummy.Constants.ConstvarULong, 4294967288UL);
- //Test.AssertEquals(Dummy.Constants.ConstvarLLong, -9223372036854775800); // TODO
- //Test.AssertEquals(Dummy.Constants.ConstvarULLong, 18446744073709551615);
+ Test.AssertEquals(Dummy.Constants.ConstvarLLong, -9223372036854775800);
+ Test.AssertEquals(Dummy.Constants.ConstvarULLong, 18446744073709551615);
Test.AssertEquals(Dummy.Constants.ConstvarFloat, 16777211.0f);
Test.AssertEquals(Dummy.Constants.ConstvarDouble, 9007199254740988.0);
Test.AssertEquals(Dummy.Constants.ConstvarChar, '!');