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)
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
45 eina::optional<std::string> name; 45 eina::optional<std::string> name;
46 std::function<std::string()> function; 46 std::function<std::string()> function;
47 } 47 }
48 /// Sizes taken from https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/sizeof
48 const match_table [] = 49 const match_table [] =
49 { 50 {
50 {"bool", [&arg] { return arg + " != IntPtr.Zero"; }} 51 {"bool", [&arg] { return "Marshal.ReadByte(" + arg + ") != 0"; }}
51 , {"int", [&arg] { return arg + ".ToInt32()"; }} 52
52 , {"uint", [&arg] { return "(uint)" + arg + ".ToInt32()";}} 53 , {"ubyte", [&arg] { return "Marshal.ReadByte(" + arg + ")"; }}
54 , {"byte", [&arg] { return "(sbyte) Marshal.ReadByte(" + arg + ")"; }}
55
56 , {"char", [&arg] { return "(char) Marshal.ReadByte(" + arg + ")"; }}
57
58 , {"short", [&arg] { return "Marshal.ReadInt16(" + arg + ")"; }}
59 , {"ushort", [&arg] { return "(ushort) Marshal.ReadInt16(" + arg + ")"; }}
60
61 , {"int", [&arg] { return "Marshal.ReadInt32(" + arg + ")"; }}
62 , {"uint", [&arg] { return "(uint) Marshal.ReadInt32(" + arg + ")"; }}
63
64 , {"long", [&arg] { return "Marshal.ReadInt64(" + arg + ")"; }}
65 , {"ulong", [&arg] { return "(ulong) Marshal.ReadInt64(" + arg + ")"; }}
66
67 , {"llong", [&arg] { return "(long) Marshal.ReadInt64(" + arg + ")"; }}
68 , {"ullong", [&arg] { return "(ulong) Marshal.ReadInt64(" + arg + ")"; }}
69
70 , {"int8", [&arg] { return "(sbyte)Marshal.ReadByte(" + arg + ")"; }}
71 , {"uint8", [&arg] { return "Marshal.ReadByte(" + arg + ")"; }}
72
73 , {"int16", [&arg] { return "Marshal.ReadInt16(" + arg + ")"; }}
74 , {"uint16", [&arg] { return "(ushort)Marshal.ReadInt16(" + arg + ")"; }}
75
76 , {"int32", [&arg] { return "Marshal.ReadInt32(" + arg + ")"; }}
77 , {"uint32", [&arg] { return "(uint) Marshal.ReadInt32(" + arg + ")"; }}
78
79 // We don't support int128 as csharp has no similar datatype.
80 , {"int64", [&arg] { return "Marshal.ReadInt64(" + arg + ")"; }}
81 , {"uint64", [&arg] { return "(ulong) Marshal.ReadInt64(" + arg + ")"; }}
82
83 , {"float", [&arg] { return "Eina.PrimitiveConversion.PointerToManaged<float>(" + arg + ")"; }}
84 , {"double", [&arg] { return "Eina.PrimitiveConversion.PointerToManaged<double>(" + arg + ")"; }}
85
53 , {"string", [&arg] { return "Eina.StringConversion.NativeUtf8ToManagedString(" + arg + ")"; }} 86 , {"string", [&arg] { return "Eina.StringConversion.NativeUtf8ToManagedString(" + arg + ")"; }}
54 , {"stringshare", [&arg] { return "Eina.StringConversion.NativeUtf8ToManagedString(" + arg + ")"; }} 87 , {"stringshare", [&arg] { return "Eina.StringConversion.NativeUtf8ToManagedString(" + arg + ")"; }}
55 , {"Eina.Error", [&arg] { return "(Eina.Error)Marshal.PtrToStructure(" + arg + ", typeof(Eina.Error))"; }} 88 , {"Eina.Error", [&arg] { return "(Eina.Error)Marshal.PtrToStructure(" + arg + ", typeof(Eina.Error))"; }}