1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5#include <stdio.h>
6#include <xplatform.h>
7
8int intManaged = 1000;
9int intNative = 2000;
10int intReturn = 3000;
11int intErrReturn = 4000;
12
13extern "C" DLL_EXPORT int STDMETHODCALLTYPE Marshal_In(/*[in]*/int intValue)
14{
15 //Check the input
16 if(intValue != intManaged)
17 {
18 printf("Error in Function Marshal_In(Native Client)\n");
19
20 //Expected
21 printf("Expected:%u\n", intManaged);
22
23 //Actual
24 printf("Actual:%u\n",intValue);
25
26 //Return the error value instead if verification failed
27 return intErrReturn;
28 }
29
30 return intReturn;
31}
32
33extern "C" DLL_EXPORT int STDMETHODCALLTYPE Marshal_InOut(/*[In,Out]*/int intValue)
34{
35 //Check the input
36 if(intValue != intManaged)
37 {
38 printf("Error in Function Marshal_InOut(Native Client)\n");
39
40 //Expected
41 printf("Expected:%u\n", intManaged);
42
43 //Actual
44 printf("Actual:%u\n",intValue);
45
46 //Return the error value instead if verification failed
47 return intErrReturn;
48 }
49
50 //In-Place Change
51 intValue = intNative;
52
53 //Return
54 return intReturn;
55}
56
57extern "C" DLL_EXPORT int STDMETHODCALLTYPE Marshal_Out(/*[Out]*/int intValue)
58{
59 intValue = intNative;
60
61 //Return
62 return intReturn;
63}
64
65extern "C" DLL_EXPORT int STDMETHODCALLTYPE MarshalPointer_In(/*[in]*/int *pintValue)
66{
67 //Check the input
68 if(*pintValue != intManaged)
69 {
70 printf("Error in Function MarshalPointer_In(Native Client)\n");
71
72 //Expected
73 printf("Expected:%u\n", intManaged);
74
75 //Actual
76 printf("Actual:%u\n",*pintValue);
77
78 //Return the error value instead if verification failed
79 return intErrReturn;
80 }
81
82 return intReturn;
83}
84
85extern "C" DLL_EXPORT int STDMETHODCALLTYPE MarshalPointer_InOut(/*[in,out]*/int *pintValue)
86{
87 //Check the input
88 if(*pintValue != intManaged)
89 {
90 printf("Error in Function MarshalPointer_InOut(Native Client)\n");
91
92 //Expected
93 printf("Expected:%u\n", intManaged);
94
95 //Actual
96 printf("Actual:%u\n",*pintValue);
97
98 //Return the error value instead if verification failed
99 return intErrReturn;
100 }
101
102 //In-Place Change
103 *pintValue = intNative;
104
105 //Return
106 return intReturn;
107}
108
109extern "C" DLL_EXPORT int STDMETHODCALLTYPE MarshalPointer_Out(/*[out]*/ int *pintValue)
110{
111 *pintValue = intNative;
112
113 //Return
114 return intReturn;
115}
116