-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTest_NativeArray.h
More file actions
84 lines (61 loc) · 2.11 KB
/
Test_NativeArray.h
File metadata and controls
84 lines (61 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#pragma once
#include "Common.h"
namespace Test_NativeArray
{
// begin-snippet: Test_NativeArray_Args_CPP
struct args
{
int Arr[8];
int Multiplier;
};
// end-snippet
bool Run(dotnet_runtime::Library& a_lib)
{
bool ret = true;
// begin-snippet: Test_NativeArray_Args_Data_CPP
args _args{
1, 2, 3, 4, 5, 6, 7, 8, // Arr[8]
2 // Multiplier
};
// end-snippet
{ // StructFixed
// begin-snippet: Test_NativeArray_StructFixed_CPP
typedef int (CORECLR_DELEGATE_CALLTYPE* custom_entry_point_fn)(args);
auto fpTest_NativeArray_StructFixed = (custom_entry_point_fn)a_lib.GetCustomEntrypoint(
STR("LibNamespace.Test_NativeArray"),
STR("Test_NativeArray_StructFixed")
);
bool success = fpTest_NativeArray_StructFixed(_args) == 72;
LogTest(success, L"Test_NativeArray_StructFixed");
// end-snippet
ret &= success;
}
{ // ArgumentFixed
// begin-snippet: Test_NativeArray_ArgumentFixed_CPP
typedef int (CORECLR_DELEGATE_CALLTYPE* custom_entry_point_fn)(int[], int);
auto fpTest_NativeArray_ArgumentFixed = (custom_entry_point_fn)a_lib.GetCustomEntrypoint(
STR("LibNamespace.Test_NativeArray"),
STR("Test_NativeArray_ArgumentFixed")
);
bool success = fpTest_NativeArray_ArgumentFixed(_args.Arr, _args.Multiplier) == 72;
LogTest(success, L"Test_NativeArray_ArgumentFixed");
// end-snippet
ret &= success;
}
{ // ArgumentFixed FunctionPointer
// begin-snippet: Test_NativeArray_ArgumentFixed_FunctionPointer_CPP
typedef void* (CORECLR_DELEGATE_CALLTYPE* custom_entry_point_fn)();
typedef int (*managed_callback_fn)(int[], int);
auto fpTest_NativeArray_ArgumentFixed_FunctionPointer = (custom_entry_point_fn)a_lib.GetCustomEntrypoint(
STR("LibNamespace.Test_NativeArray"),
STR("Test_NativeArray_ArgumentFixed_FunctionPointer")
);
managed_callback_fn callback = (managed_callback_fn)fpTest_NativeArray_ArgumentFixed_FunctionPointer();
bool success = callback(_args.Arr, _args.Multiplier) == 72;
LogTest(success, L"Test_NativeArray_ArgumentFixed_FunctionPointer");
// end-snippet
ret &= success;
}
return ret;
}
}