efl-csharp: Fix variable generation for Roslyn
authorLauro Moura <lauromoura@expertisesolutions.com.br>
Thu, 28 Feb 2019 20:15:48 +0000 (17:15 -0300)
committerWonki Kim <wonki_.kim@samsung.com>
Fri, 8 Mar 2019 11:49:37 +0000 (20:49 +0900)
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

src/bin/eolian_mono/eolian/mono/utils.hh
src/bin/eolian_mono/eolian/mono/variable_definition.hh
src/tests/efl_mono/Eo.cs

index 0912db8a715272af2868efc6f947afc72073eb41..cbea48afa323910d44329fb44e2ad32bad3c4183 100644 (file)
@@ -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
index 2a0eac30d672ac7914e248dc7647b06475f24620..d143d7e13896d6ffd6020d24766cd2b93d2a3d6a 100644 (file)
@@ -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
index 3e7f662151242170ff864aa37a8e37296a02de2b..9da7752e4b22c276a555838b30294bc5516262dd 100644 (file)
@@ -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, '!');