Skip to content

Commit d5c00d0

Browse files
feat(ffi): expose InclusiveRectangle attributes (#480)
1 parent e339346 commit d5c00d0

File tree

4 files changed

+175
-3
lines changed

4 files changed

+175
-3
lines changed

ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatRuntime.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ public DiplomatWriteable()
4646

4747
IntPtr flushFuncPtr = Marshal.GetFunctionPointerForDelegate(flushFunc);
4848
IntPtr growFuncPtr = Marshal.GetFunctionPointerForDelegate(growFunc);
49-
49+
5050
// flushFunc and growFunc are managed objects and might be disposed of by the garbage collector.
5151
// To prevent this, we make the context hold the references and protect the context itself
5252
// for automatic disposal by moving it behind a GCHandle.
53-
DiplomatWriteableContext ctx = new DiplomatWriteableContext();
53+
DiplomatWriteableContext ctx = new DiplomatWriteableContext();
5454
ctx.flushFunc = flushFunc;
5555
ctx.growFunc = growFunc;
5656
GCHandle ctxHandle = GCHandle.Alloc(ctx);
@@ -81,7 +81,7 @@ public string ToUnicode()
8181
{
8282
throw new IndexOutOfRangeException("DiplomatWriteable buffer is too big");
8383
}
84-
return Marshal.PtrToStringUTF8(buf, (int)len);
84+
return Marshal.PtrToStringUTF8(buf, (int) len);
8585
#else
8686
byte[] utf8 = ToUtf8Bytes();
8787
return DiplomatUtils.Utf8ToString(utf8);

ffi/dotnet/Devolutions.IronRdp/Generated/InclusiveRectangle.cs

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,54 @@ public partial class InclusiveRectangle: IDisposable
1515
{
1616
private unsafe Raw.InclusiveRectangle* _inner;
1717

18+
public ushort Bottom
19+
{
20+
get
21+
{
22+
return GetBottom();
23+
}
24+
}
25+
26+
public ushort Height
27+
{
28+
get
29+
{
30+
return GetHeight();
31+
}
32+
}
33+
34+
public ushort Left
35+
{
36+
get
37+
{
38+
return GetLeft();
39+
}
40+
}
41+
42+
public ushort Right
43+
{
44+
get
45+
{
46+
return GetRight();
47+
}
48+
}
49+
50+
public ushort Top
51+
{
52+
get
53+
{
54+
return GetTop();
55+
}
56+
}
57+
58+
public ushort Width
59+
{
60+
get
61+
{
62+
return GetWidth();
63+
}
64+
}
65+
1866
/// <summary>
1967
/// Creates a managed <c>InclusiveRectangle</c> from a raw handle.
2068
/// </summary>
@@ -29,6 +77,84 @@ public unsafe InclusiveRectangle(Raw.InclusiveRectangle* handle)
2977
_inner = handle;
3078
}
3179

80+
public ushort GetLeft()
81+
{
82+
unsafe
83+
{
84+
if (_inner == null)
85+
{
86+
throw new ObjectDisposedException("InclusiveRectangle");
87+
}
88+
ushort retVal = Raw.InclusiveRectangle.GetLeft(_inner);
89+
return retVal;
90+
}
91+
}
92+
93+
public ushort GetTop()
94+
{
95+
unsafe
96+
{
97+
if (_inner == null)
98+
{
99+
throw new ObjectDisposedException("InclusiveRectangle");
100+
}
101+
ushort retVal = Raw.InclusiveRectangle.GetTop(_inner);
102+
return retVal;
103+
}
104+
}
105+
106+
public ushort GetRight()
107+
{
108+
unsafe
109+
{
110+
if (_inner == null)
111+
{
112+
throw new ObjectDisposedException("InclusiveRectangle");
113+
}
114+
ushort retVal = Raw.InclusiveRectangle.GetRight(_inner);
115+
return retVal;
116+
}
117+
}
118+
119+
public ushort GetBottom()
120+
{
121+
unsafe
122+
{
123+
if (_inner == null)
124+
{
125+
throw new ObjectDisposedException("InclusiveRectangle");
126+
}
127+
ushort retVal = Raw.InclusiveRectangle.GetBottom(_inner);
128+
return retVal;
129+
}
130+
}
131+
132+
public ushort GetWidth()
133+
{
134+
unsafe
135+
{
136+
if (_inner == null)
137+
{
138+
throw new ObjectDisposedException("InclusiveRectangle");
139+
}
140+
ushort retVal = Raw.InclusiveRectangle.GetWidth(_inner);
141+
return retVal;
142+
}
143+
}
144+
145+
public ushort GetHeight()
146+
{
147+
unsafe
148+
{
149+
if (_inner == null)
150+
{
151+
throw new ObjectDisposedException("InclusiveRectangle");
152+
}
153+
ushort retVal = Raw.InclusiveRectangle.GetHeight(_inner);
154+
return retVal;
155+
}
156+
}
157+
32158
/// <summary>
33159
/// Returns the underlying raw handle.
34160
/// </summary>

ffi/dotnet/Devolutions.IronRdp/Generated/RawInclusiveRectangle.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,24 @@ public partial struct InclusiveRectangle
1616
{
1717
private const string NativeLib = "DevolutionsIronRdp";
1818

19+
[DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InclusiveRectangle_get_left", ExactSpelling = true)]
20+
public static unsafe extern ushort GetLeft(InclusiveRectangle* self);
21+
22+
[DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InclusiveRectangle_get_top", ExactSpelling = true)]
23+
public static unsafe extern ushort GetTop(InclusiveRectangle* self);
24+
25+
[DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InclusiveRectangle_get_right", ExactSpelling = true)]
26+
public static unsafe extern ushort GetRight(InclusiveRectangle* self);
27+
28+
[DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InclusiveRectangle_get_bottom", ExactSpelling = true)]
29+
public static unsafe extern ushort GetBottom(InclusiveRectangle* self);
30+
31+
[DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InclusiveRectangle_get_width", ExactSpelling = true)]
32+
public static unsafe extern ushort GetWidth(InclusiveRectangle* self);
33+
34+
[DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InclusiveRectangle_get_height", ExactSpelling = true)]
35+
public static unsafe extern ushort GetHeight(InclusiveRectangle* self);
36+
1937
[DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InclusiveRectangle_destroy", ExactSpelling = true)]
2038
public static unsafe extern void Destroy(InclusiveRectangle* self);
2139
}

ffi/src/pdu.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#[diplomat::bridge]
22
pub mod ffi {
33

4+
use ironrdp::pdu::geometry::Rectangle;
5+
46
use crate::{error::ffi::IronRdpError, utils::ffi::VecU8};
57

68
#[diplomat::opaque]
@@ -34,6 +36,32 @@ pub mod ffi {
3436
#[diplomat::opaque]
3537
pub struct InclusiveRectangle(pub ironrdp::pdu::geometry::InclusiveRectangle);
3638

39+
impl InclusiveRectangle {
40+
pub fn get_left(&self) -> u16 {
41+
self.0.left
42+
}
43+
44+
pub fn get_top(&self) -> u16 {
45+
self.0.top
46+
}
47+
48+
pub fn get_right(&self) -> u16 {
49+
self.0.right
50+
}
51+
52+
pub fn get_bottom(&self) -> u16 {
53+
self.0.bottom
54+
}
55+
56+
pub fn get_width(&self) -> u16 {
57+
self.0.width()
58+
}
59+
60+
pub fn get_height(&self) -> u16 {
61+
self.0.height()
62+
}
63+
}
64+
3765
#[diplomat::opaque]
3866
pub struct IronRdpPdu; // A struct representing the ironrdp_pdu crate
3967

0 commit comments

Comments
 (0)