functionalscript 0.0.461 → 0.0.462
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,6 +12,14 @@ pub struct CObject<T: Class> {
|
|
|
12
12
|
pub value: T,
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
const fn guid<I: Interface>() -> u128 {
|
|
16
|
+
let x = <I>::GUID;
|
|
17
|
+
(x >> 96) |
|
|
18
|
+
((x >> 48) & 0x00000_000_0000_0000_0000_FFFF_0000_0000) |
|
|
19
|
+
((x >> 16) & 0x0000_0000_0000_0000_FFFF_0000_0000_0000) |
|
|
20
|
+
(((x as u64).swap_bytes() as u128) << 64)
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
impl<T: Class> CObject<T> {
|
|
16
24
|
pub const IUNKNOWN: IUnknown<T::Interface> = IUnknown {
|
|
17
25
|
QueryInterface: Self::QueryInterface,
|
|
@@ -30,7 +38,7 @@ impl<T: Class> CObject<T> {
|
|
|
30
38
|
riid: &u128,
|
|
31
39
|
ppv_object: &mut *const Object,
|
|
32
40
|
) -> HRESULT {
|
|
33
|
-
let (p, r) = if *riid ==
|
|
41
|
+
let (p, r) = if *riid == guid::<()>() || *riid == guid::<T::Interface>() {
|
|
34
42
|
Self::AddRef(this);
|
|
35
43
|
(this.to_iunknown() as *const Object, HRESULT::S_OK)
|
|
36
44
|
} else {
|
package/com/test/cs/Program.cs
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
using System.Runtime.InteropServices;
|
|
2
|
+
using My;
|
|
2
3
|
|
|
3
4
|
[DllImport("testrust")]
|
|
4
5
|
static extern int get();
|
|
5
6
|
|
|
7
|
+
[DllImport("testrust")]
|
|
8
|
+
static extern IMy rust_my_create();
|
|
9
|
+
|
|
6
10
|
[DllImport("testc")]
|
|
7
11
|
static extern int c_get();
|
|
8
12
|
|
|
9
13
|
// See https://aka.ms/new-console-template for more information
|
|
10
14
|
Console.WriteLine("Hello, World!");
|
|
11
15
|
Console.WriteLine(get());
|
|
12
|
-
Console.WriteLine(c_get());
|
|
16
|
+
Console.WriteLine(c_get());
|
|
17
|
+
|
|
18
|
+
var x = rust_my_create();
|
|
19
|
+
x.SetSlice(new Slice { Start = null, Size = (UIntPtr)44 });
|
package/com/test/rust/src/lib.rs
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
use crate::_result::IMy::ClassEx;
|
|
2
|
-
|
|
3
1
|
mod _result;
|
|
4
2
|
|
|
3
|
+
use _result::IMy;
|
|
4
|
+
use nanocom::CObjectEx;
|
|
5
|
+
|
|
6
|
+
use crate::_result::IMy::ClassEx;
|
|
7
|
+
|
|
5
8
|
struct My {}
|
|
6
9
|
|
|
7
10
|
impl nanocom::Class for My {
|
|
@@ -18,7 +21,7 @@ impl _result::IMy::Ex for nanocom::CObject<My> {
|
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
fn SetSlice(&self, slice: _result::Slice) {
|
|
21
|
-
|
|
24
|
+
println!("SetSlice: {:?}, {:?}", slice.Start, slice.Size);
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
fn GetUnsafe(&self) -> *const bool {
|
|
@@ -43,4 +46,9 @@ impl _result::IMy::Ex for nanocom::CObject<My> {
|
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
#[no_mangle]
|
|
46
|
-
pub extern "C" fn get() -> i32 { 42 }
|
|
49
|
+
pub extern "C" fn get() -> i32 { 42 }
|
|
50
|
+
|
|
51
|
+
#[no_mangle]
|
|
52
|
+
pub extern "C" fn rust_my_create() -> IMy::Ref {
|
|
53
|
+
My {}.to_cobject()
|
|
54
|
+
}
|