summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-05-14 08:38:50 +0200
committerXavi Artigas <xavierartigas@yahoo.es>2019-05-14 08:49:17 +0200
commitf93eb3fc043fcc945fb2e65a27a05447ac8ce603 (patch)
treee609d60e9abca139191ccfdfa85ac88ce317d28f /src/bin
parentb3d7e9128b8259e67a5540eabf7469af32ac04ba (diff)
downloadefl-f93eb3fc043fcc945fb2e65a27a05447ac8ce603.tar.gz
csharp: Fix event marshalling for value types
Summary: It was wrongly assuming value types were passed by value. As stated in the documentation, all arguments are passed with a single level of indirection. Fixes T7957 Reviewers: woohyun, felipealmeida, vitor.sousa, segfaultxavi Reviewed By: segfaultxavi Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T7957 Differential Revision: https://phab.enlightenment.org/D8889
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian_mono/eolian/mono/events.hh39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/events.hh b/src/bin/eolian_mono/eolian/mono/events.hh
index 56a22d7823..b5e6e4a7f1 100644
--- a/src/bin/eolian_mono/eolian/mono/events.hh
+++ b/src/bin/eolian_mono/eolian/mono/events.hh
@@ -45,11 +45,44 @@ struct unpack_event_args_visitor
eina::optional<std::string> name;
std::function<std::string()> function;
}
+ /// Sizes taken from https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/sizeof
const match_table [] =
{
- {"bool", [&arg] { return arg + " != IntPtr.Zero"; }}
- , {"int", [&arg] { return arg + ".ToInt32()"; }}
- , {"uint", [&arg] { return "(uint)" + arg + ".ToInt32()";}}
+ {"bool", [&arg] { return "Marshal.ReadByte(" + arg + ") != 0"; }}
+
+ , {"ubyte", [&arg] { return "Marshal.ReadByte(" + arg + ")"; }}
+ , {"byte", [&arg] { return "(sbyte) Marshal.ReadByte(" + arg + ")"; }}
+
+ , {"char", [&arg] { return "(char) Marshal.ReadByte(" + arg + ")"; }}
+
+ , {"short", [&arg] { return "Marshal.ReadInt16(" + arg + ")"; }}
+ , {"ushort", [&arg] { return "(ushort) Marshal.ReadInt16(" + arg + ")"; }}
+
+ , {"int", [&arg] { return "Marshal.ReadInt32(" + arg + ")"; }}
+ , {"uint", [&arg] { return "(uint) Marshal.ReadInt32(" + arg + ")"; }}
+
+ , {"long", [&arg] { return "Marshal.ReadInt64(" + arg + ")"; }}
+ , {"ulong", [&arg] { return "(ulong) Marshal.ReadInt64(" + arg + ")"; }}
+
+ , {"llong", [&arg] { return "(long) Marshal.ReadInt64(" + arg + ")"; }}
+ , {"ullong", [&arg] { return "(ulong) Marshal.ReadInt64(" + arg + ")"; }}
+
+ , {"int8", [&arg] { return "(sbyte)Marshal.ReadByte(" + arg + ")"; }}
+ , {"uint8", [&arg] { return "Marshal.ReadByte(" + arg + ")"; }}
+
+ , {"int16", [&arg] { return "Marshal.ReadInt16(" + arg + ")"; }}
+ , {"uint16", [&arg] { return "(ushort)Marshal.ReadInt16(" + arg + ")"; }}
+
+ , {"int32", [&arg] { return "Marshal.ReadInt32(" + arg + ")"; }}
+ , {"uint32", [&arg] { return "(uint) Marshal.ReadInt32(" + arg + ")"; }}
+
+ // We don't support int128 as csharp has no similar datatype.
+ , {"int64", [&arg] { return "Marshal.ReadInt64(" + arg + ")"; }}
+ , {"uint64", [&arg] { return "(ulong) Marshal.ReadInt64(" + arg + ")"; }}
+
+ , {"float", [&arg] { return "Eina.PrimitiveConversion.PointerToManaged<float>(" + arg + ")"; }}
+ , {"double", [&arg] { return "Eina.PrimitiveConversion.PointerToManaged<double>(" + arg + ")"; }}
+
, {"string", [&arg] { return "Eina.StringConversion.NativeUtf8ToManagedString(" + arg + ")"; }}
, {"stringshare", [&arg] { return "Eina.StringConversion.NativeUtf8ToManagedString(" + arg + ")"; }}
, {"Eina.Error", [&arg] { return "(Eina.Error)Marshal.PtrToStructure(" + arg + ", typeof(Eina.Error))"; }}