Communicating native C structs with managed code
R Zaghi <[email protected]> Fri, 05 Jan 2018 09:59:35 +0000
| Newsgroups | gmane.comp.gnome.mono.devel |
|---|---|
| Message-ID | <CAFLMc5u572Co+7=z_wN8bR=iwx8mZTSwwWYokhWCeezZoAWRzg@mail.gmail.com> |
--===============5340925088972030176==
Content-Type: multipart/alternative; boundary="94eb2c192c72167b2305620482e5"
--94eb2c192c72167b2305620482e5
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Hi
What would be the most performance efficient method to pass a native C
struct of primitive data types (memory aligned or compact) to the managed
code in Mono/C# and allow modification of its member variables in the
managed code?
Do we have anything specific in Mono that helps eliminate manual
marshalling on every call? or could we? :)
Say, in the following scenarios:
struct S1 {
double x,
double y,
double z
};
Or
struct S2 {
int arr[256]
};
Or
struct S3 {
double x,
int arr[256]
};
Ramin
--=20
Ramin Zaghi
*Mosaic3DX=E2=84=A2 | User Interface Technology*
St John's Innovation Centre,
Cowley Road,
Cambridge,
CB4 0WS, UK
*E*: [email protected]
*T*: +44 1223 421 311
http://linkedin.com/in/raminzaghi
--94eb2c192c72167b2305620482e5
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"auto">Hi</div><div dir=3D"auto"><br></div><div dir=3D"auto">Wha=
t would be the most performance efficient method to pass a native C struct =
of primitive data types (memory aligned or compact) to the managed code in =
Mono/C# and allow modification of its member variables in the managed code?=
</div><div dir=3D"auto"><br></div><div dir=3D"auto">Do we have anything spe=
cific in Mono that helps eliminate manual marshalling on every call? or cou=
ld we? :)</div><div dir=3D"auto"><br></div><div dir=3D"auto">Say, in the fo=
llowing scenarios:</div><div dir=3D"auto"><br></div><div dir=3D"auto">struc=
t S1 {</div><div dir=3D"auto">double x,</div><div dir=3D"auto">double y,</d=
iv><div dir=3D"auto">double z</div><div dir=3D"auto">};</div><div dir=3D"au=
to"><br></div><div dir=3D"auto">Or</div><div dir=3D"auto"><br></div><div di=
r=3D"auto">struct S2 {</div><div dir=3D"auto">int arr[256]</div><div dir=3D=
"auto">};</div><div dir=3D"auto"><br></div><div dir=3D"auto">Or</div><div d=
ir=3D"auto"><br></div><div dir=3D"auto">struct S3 {</div><div dir=3D"auto">=
double x,</div><div dir=3D"auto">int arr[256]</div><div dir=3D"auto">};</di=
v><div dir=3D"auto"><br></div><div dir=3D"auto"><br></div><div dir=3D"auto"=
><br></div><div dir=3D"auto">Ramin</div><div dir=3D"auto"><br></div><div di=
r=3D"auto"><br></div><div dir=3D"auto"><br></div><div dir=3D"ltr">-- <br></=
div><div class=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div =
dir=3D"ltr"><div><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div dir=3D"lt=
r"><div><div dir=3D"ltr"><br></div><div dir=3D"ltr"><br></div><div dir=3D"l=
tr"><br></div><div dir=3D"ltr">Ramin Zaghi</div><div dir=3D"ltr"><br><div><=
img src=3D"https://drive.google.com/uc?id=3D0B3xiwa7kf1uwRlYxenBFM1o2NEk&am=
p;export=3Ddownload"><b>Mosaic3DX=E2=84=A2 | <font size=3D"1">User Interfac=
e Technology</font></b></div><div><div style=3D"font-size:small">St John=
9;s Innovation Centre,</div><div style=3D"font-size:small">Cowley Road,</di=
v><div style=3D"font-size:small">Cambridge,</div><div style=3D"font-size:sm=
all">CB4 0WS, UK<b><br></b></div><div style=3D"font-size:small"><b>E</b>:<b=
>=C2=A0</b><a href=3D"mailto:[email protected]" target=3D"_blank">rzaghi=
@mosaic3dx.com</a></div><div style=3D"font-size:small"><b>T</b>:=C2=A0+44 1=
223 421 311</div></div><div><font size=3D"2"><a href=3D"http://linkedin.com=
/in/raminzaghi" target=3D"_blank">http://linkedin.com/in/raminzaghi</a></fo=
nt></div><div><font size=3D"2"><br></font></div></div></div></div></div></d=
iv></div></div></div></div></div>
--94eb2c192c72167b2305620482e5--
--===============5340925088972030176==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline
X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KTW9uby1kZXZl
bC1saXN0IG1haWxpbmcgbGlzdApNb25vLWRldmVsLWxpc3RAbGlzdHMuZG90Lm5ldApodHRwOi8v
bGlzdHMuZG90Lm5ldC9tYWlsbWFuL2xpc3RpbmZvL21vbm8tZGV2ZWwtbGlzdAo=
--===============5340925088972030176==--